[PATCH resend 1/2] winex11.drv: Use a helper to retrieve the decoration rect for managed windows.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com> --- This simplifies the next patch and avoids duplicating code. dlls/winex11.drv/window.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index d6873ce..595c54a 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -1154,19 +1154,16 @@ void make_window_embedded( struct x11drv_win_data *data ) /*********************************************************************** - * X11DRV_window_to_X_rect - * - * Convert a rect from client to X window coordinates + * get_decoration_rect */ -static void X11DRV_window_to_X_rect( struct x11drv_win_data *data, RECT *rect, - const RECT *window_rect, const RECT *client_rect ) +static void get_decoration_rect( struct x11drv_win_data *data, RECT *rect, + const RECT *window_rect, const RECT *client_rect ) { DWORD style, ex_style, style_mask = 0, ex_style_mask = 0; unsigned long decor; - RECT rc; + SetRectEmpty( rect ); if (!data->managed) return; - if (IsRectEmpty( rect )) return; style = GetWindowLongW( data->hwnd, GWL_STYLE ); ex_style = GetWindowLongW( data->hwnd, GWL_EXSTYLE ); @@ -1179,9 +1176,23 @@ static void X11DRV_window_to_X_rect( struct x11drv_win_data *data, RECT *rect, ex_style_mask |= WS_EX_DLGMODALFRAME; } - SetRectEmpty( &rc ); - AdjustWindowRectEx( &rc, style & style_mask, FALSE, ex_style & ex_style_mask ); + AdjustWindowRectEx( rect, style & style_mask, FALSE, ex_style & ex_style_mask ); +} + + +/*********************************************************************** + * X11DRV_window_to_X_rect + * + * Convert a rect from client to X window coordinates + */ +static void X11DRV_window_to_X_rect( struct x11drv_win_data *data, RECT *rect, + const RECT *window_rect, const RECT *client_rect ) +{ + RECT rc; + + if (IsRectEmpty( rect )) return; + get_decoration_rect( data, &rc, window_rect, client_rect ); rect->left -= rc.left; rect->right -= rc.right; rect->top -= rc.top; -- 2.21.0
A window can be resized to a smaller size than the decoration (title + borders), such as when it is minimized. In such cases it is necessary to recompute the minimum bounds, as it is done in the opposite function X11DRV_window_to_X_rect, since the real information was lost. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48490 Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com> --- dlls/winex11.drv/window.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index 595c54a..a16b835 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -1209,12 +1209,16 @@ static void X11DRV_window_to_X_rect( struct x11drv_win_data *data, RECT *rect, */ void X11DRV_X_to_window_rect( struct x11drv_win_data *data, RECT *rect, int x, int y, int cx, int cy ) { - x += data->window_rect.left - data->whole_rect.left; - y += data->window_rect.top - data->whole_rect.top; - cx += (data->window_rect.right - data->window_rect.left) - - (data->whole_rect.right - data->whole_rect.left); - cy += (data->window_rect.bottom - data->window_rect.top) - - (data->whole_rect.bottom - data->whole_rect.top); + RECT rc; + + get_decoration_rect( data, &rc, &data->window_rect, &data->client_rect ); + + x += min( data->window_rect.left - data->whole_rect.left, rc.left ); + y += min( data->window_rect.top - data->whole_rect.top, rc.top ); + cx += max( (data->window_rect.right - data->window_rect.left) - + (data->whole_rect.right - data->whole_rect.left), rc.right - rc.left ); + cy += max( (data->window_rect.bottom - data->window_rect.top) - + (data->whole_rect.bottom - data->whole_rect.top), rc.bottom - rc.top ); SetRect( rect, x, y, x + cx, y + cy ); } -- 2.21.0
participants (1)
-
Gabriel Ivăncescu