History

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

apricotbucket28 committed 2 years ago

Commit 04e25521 parent 3a44a593 files · +23 −14Browse files

Unified · Split

3 files
  1. crates/gpui/src/platform.rs +14 −7
  2. crates/gpui/src/platform/linux/wayland/window.rs +1 −7
  3. crates/gpui/src/platform/linux/x11/window.rs +8 −0
crates/gpui/src/platform.rs+14−7
@@ -255,7 +255,7 @@ pub enum Decorations { · 254 unmodified lines
255255 }
256256
257257 /// What window controls this platform supports
258−#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Default)]
258+#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
259259 pub struct WindowControls {
260260 /// Whether this platform supports fullscreen
261261 pub fullscreen: bool,
@@ -267,6 +267,18 @@ pub struct WindowControls { · 5 unmodified lines
267267 pub window_menu: bool,
268268 }
269269
270+impl Default for WindowControls {
271+ fn default() -> Self {
272+ // Assume that we can do anything, unless told otherwise
273+ Self {
274+ fullscreen: true,
275+ maximize: true,
276+ minimize: true,
277+ window_menu: true,
278+ }
279+ }
280+}
281+
270282 /// A type to describe which sides of the window are currently tiled in some way
271283 #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Default)]
272284 pub struct Tiling {
@@ -355,12 +367,7 @@ pub(crate) trait PlatformWindow: HasWindowHandle + HasDisplayHandle { · 82 unmodified lines
355367 }
356368 fn set_app_id(&mut self, _app_id: &str) {}
357369 fn window_controls(&self) -> WindowControls {
358− WindowControls {
359− fullscreen: true,
360− maximize: true,
361− minimize: true,
362− window_menu: false,
363− }
370+ WindowControls::default()
364371 }
365372 fn set_client_inset(&self, _inset: Pixels) {}
366373 fn gpu_specs(&self) -> Option<GPUSpecs>;
crates/gpui/src/platform/linux/wayland/window.rs+1−7
@@ -185,13 +185,7 @@ impl WaylandWindowState { · 184 unmodified lines
185185 active: false,
186186 hovered: false,
187187 in_progress_window_controls: None,
188− // Assume that we can do anything, unless told otherwise
189− window_controls: WindowControls {
190− fullscreen: true,
191− maximize: true,
192− minimize: true,
193− window_menu: true,
194− },
188+ window_controls: WindowControls::default(),
195189 inset: None,
196190 })
197191 }
crates/gpui/src/platform/linux/x11/window.rs+8−0
@@ -1230,6 +1230,14 @@ impl PlatformWindow for X11Window { · 1229 unmodified lines
12301230
12311231 fn show_window_menu(&self, position: Point<Pixels>) {
12321232 let state = self.0.state.borrow();
1233+
1234+ self.0
1235+ .xcb_connection
1236+ .ungrab_pointer(x11rb::CURRENT_TIME)
1237+ .unwrap()
1238+ .check()
1239+ .unwrap();
1240+
12331241 let coords = self.get_root_position(position);
12341242 let message = ClientMessageEvent::new(
12351243 32,