Cross-platform titlebar (#9405)

This PR reverts https://github.com/zed-industries/zed/pull/9392 and
fixes the regressions that led to the reversion.

Release Notes:

- N/A

---------

Co-authored-by: Ezekiel Warren <ezekiel@seaube.com>
This commit is contained in:
Mikayla Maki 2024-03-15 10:40:58 -07:00 committed by GitHub
parent 44ac6ca45c
commit 328aa2cc95
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 719 additions and 156 deletions

View file

@ -1,6 +1,6 @@
// todo(linux): remove
#![cfg_attr(target_os = "linux", allow(dead_code))]
// todo("windows"): remove
// todo(windows): remove
#![cfg_attr(windows, allow(dead_code))]
mod app_menu;
@ -22,10 +22,10 @@ mod test;
mod windows;
use crate::{
Action, AnyWindowHandle, AsyncWindowContext, BackgroundExecutor, Bounds, DevicePixels, Font,
FontId, FontMetrics, FontRun, ForegroundExecutor, GlobalPixels, GlyphId, Keymap, LineLayout,
Pixels, PlatformInput, Point, RenderGlyphParams, RenderImageParams, RenderSvgParams, Scene,
SharedString, Size, Task, TaskLabel, WindowContext,
Action, AnyWindowHandle, AsyncWindowContext, BackgroundExecutor, Bounds, DevicePixels,
DispatchEventResult, Font, FontId, FontMetrics, FontRun, ForegroundExecutor, GlobalPixels,
GlyphId, Keymap, LineLayout, Pixels, PlatformInput, Point, RenderGlyphParams,
RenderImageParams, RenderSvgParams, Scene, SharedString, Size, Task, TaskLabel, WindowContext,
};
use anyhow::Result;
use async_task::Runnable;
@ -170,9 +170,9 @@ unsafe impl Send for DisplayId {}
pub(crate) trait PlatformWindow: HasWindowHandle + HasDisplayHandle {
fn bounds(&self) -> Bounds<GlobalPixels>;
fn is_maximized(&self) -> bool;
fn content_size(&self) -> Size<Pixels>;
fn scale_factor(&self) -> f32;
fn titlebar_height(&self) -> Pixels;
fn appearance(&self) -> WindowAppearance;
fn display(&self) -> Rc<dyn PlatformDisplay>;
fn mouse_position(&self) -> Point<Pixels>;
@ -196,7 +196,7 @@ pub(crate) trait PlatformWindow: HasWindowHandle + HasDisplayHandle {
fn toggle_fullscreen(&self);
fn is_fullscreen(&self) -> bool;
fn on_request_frame(&self, callback: Box<dyn FnMut()>);
fn on_input(&self, callback: Box<dyn FnMut(PlatformInput) -> bool>);
fn on_input(&self, callback: Box<dyn FnMut(PlatformInput) -> DispatchEventResult>);
fn on_active_status_change(&self, callback: Box<dyn FnMut(bool)>);
fn on_resize(&self, callback: Box<dyn FnMut(Size<Pixels>, f32)>);
fn on_fullscreen(&self, callback: Box<dyn FnMut(bool)>);
@ -206,9 +206,11 @@ pub(crate) trait PlatformWindow: HasWindowHandle + HasDisplayHandle {
fn on_appearance_changed(&self, callback: Box<dyn FnMut()>);
fn is_topmost_for_position(&self, position: Point<Pixels>) -> bool;
fn draw(&self, scene: &Scene);
fn sprite_atlas(&self) -> Arc<dyn PlatformAtlas>;
#[cfg(target_os = "windows")]
fn get_raw_handle(&self) -> windows::HWND;
#[cfg(any(test, feature = "test-support"))]
fn as_test(&mut self) -> Option<&mut TestWindow> {
None