From 2c4e70d05e9df86d6bdea734acbf7b6e356cdc6a Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Fri, 4 Sep 2026 14:17:35 +0200 Subject: [PATCH] implement setting the decoration mode for dialogs --- src/shell/xdg/dialog.rs | 18 +++++++++++++++++- src/shell/xdg/window/inner.rs | 24 ++++++++++++++++++++++++ src/shell/xdg/window/mod.rs | 10 ++-------- 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/src/shell/xdg/dialog.rs b/src/shell/xdg/dialog.rs index 5a87e9460..dd60877b8 100644 --- a/src/shell/xdg/dialog.rs +++ b/src/shell/xdg/dialog.rs @@ -4,7 +4,7 @@ use crate::reexports::protocols::xdg::decoration::zv1::client::zxdg_decoration_m use crate::shell::xdg::window::inner::{ determine_decoration_mode, determine_window_state, determine_wm_capabilities, WindowInner, }; -use crate::shell::xdg::window::WindowConfigure; +use crate::shell::xdg::window::{DecorationMode, WindowConfigure}; use crate::shell::xdg::Dispatch2; use crate::shell::xdg::WindowDecorations; use crate::shell::WaylandSurface; @@ -189,6 +189,22 @@ impl Dialog { self.inner.xdg_dialog.unset_modal(); } } + + /// Requests the dialog should use the specified decoration mode. + /// + /// A mode of [`None`] indicates that the dialog does not care what type of decorations are + /// used. + /// + /// The compositor will respond with a [`configure`](DialogHandler::configure). The configure + /// will indicate whether the dialog's decoration mode has changed. + /// + /// # Configure loops + /// + /// You should avoid sending multiple decoration mode requests to ensure you do not enter a + /// configure loop. + pub fn request_decoration_mode(&self, mode: Option) { + self.inner.window.request_decoration_mode(mode) + } } impl WaylandSurface for Dialog { diff --git a/src/shell/xdg/window/inner.rs b/src/shell/xdg/window/inner.rs index 9cb4cabc4..2b1bbfab1 100644 --- a/src/shell/xdg/window/inner.rs +++ b/src/shell/xdg/window/inner.rs @@ -50,6 +50,30 @@ pub struct WindowInner { pub pending_configure: Mutex, } +impl WindowInner { + /// Requests the surface should use the specified decoration mode. + /// + /// A mode of [`None`] indicates that the surface does not care what type of decorations are + /// used. + /// + /// The compositor will respond with a configure indicating whether the decoration mode has + /// changed. + /// + /// # Configure loops + /// + /// You should avoid sending multiple decoration mode requests to ensure you do not enter a + /// configure loop. + pub fn request_decoration_mode(&self, mode: Option) { + if let Some(toplevel_decoration) = &self.toplevel_decoration { + match mode { + Some(DecorationMode::Client) => toplevel_decoration.set_mode(Mode::ClientSide), + Some(DecorationMode::Server) => toplevel_decoration.set_mode(Mode::ServerSide), + None => toplevel_decoration.unset_mode(), + } + } + } +} + impl ProvidesBoundGlobal for XdgShell { fn bound_global( &self, diff --git a/src/shell/xdg/window/mod.rs b/src/shell/xdg/window/mod.rs index a6a155e5f..f09e5cc62 100644 --- a/src/shell/xdg/window/mod.rs +++ b/src/shell/xdg/window/mod.rs @@ -11,7 +11,7 @@ use crate::reexports::client::{ }; use crate::reexports::csd_frame::{WindowManagerCapabilities, WindowState}; use crate::reexports::protocols::{ - xdg::decoration::zv1::client::zxdg_toplevel_decoration_v1::{self, Mode}, + xdg::decoration::zv1::client::zxdg_toplevel_decoration_v1, xdg::shell::client::{xdg_surface, xdg_toplevel}, }; @@ -261,13 +261,7 @@ impl Window { /// /// You should avoid sending multiple decoration mode requests to ensure you do not enter a configure loop. pub fn request_decoration_mode(&self, mode: Option) { - if let Some(toplevel_decoration) = &self.0.toplevel_decoration { - match mode { - Some(DecorationMode::Client) => toplevel_decoration.set_mode(Mode::ClientSide), - Some(DecorationMode::Server) => toplevel_decoration.set_mode(Mode::ServerSide), - None => toplevel_decoration.unset_mode(), - } - } + self.0.request_decoration_mode(mode) } pub fn move_(&self, seat: &wl_seat::WlSeat, serial: u32) {