Fix cursors on some GNOME installations (#12914)
This PR adds support for `org.gnome.desktop.interface`'s `cursor-theme` setting on Wayland. This should fix cursors not showing up on some GNOME installs. This PR also adds the wiring to watch the current cursor theme value. Thanks to @apricotbucket28 for helping debug the issue. Release Notes: - N/A
This commit is contained in:
parent
4cb8d6f40e
commit
ab41eddd8b
4 changed files with 145 additions and 30 deletions
|
@ -63,7 +63,9 @@ use crate::platform::linux::is_within_click_distance;
|
|||
use crate::platform::linux::wayland::cursor::Cursor;
|
||||
use crate::platform::linux::wayland::serial::{SerialKind, SerialTracker};
|
||||
use crate::platform::linux::wayland::window::WaylandWindow;
|
||||
use crate::platform::linux::xdg_desktop_portal::{Event as XDPEvent, XDPEventSource};
|
||||
use crate::platform::linux::xdg_desktop_portal::{
|
||||
cursor_settings, Event as XDPEvent, XDPEventSource,
|
||||
};
|
||||
use crate::platform::linux::LinuxClient;
|
||||
use crate::platform::PlatformWindow;
|
||||
use crate::{
|
||||
|
@ -430,7 +432,7 @@ impl WaylandClient {
|
|||
|
||||
let (primary, clipboard) = unsafe { create_clipboards_from_external(display) };
|
||||
|
||||
let cursor = Cursor::new(&conn, &globals, 24);
|
||||
let mut cursor = Cursor::new(&conn, &globals, 24);
|
||||
|
||||
handle
|
||||
.insert_source(XDPEventSource::new(&common.background_executor), {
|
||||
|
@ -446,10 +448,24 @@ impl WaylandClient {
|
|||
}
|
||||
}
|
||||
}
|
||||
XDPEvent::CursorTheme(theme) => {
|
||||
if let Some(client) = client.0.upgrade() {
|
||||
let mut client = client.borrow_mut();
|
||||
client.cursor.set_theme(theme.as_str(), None);
|
||||
}
|
||||
}
|
||||
XDPEvent::CursorSize(size) => {
|
||||
if let Some(client) = client.0.upgrade() {
|
||||
let mut client = client.borrow_mut();
|
||||
client.cursor.set_size(size);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
let foreground = common.foreground_executor.clone();
|
||||
|
||||
let mut state = Rc::new(RefCell::new(WaylandClientState {
|
||||
serial_tracker: SerialTracker::new(),
|
||||
globals,
|
||||
|
@ -511,6 +527,18 @@ impl WaylandClient {
|
|||
pending_open_uri: None,
|
||||
}));
|
||||
|
||||
foreground
|
||||
.spawn({
|
||||
let state = state.clone();
|
||||
async move {
|
||||
if let Ok((theme, size)) = cursor_settings().await {
|
||||
let mut state = state.borrow_mut();
|
||||
state.cursor.set_theme(theme.as_str(), size);
|
||||
}
|
||||
}
|
||||
})
|
||||
.detach();
|
||||
|
||||
WaylandSource::new(conn, event_queue)
|
||||
.insert(handle)
|
||||
.unwrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue