From 726994b8584aac87dc02d74646e8d71d17cc86d9 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Fri, 6 Jun 2025 15:54:02 -0700 Subject: [PATCH] Consider cursor and drag surfaces in `visible_output_for_surface` This ensures that a commit to a cursor or drag surface will queue a redraw, even if nothing else has changed on screen. This can be tested by running `vkgears` in an otherwise empty cosmic-comp instance, and dragging it. --- src/shell/mod.rs | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/shell/mod.rs b/src/shell/mod.rs index 42dc82e5..506fd0b6 100644 --- a/src/shell/mod.rs +++ b/src/shell/mod.rs @@ -12,7 +12,7 @@ use std::{ use wayland_backend::server::ClientId; use crate::wayland::{ - handlers::data_device, + handlers::data_device::{self, get_dnd_icon}, protocols::workspace::{State as WState, WorkspaceCapabilities}, }; use cosmic_comp_config::{ @@ -1833,6 +1833,38 @@ impl Shell { .any(|e| e.has_surface(surface, WindowSurfaceType::ALL)) }) }) + // cursor and drag surfaces + .or_else(|| { + self.outputs().find(|o| { + self.seats + .iter() + .filter(|seat| seat.active_output() == **o) + .any(|seat| { + let cursor_status = seat.cursor_image_status(); + if let CursorImageStatus::Surface(s) = cursor_status { + if s == *surface { + return true; + } + } + + if let Some(move_grab) = seat.user_data().get::() { + if let Some(grab_state) = move_grab.lock().unwrap().as_ref() { + for (window, _) in grab_state.element().windows() { + let mut matches = false; + window.0.with_surfaces(|s, _| { + matches |= s == surface; + }); + if matches { + return true; + } + } + } + } + + get_dnd_icon(seat).is_some_and(|icon| icon.surface == *surface) + }) + }) + }) } pub fn workspace_for_surface(&self, surface: &WlSurface) -> Option<(WorkspaceHandle, Output)> {