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
255}255}
256 256
257/// What window controls this platform supports257/// What window controls this platform supports
258#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Default)]258#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
259pub struct WindowControls {259pub struct WindowControls {
260 /// Whether this platform supports fullscreen260 /// Whether this platform supports fullscreen
261 pub fullscreen: bool,261 pub fullscreen: bool,
@@ -267,6 +267,18 @@ pub struct WindowControls { · 5 unmodified lines
267 pub window_menu: bool,267 pub window_menu: bool,
268}268}
269 269
270impl 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
270/// A type to describe which sides of the window are currently tiled in some way282/// A type to describe which sides of the window are currently tiled in some way
271#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Default)]283#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Default)]
272pub struct Tiling {284pub struct Tiling {
@@ -355,12 +367,7 @@ pub(crate) trait PlatformWindow: HasWindowHandle + HasDisplayHandle { · 82 unmodified lines
355 }367 }
356 fn set_app_id(&mut self, _app_id: &str) {}368 fn set_app_id(&mut self, _app_id: &str) {}
357 fn window_controls(&self) -> WindowControls {369 fn window_controls(&self) -> WindowControls {
358 WindowControls {370 WindowControls::default()
359 fullscreen: true,
360 maximize: true,
361 minimize: true,
362 window_menu: false,
363 }
364 }371 }
365 fn set_client_inset(&self, _inset: Pixels) {}372 fn set_client_inset(&self, _inset: Pixels) {}
366 fn gpu_specs(&self) -> Option<GPUSpecs>;373 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
185 active: false,185 active: false,
186 hovered: false,186 hovered: false,
187 in_progress_window_controls: None,187 in_progress_window_controls: None,
188 // Assume that we can do anything, unless told otherwise188 window_controls: WindowControls::default(),
189 window_controls: WindowControls {
190 fullscreen: true,
191 maximize: true,
192 minimize: true,
193 window_menu: true,
194 },
195 inset: None,189 inset: None,
196 })190 })
197 }191 }
crates/gpui/src/platform/linux/x11/window.rs+8−0
@@ -1230,6 +1230,14 @@ impl PlatformWindow for X11Window { · 1229 unmodified lines
1230 1230
1231 fn show_window_menu(&self, position: Point<Pixels>) {1231 fn show_window_menu(&self, position: Point<Pixels>) {
1232 let state = self.0.state.borrow();1232 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
1233 let coords = self.get_root_position(position);1241 let coords = self.get_root_position(position);
1234 let message = ClientMessageEvent::new(1242 let message = ClientMessageEvent::new(
1235 32,1243 32,