Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/shell/xdg/dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<DecorationMode>) {
self.inner.window.request_decoration_mode(mode)
}
}

impl WaylandSurface for Dialog {
Expand Down
24 changes: 24 additions & 0 deletions src/shell/xdg/window/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,30 @@ pub struct WindowInner {
pub pending_configure: Mutex<WindowConfigure>,
}

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<DecorationMode>) {
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<zxdg_decoration_manager_v1::ZxdgDecorationManagerV1, 1> for XdgShell {
fn bound_global(
&self,
Expand Down
10 changes: 2 additions & 8 deletions src/shell/xdg/window/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
};

Expand Down Expand Up @@ -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<DecorationMode>) {
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) {
Expand Down