1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-26 08:25:50 +03:00

Fix cursor setting

This commit is contained in:
V 2024-04-08 03:55:53 +02:00 committed by Wez Furlong
parent fdc805bb2e
commit ccbdd4da6a
No known key found for this signature in database
GPG Key ID: 7A7F66A31EC9B387

View File

@ -24,6 +24,7 @@ use smithay_client_toolkit::compositor::{CompositorHandler, SurfaceData, Surface
use smithay_client_toolkit::reexports::csd_frame::{
DecorationsFrame, FrameAction, WindowState as SCTKWindowState,
};
use smithay_client_toolkit::seat::pointer::CursorIcon;
use smithay_client_toolkit::shell::xdg::fallback_frame::FallbackFrame;
use smithay_client_toolkit::shell::xdg::window::{
DecorationMode, Window as XdgWindow, WindowConfigure, WindowDecorations as Decorations,
@ -195,11 +196,6 @@ impl WaylandWindow {
compositor.create_surface_with_data(&qh, surface_data)
};
let pointer_surface = {
let compositor = &conn.wayland_state.borrow().compositor;
compositor.create_surface(&qh)
};
let ResolvedGeometry {
x: _,
y: _,
@ -292,7 +288,6 @@ impl WaylandWindow {
key_repeat: None,
pending_event,
pending_mouse,
pointer_surface,
pending_first_configure: Some(pending_first_configure),
frame_callback: None,
@ -507,7 +502,6 @@ pub struct WaylandWindowInner {
dimensions: Dimensions,
resize_increments: Option<ResizeIncrement>,
window_state: WindowState,
pointer_surface: WlSurface,
last_mouse_coords: Point,
mouse_buttons: MouseButtons,
hscroll_remainder: f64,
@ -907,26 +901,24 @@ impl WaylandWindowInner {
}
fn set_cursor(&mut self, cursor: Option<MouseCursor>) {
let name = cursor.map_or("none", |cursor| match cursor {
MouseCursor::Arrow => "arrow",
MouseCursor::Hand => "hand",
MouseCursor::SizeUpDown => "ns-resize",
MouseCursor::SizeLeftRight => "ew-resize",
MouseCursor::Text => "xterm",
});
let conn = Connection::get().unwrap().wayland();
let state = conn.wayland_state.borrow_mut();
let (shm, pointer) =
RefMut::map_split(state, |s| (&mut s.shm, s.pointer.as_mut().unwrap()));
if let Err(err) = pointer.set_cursor(
&conn.connection,
todo!(),
// name,
// shm.wl_shm(),
// &self.pointer_surface,
// 1,
) {
if let Err(err) = match cursor {
Some(cursor) => pointer.set_cursor(
&conn.connection,
match cursor {
MouseCursor::Arrow => CursorIcon::Default,
MouseCursor::Hand => CursorIcon::Pointer,
MouseCursor::SizeUpDown => CursorIcon::NsResize,
MouseCursor::SizeLeftRight => CursorIcon::EwResize,
MouseCursor::Text => CursorIcon::Text,
},
),
None => pointer.hide_cursor(),
} {
log::error!("set_cursor: {}", err);
}
}