Enable server side decorations on wayland (#8037)
This PR enables server side decorations on Wayland if possible. This is stopgap solution, so that the window can be moved, resized and dragged on Wayland sessions at all.  Since Wayland compositors can decide to force either mode (as in, forcing server or client side decorations), this requires additional handling in zed. Since zed doesn't provide any of that handling as of now, as a temporary solution server side decorations are always requested.
This commit is contained in:
parent
77974a4367
commit
fddb778e5f
3 changed files with 110 additions and 2 deletions
|
@ -41,6 +41,7 @@ struct WaylandWindowInner {
|
|||
bounds: Bounds<i32>,
|
||||
scale: f32,
|
||||
input_handler: Option<PlatformInputHandler>,
|
||||
decoration_state: WaylandDecorationState,
|
||||
}
|
||||
|
||||
struct RawWindow {
|
||||
|
@ -96,6 +97,9 @@ impl WaylandWindowInner {
|
|||
bounds,
|
||||
scale: 1.0,
|
||||
input_handler: None,
|
||||
|
||||
// On wayland, decorations are by default provided by the client
|
||||
decoration_state: WaylandDecorationState::Client,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -187,6 +191,20 @@ impl WaylandWindowState {
|
|||
self.set_size_and_scale(bounds.size.width, bounds.size.height, scale)
|
||||
}
|
||||
|
||||
/// Notifies the window of the state of the decorations.
|
||||
///
|
||||
/// # Note
|
||||
///
|
||||
/// This API is indirectly called by the wayland compositor and
|
||||
/// not meant to be called by a user who wishes to change the state
|
||||
/// of the decorations. This is because the state of the decorations
|
||||
/// is managed by the compositor and not the client.
|
||||
pub fn set_decoration_state(&self, state: WaylandDecorationState) {
|
||||
self.inner.lock().decoration_state = state;
|
||||
log::trace!("Window decorations are now handled by {:?}", state);
|
||||
// todo!(linux) - Handle this properly
|
||||
}
|
||||
|
||||
pub fn close(&self) {
|
||||
let mut callbacks = self.callbacks.lock();
|
||||
if let Some(fun) = callbacks.close.take() {
|
||||
|
@ -377,3 +395,12 @@ impl PlatformWindow for WaylandWindow {
|
|||
//todo!(linux)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
|
||||
pub enum WaylandDecorationState {
|
||||
/// Decorations are to be provided by the client
|
||||
Client,
|
||||
|
||||
/// Decorations are provided by the server
|
||||
Server,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue