From d202712694ba2a5b668f3dc892faa37967983c65 Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Wed, 7 Feb 2024 21:22:44 +0100 Subject: [PATCH 1/3] input: log reason for ignoring set_cursor request --- src/ifs/wl_seat/wl_pointer.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ifs/wl_seat/wl_pointer.rs b/src/ifs/wl_seat/wl_pointer.rs index 49149d57..5a077326 100644 --- a/src/ifs/wl_seat/wl_pointer.rs +++ b/src/ifs/wl_seat/wl_pointer.rs @@ -192,13 +192,20 @@ impl WlPointer { Some(n) => n, _ => { // cannot happen + log::warn!("ignoring wl_pointer.set_cursor (1)"); return Ok(()); } }; if pointer_node.node_client_id() != Some(self.seat.client.id) { + log::warn!("ignoring wl_pointer.set_cursor (2)"); return Ok(()); } if req.serial != self.seat.client.last_enter_serial.get() { + log::warn!( + "ignoring wl_pointer.set_cursor (3) ({} != {})", + req.serial, + self.seat.client.last_enter_serial.get(), + ); return Ok(()); } self.seat.global.set_app_cursor(cursor_opt); From f68e2e6fd4de8a9273ce23924033f8a853d35208 Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Wed, 7 Feb 2024 21:25:45 +0100 Subject: [PATCH 2/3] render: render dnd icons for hardware cursors --- src/gfx_apis/gl/renderer/framebuffer.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/gfx_apis/gl/renderer/framebuffer.rs b/src/gfx_apis/gl/renderer/framebuffer.rs index 8ffb32a0..1d73d475 100644 --- a/src/gfx_apis/gl/renderer/framebuffer.rs +++ b/src/gfx_apis/gl/renderer/framebuffer.rs @@ -190,9 +190,6 @@ impl Framebuffer { if let Some(rect) = cursor_rect { let seats = state.globals.lock_seats(); for seat in seats.values() { - if !render_hardware_cursor && seat.hardware_cursor() { - continue; - } if let Some(cursor) = seat.get_cursor() { let (mut x, mut y) = seat.get_position(); if let Some(dnd_icon) = seat.dnd_icon() { @@ -205,10 +202,12 @@ impl Framebuffer { renderer.render_surface(&dnd_icon, x, y, i32::MAX, i32::MAX); } } - cursor.tick(); - x -= Fixed::from_int(rect.x1()); - y -= Fixed::from_int(rect.y1()); - cursor.render(&mut renderer, x, y); + if render_hardware_cursor || !seat.hardware_cursor() { + cursor.tick(); + x -= Fixed::from_int(rect.x1()); + y -= Fixed::from_int(rect.y1()); + cursor.render(&mut renderer, x, y); + } } } } From 71fc85170557938ebb402d48350e087204183bcc Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Wed, 7 Feb 2024 21:43:01 +0100 Subject: [PATCH 3/3] render: keep track of outputs whose hardware cursor must be rendered --- src/compositor.rs | 1 + src/ifs/wl_seat.rs | 4 ++++ src/tasks/connector.rs | 1 + src/tree/output.rs | 1 + 4 files changed, 7 insertions(+) diff --git a/src/compositor.rs b/src/compositor.rs index 190b18f8..2524bbf1 100644 --- a/src/compositor.rs +++ b/src/compositor.rs @@ -392,6 +392,7 @@ fn create_dummy_output(state: &Rc) { hardware_cursor: Default::default(), update_render_data_scheduled: Cell::new(false), screencasts: Default::default(), + hardware_cursor_needs_render: Cell::new(false), }); let dummy_workspace = Rc::new(WorkspaceNode { id: state.node_ids.next(), diff --git a/src/ifs/wl_seat.rs b/src/ifs/wl_seat.rs index d68f9f9b..d9dabe6e 100644 --- a/src/ifs/wl_seat.rs +++ b/src/ifs/wl_seat.rs @@ -258,6 +258,7 @@ impl WlSeatGlobal { let (x, y) = self.get_position(); for output in self.state.root.outputs.lock().values() { if let Some(hc) = output.hardware_cursor.get() { + let render = render | output.hardware_cursor_needs_render.take(); let scale = output.preferred_scale.get(); let extents = cursor.extents_at_scale(scale); if render { @@ -290,6 +291,9 @@ impl WlSeatGlobal { hc.set_enabled(true); hc.set_position(x_rel + extents.x1(), y_rel + extents.y1()); } else { + if render { + output.hardware_cursor_needs_render.set(true); + } hc.set_enabled(false); } hc.commit(); diff --git a/src/tasks/connector.rs b/src/tasks/connector.rs index 2d7ac31f..e3d1a2e9 100644 --- a/src/tasks/connector.rs +++ b/src/tasks/connector.rs @@ -128,6 +128,7 @@ impl ConnectorHandler { jay_outputs: Default::default(), screencasts: Default::default(), update_render_data_scheduled: Cell::new(false), + hardware_cursor_needs_render: Cell::new(false), }); self.state.add_output_scale(on.preferred_scale.get()); let mode = info.initial_mode; diff --git a/src/tree/output.rs b/src/tree/output.rs index 53379c43..933188c4 100644 --- a/src/tree/output.rs +++ b/src/tree/output.rs @@ -61,6 +61,7 @@ pub struct OutputNode { pub lock_surface: CloneCell>>, pub preferred_scale: Cell, pub hardware_cursor: CloneCell>>, + pub hardware_cursor_needs_render: Cell, pub update_render_data_scheduled: Cell, pub screencasts: CopyHashMap<(ClientId, JayScreencastId), Rc>, }