diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m index 7f71fea70f9..1bb99a956ab 100644 --- a/dlls/winemac.drv/cocoa_window.m +++ b/dlls/winemac.drv/cocoa_window.m @@ -650,7 +650,7 @@ - (void) dealloc - (BOOL) preventResizing { BOOL preventForClipping = cursor_clipping_locks_windows && [[WineApplicationController sharedController] clippingCursor]; - return ([self styleMask] & NSResizableWindowMask) && (disabled || !resizable || maximized || preventForClipping); + return ([self styleMask] & NSResizableWindowMask) && (disabled || !resizable || preventForClipping); } - (void) adjustFeaturesForState @@ -814,6 +814,16 @@ - (void) postDidUnminimizeEvent macdrv_release_event(event); } + - (void) sendResizeStartQuery + { + macdrv_query* query = macdrv_create_query(); + query->type = QUERY_RESIZE_START; + query->window = (macdrv_window)[self retain]; + + [self.queue query:query timeout:0.3]; + macdrv_release_query(query); + } + - (void) setMacDrvState:(const struct macdrv_window_state*)state { NSWindowCollectionBehavior behavior; @@ -892,6 +902,9 @@ - (void) setMacDrvState:(const struct macdrv_window_state*)state { maximized = state->maximized; [self adjustFeaturesForState]; + + if (!maximized && [self inLiveResize]) + [self sendResizeStartQuery]; } behavior = NSWindowCollectionBehaviorDefault; @@ -1797,9 +1810,12 @@ - (void)windowDidDeminiaturize:(NSNotification *)notification - (void) windowDidEndLiveResize:(NSNotification *)notification { - macdrv_event* event = macdrv_create_event(WINDOW_RESIZE_ENDED, self); - [queue postEvent:event]; - macdrv_release_event(event); + if (!maximized) + { + macdrv_event* event = macdrv_create_event(WINDOW_RESIZE_ENDED, self); + [queue postEvent:event]; + macdrv_release_event(event); + } self.liveResizeDisplayTimer = nil; } @@ -1958,6 +1974,9 @@ - (NSSize) windowWillResize:(NSWindow*)sender toSize:(NSSize)frameSize { if ([self inLiveResize]) { + if (maximized) + return self.frame.size; + NSRect rect; macdrv_query* query; @@ -1992,12 +2011,21 @@ - (NSSize) windowWillResize:(NSWindow*)sender toSize:(NSSize)frameSize - (void) windowWillStartLiveResize:(NSNotification *)notification { - macdrv_query* query = macdrv_create_query(); - query->type = QUERY_RESIZE_START; - query->window = (macdrv_window)[self retain]; + if (maximized) + { + macdrv_event* event; + NSRect frame = [self contentRectForFrameRect:self.frame]; - [self.queue query:query timeout:0.3]; - macdrv_release_query(query); + [[WineApplicationController sharedController] flipRect:&frame]; + + event = macdrv_create_event(WINDOW_RESTORE_REQUESTED, self); + event->window_restore_requested.keep_frame = TRUE; + event->window_restore_requested.frame = NSRectToCGRect(frame); + [queue postEvent:event]; + macdrv_release_event(event); + } + else + [self sendResizeStartQuery]; frameAtResizeStart = [self frame]; resizingFromLeft = resizingFromTop = FALSE; diff --git a/dlls/winemac.drv/event.c b/dlls/winemac.drv/event.c index 8e030807659..58b507c51d1 100644 --- a/dlls/winemac.drv/event.c +++ b/dlls/winemac.drv/event.c @@ -280,7 +280,7 @@ void macdrv_handle_event(const macdrv_event *event) macdrv_window_resize_ended(hwnd); break; case WINDOW_RESTORE_REQUESTED: - macdrv_window_restore_requested(hwnd); + macdrv_window_restore_requested(hwnd, event); break; default: TRACE(" ignoring\n"); diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index cf0fc64fbc9..a874dfbaeeb 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -172,7 +172,7 @@ static inline RECT rect_from_cgrect(CGRect cgrect) extern void macdrv_window_did_unminimize(HWND hwnd) DECLSPEC_HIDDEN; extern void macdrv_window_brought_forward(HWND hwnd) DECLSPEC_HIDDEN; extern void macdrv_window_resize_ended(HWND hwnd) DECLSPEC_HIDDEN; -extern void macdrv_window_restore_requested(HWND hwnd) DECLSPEC_HIDDEN; +extern void macdrv_window_restore_requested(HWND hwnd, const macdrv_event *event) DECLSPEC_HIDDEN; extern void macdrv_window_drag_begin(HWND hwnd) DECLSPEC_HIDDEN; extern void macdrv_window_drag_end(HWND hwnd) DECLSPEC_HIDDEN; extern BOOL query_resize_size(HWND hwnd, macdrv_query *query) DECLSPEC_HIDDEN; diff --git a/dlls/winemac.drv/macdrv_cocoa.h b/dlls/winemac.drv/macdrv_cocoa.h index 30b6b644924..4b68adca2f0 100644 --- a/dlls/winemac.drv/macdrv_cocoa.h +++ b/dlls/winemac.drv/macdrv_cocoa.h @@ -291,6 +291,10 @@ extern int macdrv_set_display_mode(const struct macdrv_display* display, unsigned long serial; void *tried_windows; } window_got_focus; + struct { + int keep_frame; + CGRect frame; + } window_restore_requested; }; } macdrv_event; diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index 54bd56ebc78..7a777e6b73e 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -2139,8 +2139,28 @@ void macdrv_window_resize_ended(HWND hwnd) * Handler for WINDOW_RESTORE_REQUESTED events. This is specifically * for restoring from maximized, not from minimized. */ -void macdrv_window_restore_requested(HWND hwnd) +void macdrv_window_restore_requested(HWND hwnd, const macdrv_event *event) { + if (event->window_restore_requested.keep_frame && hwnd) + { + DWORD style = GetWindowLongW(hwnd, GWL_STYLE); + struct macdrv_win_data *data; + + if ((style & WS_MAXIMIZE) && (style & WS_VISIBLE) && (data = get_win_data(hwnd))) + { + RECT rect; + HWND parent = GetAncestor(hwnd, GA_PARENT); + + rect = rect_from_cgrect(event->window_restore_requested.frame); + macdrv_mac_to_window_rect(data, &rect); + MapWindowPoints(0, parent, (POINT *)&rect, 2); + + release_win_data(data); + + SetInternalWindowPos(hwnd, SW_SHOW, &rect, NULL); + } + } + perform_window_command(hwnd, WS_MAXIMIZE, 0, SC_RESTORE, HTMAXBUTTON); }