winemac: Implement support for owned windows.
This commit is contained in:
parent
429732ce1a
commit
b6544d19dd
|
@ -27,6 +27,7 @@ @interface WineWindow : NSPanel <NSWindowDelegate>
|
|||
BOOL disabled;
|
||||
BOOL noActivate;
|
||||
BOOL floating;
|
||||
WineWindow* latentParentWindow;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -63,6 +63,7 @@ @interface WineWindow ()
|
|||
@property (nonatomic) BOOL disabled;
|
||||
@property (nonatomic) BOOL noActivate;
|
||||
@property (nonatomic) BOOL floating;
|
||||
@property (retain, nonatomic) NSWindow* latentParentWindow;
|
||||
|
||||
+ (void) flipRect:(NSRect*)rect;
|
||||
|
||||
|
@ -81,7 +82,7 @@ - (BOOL) isFlipped
|
|||
|
||||
@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 @@ + (WineWindow*) createWindowWithFeatures:(const struct macdrv_window_features*)w
|
|||
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 @@ - (BOOL) orderBelow:(WineWindow*)prev orAbove:(WineWindow*)next
|
|||
[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 @@ - (BOOL) setFrameIfOnScreen:(NSRect)contentRect
|
|||
{
|
||||
on_screen = frame_intersects_screens(contentRect, screens);
|
||||
if (!on_screen)
|
||||
[self orderOut:nil];
|
||||
[self doOrderOut];
|
||||
}
|
||||
|
||||
oldFrame = [self frame];
|
||||
|
@ -209,6 +228,19 @@ - (BOOL) setFrameIfOnScreen:(NSRect)contentRect
|
|||
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];
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue