Anvil XDG Decoration

This commit is contained in:
Poly 2021-10-08 20:57:26 +02:00 committed by Victor Berger
parent 10aee60b87
commit 67ed81a00c
1 changed files with 22 additions and 0 deletions

View File

@ -10,6 +10,7 @@ use std::{
use smithay::{ use smithay::{
reexports::{ reexports::{
calloop::{generic::Generic, Interest, LoopHandle, Mode, PostAction}, calloop::{generic::Generic, Interest, LoopHandle, Mode, PostAction},
wayland_protocols::unstable::xdg_decoration,
wayland_server::{protocol::wl_surface::WlSurface, Display}, wayland_server::{protocol::wl_surface::WlSurface, Display},
}, },
utils::{Logical, Point}, utils::{Logical, Point},
@ -17,6 +18,7 @@ use smithay::{
data_device::{default_action_chooser, init_data_device, set_data_device_focus, DataDeviceEvent}, data_device::{default_action_chooser, init_data_device, set_data_device_focus, DataDeviceEvent},
output::xdg::init_xdg_output_manager, output::xdg::init_xdg_output_manager,
seat::{CursorImageStatus, KeyboardHandle, PointerHandle, Seat, XkbConfig}, seat::{CursorImageStatus, KeyboardHandle, PointerHandle, Seat, XkbConfig},
shell::xdg::decoration::{init_xdg_decoration_manager, XdgDecorationRequest},
shm::init_shm_global, shm::init_shm_global,
tablet_manager::{init_tablet_manager_global, TabletSeatTrait}, tablet_manager::{init_tablet_manager_global, TabletSeatTrait},
xdg_activation::{init_xdg_activation_global, XdgActivationEvent}, xdg_activation::{init_xdg_activation_global, XdgActivationEvent},
@ -120,6 +122,26 @@ impl<BackendData: Backend + 'static> AnvilState<BackendData> {
log.clone(), log.clone(),
); );
init_xdg_decoration_manager(
&mut display.borrow_mut(),
|req, _ddata| match req {
XdgDecorationRequest::NewToplevelDecoration { toplevel } => {
use xdg_decoration::v1::server::zxdg_toplevel_decoration_v1::Mode;
let res = toplevel.with_pending_state(|state| {
state.decoration_mode = Some(Mode::ClientSide);
});
if res.is_ok() {
toplevel.send_configure();
}
}
XdgDecorationRequest::SetMode { .. } => {}
XdgDecorationRequest::UnsetMode { .. } => {}
},
log.clone(),
);
let socket_name = if listen_on_socket { let socket_name = if listen_on_socket {
let socket_name = display let socket_name = display
.borrow_mut() .borrow_mut()