Ken Thomases : winemac: Update the window min/ max size info and enforce it when zooming.
Alexandre Julliard
julliard at winehq.org
Tue Oct 8 15:41:06 CDT 2013
Module: wine
Branch: master
Commit: 4d9340eb41b0bbca1c801e032d0440a2257678aa
URL: http://source.winehq.org/git/wine.git/?a=commit;h=4d9340eb41b0bbca1c801e032d0440a2257678aa
Author: Ken Thomases <ken at codeweavers.com>
Date: Tue Oct 8 02:21:29 2013 -0500
winemac: Update the window min/max size info and enforce it when zooming.
---
dlls/winemac.drv/cocoa_window.m | 41 +++++++++++++++++++++++++++++++++++++++
dlls/winemac.drv/event.c | 4 +++
dlls/winemac.drv/macdrv.h | 1 +
dlls/winemac.drv/macdrv_cocoa.h | 1 +
dlls/winemac.drv/window.c | 13 ++++++++++++
5 files changed, 60 insertions(+), 0 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m
index 9b3fa9d..380469c 100644
--- a/dlls/winemac.drv/cocoa_window.m
+++ b/dlls/winemac.drv/cocoa_window.m
@@ -1616,6 +1616,47 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
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 ----------
diff --git a/dlls/winemac.drv/event.c b/dlls/winemac.drv/event.c
index 515671e..b9b9778 100644
--- a/dlls/winemac.drv/event.c
+++ b/dlls/winemac.drv/event.c
@@ -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;
diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h
index e2a54cc..4a7e259 100644
--- a/dlls/winemac.drv/macdrv.h
+++ b/dlls/winemac.drv/macdrv.h
@@ -164,6 +164,7 @@ extern void macdrv_window_minimize_requested(HWND hwnd) DECLSPEC_HIDDEN;
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;
diff --git a/dlls/winemac.drv/macdrv_cocoa.h b/dlls/winemac.drv/macdrv_cocoa.h
index 63f537e..d99a5ec 100644
--- a/dlls/winemac.drv/macdrv_cocoa.h
+++ b/dlls/winemac.drv/macdrv_cocoa.h
@@ -287,6 +287,7 @@ enum {
QUERY_PASTEBOARD_DATA,
QUERY_RESIZE_END,
QUERY_RESIZE_START,
+ QUERY_MIN_MAX_INFO,
NUM_QUERY_TYPES
};
diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c
index efd63d1..1afe294 100644
--- a/dlls/winemac.drv/window.c
+++ b/dlls/winemac.drv/window.c
@@ -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;
+}
More information about the wine-cvs
mailing list