Skip to content

Commit

Permalink
shell: add support for kde server decorations
Browse files Browse the repository at this point in the history
This should provide server side decorations for the gtk3 applications,
like firefox.
  • Loading branch information
kchibisov authored and YaLTeR committed Sep 27, 2023
1 parent cf123dd commit 804e064
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/backend/tty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
11 changes: 10 additions & 1 deletion src/handlers/xdg_shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions src/niri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
};
Expand All @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -235,6 +239,14 @@ impl Niri {
[WmCapabilities::Fullscreen],
);
let xdg_decoration_state = XdgDecorationState::new::<State>(&display_handle);
let kde_decoration_state = KdeDecorationState::new::<State>(
&display_handle,
if config_.prefer_no_csd {
KdeDecorationsMode::Server
} else {
KdeDecorationsMode::Client
},
);
let layer_shell_state = WlrLayerShellState::new::<State>(&display_handle);
let shm_state = ShmState::new::<State>(&display_handle, vec![]);
let output_manager_state =
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 804e064

Please sign in to comment.