diff --git a/src/backend/render/mod.rs b/src/backend/render/mod.rs index 4a94b9bc..c824494d 100644 --- a/src/backend/render/mod.rs +++ b/src/backend/render/mod.rs @@ -592,7 +592,7 @@ where .render::( renderer, &state.shell.override_redirect_windows, - state.xwayland_state.as_mut(), + state.shell.xwayland_state.as_mut(), (!move_active && is_active_space).then_some(&last_active_seat), overview.clone(), resize_indicator.clone(), @@ -650,7 +650,7 @@ where .render::( renderer, &state.shell.override_redirect_windows, - state.xwayland_state.as_mut(), + state.shell.xwayland_state.as_mut(), (!move_active && is_active_space).then_some(&last_active_seat), overview, resize_indicator, diff --git a/src/input/mod.rs b/src/input/mod.rs index e9ccdbe8..0d86e6d0 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -1838,6 +1838,7 @@ impl State { let wayland_display = self.common.socket.clone(); let display = self .common + .shell .xwayland_state .as_ref() .map(|s| format!(":{}", s.display)) diff --git a/src/session.rs b/src/session.rs index c88d6351..c6458c46 100644 --- a/src/session.rs +++ b/src/session.rs @@ -82,7 +82,13 @@ pub fn setup_socket(handle: LoopHandle, state: &State) -> Result<()> { .into_string() .map_err(|_| anyhow!("wayland socket is no valid utf-8 string?"))?, ); - if let Some(display) = state.common.xwayland_state.as_ref().map(|s| s.display) { + if let Some(display) = state + .common + .shell + .xwayland_state + .as_ref() + .map(|s| s.display) + { env.insert(String::from("DISPLAY"), format!(":{}", display)); } let message = serde_json::to_string(&Message::SetEnv { variables: env }) diff --git a/src/shell/mod.rs b/src/shell/mod.rs index 58c6b6f5..37c33b09 100644 --- a/src/shell/mod.rs +++ b/src/shell/mod.rs @@ -54,6 +54,7 @@ use crate::{ }, }, }, + xwayland::XWaylandState, }; pub mod element; @@ -188,6 +189,7 @@ pub struct Shell { pub xdg_shell_state: XdgShellState, pub xdg_activation_state: XdgActivationState, pub workspace_state: WorkspaceState, + pub xwayland_state: Option, theme: cosmic::Theme, overview_mode: OverviewMode, @@ -1022,6 +1024,7 @@ impl Shell { xdg_shell_state, xdg_activation_state, workspace_state, + xwayland_state: None, theme, overview_mode: OverviewMode::None, diff --git a/src/state.rs b/src/state.rs index b32368fa..48da8300 100644 --- a/src/state.rs +++ b/src/state.rs @@ -16,7 +16,6 @@ use crate::{ screencopy::{BufferParams, ScreencopyState, Session as ScreencopySession}, workspace::WorkspaceClientState, }, - xwayland::XWaylandState, }; use anyhow::Context; use cosmic_protocols::screencopy::v1::server::zcosmic_screencopy_manager_v1::CursorMode; @@ -170,9 +169,6 @@ pub struct Common { pub viewporter_state: ViewporterState, pub kde_decoration_state: KdeDecorationState, pub xdg_decoration_state: XdgDecorationState, - - // xwayland state - pub xwayland_state: Option, } #[derive(Debug)] @@ -421,8 +417,6 @@ impl State { wl_drm_state, kde_decoration_state, xdg_decoration_state, - - xwayland_state: None, }, backend: BackendData::Unset, } diff --git a/src/systemd.rs b/src/systemd.rs index d75f3f82..244e419b 100644 --- a/src/systemd.rs +++ b/src/systemd.rs @@ -14,6 +14,7 @@ pub fn ready(state: &State) { "DISPLAY", &state .common + .shell .xwayland_state .as_ref() .map(|s| format!(":{}", s.display)) diff --git a/src/wayland/handlers/selection.rs b/src/wayland/handlers/selection.rs index 6d157a5f..c3bcdcf8 100644 --- a/src/wayland/handlers/selection.rs +++ b/src/wayland/handlers/selection.rs @@ -20,6 +20,7 @@ impl SelectionHandler for State { ) { if let Some(xwm) = self .common + .shell .xwayland_state .as_mut() .and_then(|xstate| xstate.xwm.as_mut()) @@ -44,6 +45,7 @@ impl SelectionHandler for State { ) { if let Some(xwm) = self .common + .shell .xwayland_state .as_mut() .and_then(|xstate| xstate.xwm.as_mut()) diff --git a/src/xwayland.rs b/src/xwayland.rs index 600632e5..03d68044 100644 --- a/src/xwayland.rs +++ b/src/xwayland.rs @@ -46,7 +46,7 @@ pub struct XWaylandState { impl State { pub fn launch_xwayland(&mut self, render_node: Option) { - if self.common.xwayland_state.is_some() { + if self.common.shell.xwayland_state.is_some() { return; } @@ -90,11 +90,11 @@ impl State { ); } - let xwayland_state = data.common.xwayland_state.as_mut().unwrap(); + let xwayland_state = data.common.shell.xwayland_state.as_mut().unwrap(); xwayland_state.xwm = Some(wm); } XWaylandEvent::Exited => { - if let Some(mut xwayland_state) = data.common.xwayland_state.take() { + if let Some(mut xwayland_state) = data.common.shell.xwayland_state.take() { xwayland_state.xwm = None; } } @@ -119,7 +119,7 @@ impl State { }, ) { Ok(display) => { - self.common.xwayland_state = Some(XWaylandState { + self.common.shell.xwayland_state = Some(XWaylandState { xwayland, xwm: None, display, @@ -136,6 +136,7 @@ impl State { impl XwmHandler for State { fn xwm_state(&mut self, _xwm: XwmId) -> &mut X11Wm { self.common + .shell .xwayland_state .as_mut() .and_then(|state| state.xwm.as_mut())