1
0
Fork 0
forked from wry/wry

cursor: respect XCURSOR_SIZE

This commit is contained in:
Julian Orth 2024-03-10 17:42:06 +01:00
parent 7f5161806b
commit 7381e5df37
2 changed files with 14 additions and 5 deletions

View file

@ -16,6 +16,7 @@ use {
byteorder::{LittleEndian, ReadBytesExt}, byteorder::{LittleEndian, ReadBytesExt},
isnt::std_1::primitive::IsntSliceExt, isnt::std_1::primitive::IsntSliceExt,
num_derive::FromPrimitive, num_derive::FromPrimitive,
once_cell::sync::Lazy,
std::{ std::{
cell::Cell, cell::Cell,
convert::TryInto, convert::TryInto,
@ -38,10 +39,20 @@ const XCURSOR_PATH_DEFAULT: &[u8] =
b"~/.icons:/usr/share/icons:/usr/share/pixmaps:/usr/X11R6/lib/X11/icons"; b"~/.icons:/usr/share/icons:/usr/share/pixmaps:/usr/X11R6/lib/X11/icons";
const XCURSOR_PATH: &str = "XCURSOR_PATH"; const XCURSOR_PATH: &str = "XCURSOR_PATH";
const XCURSOR_THEME: &str = "XCURSOR_THEME"; const XCURSOR_THEME: &str = "XCURSOR_THEME";
const XCURSOR_SIZE: &str = "XCURSOR_SIZE";
const HOME: &str = "HOME"; const HOME: &str = "HOME";
const HEADER_SIZE: u32 = 16; const HEADER_SIZE: u32 = 16;
pub static DEFAULT_CURSOR_SIZE: Lazy<u32> = Lazy::new(|| {
if let Ok(size) = env::var(XCURSOR_SIZE) {
if let Ok(val) = size.parse() {
return val;
}
}
24
});
pub trait Cursor { pub trait Cursor {
fn render(&self, renderer: &mut Renderer, x: Fixed, y: Fixed); fn render(&self, renderer: &mut Renderer, x: Fixed, y: Fixed);
fn render_hardware_cursor(&self, renderer: &mut Renderer); fn render_hardware_cursor(&self, renderer: &mut Renderer);

View file

@ -13,7 +13,7 @@ use {
crate::{ crate::{
async_engine::SpawnedFuture, async_engine::SpawnedFuture,
client::{Client, ClientError, ClientId}, client::{Client, ClientError, ClientId},
cursor::{Cursor, KnownCursor}, cursor::{Cursor, KnownCursor, DEFAULT_CURSOR_SIZE},
fixed::Fixed, fixed::Fixed,
globals::{Global, GlobalName}, globals::{Global, GlobalName},
ifs::{ ifs::{
@ -166,8 +166,6 @@ pub struct WlSeatGlobal {
const CHANGE_CURSOR_MOVED: u32 = 1 << 0; const CHANGE_CURSOR_MOVED: u32 = 1 << 0;
const CHANGE_TREE: u32 = 1 << 1; const CHANGE_TREE: u32 = 1 << 1;
const DEFAULT_CURSOR_SIZE: u32 = 16;
impl Drop for WlSeatGlobal { impl Drop for WlSeatGlobal {
fn drop(&mut self) { fn drop(&mut self) {
self.state.remove_cursor_size(self.cursor_size.get()); self.state.remove_cursor_size(self.cursor_size.get());
@ -212,13 +210,13 @@ impl WlSeatGlobal {
output: CloneCell::new(state.dummy_output.get().unwrap()), output: CloneCell::new(state.dummy_output.get().unwrap()),
desired_known_cursor: Cell::new(None), desired_known_cursor: Cell::new(None),
changes: NumCell::new(CHANGE_CURSOR_MOVED | CHANGE_TREE), changes: NumCell::new(CHANGE_CURSOR_MOVED | CHANGE_TREE),
cursor_size: Cell::new(DEFAULT_CURSOR_SIZE), cursor_size: Cell::new(*DEFAULT_CURSOR_SIZE),
hardware_cursor: Cell::new(state.globals.seats.len() == 0), hardware_cursor: Cell::new(state.globals.seats.len() == 0),
constraint: Default::default(), constraint: Default::default(),
idle_notifications: Default::default(), idle_notifications: Default::default(),
last_input_usec: Cell::new(now_usec()), last_input_usec: Cell::new(now_usec()),
}); });
state.add_cursor_size(DEFAULT_CURSOR_SIZE); state.add_cursor_size(*DEFAULT_CURSOR_SIZE);
let seat = slf.clone(); let seat = slf.clone();
let future = state.eng.spawn(async move { let future = state.eng.spawn(async move {
loop { loop {