Ken Thomases : winemac: Implement support for owned windows.
Alexandre Julliard
julliard at winehq.org
Fri Jan 11 13:46:58 CST 2013
Module: wine
Branch: master
Commit: b6544d19ddd1e4d5af2cef69ec14bb414b179573
URL: http://source.winehq.org/git/wine.git/?a=commit;h=b6544d19ddd1e4d5af2cef69ec14bb414b179573
Author: Ken Thomases <ken at codeweavers.com>
Date: Fri Jan 11 06:19:36 2013 -0600
winemac: Implement support for owned windows.
---
dlls/winemac.drv/cocoa_window.h | 1 +
dlls/winemac.drv/cocoa_window.m | 53 ++++++++++++++++++++++++++++++++++++--
dlls/winemac.drv/macdrv_cocoa.h | 1 +
dlls/winemac.drv/window.c | 6 ++++
4 files changed, 58 insertions(+), 3 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_window.h b/dlls/winemac.drv/cocoa_window.h
index 41e0b90..8533e2a 100644
--- a/dlls/winemac.drv/cocoa_window.h
+++ b/dlls/winemac.drv/cocoa_window.h
@@ -27,6 +27,7 @@
BOOL disabled;
BOOL noActivate;
BOOL floating;
+ WineWindow* latentParentWindow;
}
@end
diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m
index 16217c2..e6ae103 100644
--- a/dlls/winemac.drv/cocoa_window.m
+++ b/dlls/winemac.drv/cocoa_window.m
@@ -63,6 +63,7 @@ static BOOL frame_intersects_screens(NSRect frame, NSArray* screens)
@property (nonatomic) BOOL disabled;
@property (nonatomic) BOOL noActivate;
@property (nonatomic) BOOL floating;
+ at property (retain, nonatomic) NSWindow* latentParentWindow;
+ (void) flipRect:(NSRect*)rect;
@@ -81,7 +82,7 @@ static BOOL frame_intersects_screens(NSRect frame, NSArray* screens)
@implementation WineWindow
- @synthesize disabled, noActivate, floating;
+ @synthesize disabled, noActivate, floating, latentParentWindow;
+ (WineWindow*) createWindowWithFeatures:(const struct macdrv_window_features*)wf
windowFrame:(NSRect)window_frame
@@ -119,6 +120,12 @@ static BOOL frame_intersects_screens(NSRect frame, NSArray* screens)
return window;
}
+ - (void) dealloc
+ {
+ [latentParentWindow release];
+ [super dealloc];
+ }
+
+ (void) flipRect:(NSRect*)rect
{
rect->origin.y = NSMaxY([[[NSScreen screens] objectAtIndex:0] frame]) - NSMaxY(*rect);
@@ -172,11 +179,23 @@ static BOOL frame_intersects_screens(NSRect frame, NSArray* screens)
[self orderWindow:NSWindowBelow relativeTo:[prev windowNumber]];
else
[self orderWindow:NSWindowAbove relativeTo:[next windowNumber]];
+ if (latentParentWindow)
+ {
+ [latentParentWindow addChildWindow:self ordered:NSWindowAbove];
+ self.latentParentWindow = nil;
+ }
}
return on_screen;
}
+ - (void) doOrderOut
+ {
+ self.latentParentWindow = [self parentWindow];
+ [latentParentWindow removeChildWindow:self];
+ [self orderOut:nil];
+ }
+
- (BOOL) setFrameIfOnScreen:(NSRect)contentRect
{
NSArray* screens = [NSScreen screens];
@@ -193,7 +212,7 @@ static BOOL frame_intersects_screens(NSRect frame, NSArray* screens)
{
on_screen = frame_intersects_screens(contentRect, screens);
if (!on_screen)
- [self orderOut:nil];
+ [self doOrderOut];
}
oldFrame = [self frame];
@@ -209,6 +228,19 @@ static BOOL frame_intersects_screens(NSRect frame, NSArray* screens)
return on_screen;
}
+ - (void) setMacDrvParentWindow:(WineWindow*)parent
+ {
+ if ([self parentWindow] != parent)
+ {
+ [[self parentWindow] removeChildWindow:self];
+ self.latentParentWindow = nil;
+ if ([self isVisible] && parent)
+ [parent addChildWindow:self ordered:NSWindowAbove];
+ else
+ self.latentParentWindow = parent;
+ }
+ }
+
- (void) setDisabled:(BOOL)newValue
{
if (disabled != newValue)
@@ -368,7 +400,7 @@ void macdrv_hide_cocoa_window(macdrv_window w)
WineWindow* window = (WineWindow*)w;
OnMainThread(^{
- [window orderOut:nil];
+ [window doOrderOut];
});
}
@@ -392,3 +424,18 @@ int macdrv_set_cocoa_window_frame(macdrv_window w, const CGRect* new_frame)
return on_screen;
}
+
+/***********************************************************************
+ * macdrv_set_cocoa_parent_window
+ *
+ * Sets the parent window for a Cocoa window. If parent is NULL, clears
+ * the parent window.
+ */
+void macdrv_set_cocoa_parent_window(macdrv_window w, macdrv_window parent)
+{
+ WineWindow* window = (WineWindow*)w;
+
+ OnMainThread(^{
+ [window setMacDrvParentWindow:(WineWindow*)parent];
+ });
+}
diff --git a/dlls/winemac.drv/macdrv_cocoa.h b/dlls/winemac.drv/macdrv_cocoa.h
index fa2e083..86a49ce 100644
--- a/dlls/winemac.drv/macdrv_cocoa.h
+++ b/dlls/winemac.drv/macdrv_cocoa.h
@@ -144,5 +144,6 @@ extern int macdrv_order_cocoa_window(macdrv_window w, macdrv_window prev,
macdrv_window next) DECLSPEC_HIDDEN;
extern void macdrv_hide_cocoa_window(macdrv_window w) DECLSPEC_HIDDEN;
extern int macdrv_set_cocoa_window_frame(macdrv_window w, const CGRect* new_frame) DECLSPEC_HIDDEN;
+extern void macdrv_set_cocoa_parent_window(macdrv_window w, macdrv_window parent) DECLSPEC_HIDDEN;
#endif /* __WINE_MACDRV_COCOA_H */
diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c
index 232c60a..21c9e59 100644
--- a/dlls/winemac.drv/window.c
+++ b/dlls/winemac.drv/window.c
@@ -301,12 +301,18 @@ static macdrv_window macdrv_get_cocoa_window(HWND hwnd)
static void set_cocoa_window_properties(struct macdrv_win_data *data)
{
DWORD style, ex_style;
+ HWND owner;
+ macdrv_window owner_win;
struct macdrv_window_features wf;
struct macdrv_window_state state;
style = GetWindowLongW(data->hwnd, GWL_STYLE);
ex_style = GetWindowLongW(data->hwnd, GWL_EXSTYLE);
+ owner = GetWindow(data->hwnd, GW_OWNER);
+ owner_win = macdrv_get_cocoa_window(owner);
+ macdrv_set_cocoa_parent_window(data->cocoa_window, owner_win);
+
get_cocoa_window_features(data, style, ex_style, &wf);
macdrv_set_cocoa_window_features(data->cocoa_window, &wf);
More information about the wine-cvs
mailing list