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
|
@ -1143,6 +1143,23 @@ impl<'a> WindowContext<'a> {
|
|||
self.window.platform_window.zoom();
|
||||
}
|
||||
|
||||
/// Opens the native title bar context menu, useful when implementing client side decorations (Wayland only)
|
||||
pub fn show_window_menu(&self, position: Point<Pixels>) {
|
||||
self.window.platform_window.show_window_menu(position)
|
||||
}
|
||||
|
||||
/// Tells the compositor to take control of window movement (Wayland only)
|
||||
///
|
||||
/// Events may not be received during a move operation.
|
||||
pub fn start_system_move(&self) {
|
||||
self.window.platform_window.start_system_move()
|
||||
}
|
||||
|
||||
/// Returns whether the title bar window controls need to be rendered by the application (Wayland and X11)
|
||||
pub fn should_render_window_controls(&self) -> bool {
|
||||
self.window.platform_window.should_render_window_controls()
|
||||
}
|
||||
|
||||
/// Updates the window's title at the platform level.
|
||||
pub fn set_window_title(&mut self, title: &str) {
|
||||
self.window.platform_window.set_title(title);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue