wayland: Window controls and drag (#11525)
Based on https://github.com/zed-industries/zed/pull/11046 - Partially fixes #10346 - Fixes https://github.com/zed-industries/zed/issues/9964 ## Features Window buttons  Window drag  Native window context menu  ### Limitations - No resizing - Wayland only (though X11 always has window decorations) ### Technical This PR adds three APIs to gpui. 1. `show_window_menu`: Triggers the native title bar context menu. 2. `start_system_move`: Tells the compositor to start dragging the window. 3. `should_render_window_controls`: Whether the compositor doesn't support server side decorations. These APIs have only been implemented for Wayland, but they should be portable to other platforms. Release Notes: - N/A --------- Co-authored-by: Akilan Elango <akilan1997@gmail.com>
This commit is contained in:
parent
db89353193
commit
d1ee2d0749
13 changed files with 277 additions and 11 deletions
|
@ -23,12 +23,13 @@ use wayland_protocols_plasma::blur::client::{org_kde_kwin_blur, org_kde_kwin_blu
|
|||
|
||||
use crate::platform::blade::{BladeRenderer, BladeSurfaceConfig};
|
||||
use crate::platform::linux::wayland::display::WaylandDisplay;
|
||||
use crate::platform::linux::wayland::serial::SerialKind;
|
||||
use crate::platform::{PlatformAtlas, PlatformInputHandler, PlatformWindow};
|
||||
use crate::scene::Scene;
|
||||
use crate::{
|
||||
px, size, Bounds, DevicePixels, Globals, Modifiers, Pixels, PlatformDisplay, PlatformInput,
|
||||
Point, PromptLevel, Size, WaylandClientState, WaylandClientStatePtr, WindowAppearance,
|
||||
WindowBackgroundAppearance, WindowBounds, WindowParams,
|
||||
Point, PromptLevel, Size, WaylandClientStatePtr, WindowAppearance, WindowBackgroundAppearance,
|
||||
WindowBounds, WindowParams,
|
||||
};
|
||||
|
||||
#[derive(Default)]
|
||||
|
@ -753,6 +754,27 @@ impl PlatformWindow for WaylandWindow {
|
|||
let state = self.borrow();
|
||||
state.renderer.sprite_atlas().clone()
|
||||
}
|
||||
|
||||
fn show_window_menu(&self, position: Point<Pixels>) {
|
||||
let state = self.borrow();
|
||||
let serial = state.client.get_serial(SerialKind::MousePress);
|
||||
state.toplevel.show_window_menu(
|
||||
&state.globals.seat,
|
||||
serial,
|
||||
position.x.0 as i32,
|
||||
position.y.0 as i32,
|
||||
);
|
||||
}
|
||||
|
||||
fn start_system_move(&self) {
|
||||
let state = self.borrow();
|
||||
let serial = state.client.get_serial(SerialKind::MousePress);
|
||||
state.toplevel._move(&state.globals.seat, serial);
|
||||
}
|
||||
|
||||
fn should_render_window_controls(&self) -> bool {
|
||||
self.borrow().decoration_state == WaylandDecorationState::Client
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue