On Windows, applications can disable titlebar by extending the client rect to a bigger rect which will cover the area of the titlebar from WM_NCCALCSIZE: https://learn.microsoft.com/en-us/windows/win32/dwm/customframe#removing-the... Our current x11 and Mac driver doesn't handle this case.
Attached is a test case for reproducing the issue.
[hide_caption.c](/uploads/46a725e32569a6a0a929a0f183cf9ed8/hide_caption.c)
-- v2: winemac.drv: Disable native titlebar while lacking enough space for SM_CYCAPTION. winex11.drv: Disable native titlebar while lacking enough space for SM_CYCAPTION.
From: Jactry Zeng jzeng@codeweavers.com
--- dlls/winex11.drv/window.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index beb93d66251..af876baaf47 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -452,7 +452,7 @@ static inline BOOL is_window_resizable( struct x11drv_win_data *data, DWORD styl /*********************************************************************** * get_mwm_decorations */ -static unsigned long get_mwm_decorations_for_style( DWORD style, DWORD ex_style ) +static unsigned long get_mwm_decorations_for_style( struct x11drv_win_data *data, DWORD style, DWORD ex_style ) { unsigned long ret = 0;
@@ -461,6 +461,9 @@ static unsigned long get_mwm_decorations_for_style( DWORD style, DWORD ex_style
if ((style & WS_CAPTION) == WS_CAPTION) { + if (data && ((data->rects.client.top - data->rects.window.top) < NtUserGetSystemMetrics(SM_CYCAPTION))) + return 0; + ret |= MWM_DECOR_TITLE | MWM_DECOR_BORDER; if (style & WS_SYSMENU) ret |= MWM_DECOR_MENU; if (style & WS_MINIMIZEBOX) ret |= MWM_DECOR_MINIMIZE; @@ -476,7 +479,7 @@ static unsigned long get_mwm_decorations_for_style( DWORD style, DWORD ex_style static unsigned long get_mwm_decorations( struct x11drv_win_data *data, DWORD style, DWORD ex_style ) { if (EqualRect( &data->rects.window, &data->rects.visible )) return 0; - return get_mwm_decorations_for_style( style, ex_style ); + return get_mwm_decorations_for_style( data, style, ex_style ); }
@@ -3141,10 +3144,13 @@ void X11DRV_MoveWindowBits( HWND hwnd, const struct window_rects *old_rects, */ BOOL X11DRV_GetWindowStyleMasks( HWND hwnd, UINT style, UINT ex_style, UINT *style_mask, UINT *ex_style_mask ) { - unsigned long decor = get_mwm_decorations_for_style( style, ex_style ); struct x11drv_win_data *data; + unsigned long decor;
- if ((data = get_win_data( hwnd ))) + data = get_win_data( hwnd ); + decor = get_mwm_decorations_for_style( data, style, ex_style ); + + if (data) { if (!data->managed) decor = 0; release_win_data( data );
From: Jactry Zeng jzeng@codeweavers.com
--- dlls/winemac.drv/window.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index 940fdffa800..8e8ae7daab4 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -56,7 +56,7 @@ static BOOL set_window_pos(HWND hwnd, HWND after, INT x, INT y, INT cx, INT cy, }
-static struct macdrv_window_features get_window_features_for_style(DWORD style, DWORD ex_style, BOOL shaped) +static struct macdrv_window_features get_window_features_for_style(struct macdrv_win_data *data, DWORD style, DWORD ex_style, BOOL shaped) { struct macdrv_window_features wf = {0};
@@ -67,11 +67,16 @@ static struct macdrv_window_features get_window_features_for_style(DWORD style, wf.shadow = TRUE; if (!shaped) { - wf.title_bar = TRUE; - if (style & WS_SYSMENU) wf.close_button = TRUE; - if (style & WS_MINIMIZEBOX) wf.minimize_button = TRUE; - if (style & WS_MAXIMIZEBOX) wf.maximize_button = TRUE; - if (ex_style & WS_EX_TOOLWINDOW) wf.utility = TRUE; + if (data && ((data->rects.client.top - data->rects.window.top) < NtUserGetSystemMetrics(SM_CYCAPTION))) + wf.title_bar = FALSE; + else + { + wf.title_bar = TRUE; + if (style & WS_SYSMENU) wf.close_button = TRUE; + if (style & WS_MINIMIZEBOX) wf.minimize_button = TRUE; + if (style & WS_MAXIMIZEBOX) wf.maximize_button = TRUE; + if (ex_style & WS_EX_TOOLWINDOW) wf.utility = TRUE; + } } } if (style & WS_THICKFRAME) @@ -95,7 +100,7 @@ static struct macdrv_window_features get_cocoa_window_features(struct macdrv_win if (ex_style & WS_EX_NOACTIVATE) wf.prevents_app_activation = TRUE; if (EqualRect(&data->rects.window, &data->rects.visible)) return wf;
- return get_window_features_for_style(style, ex_style, data->shaped); + return get_window_features_for_style(data, style, ex_style, data->shaped); }
@@ -1697,7 +1702,11 @@ BOOL macdrv_WindowPosChanging(HWND hwnd, UINT swp_flags, BOOL shaped, const stru */ BOOL macdrv_GetWindowStyleMasks(HWND hwnd, UINT style, UINT ex_style, UINT *style_mask, UINT *ex_style_mask) { - struct macdrv_window_features wf = get_window_features_for_style(style, ex_style, FALSE); + struct macdrv_win_data *data = get_win_data(hwnd); + struct macdrv_window_features wf; + + wf = get_window_features_for_style(data, style, ex_style, FALSE); + release_win_data(data);
*style_mask = ex_style = 0; if (wf.title_bar)