From 8da782df677bd83913b3e0fb4d20249ad1426e05 Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Wed, 22 Nov 2023 12:49:19 +0100 Subject: [PATCH] shell: Raise X11 surfaces on workspace activate --- src/shell/mod.rs | 10 ++++++++++ src/shell/workspace.rs | 25 +++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/shell/mod.rs b/src/shell/mod.rs index cf3b7c2f..37fdc314 100644 --- a/src/shell/mod.rs +++ b/src/shell/mod.rs @@ -1106,6 +1106,16 @@ impl Shell { set.workspaces[set.active].tiling_layer.cleanup_drag(); } set.activate(idx, &mut self.workspace_state.update())?; + if let Some(xwm) = self + .xwayland_state + .as_mut() + .and_then(|state| state.xwm.as_mut()) + { + let _ = set.workspaces[idx].raise_x11_windows(xwm); + for surface in &self.override_redirect_windows { + let _ = xwm.raise_window(surface); + } + } let output_geo = output.geometry(); Ok(Some( diff --git a/src/shell/workspace.rs b/src/shell/workspace.rs index 3db61f06..9b2e20a4 100644 --- a/src/shell/workspace.rs +++ b/src/shell/workspace.rs @@ -38,14 +38,17 @@ use smithay::{ desktop::{layer_map_for_output, space::SpaceElement}, input::{pointer::GrabStartData as PointerGrabStartData, Seat}, output::Output, - reexports::wayland_server::{protocol::wl_surface::WlSurface, Client, Resource}, + reexports::{ + wayland_server::{protocol::wl_surface::WlSurface, Client, Resource}, + x11rb::xcb_ffi::ConnectionError, + }, utils::{Buffer as BufferCoords, IsAlive, Logical, Physical, Point, Rectangle, Scale, Size}, wayland::{ compositor::{add_blocker, Blocker, BlockerState}, seat::WaylandFocus, xdg_activation::{XdgActivationState, XdgActivationToken}, }, - xwayland::X11Surface, + xwayland::{X11Surface, X11Wm}, }; use std::{ collections::{HashMap, HashSet, VecDeque}, @@ -866,6 +869,24 @@ impl Workspace { } } + pub fn raise_x11_windows(&mut self, xwm: &mut X11Wm) -> Result<(), ConnectionError> { + for window in self + .tiling_layer + .mapped() + .map(|(_, w, _)| w) + .chain(self.floating_layer.space.elements()) + { + if let CosmicSurface::X11(surf) = window.active_window() { + xwm.raise_window(&surf)?; + } + } + if let Some(CosmicSurface::X11(ref surf)) = self.fullscreen.as_ref().map(|f| &f.surface) { + xwm.raise_window(surf)?; + } + + Ok(()) + } + pub fn render<'a, R>( &self, renderer: &mut R,