diff --git a/crates/gpui/src/platform/windows/events.rs b/crates/gpui/src/platform/windows/events.rs index 7c5a9736146f8c83bef3fade0566262942e68fc5..dc6183e3990952b39de2bdbca38cb73f1c83d4c9 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 02e6390c2db6cc03e1b73d7e79c6fef2a45c79c1..e2cd45b1c44317c72c6ab86d934350feb22520d8 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;