From: Rémi Bernon <rbernon(a)codeweavers.com> --- dlls/winemac.drv/cocoa_window.m | 9 +++++++++ dlls/winemac.drv/window.c | 22 +++++++++++++--------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m index b209324c7c7..8967a94521d 100644 --- a/dlls/winemac.drv/cocoa_window.m +++ b/dlls/winemac.drv/cocoa_window.m @@ -365,6 +365,7 @@ - (id) initWithFrame:(NSRect)frame device:(id<MTLDevice>)device; @interface WineContentView : WineBaseView <NSTextInputClient, NSViewLayerContentScaleDelegate> { + CGRect surfaceRect; CGImageRef colorImage; NSMutableArray* glContexts; @@ -489,6 +490,7 @@ - (instancetype) initWithFrame:(NSRect)frame self = [super initWithFrame:frame]; if (self) { + [self setLayerContentsPlacement:NSViewLayerContentsPlacementTopLeft]; [self setWantsLayer:YES]; [self setLayerRetinaProperties:retina_on]; [self setAutoresizesSubviews:NO]; @@ -552,6 +554,7 @@ - (void) updateLayer if (image) { + layer.position = surfaceRect.origin; layer.contents = (id)image; CFRelease(image); [window windowDidDrawContent]; @@ -567,6 +570,11 @@ - (void) updateLayer } } + - (void) setSurfaceRect:(CGRect)rect + { + surfaceRect = rect; + } + - (void) setColorImage:(CGImageRef)image { CGImageRelease(colorImage); @@ -3516,6 +3524,7 @@ void macdrv_window_set_color_image(macdrv_window w, CGImageRef image, CGRect rec WineContentView *view = [window contentView]; [view setColorImage:image]; + [view setSurfaceRect:cgrect_mac_from_win(rect)]; [view setNeedsDisplayInRect:NSRectFromCGRect(cgrect_mac_from_win(dirty))]; CGImageRelease(image); diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index 8fb207a8684..fc7a6ac2fc1 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -1983,16 +1983,18 @@ LRESULT macdrv_WindowMessage(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) } -static inline RECT get_surface_rect(const RECT *visible_rect) +static BOOL get_surface_rect( const RECT *visible_rect, RECT *surface_rect ) { - RECT rect = *visible_rect; + *surface_rect = NtUserGetVirtualScreenRect(); - OffsetRect(&rect, -visible_rect->left, -visible_rect->top); - rect.left &= ~127; - rect.top &= ~127; - rect.right = max(rect.left + 128, (rect.right + 127) & ~127); - rect.bottom = max(rect.top + 128, (rect.bottom + 127) & ~127); - return rect; + if (!intersect_rect( surface_rect, surface_rect, visible_rect )) return FALSE; + OffsetRect( surface_rect, -visible_rect->left, -visible_rect->top ); + surface_rect->left &= ~127; + surface_rect->top &= ~127; + surface_rect->right = max( surface_rect->left + 128, (surface_rect->right + 127) & ~127 ); + surface_rect->bottom = max( surface_rect->top + 128, (surface_rect->bottom + 127) & ~127 ); + + return TRUE; } @@ -2003,6 +2005,7 @@ BOOL macdrv_WindowPosChanging(HWND hwnd, UINT swp_flags, const RECT *window_rect { struct macdrv_win_data *data = get_win_data(hwnd); DWORD style = NtUserGetWindowLongW(hwnd, GWL_STYLE); + RECT surface_rect; BOOL ret = FALSE; TRACE("%p swp %04x window %s client %s visible %s\n", hwnd, @@ -2018,6 +2021,7 @@ BOOL macdrv_WindowPosChanging(HWND hwnd, UINT swp_flags, const RECT *window_rect if (!data->cocoa_window) goto done; /* use default surface */ if (swp_flags & SWP_HIDEWINDOW) goto done; /* use default surface */ if (data->ulw_layered) goto done; /* use default surface */ + if (!get_surface_rect( visible_rect, &surface_rect )) goto done; /* use default surface */ ret = TRUE; @@ -2043,7 +2047,7 @@ BOOL macdrv_CreateWindowSurface(HWND hwnd, UINT swp_flags, const RECT *visible_r if (*surface) window_surface_release(*surface); *surface = NULL; - surface_rect = get_surface_rect(visible_rect); + if (!get_surface_rect(visible_rect, &surface_rect)) goto done; if (data->surface) { if (EqualRect(&data->surface->rect, &surface_rect)) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/5798