Fixes an issue where a window's image would be stretched as it was moved further offscreen. The offscreen part of a window also did not display correctly in Exposé.
-- v2: winemac: Don't constrain surface dimensions to the onscreen part of a window. winemac: Set the Cocoa window contentMaxSize to the size limits from constrain_window_frame(). winemac: Refactor constrain_window_frame() to use separate origin and size arguments.
From: Brendan Shanks bshanks@codeweavers.com
--- dlls/winemac.drv/window.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index 896efb6a68e..2a7998762ac 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -216,7 +216,7 @@ static void macdrv_mac_to_window_rect(struct macdrv_win_data *data, RECT *rect) * Alter a window frame rectangle to fit within a) Cocoa's documented * limits, and b) sane sizes, like twice the desktop rect. */ -static void constrain_window_frame(CGRect* frame) +static void constrain_window_frame(CGPoint* origin, CGSize* size) { CGRect desktop_rect = macdrv_get_desktop_rect(); int max_width, max_height; @@ -224,12 +224,18 @@ static void constrain_window_frame(CGRect* frame) max_width = min(32000, 2 * CGRectGetWidth(desktop_rect)); max_height = min(32000, 2 * CGRectGetHeight(desktop_rect));
- if (frame->origin.x < -16000) frame->origin.x = -16000; - if (frame->origin.y < -16000) frame->origin.y = -16000; - if (frame->origin.x > 16000) frame->origin.x = 16000; - if (frame->origin.y > 16000) frame->origin.y = 16000; - if (frame->size.width > max_width) frame->size.width = max_width; - if (frame->size.height > max_height) frame->size.height = max_height; + if (origin) + { + if (origin->x < -16000) origin->x = -16000; + if (origin->y < -16000) origin->y = -16000; + if (origin->x > 16000) origin->x = 16000; + if (origin->y > 16000) origin->y = 16000; + } + if (size) + { + if (size->width > max_width) size->width = max_width; + if (size->height > max_height) size->height = max_height; + } }
@@ -698,7 +704,7 @@ static void create_cocoa_window(struct macdrv_win_data *data) get_cocoa_window_features(data, style, ex_style, &wf, &data->window_rect, &data->client_rect);
frame = cgrect_from_rect(data->whole_rect); - constrain_window_frame(&frame); + constrain_window_frame(&frame.origin, &frame.size); if (frame.size.width < 1 || frame.size.height < 1) frame.size.width = frame.size.height = 1;
@@ -1139,7 +1145,7 @@ static void sync_window_position(struct macdrv_win_data *data, UINT swp_flags, c { if (data->minimized) return;
- constrain_window_frame(&frame); + constrain_window_frame(&frame.origin, &frame.size); if (frame.size.width < 1 || frame.size.height < 1) frame.size.width = frame.size.height = 1;
From: Brendan Shanks bshanks@codeweavers.com
--- dlls/winemac.drv/window.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index 2a7998762ac..a3690585127 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -641,6 +641,8 @@ static void sync_window_min_max_info(HWND hwnd) max_size = CGSizeMake(max_rect.right - max_rect.left, max_rect.bottom - max_rect.top); }
+ constrain_window_frame(NULL, &max_size); + TRACE("min_size (%g,%g) max_size (%g,%g)\n", min_size.width, min_size.height, max_size.width, max_size.height); macdrv_set_window_min_max_sizes(data->cocoa_window, min_size, max_size); }
From: Brendan Shanks bshanks@codeweavers.com
Fixes an issue where a window's image would be stretched as it was moved further offscreen. The offscreen part of a window also did not display correctly in Exposé. --- dlls/winemac.drv/window.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index a3690585127..104100a0770 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -2037,10 +2037,8 @@ LRESULT macdrv_WindowMessage(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
static inline RECT get_surface_rect(const RECT *visible_rect) { - RECT rect; - RECT desktop_rect = rect_from_cgrect(macdrv_get_desktop_rect()); + RECT rect = *visible_rect;
- intersect_rect(&rect, visible_rect, &desktop_rect); OffsetRect(&rect, -visible_rect->left, -visible_rect->top); rect.left &= ~127; rect.top &= ~127;
On Mon Apr 17 22:46:01 2023 +0000, Alexandre Julliard wrote:
Note that the reason for doing this is that some apps create huge windows (like 32,000 x 32,000). Without additional constraints this would create a 4Gb surface.
I think [`constrain_window_frame()`](https://gitlab.winehq.org/wine/wine/-/blob/master/dlls/winemac.drv/window.c#...) should prevent a window that large from being created or resized from Win32, and I added a commit to apply that maximum size to Mac-side resizing also.