From ca192e18a9f49d7ffad3126a026e013b7c2c80e8 Mon Sep 17 00:00:00 2001 From: Nova Date: Mon, 19 Sep 2022 08:13:23 -0400 Subject: [PATCH] feat(wayland): kde decoration support --- .../{xdg_decoration.rs => decoration.rs} | 13 ++++++++++-- src/wayland/mod.rs | 4 ++-- src/wayland/state.rs | 20 ++++++++++++++----- src/wayland/xdg_shell.rs | 2 +- 4 files changed, 29 insertions(+), 10 deletions(-) rename src/wayland/{xdg_decoration.rs => decoration.rs} (67%) diff --git a/src/wayland/xdg_decoration.rs b/src/wayland/decoration.rs similarity index 67% rename from src/wayland/xdg_decoration.rs rename to src/wayland/decoration.rs index 78c632b..69380b3 100644 --- a/src/wayland/xdg_decoration.rs +++ b/src/wayland/decoration.rs @@ -1,8 +1,10 @@ use super::state::WaylandState; use smithay::{ - delegate_xdg_decoration, + delegate_kde_decoration, delegate_xdg_decoration, reexports::wayland_protocols::xdg::decoration::zv1::server::zxdg_toplevel_decoration_v1::Mode, - wayland::shell::xdg::decoration::XdgDecorationHandler, + wayland::shell::{ + self, kde::decoration::KdeDecorationHandler, xdg::decoration::XdgDecorationHandler, + }, }; impl XdgDecorationHandler for WaylandState { @@ -23,3 +25,10 @@ impl XdgDecorationHandler for WaylandState { fn unset_mode(&mut self, _toplevel: smithay::wayland::shell::xdg::ToplevelSurface) {} } delegate_xdg_decoration!(WaylandState); + +impl KdeDecorationHandler for WaylandState { + fn kde_decoration_state(&self) -> &shell::kde::decoration::KdeDecorationState { + &self.kde_decoration_state + } +} +delegate_kde_decoration!(WaylandState); diff --git a/src/wayland/mod.rs b/src/wayland/mod.rs index 53577da..278c6af 100644 --- a/src/wayland/mod.rs +++ b/src/wayland/mod.rs @@ -1,15 +1,15 @@ pub mod compositor; mod data_device; +pub mod decoration; pub mod panel_item; pub mod seat; pub mod shaders; pub mod state; pub mod surface; -pub mod xdg_decoration; pub mod xdg_shell; use self::{panel_item::PanelItem, state::WaylandState, surface::CORE_SURFACES}; -use crate::wayland::{seat::SeatData, state::ClientState}; +use crate::wayland::state::ClientState; use anyhow::{ensure, Result}; use once_cell::sync::OnceCell; use parking_lot::Mutex; diff --git a/src/wayland/state.rs b/src/wayland/state.rs index 584a4a1..6937548 100644 --- a/src/wayland/state.rs +++ b/src/wayland/state.rs @@ -5,17 +5,23 @@ use slog::Logger; use smithay::{ delegate_output, delegate_shm, output::{Output, Scale, Subpixel}, - reexports::wayland_server::{ - backend::{ClientData, ClientId, DisconnectReason}, - protocol::wl_data_device_manager::WlDataDeviceManager, - Display, DisplayHandle, + reexports::{ + wayland_protocols_misc::server_decoration::server::org_kde_kwin_server_decoration_manager::Mode, + wayland_server::{ + backend::{ClientData, ClientId, DisconnectReason}, + protocol::wl_data_device_manager::WlDataDeviceManager, + Display, DisplayHandle, + }, }, utils::Size, wayland::{ buffer::BufferHandler, compositor::CompositorState, output::OutputManagerState, - shell::xdg::{decoration::XdgDecorationState, XdgShellState}, + shell::{ + kde::decoration::KdeDecorationState, + xdg::{decoration::XdgDecorationState, XdgShellState}, + }, shm::{ShmHandler, ShmState}, }, }; @@ -42,6 +48,7 @@ pub struct WaylandState { pub compositor_state: CompositorState, pub xdg_shell_state: XdgShellState, pub xdg_decoration_state: XdgDecorationState, + pub kde_decoration_state: KdeDecorationState, pub shm_state: ShmState, pub output_manager_state: OutputManagerState, pub output: Output, @@ -57,6 +64,8 @@ impl WaylandState { let compositor_state = CompositorState::new::(&display_handle, log.clone()); let xdg_shell_state = XdgShellState::new::(&display_handle, log.clone()); let xdg_decoration_state = XdgDecorationState::new::(&display_handle, log.clone()); + let kde_decoration_state = + KdeDecorationState::new::(&display_handle, Mode::Server, log.clone()); let shm_state = ShmState::new::(&display_handle, vec![], log.clone()); let output_manager_state = OutputManagerState::new_with_xdg_output::(&display_handle); let output = Output::new( @@ -82,6 +91,7 @@ impl WaylandState { compositor_state, xdg_shell_state, xdg_decoration_state, + kde_decoration_state, shm_state, output_manager_state, output, diff --git a/src/wayland/xdg_shell.rs b/src/wayland/xdg_shell.rs index 3f5ecbe..1d914fc 100644 --- a/src/wayland/xdg_shell.rs +++ b/src/wayland/xdg_shell.rs @@ -23,7 +23,7 @@ impl XdgShellHandler for WaylandState { self.output .enter(&self.display_handle, surface.wl_surface()); surface.with_pending_state(|state| { - state.states.set(State::Fullscreen); + state.states.set(State::Maximized); state.states.set(State::Activated); state.decoration_mode = Some(Mode::ServerSide); });