x11: Fix window menu not showing (#15328)

Fixes
https://github.com/zed-industries/zed/issues/15245#issuecomment-2252790889

Release Notes:

- Linux: Fixed window menu not showing on X11
This commit is contained in:
apricotbucket28 2024-07-27 16:29:48 -03:00 committed by GitHub
parent 3a44a59f8e
commit 04e25525bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 23 additions and 14 deletions

View File

@ -255,7 +255,7 @@ pub enum Decorations {
}
/// What window controls this platform supports
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Default)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub struct WindowControls {
/// Whether this platform supports fullscreen
pub fullscreen: bool,
@ -267,6 +267,18 @@ pub struct WindowControls {
pub window_menu: bool,
}
impl Default for WindowControls {
fn default() -> Self {
// Assume that we can do anything, unless told otherwise
Self {
fullscreen: true,
maximize: true,
minimize: true,
window_menu: true,
}
}
}
/// A type to describe which sides of the window are currently tiled in some way
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Default)]
pub struct Tiling {
@ -355,12 +367,7 @@ pub(crate) trait PlatformWindow: HasWindowHandle + HasDisplayHandle {
}
fn set_app_id(&mut self, _app_id: &str) {}
fn window_controls(&self) -> WindowControls {
WindowControls {
fullscreen: true,
maximize: true,
minimize: true,
window_menu: false,
}
WindowControls::default()
}
fn set_client_inset(&self, _inset: Pixels) {}
fn gpu_specs(&self) -> Option<GPUSpecs>;

View File

@ -185,13 +185,7 @@ impl WaylandWindowState {
active: false,
hovered: false,
in_progress_window_controls: None,
// Assume that we can do anything, unless told otherwise
window_controls: WindowControls {
fullscreen: true,
maximize: true,
minimize: true,
window_menu: true,
},
window_controls: WindowControls::default(),
inset: None,
})
}

View File

@ -1230,6 +1230,14 @@ impl PlatformWindow for X11Window {
fn show_window_menu(&self, position: Point<Pixels>) {
let state = self.0.state.borrow();
self.0
.xcb_connection
.ungrab_pointer(x11rb::CURRENT_TIME)
.unwrap()
.check()
.unwrap();
let coords = self.get_root_position(position);
let message = ClientMessageEvent::new(
32,