Skip to content

Commit 75aba5c

Browse files
committed
Remove depdendency x11rb's image feature
The code only used x11rb's image feature for splitting a large PutImage request into smaller pieces. Since X11 servers usually have a maximum request size of 16 MiB these days, it is unlikely that people create cursors large enough to go above this limit. You'd need a 2k x 2k cursor for that! Signed-off-by: Uli Schlachter <psychon@znc.in>
1 parent 912991d commit 75aba5c

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

druid-shell/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ glib = { version = "0.10.1", optional = true }
8888
glib-sys = { version = "0.10.0", optional = true }
8989
gtk-sys = { version = "0.10.0", optional = true }
9090
nix = { version = "0.18.0", optional = true }
91-
x11rb = { version = "0.8.0", features = ["allow-unsafe-code", "present", "render", "randr", "xfixes", "resource_manager", "cursor", "image"], optional = true }
91+
x11rb = { version = "0.8.0", features = ["allow-unsafe-code", "present", "render", "randr", "xfixes", "resource_manager", "cursor"], optional = true }
9292

9393
[target.'cfg(target_arch="wasm32")'.dependencies]
9494
wasm-bindgen = "0.2.67"

druid-shell/src/platform/x11/window.rs

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
//! X11 window creation and window management.
1616
17-
use std::borrow::Cow;
1817
use std::cell::{Cell, RefCell};
1918
use std::collections::BinaryHeap;
2019
use std::convert::{TryFrom, TryInto};
@@ -31,14 +30,13 @@ use tracing::{error, info, warn};
3130
use x11rb::atom_manager;
3231
use x11rb::connection::Connection;
3332
use x11rb::errors::ReplyOrIdError;
34-
use x11rb::image::{BitsPerPixel, Image, ImageOrder, ScanlinePad};
3533
use x11rb::protocol::present::{CompleteNotifyEvent, ConnectionExt as _, IdleNotifyEvent};
3634
use x11rb::protocol::render::{ConnectionExt as _, Pictformat};
3735
use x11rb::protocol::xfixes::{ConnectionExt as _, Region as XRegion};
3836
use x11rb::protocol::xproto::{
3937
self, AtomEnum, ChangeWindowAttributesAux, ConfigureNotifyEvent, ConnectionExt, CreateGCAux,
40-
EventMask, Gcontext, ImageOrder as X11ImageOrder, Pixmap, PropMode, Rectangle, Visualtype,
41-
WindowClass,
38+
EventMask, Gcontext, ImageFormat, ImageOrder as X11ImageOrder, Pixmap, PropMode, Rectangle,
39+
Visualtype, WindowClass,
4240
};
4341
use x11rb::wrapper::ConnectionExt as _;
4442
use x11rb::xcb_ffi::XCBConnection;
@@ -1734,27 +1732,31 @@ fn make_cursor(
17341732
})
17351733
})
17361734
.collect::<Vec<u8>>();
1737-
let image = Image::new(
1738-
desc.image.width().try_into().expect("Invalid cursor width"),
1739-
desc.image
1740-
.height()
1741-
.try_into()
1742-
.expect("Invalid cursor height"),
1743-
ScanlinePad::Pad8,
1744-
32,
1745-
BitsPerPixel::B32,
1746-
ImageOrder::MSBFirst,
1747-
Cow::Owned(pixels),
1748-
)
1749-
.expect("We got the number of bytes for this image wrong?!");
1735+
let width = desc.image.width().try_into().expect("Invalid cursor width");
1736+
let height = desc
1737+
.image
1738+
.height()
1739+
.try_into()
1740+
.expect("Invalid cursor height");
17501741

17511742
let pixmap = conn.generate_id()?;
17521743
let gc = conn.generate_id()?;
17531744
let picture = conn.generate_id()?;
1754-
conn.create_pixmap(32, pixmap, root_window, image.width(), image.height())?;
1745+
conn.create_pixmap(32, pixmap, root_window, width, height)?;
17551746
conn.create_gc(gc, pixmap, &Default::default())?;
17561747

1757-
image.put(conn, pixmap, gc, 0, 0)?;
1748+
conn.put_image(
1749+
ImageFormat::Z_PIXMAP,
1750+
pixmap,
1751+
gc,
1752+
width,
1753+
height,
1754+
0,
1755+
0,
1756+
0,
1757+
32,
1758+
&pixels,
1759+
)?;
17581760
conn.render_create_picture(picture, pixmap, argb32_format, &Default::default())?;
17591761

17601762
conn.free_gc(gc)?;

0 commit comments

Comments
 (0)