diff --git a/src/backend/tty.rs b/src/backend/tty.rs index 2c56dd74f..c7ebab4b3 100644 --- a/src/backend/tty.rs +++ b/src/backend/tty.rs @@ -3,7 +3,7 @@ use std::collections::{HashMap, HashSet}; use std::os::fd::FromRawFd; use std::path::{Path, PathBuf}; use std::rc::Rc; -use std::sync::{Mutex, Arc}; +use std::sync::{Arc, Mutex}; use std::time::Duration; use anyhow::{anyhow, Context}; diff --git a/src/handlers/xdg_shell.rs b/src/handlers/xdg_shell.rs index 387e4bb3b..80a50cd07 100644 --- a/src/handlers/xdg_shell.rs +++ b/src/handlers/xdg_shell.rs @@ -7,12 +7,13 @@ use smithay::reexports::wayland_server::protocol::wl_seat::WlSeat; use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; use smithay::utils::Serial; use smithay::wayland::compositor::with_states; +use smithay::wayland::shell::kde::decoration::{KdeDecorationHandler, KdeDecorationState}; use smithay::wayland::shell::xdg::decoration::XdgDecorationHandler; use smithay::wayland::shell::xdg::{ PopupSurface, PositionerState, ToplevelSurface, XdgPopupSurfaceData, XdgShellHandler, XdgShellState, XdgToplevelSurfaceData, }; -use smithay::{delegate_xdg_decoration, delegate_xdg_shell}; +use smithay::{delegate_kde_decoration, delegate_xdg_decoration, delegate_xdg_shell}; use crate::layout::configure_new_window; use crate::niri::State; @@ -201,6 +202,14 @@ impl XdgDecorationHandler for State { } delegate_xdg_decoration!(State); +impl KdeDecorationHandler for State { + fn kde_decoration_state(&self) -> &KdeDecorationState { + &self.niri.kde_decoration_state + } +} + +delegate_kde_decoration!(State); + pub fn send_initial_configure_if_needed(window: &Window) { let initial_configure_sent = with_states(window.toplevel().wl_surface(), |states| { states diff --git a/src/niri.rs b/src/niri.rs index 1cbebe6c5..ab8234651 100644 --- a/src/niri.rs +++ b/src/niri.rs @@ -8,6 +8,7 @@ use std::sync::{Arc, Mutex}; use std::time::Duration; use std::{env, thread}; +use _server_decoration::server::org_kde_kwin_server_decoration_manager::Mode as KdeDecorationsMode; use anyhow::Context; use sd_notify::NotifyState; use smithay::backend::allocator::dmabuf::Dmabuf; @@ -37,6 +38,7 @@ use smithay::reexports::calloop::timer::{TimeoutAction, Timer}; use smithay::reexports::calloop::{self, Idle, Interest, LoopHandle, LoopSignal, Mode, PostAction}; use smithay::reexports::nix::libc::CLOCK_MONOTONIC; use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel::WmCapabilities; +use smithay::reexports::wayland_protocols_misc::server_decoration as _server_decoration; use smithay::reexports::wayland_server::backend::{ ClientData, ClientId, DisconnectReason, GlobalId, }; @@ -52,6 +54,7 @@ use smithay::wayland::output::OutputManagerState; use smithay::wayland::pointer_gestures::PointerGesturesState; use smithay::wayland::presentation::PresentationState; use smithay::wayland::primary_selection::PrimarySelectionState; +use smithay::wayland::shell::kde::decoration::KdeDecorationState; use smithay::wayland::shell::wlr_layer::{Layer, WlrLayerShellState}; use smithay::wayland::shell::xdg::decoration::XdgDecorationState; use smithay::wayland::shell::xdg::XdgShellState; @@ -95,6 +98,7 @@ pub struct Niri { pub compositor_state: CompositorState, pub xdg_shell_state: XdgShellState, pub xdg_decoration_state: XdgDecorationState, + pub kde_decoration_state: KdeDecorationState, pub layer_shell_state: WlrLayerShellState, pub shm_state: ShmState, pub output_manager_state: OutputManagerState, @@ -235,6 +239,14 @@ impl Niri { [WmCapabilities::Fullscreen], ); let xdg_decoration_state = XdgDecorationState::new::(&display_handle); + let kde_decoration_state = KdeDecorationState::new::( + &display_handle, + if config_.prefer_no_csd { + KdeDecorationsMode::Server + } else { + KdeDecorationsMode::Client + }, + ); let layer_shell_state = WlrLayerShellState::new::(&display_handle); let shm_state = ShmState::new::(&display_handle, vec![]); let output_manager_state = @@ -587,6 +599,7 @@ impl Niri { compositor_state, xdg_shell_state, xdg_decoration_state, + kde_decoration_state, layer_shell_state, shm_state, output_manager_state,