Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

windows: Fix and simplify title bar padding (#13420)

Matin Aniss68b5ea4e606a
diff --git a/crates/gpui/src/platform/windows/events.rs b/crates/gpui/src/platform/windows/events.rs
index 7c5a9736146..dc6183e3990 100644
--- a/crates/gpui/src/platform/windows/events.rs
+++ b/crates/gpui/src/platform/windows/events.rs
@@ -659,6 +659,13 @@ fn handle_calc_client_size(
requested_client_rect[0].left += frame_x + padding;
requested_client_rect[0].bottom -= frame_y + padding;
+ if state_ptr.state.borrow().is_maximized() {
+ requested_client_rect[0].top += frame_y + padding;
+ } else {
+ // Magic number that calculates the width of the border
+ requested_client_rect[0].top += frame_y - 3;
+ }
+
Some(0)
}
@@ -821,14 +828,14 @@ fn handle_hit_test_msg(
let dpi = unsafe { GetDpiForWindow(handle) };
let frame_y = unsafe { GetSystemMetricsForDpi(SM_CYFRAME, dpi) };
- let padding = unsafe { GetSystemMetricsForDpi(SM_CXPADDEDBORDER, dpi) };
let mut cursor_point = POINT {
x: lparam.signed_loword().into(),
y: lparam.signed_hiword().into(),
};
unsafe { ScreenToClient(handle, &mut cursor_point).ok().log_err() };
- if cursor_point.y > 0 && cursor_point.y < frame_y + padding {
+ if !state_ptr.state.borrow().is_maximized() && cursor_point.y >= 0 && cursor_point.y <= frame_y
+ {
return Some(HTTOP as _);
}
diff --git a/crates/title_bar/src/title_bar.rs b/crates/title_bar/src/title_bar.rs
index 02e6390c2db..e2cd45b1c44 100644
--- a/crates/title_bar/src/title_bar.rs
+++ b/crates/title_bar/src/title_bar.rs
@@ -77,8 +77,7 @@ impl Render for TitleBar {
h_flex()
.id("titlebar")
.w_full()
- .pt(Self::top_padding(cx))
- .h(height + Self::top_padding(cx))
+ .h(height)
.map(|this| {
if cx.is_fullscreen() {
this.pl_2()
@@ -235,28 +234,6 @@ impl TitleBar {
px(32.)
}
- #[cfg(not(target_os = "windows"))]
- fn top_padding(_cx: &WindowContext) -> Pixels {
- px(0.)
- }
-
- #[cfg(target_os = "windows")]
- fn top_padding(cx: &WindowContext) -> Pixels {
- use windows::Win32::UI::{
- HiDpi::GetSystemMetricsForDpi,
- WindowsAndMessaging::{SM_CXPADDEDBORDER, USER_DEFAULT_SCREEN_DPI},
- };
-
- // This top padding is not dependent on the title bar style and is instead a quirk of maximized windows on Windows:
- // https://devblogs.microsoft.com/oldnewthing/20150304-00/?p=44543
- let padding = unsafe { GetSystemMetricsForDpi(SM_CXPADDEDBORDER, USER_DEFAULT_SCREEN_DPI) };
- if cx.is_maximized() {
- px((padding * 2) as f32)
- } else {
- px(0.)
- }
- }
-
/// Sets the platform style.
pub fn platform_style(mut self, style: PlatformStyle) -> Self {
self.platform_style = style;