mirror of
https://github.com/wez/wezterm.git
synced 2024-11-22 22:42:48 +03:00
Theme the pointer
This commit is contained in:
parent
60066034aa
commit
30727e96ac
@ -1,3 +1,4 @@
|
||||
use smithay_client_toolkit::seat::pointer::ThemeSpec;
|
||||
use smithay_client_toolkit::seat::{Capability, SeatHandler, SeatState};
|
||||
use wayland_client::protocol::wl_seat::WlSeat;
|
||||
use wayland_client::{Connection, QueueHandle};
|
||||
@ -33,7 +34,12 @@ impl SeatHandler for WaylandState {
|
||||
log::trace!("Setting pointer capability");
|
||||
let pointer = self
|
||||
.seat_state()
|
||||
.get_pointer_with_data(qh, &seat, PointerUserData::new(seat.clone()))
|
||||
.get_pointer_with_theme_and_data(
|
||||
qh,
|
||||
&seat,
|
||||
ThemeSpec::System,
|
||||
PointerUserData::new(seat.clone()),
|
||||
)
|
||||
.expect("Failed to create pointer");
|
||||
self.pointer = Some(pointer);
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ use std::sync::{Arc, Mutex};
|
||||
use smithay_client_toolkit::compositor::CompositorState;
|
||||
use smithay_client_toolkit::output::{OutputHandler, OutputState};
|
||||
use smithay_client_toolkit::registry::{ProvidesRegistryState, RegistryState};
|
||||
use smithay_client_toolkit::seat::pointer::ThemedPointer;
|
||||
use smithay_client_toolkit::seat::SeatState;
|
||||
use smithay_client_toolkit::shell::xdg::XdgShell;
|
||||
use smithay_client_toolkit::shm::slot::SlotPool;
|
||||
@ -45,10 +46,10 @@ pub(super) struct WaylandState {
|
||||
pub(super) key_repeat_rate: i32,
|
||||
pub(super) keyboard_window_id: Option<usize>,
|
||||
|
||||
pub(super) pointer: Option<WlPointer>,
|
||||
pub(super) pointer: Option<ThemedPointer<PointerUserData>>,
|
||||
pub(super) surface_to_pending: HashMap<ObjectId, Arc<Mutex<PendingMouse>>>,
|
||||
|
||||
shm: Shm,
|
||||
pub(super) shm: Shm,
|
||||
pub(super) mem_pool: RefCell<SlotPool>,
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
use std::any::Any;
|
||||
use std::cell::RefCell;
|
||||
use std::cell::{RefCell, RefMut};
|
||||
use std::convert::TryInto;
|
||||
use std::rc::Rc;
|
||||
use std::sync::{Arc, Mutex};
|
||||
@ -183,6 +183,11 @@ 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: _,
|
||||
@ -256,6 +261,7 @@ impl WaylandWindow {
|
||||
key_repeat: None,
|
||||
pending_event,
|
||||
pending_mouse,
|
||||
pointer_surface,
|
||||
|
||||
pending_first_configure: Some(pending_first_configure),
|
||||
frame_callback: None,
|
||||
@ -387,6 +393,7 @@ pub struct WaylandWindowInner {
|
||||
dimensions: Dimensions,
|
||||
resize_increments: Option<(u16, u16)>,
|
||||
window_state: WindowState,
|
||||
pointer_surface: WlSurface,
|
||||
last_mouse_coords: Point,
|
||||
mouse_buttons: MouseButtons,
|
||||
hscroll_remainder: f64,
|
||||
@ -743,17 +750,28 @@ impl WaylandWindowInner {
|
||||
}
|
||||
|
||||
fn set_cursor(&mut self, cursor: Option<MouseCursor>) {
|
||||
// TODO: Deal with cursors later
|
||||
let _names: &[&str] = match cursor {
|
||||
Some(MouseCursor::Arrow) => &["arrow"],
|
||||
Some(MouseCursor::Hand) => &["hand"],
|
||||
Some(MouseCursor::SizeUpDown) => &["ns-resize"],
|
||||
Some(MouseCursor::SizeLeftRight) => &["ew-resize"],
|
||||
Some(MouseCursor::Text) => &["xterm"],
|
||||
None => &[],
|
||||
};
|
||||
// let conn = Connection::get().unwrap().wayland();
|
||||
// conn.pointer.borrow().set_cursor(names, None);
|
||||
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()));
|
||||
|
||||
// Much different API in 0.18
|
||||
if let Err(err) = pointer.set_cursor(
|
||||
&conn.connection,
|
||||
name,
|
||||
shm.wl_shm(),
|
||||
&self.pointer_surface,
|
||||
1,
|
||||
) {
|
||||
log::error!("set_cursor: {}", err);
|
||||
}
|
||||
}
|
||||
|
||||
fn invalidate(&mut self) {
|
||||
|
Loading…
Reference in New Issue
Block a user