From 12e13f863b4165da29b4bf74acd5747631bc6ff1 Mon Sep 17 00:00:00 2001 From: Victor Berger Date: Sun, 22 Apr 2018 19:58:10 +0200 Subject: [PATCH] wayland.shell.xdg: make names more explicit --- examples/helpers/implementations.rs | 10 +-- examples/helpers/window_map.rs | 6 +- src/wayland/shell/xdg/mod.rs | 60 ++++++++-------- src/wayland/shell/xdg/xdg_handlers.rs | 88 ++++++++++++------------ src/wayland/shell/xdg/zxdgv6_handlers.rs | 88 ++++++++++++------------ 5 files changed, 123 insertions(+), 129 deletions(-) diff --git a/examples/helpers/implementations.rs b/examples/helpers/implementations.rs index 2714773..10ef7bd 100644 --- a/examples/helpers/implementations.rs +++ b/examples/helpers/implementations.rs @@ -4,8 +4,8 @@ use rand; use smithay::backend::graphics::egl::wayland::{BufferAccessError, Format}; use smithay::backend::graphics::egl::wayland::{EGLDisplay, EGLImages}; use smithay::wayland::compositor::{compositor_init, CompositorToken, SurfaceAttributes, SurfaceEvent}; -use smithay::wayland::shell::xdg::{xdg_shell_init, PopupConfigure, ShellEvent, ShellState, ShellSurfaceRole, - ToplevelConfigure}; +use smithay::wayland::shell::xdg::{xdg_shell_init, PopupConfigure, ShellState, ToplevelConfigure, + XdgRequest, XdgSurfaceRole}; use smithay::wayland::shm::with_buffer_contents as shm_buffer_contents; use std::cell::RefCell; use std::rc::Rc; @@ -13,7 +13,7 @@ use std::sync::{Arc, Mutex}; use wayland_server::{Display, LoopToken, Resource}; use wayland_server::protocol::{wl_buffer, wl_callback, wl_surface}; -define_roles!(Roles => [ ShellSurface, ShellSurfaceRole ] ); +define_roles!(Roles => [ ShellSurface, XdgSurfaceRole ] ); #[derive(Default)] pub struct SurfaceData { @@ -137,7 +137,7 @@ pub fn init_shell( looptoken, compositor_token.clone(), move |shell_event, ()| match shell_event { - ShellEvent::NewToplevel { surface } => { + XdgRequest::NewToplevel { surface } => { // place the window at a random location in the [0;300]x[0;300] square use rand::distributions::{IndependentSample, Range}; let range = Range::new(0, 300); @@ -151,7 +151,7 @@ pub fn init_shell( }); shell_window_map.borrow_mut().insert(surface, (x, y)); } - ShellEvent::NewPopup { surface } => surface.send_configure(PopupConfigure { + XdgRequest::NewPopup { surface } => surface.send_configure(PopupConfigure { size: (10, 10), position: (10, 10), serial: 42, diff --git a/examples/helpers/window_map.rs b/examples/helpers/window_map.rs index 71a401a..b48a6e1 100644 --- a/examples/helpers/window_map.rs +++ b/examples/helpers/window_map.rs @@ -1,7 +1,7 @@ use smithay::utils::Rectangle; use smithay::wayland::compositor::{CompositorToken, SubsurfaceRole, SurfaceAttributes, TraversalAction}; use smithay::wayland::compositor::roles::Role; -use smithay::wayland::shell::xdg::{ShellSurfaceRole, ToplevelSurface}; +use smithay::wayland::shell::xdg::{ToplevelSurface, XdgSurfaceRole}; use wayland_server::Resource; use wayland_server::protocol::wl_surface; @@ -14,7 +14,7 @@ struct Window { impl Window where U: 'static, - R: Role + Role + 'static, + R: Role + Role + 'static, SD: 'static, { // Find the topmost surface under this point if any and the location of this point in the surface @@ -121,7 +121,7 @@ impl WindowMap where F: Fn(&SurfaceAttributes) -> Option<(i32, i32)>, U: 'static, - R: Role + Role + 'static, + R: Role + Role + 'static, SD: 'static, { pub fn new(ctoken: CompositorToken, get_size: F) -> WindowMap { diff --git a/src/wayland/shell/xdg/mod.rs b/src/wayland/shell/xdg/mod.rs index 94326cc..c091f73 100644 --- a/src/wayland/shell/xdg/mod.rs +++ b/src/wayland/shell/xdg/mod.rs @@ -32,15 +32,15 @@ //! # //! use smithay::wayland::compositor::roles::*; //! use smithay::wayland::compositor::CompositorToken; -//! use smithay::wayland::shell::xdg::{xdg_shell_init, ShellSurfaceRole, ShellEvent}; +//! use smithay::wayland::shell::xdg::{xdg_shell_init, XdgSurfaceRole, XdgRequest}; //! use wayland_protocols::unstable::xdg_shell::v6::server::zxdg_shell_v6::ZxdgShellV6; //! use wayland_server::{EventLoop, LoopToken}; //! # use wayland_server::protocol::{wl_seat, wl_output}; //! # #[derive(Default)] struct MySurfaceData; //! -//! // define the roles type. You need to integrate the ShellSurface role: +//! // define the roles type. You need to integrate the XdgSurface role: //! define_roles!(MyRoles => -//! [ShellSurface, ShellSurfaceRole] +//! [XdgSurface, XdgSurfaceRole] //! ); //! //! // define the metadata you want associated with the shell clients @@ -63,8 +63,8 @@ //! // token from the compositor implementation //! compositor_token, //! // your implementation, can also be a strucy implementing the -//! // appropriate Implementation<(), ShellEvent<_, _, _>> trait -//! |event: ShellEvent<_, _, MyShellData>, ()| { /* ... */ }, +//! // appropriate Implementation<(), XdgRequest<_, _, _>> trait +//! |event: XdgRequest<_, _, MyShellData>, ()| { /* ... */ }, //! None // put a logger if you want //! ); //! @@ -106,13 +106,13 @@ mod xdg_handlers; // compatibility handlers for the zxdg_shell_v6 protocol, its earlier version mod zxdgv6_handlers; -/// Metadata associated with the `shell_surface` role -pub struct ShellSurfaceRole { +/// Metadata associated with the `xdg_surface` role +pub struct XdgSurfaceRole { /// Pending state as requested by the client /// /// The data in this field are double-buffered, you should /// apply them on a surface commit. - pub pending_state: ShellSurfacePendingState, + pub pending_state: XdgSurfacePendingState, /// Geometry of the surface /// /// Defines, in surface relative coordinates, what should @@ -175,7 +175,7 @@ impl PositionerState { } /// Contents of the pending state of a shell surface, depending on its role -pub enum ShellSurfacePendingState { +pub enum XdgSurfacePendingState { /// This a regular, toplevel surface /// /// This corresponds to the `xdg_toplevel` role @@ -248,9 +248,9 @@ impl Clone for PopupState { } } -impl Default for ShellSurfacePendingState { - fn default() -> ShellSurfacePendingState { - ShellSurfacePendingState::None +impl Default for XdgSurfacePendingState { + fn default() -> XdgSurfacePendingState { + XdgSurfacePendingState::None } } @@ -258,7 +258,7 @@ pub(crate) struct ShellImplementation { log: ::slog::Logger, compositor_token: CompositorToken, loop_token: LoopToken, - user_impl: Rc>>>, + user_impl: Rc>>>, shell_state: Arc>>, } @@ -288,10 +288,10 @@ pub fn xdg_shell_init( ) where U: 'static, - R: Role + 'static, + R: Role + 'static, SD: Default + 'static, L: Into>, - Impl: Implementation<(), ShellEvent>, + Impl: Implementation<(), XdgRequest>, { let log = ::slog_or_stdlog(logger); let shell_state = Arc::new(Mutex::new(ShellState { @@ -300,7 +300,7 @@ where })); let shell_impl = ShellImplementation { - log: log.new(o!("smithay_module" => "shell_handler")), + log: log.new(o!("smithay_module" => "xdg_shell_handler")), loop_token: ltoken.clone(), compositor_token: ctoken, user_impl: Rc::new(RefCell::new(implementation)), @@ -332,15 +332,9 @@ pub struct ShellState { impl ShellState where U: 'static, - R: Role + 'static, + R: Role + 'static, SD: 'static, { - /// Cleans the internal surface storage by removing all dead surfaces - pub fn cleanup_surfaces(&mut self) { - self.known_toplevels.retain(|s| s.alive()); - self.known_popups.retain(|s| s.alive()); - } - /// Access all the shell surfaces known by this handler pub fn toplevel_surfaces(&self) -> &[ToplevelSurface] { &self.known_toplevels[..] @@ -409,7 +403,7 @@ impl ShellClient { /// Send a ping request to this shell client /// - /// You'll receive the reply in the `Handler::cient_pong()` method. + /// You'll receive the reply as a `XdgRequest::ClientPong` request. /// /// A typical use is to start a timer at the same time you send this ping /// request, and cancel it when you receive the pong. If the timer runs @@ -486,7 +480,7 @@ pub struct ToplevelSurface { impl ToplevelSurface where U: 'static, - R: Role + 'static, + R: Role + 'static, SD: 'static, { /// Is the toplevel surface refered by this handle still alive? @@ -556,7 +550,7 @@ where return false; } let configured = self.token - .with_role_data::(&self.wl_surface, |data| data.configured) + .with_role_data::(&self.wl_surface, |data| data.configured) .expect("A shell surface object exists but the surface does not have the shell_surface role ?!"); if !configured { match self.shell_surface { @@ -610,8 +604,8 @@ where return None; } self.token - .with_role_data::(&self.wl_surface, |data| match data.pending_state { - ShellSurfacePendingState::Toplevel(ref state) => Some(state.clone()), + .with_role_data::(&self.wl_surface, |data| match data.pending_state { + XdgSurfacePendingState::Toplevel(ref state) => Some(state.clone()), _ => None, }) .ok() @@ -638,7 +632,7 @@ pub struct PopupSurface { impl PopupSurface where U: 'static, - R: Role + 'static, + R: Role + 'static, SD: 'static, { /// Is the popup surface refered by this handle still alive? @@ -712,7 +706,7 @@ where return false; } let configured = self.token - .with_role_data::(&self.wl_surface, |data| data.configured) + .with_role_data::(&self.wl_surface, |data| data.configured) .expect("A shell surface object exists but the surface does not have the shell_surface role ?!"); if !configured { match self.shell_surface { @@ -769,8 +763,8 @@ where return None; } self.token - .with_role_data::(&self.wl_surface, |data| match data.pending_state { - ShellSurfacePendingState::Popup(ref state) => Some(state.clone()), + .with_role_data::(&self.wl_surface, |data| match data.pending_state { + XdgSurfacePendingState::Popup(ref state) => Some(state.clone()), _ => None, }) .ok() @@ -816,7 +810,7 @@ pub struct PopupConfigure { /// for you directly. /// /// Depending on what you want to do, you might ignore some of them -pub enum ShellEvent { +pub enum XdgRequest { /// A new shell client was instanciated NewClient { /// the client diff --git a/src/wayland/shell/xdg/xdg_handlers.rs b/src/wayland/shell/xdg/xdg_handlers.rs index 7858dac..68c11e0 100644 --- a/src/wayland/shell/xdg/xdg_handlers.rs +++ b/src/wayland/shell/xdg/xdg_handlers.rs @@ -1,6 +1,6 @@ use super::{make_shell_client_data, PopupConfigure, PopupKind, PopupState, PositionerState, ShellClient, - ShellClientData, ShellEvent, ShellImplementation, ShellSurfacePendingState, ShellSurfaceRole, - ToplevelConfigure, ToplevelKind, ToplevelState}; + ShellClientData, ShellImplementation, ToplevelConfigure, ToplevelKind, ToplevelState, + XdgRequest, XdgSurfacePendingState, XdgSurfaceRole}; use std::sync::Mutex; use utils::Rectangle; use wayland::compositor::CompositorToken; @@ -16,7 +16,7 @@ pub(crate) fn implement_wm_base( ) -> Resource where U: 'static, - R: Role + 'static, + R: Role + 'static, SD: Default + 'static, { let shell = shell.implement_nonsend( @@ -27,7 +27,7 @@ where shell.set_user_data(Box::into_raw(Box::new(Mutex::new(make_shell_client_data::()))) as *mut _); let mut user_impl = implem.user_impl.borrow_mut(); user_impl.receive( - ShellEvent::NewClient { + XdgRequest::NewClient { client: make_shell_client(&shell), }, (), @@ -60,7 +60,7 @@ impl Implementation, xdg_wm_base::Req for ShellImplementation where U: 'static, - R: Role + 'static, + R: Role + 'static, SD: 'static, { fn receive(&mut self, request: xdg_wm_base::Request, shell: Resource) { @@ -72,8 +72,8 @@ where implement_positioner(id, &self.loop_token); } xdg_wm_base::Request::GetXdgSurface { id, surface } => { - let role_data = ShellSurfaceRole { - pending_state: ShellSurfacePendingState::None, + let role_data = XdgSurfaceRole { + pending_state: XdgSurfacePendingState::None, window_geometry: None, pending_configures: Vec::new(), configured: false, @@ -110,7 +110,7 @@ where if valid { let mut user_impl = self.user_impl.borrow_mut(); user_impl.receive( - ShellEvent::ClientPong { + XdgRequest::ClientPong { client: make_shell_client(&shell), }, (), @@ -216,7 +216,7 @@ fn destroy_surface( implem: Box, xdg_surface::Request>>, ) where U: 'static, - R: Role + 'static, + R: Role + 'static, SD: 'static, { let implem: ShellImplementation = *downcast_impl(implem).unwrap_or_else(|_| unreachable!()); @@ -232,8 +232,8 @@ fn destroy_surface( } implem .compositor_token - .with_role_data::(&data.0, |rdata| { - if let ShellSurfacePendingState::None = rdata.pending_state { + .with_role_data::(&data.0, |rdata| { + if let XdgSurfacePendingState::None = rdata.pending_state { // all is good } else { data.1.post_error( @@ -249,7 +249,7 @@ impl Implementation, xdg_surface::Re for ShellImplementation where U: 'static, - R: Role + 'static, + R: Role + 'static, SD: 'static, { fn receive(&mut self, request: xdg_surface::Request, xdg_surface: Resource) { @@ -261,8 +261,8 @@ where } xdg_surface::Request::GetToplevel { id } => { self.compositor_token - .with_role_data::(surface, |data| { - data.pending_state = ShellSurfacePendingState::Toplevel(ToplevelState { + .with_role_data::(surface, |data| { + data.pending_state = XdgSurfacePendingState::Toplevel(ToplevelState { parent: None, title: String::new(), app_id: String::new(), @@ -290,7 +290,7 @@ where let handle = make_toplevel_handle(self.compositor_token, &toplevel); let mut user_impl = self.user_impl.borrow_mut(); - user_impl.receive(ShellEvent::NewToplevel { surface: handle }, ()); + user_impl.receive(XdgRequest::NewToplevel { surface: handle }, ()); } xdg_surface::Request::GetPopup { id, @@ -305,8 +305,8 @@ where parent_surface.clone() }); self.compositor_token - .with_role_data::(surface, |data| { - data.pending_state = ShellSurfacePendingState::Popup(PopupState { + .with_role_data::(surface, |data| { + data.pending_state = XdgSurfacePendingState::Popup(PopupState { parent: parent_surface, positioner: positioner_data.clone(), }); @@ -331,7 +331,7 @@ where let handle = make_popup_handle(self.compositor_token, &popup); let mut user_impl = self.user_impl.borrow_mut(); - user_impl.receive(ShellEvent::NewPopup { surface: handle }, ()); + user_impl.receive(XdgRequest::NewPopup { surface: handle }, ()); } xdg_surface::Request::SetWindowGeometry { x, @@ -340,7 +340,7 @@ where height, } => { self.compositor_token - .with_role_data::(surface, |data| { + .with_role_data::(surface, |data| { data.window_geometry = Some(Rectangle { x, y, @@ -352,7 +352,7 @@ where } xdg_surface::Request::AckConfigure { serial } => { self.compositor_token - .with_role_data::(surface, |data| { + .with_role_data::(surface, |data| { let mut found = false; data.pending_configures.retain(|&s| { if s == serial { @@ -392,7 +392,7 @@ fn with_surface_toplevel_data( f: F, ) where U: 'static, - R: Role + 'static, + R: Role + 'static, SD: 'static, F: FnOnce(&mut ToplevelState), { @@ -400,8 +400,8 @@ fn with_surface_toplevel_data( let &(ref surface, _, _) = unsafe { &*(ptr as *mut ShellSurfaceUserData) }; implem .compositor_token - .with_role_data::(surface, |data| match data.pending_state { - ShellSurfacePendingState::Toplevel(ref mut toplevel_data) => f(toplevel_data), + .with_role_data::(surface, |data| match data.pending_state { + XdgSurfacePendingState::Toplevel(ref mut toplevel_data) => f(toplevel_data), _ => unreachable!(), }) .expect("xdg_toplevel exists but surface has not shell_surface role?!"); @@ -413,7 +413,7 @@ pub fn send_toplevel_configure( configure: ToplevelConfigure, ) where U: 'static, - R: Role + 'static, + R: Role + 'static, { let &(ref surface, _, ref shell_surface) = unsafe { &*(resource.get_user_data() as *mut ShellSurfaceUserData) }; @@ -436,7 +436,7 @@ pub fn send_toplevel_configure( shell_surface.send(xdg_surface::Event::Configure { serial }); // Add the configure as pending token - .with_role_data::(surface, |data| data.pending_configures.push(serial)) + .with_role_data::(surface, |data| data.pending_configures.push(serial)) .expect("xdg_toplevel exists but surface has not shell_surface role?!"); } @@ -458,7 +458,7 @@ impl Implementation, xdg_toplevel: for ShellImplementation where U: 'static, - R: Role + 'static, + R: Role + 'static, SD: 'static, { fn receive(&mut self, request: xdg_toplevel::Request, toplevel: Resource) { @@ -490,7 +490,7 @@ where let handle = make_toplevel_handle(self.compositor_token, &toplevel); let mut user_impl = self.user_impl.borrow_mut(); user_impl.receive( - ShellEvent::ShowWindowMenu { + XdgRequest::ShowWindowMenu { surface: handle, seat, serial, @@ -503,7 +503,7 @@ where let handle = make_toplevel_handle(self.compositor_token, &toplevel); let mut user_impl = self.user_impl.borrow_mut(); user_impl.receive( - ShellEvent::Move { + XdgRequest::Move { surface: handle, seat, serial, @@ -521,7 +521,7 @@ where let handle = make_toplevel_handle(self.compositor_token, &toplevel); let mut user_impl = self.user_impl.borrow_mut(); user_impl.receive( - ShellEvent::Resize { + XdgRequest::Resize { surface: handle, seat, serial, @@ -543,18 +543,18 @@ where xdg_toplevel::Request::SetMaximized => { let handle = make_toplevel_handle(self.compositor_token, &toplevel); let mut user_impl = self.user_impl.borrow_mut(); - user_impl.receive(ShellEvent::Maximize { surface: handle }, ()); + user_impl.receive(XdgRequest::Maximize { surface: handle }, ()); } xdg_toplevel::Request::UnsetMaximized => { let handle = make_toplevel_handle(self.compositor_token, &toplevel); let mut user_impl = self.user_impl.borrow_mut(); - user_impl.receive(ShellEvent::UnMaximize { surface: handle }, ()); + user_impl.receive(XdgRequest::UnMaximize { surface: handle }, ()); } xdg_toplevel::Request::SetFullscreen { output } => { let handle = make_toplevel_handle(self.compositor_token, &toplevel); let mut user_impl = self.user_impl.borrow_mut(); user_impl.receive( - ShellEvent::Fullscreen { + XdgRequest::Fullscreen { surface: handle, output, }, @@ -564,12 +564,12 @@ where xdg_toplevel::Request::UnsetFullscreen => { let handle = make_toplevel_handle(self.compositor_token, &toplevel); let mut user_impl = self.user_impl.borrow_mut(); - user_impl.receive(ShellEvent::UnFullscreen { surface: handle }, ()); + user_impl.receive(XdgRequest::UnFullscreen { surface: handle }, ()); } xdg_toplevel::Request::SetMinimized => { let handle = make_toplevel_handle(self.compositor_token, &toplevel); let mut user_impl = self.user_impl.borrow_mut(); - user_impl.receive(ShellEvent::Minimize { surface: handle }, ()); + user_impl.receive(XdgRequest::Minimize { surface: handle }, ()); } } } @@ -580,7 +580,7 @@ fn destroy_toplevel( implem: Box, xdg_toplevel::Request>>, ) where U: 'static, - R: Role + 'static, + R: Role + 'static, SD: 'static, { let implem: ShellImplementation = *downcast_impl(implem).unwrap_or_else(|_| unreachable!()); @@ -596,8 +596,8 @@ fn destroy_toplevel( } else { implem .compositor_token - .with_role_data::(&data.0, |data| { - data.pending_state = ShellSurfacePendingState::None; + .with_role_data::(&data.0, |data| { + data.pending_state = XdgSurfacePendingState::None; data.configured = false; }) .expect("xdg_toplevel exists but surface has not shell_surface role?!"); @@ -621,7 +621,7 @@ pub(crate) fn send_popup_configure( configure: PopupConfigure, ) where U: 'static, - R: Role + 'static, + R: Role + 'static, { let &(ref surface, _, ref shell_surface) = unsafe { &*(resource.get_user_data() as *mut ShellSurfaceUserData) }; @@ -637,7 +637,7 @@ pub(crate) fn send_popup_configure( shell_surface.send(xdg_surface::Event::Configure { serial }); // Add the configure as pending token - .with_role_data::(surface, |data| data.pending_configures.push(serial)) + .with_role_data::(surface, |data| data.pending_configures.push(serial)) .expect("xdg_toplevel exists but surface has not shell_surface role?!"); } @@ -659,7 +659,7 @@ impl Implementation, xdg_popup::Request> for ShellImplementation where U: 'static, - R: Role + 'static, + R: Role + 'static, SD: 'static, { fn receive(&mut self, request: xdg_popup::Request, popup: Resource) { @@ -671,7 +671,7 @@ where let handle = make_popup_handle(self.compositor_token, &popup); let mut user_impl = self.user_impl.borrow_mut(); user_impl.receive( - ShellEvent::Grab { + XdgRequest::Grab { surface: handle, seat, serial, @@ -688,7 +688,7 @@ fn destroy_popup( implem: Box, xdg_popup::Request>>, ) where U: 'static, - R: Role + 'static, + R: Role + 'static, SD: 'static, { let implem: ShellImplementation = *downcast_impl(implem).unwrap_or_else(|_| unreachable!()); @@ -704,8 +704,8 @@ fn destroy_popup( } else { implem .compositor_token - .with_role_data::(&data.0, |data| { - data.pending_state = ShellSurfacePendingState::None; + .with_role_data::(&data.0, |data| { + data.pending_state = XdgSurfacePendingState::None; data.configured = false; }) .expect("xdg_popup exists but surface has not shell_surface role?!"); diff --git a/src/wayland/shell/xdg/zxdgv6_handlers.rs b/src/wayland/shell/xdg/zxdgv6_handlers.rs index 4a0d9dc..8e25154 100644 --- a/src/wayland/shell/xdg/zxdgv6_handlers.rs +++ b/src/wayland/shell/xdg/zxdgv6_handlers.rs @@ -1,6 +1,6 @@ use super::{make_shell_client_data, PopupConfigure, PopupKind, PopupState, PositionerState, ShellClient, - ShellClientData, ShellEvent, ShellImplementation, ShellSurfacePendingState, ShellSurfaceRole, - ToplevelConfigure, ToplevelKind, ToplevelState}; + ShellClientData, ShellImplementation, ToplevelConfigure, ToplevelKind, ToplevelState, + XdgRequest, XdgSurfacePendingState, XdgSurfaceRole}; use std::sync::Mutex; use utils::Rectangle; use wayland::compositor::CompositorToken; @@ -18,7 +18,7 @@ pub(crate) fn implement_shell( ) -> Resource where U: 'static, - R: Role + 'static, + R: Role + 'static, SD: Default + 'static, { let shell = shell.implement_nonsend( @@ -29,7 +29,7 @@ where shell.set_user_data(Box::into_raw(Box::new(Mutex::new(make_shell_client_data::()))) as *mut _); let mut user_impl = implem.user_impl.borrow_mut(); user_impl.receive( - ShellEvent::NewClient { + XdgRequest::NewClient { client: make_shell_client(&shell), }, (), @@ -62,7 +62,7 @@ impl Implementation, zxdg_shell_v for ShellImplementation where U: 'static, - R: Role + 'static, + R: Role + 'static, SD: 'static, { fn receive(&mut self, request: zxdg_shell_v6::Request, shell: Resource) { @@ -74,8 +74,8 @@ where implement_positioner(id, &self.loop_token); } zxdg_shell_v6::Request::GetXdgSurface { id, surface } => { - let role_data = ShellSurfaceRole { - pending_state: ShellSurfacePendingState::None, + let role_data = XdgSurfaceRole { + pending_state: XdgSurfacePendingState::None, window_geometry: None, pending_configures: Vec::new(), configured: false, @@ -112,7 +112,7 @@ where if valid { let mut user_impl = self.user_impl.borrow_mut(); user_impl.receive( - ShellEvent::ClientPong { + XdgRequest::ClientPong { client: make_shell_client(&shell), }, (), @@ -232,7 +232,7 @@ fn destroy_surface( implem: Box, zxdg_surface_v6::Request>>, ) where U: 'static, - R: Role + 'static, + R: Role + 'static, SD: 'static, { let implem: ShellImplementation = *downcast_impl(implem).unwrap_or_else(|_| unreachable!()); @@ -248,8 +248,8 @@ fn destroy_surface( } implem .compositor_token - .with_role_data::(&data.0, |rdata| { - if let ShellSurfacePendingState::None = rdata.pending_state { + .with_role_data::(&data.0, |rdata| { + if let XdgSurfacePendingState::None = rdata.pending_state { // all is good } else { data.1.post_error( @@ -265,7 +265,7 @@ impl Implementation, zxdg_sur for ShellImplementation where U: 'static, - R: Role + 'static, + R: Role + 'static, SD: 'static, { fn receive( @@ -281,8 +281,8 @@ where } zxdg_surface_v6::Request::GetToplevel { id } => { self.compositor_token - .with_role_data::(surface, |data| { - data.pending_state = ShellSurfacePendingState::Toplevel(ToplevelState { + .with_role_data::(surface, |data| { + data.pending_state = XdgSurfacePendingState::Toplevel(ToplevelState { parent: None, title: String::new(), app_id: String::new(), @@ -310,7 +310,7 @@ where let handle = make_toplevel_handle(self.compositor_token, &toplevel); let mut user_impl = self.user_impl.borrow_mut(); - user_impl.receive(ShellEvent::NewToplevel { surface: handle }, ()); + user_impl.receive(XdgRequest::NewToplevel { surface: handle }, ()); } zxdg_surface_v6::Request::GetPopup { id, @@ -322,8 +322,8 @@ where let parent_ptr = parent.get_user_data(); let &(ref parent_surface, _) = unsafe { &*(parent_ptr as *mut XdgSurfaceUserData) }; self.compositor_token - .with_role_data::(surface, |data| { - data.pending_state = ShellSurfacePendingState::Popup(PopupState { + .with_role_data::(surface, |data| { + data.pending_state = XdgSurfacePendingState::Popup(PopupState { parent: Some(parent_surface.clone()), positioner: positioner_data.clone(), }); @@ -348,7 +348,7 @@ where let handle = make_popup_handle(self.compositor_token, &popup); let mut user_impl = self.user_impl.borrow_mut(); - user_impl.receive(ShellEvent::NewPopup { surface: handle }, ()); + user_impl.receive(XdgRequest::NewPopup { surface: handle }, ()); } zxdg_surface_v6::Request::SetWindowGeometry { x, @@ -357,7 +357,7 @@ where height, } => { self.compositor_token - .with_role_data::(surface, |data| { + .with_role_data::(surface, |data| { data.window_geometry = Some(Rectangle { x, y, @@ -369,7 +369,7 @@ where } zxdg_surface_v6::Request::AckConfigure { serial } => { self.compositor_token - .with_role_data::(surface, |data| { + .with_role_data::(surface, |data| { let mut found = false; data.pending_configures.retain(|&s| { if s == serial { @@ -409,7 +409,7 @@ fn with_surface_toplevel_data( f: F, ) where U: 'static, - R: Role + 'static, + R: Role + 'static, SD: 'static, F: FnOnce(&mut ToplevelState), { @@ -417,8 +417,8 @@ fn with_surface_toplevel_data( let &(ref surface, _, _) = unsafe { &*(ptr as *mut ShellSurfaceUserData) }; implem .compositor_token - .with_role_data::(surface, |data| match data.pending_state { - ShellSurfacePendingState::Toplevel(ref mut toplevel_data) => f(toplevel_data), + .with_role_data::(surface, |data| match data.pending_state { + XdgSurfacePendingState::Toplevel(ref mut toplevel_data) => f(toplevel_data), _ => unreachable!(), }) .expect("xdg_toplevel exists but surface has not shell_surface role?!"); @@ -430,7 +430,7 @@ pub fn send_toplevel_configure( configure: ToplevelConfigure, ) where U: 'static, - R: Role + 'static, + R: Role + 'static, { let &(ref surface, _, ref shell_surface) = unsafe { &*(resource.get_user_data() as *mut ShellSurfaceUserData) }; @@ -453,7 +453,7 @@ pub fn send_toplevel_configure( shell_surface.send(zxdg_surface_v6::Event::Configure { serial }); // Add the configure as pending token - .with_role_data::(surface, |data| data.pending_configures.push(serial)) + .with_role_data::(surface, |data| data.pending_configures.push(serial)) .expect("xdg_toplevel exists but surface has not shell_surface role?!"); } @@ -475,7 +475,7 @@ impl Implementation, zxdg_t for ShellImplementation where U: 'static, - R: Role + 'static, + R: Role + 'static, SD: 'static, { fn receive( @@ -511,7 +511,7 @@ where let handle = make_toplevel_handle(self.compositor_token, &toplevel); let mut user_impl = self.user_impl.borrow_mut(); user_impl.receive( - ShellEvent::ShowWindowMenu { + XdgRequest::ShowWindowMenu { surface: handle, seat, serial, @@ -524,7 +524,7 @@ where let handle = make_toplevel_handle(self.compositor_token, &toplevel); let mut user_impl = self.user_impl.borrow_mut(); user_impl.receive( - ShellEvent::Move { + XdgRequest::Move { surface: handle, seat, serial, @@ -542,7 +542,7 @@ where let handle = make_toplevel_handle(self.compositor_token, &toplevel); let mut user_impl = self.user_impl.borrow_mut(); user_impl.receive( - ShellEvent::Resize { + XdgRequest::Resize { surface: handle, seat, serial, @@ -564,18 +564,18 @@ where zxdg_toplevel_v6::Request::SetMaximized => { let handle = make_toplevel_handle(self.compositor_token, &toplevel); let mut user_impl = self.user_impl.borrow_mut(); - user_impl.receive(ShellEvent::Maximize { surface: handle }, ()); + user_impl.receive(XdgRequest::Maximize { surface: handle }, ()); } zxdg_toplevel_v6::Request::UnsetMaximized => { let handle = make_toplevel_handle(self.compositor_token, &toplevel); let mut user_impl = self.user_impl.borrow_mut(); - user_impl.receive(ShellEvent::UnMaximize { surface: handle }, ()); + user_impl.receive(XdgRequest::UnMaximize { surface: handle }, ()); } zxdg_toplevel_v6::Request::SetFullscreen { output } => { let handle = make_toplevel_handle(self.compositor_token, &toplevel); let mut user_impl = self.user_impl.borrow_mut(); user_impl.receive( - ShellEvent::Fullscreen { + XdgRequest::Fullscreen { surface: handle, output, }, @@ -585,12 +585,12 @@ where zxdg_toplevel_v6::Request::UnsetFullscreen => { let handle = make_toplevel_handle(self.compositor_token, &toplevel); let mut user_impl = self.user_impl.borrow_mut(); - user_impl.receive(ShellEvent::UnFullscreen { surface: handle }, ()); + user_impl.receive(XdgRequest::UnFullscreen { surface: handle }, ()); } zxdg_toplevel_v6::Request::SetMinimized => { let handle = make_toplevel_handle(self.compositor_token, &toplevel); let mut user_impl = self.user_impl.borrow_mut(); - user_impl.receive(ShellEvent::Minimize { surface: handle }, ()); + user_impl.receive(XdgRequest::Minimize { surface: handle }, ()); } } } @@ -601,7 +601,7 @@ fn destroy_toplevel( implem: Box, zxdg_toplevel_v6::Request>>, ) where U: 'static, - R: Role + 'static, + R: Role + 'static, SD: 'static, { let implem: ShellImplementation = *downcast_impl(implem).unwrap_or_else(|_| unreachable!()); @@ -617,8 +617,8 @@ fn destroy_toplevel( } else { implem .compositor_token - .with_role_data::(&data.0, |data| { - data.pending_state = ShellSurfacePendingState::None; + .with_role_data::(&data.0, |data| { + data.pending_state = XdgSurfacePendingState::None; data.configured = false; }) .expect("xdg_toplevel exists but surface has not shell_surface role?!"); @@ -642,7 +642,7 @@ pub(crate) fn send_popup_configure( configure: PopupConfigure, ) where U: 'static, - R: Role + 'static, + R: Role + 'static, { let &(ref surface, _, ref shell_surface) = unsafe { &*(resource.get_user_data() as *mut ShellSurfaceUserData) }; @@ -658,7 +658,7 @@ pub(crate) fn send_popup_configure( shell_surface.send(zxdg_surface_v6::Event::Configure { serial }); // Add the configure as pending token - .with_role_data::(surface, |data| data.pending_configures.push(serial)) + .with_role_data::(surface, |data| data.pending_configures.push(serial)) .expect("xdg_toplevel exists but surface has not shell_surface role?!"); } @@ -680,7 +680,7 @@ impl Implementation, zxdg_popup_v for ShellImplementation where U: 'static, - R: Role + 'static, + R: Role + 'static, SD: 'static, { fn receive(&mut self, request: zxdg_popup_v6::Request, popup: Resource) { @@ -692,7 +692,7 @@ where let handle = make_popup_handle(self.compositor_token, &popup); let mut user_impl = self.user_impl.borrow_mut(); user_impl.receive( - ShellEvent::Grab { + XdgRequest::Grab { surface: handle, seat, serial, @@ -709,7 +709,7 @@ fn destroy_popup( implem: Box, zxdg_popup_v6::Request>>, ) where U: 'static, - R: Role + 'static, + R: Role + 'static, SD: 'static, { let implem: ShellImplementation = *downcast_impl(implem).unwrap_or_else(|_| unreachable!()); @@ -725,8 +725,8 @@ fn destroy_popup( } else { implem .compositor_token - .with_role_data::(&data.0, |data| { - data.pending_state = ShellSurfacePendingState::None; + .with_role_data::(&data.0, |data| { + data.pending_state = XdgSurfacePendingState::None; data.configured = false; }) .expect("xdg_popup exists but surface has not shell_surface role?!");