winemac: Update the window min/max size info and enforce it when zooming.

This commit is contained in:
Ken Thomases 2013-10-08 02:21:29 -05:00 committed by Alexandre Julliard
parent bdcb8138fe
commit 4d9340eb41
5 changed files with 60 additions and 0 deletions

View File

@ -1616,6 +1616,47 @@ - (void) windowWillStartLiveResize:(NSNotification *)notification
forMode:NSRunLoopCommonModes];
}
- (NSRect) windowWillUseStandardFrame:(NSWindow*)window defaultFrame:(NSRect)proposedFrame
{
macdrv_query* query;
NSRect currentContentRect, proposedContentRect, newContentRect, screenRect;
NSSize maxSize;
query = macdrv_create_query();
query->type = QUERY_MIN_MAX_INFO;
query->window = (macdrv_window)[self retain];
[self.queue query:query timeout:0.5];
macdrv_release_query(query);
currentContentRect = [self contentRectForFrameRect:[self frame]];
proposedContentRect = [self contentRectForFrameRect:proposedFrame];
maxSize = [self contentMaxSize];
newContentRect.size.width = MIN(NSWidth(proposedContentRect), maxSize.width);
newContentRect.size.height = MIN(NSHeight(proposedContentRect), maxSize.height);
// Try to keep the top-left corner where it is.
newContentRect.origin.x = NSMinX(currentContentRect);
newContentRect.origin.y = NSMaxY(currentContentRect) - NSHeight(newContentRect);
// If that pushes the bottom or right off the screen, pull it up and to the left.
screenRect = [self contentRectForFrameRect:[[self screen] visibleFrame]];
if (NSMaxX(newContentRect) > NSMaxX(screenRect))
newContentRect.origin.x = NSMaxX(screenRect) - NSWidth(newContentRect);
if (NSMinY(newContentRect) < NSMinY(screenRect))
newContentRect.origin.y = NSMinY(screenRect);
// If that pushes the top or left off the screen, push it down and the right
// again. Do this last because the top-left corner is more important than the
// bottom-right.
if (NSMinX(newContentRect) < NSMinX(screenRect))
newContentRect.origin.x = NSMinX(screenRect);
if (NSMaxY(newContentRect) > NSMaxY(screenRect))
newContentRect.origin.y = NSMaxY(screenRect) - NSHeight(newContentRect);
return [self frameRectForContentRect:newContentRect];
}
/*
* ---------- NSPasteboardOwner methods ----------

View File

@ -158,6 +158,10 @@ static void macdrv_query_event(HWND hwnd, const macdrv_event *event)
TRACE("QUERY_RESIZE_START\n");
success = query_resize_start(hwnd);
break;
case QUERY_MIN_MAX_INFO:
TRACE("QUERY_MIN_MAX_INFO\n");
success = query_min_max_info(hwnd);
break;
default:
FIXME("unrecognized query type %d\n", query->type);
break;

View File

@ -164,6 +164,7 @@ static inline RECT rect_from_cgrect(CGRect cgrect)
extern void macdrv_window_did_unminimize(HWND hwnd) DECLSPEC_HIDDEN;
extern BOOL query_resize_end(HWND hwnd) DECLSPEC_HIDDEN;
extern BOOL query_resize_start(HWND hwnd) DECLSPEC_HIDDEN;
extern BOOL query_min_max_info(HWND hwnd) DECLSPEC_HIDDEN;
extern void macdrv_mouse_button(HWND hwnd, const macdrv_event *event) DECLSPEC_HIDDEN;
extern void macdrv_mouse_moved(HWND hwnd, const macdrv_event *event) DECLSPEC_HIDDEN;

View File

@ -287,6 +287,7 @@ extern int macdrv_set_display_mode(const struct macdrv_display* display,
QUERY_PASTEBOARD_DATA,
QUERY_RESIZE_END,
QUERY_RESIZE_START,
QUERY_MIN_MAX_INFO,
NUM_QUERY_TYPES
};

View File

@ -2048,3 +2048,16 @@ BOOL query_resize_end(HWND hwnd)
SendMessageW(hwnd, WM_EXITSIZEMOVE, 0, 0);
return TRUE;
}
/***********************************************************************
* query_min_max_info
*
* Handler for QUERY_MIN_MAX_INFO query.
*/
BOOL query_min_max_info(HWND hwnd)
{
TRACE("hwnd %p\n", hwnd);
sync_window_min_max_info(hwnd);
return TRUE;
}