mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-07 20:39:04 +03:00
windows: Fix and simplify title bar padding (#13420)
This PR fixes the off by one pixel of the top client rect when not maximized due to the added border. It also simplifies and properly fixes the title bar padding problem when maximized, it is now properly taken care of in GPUI rather then adding the padding in the UI. Release Notes: - N/A
This commit is contained in:
parent
5e1521eded
commit
68b5ea4e60
@ -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 _);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user