diff --git a/dlls/winemac.drv/cocoa_window.h b/dlls/winemac.drv/cocoa_window.h index 1edcd9c85a5..86211dd4983 100644 --- a/dlls/winemac.drv/cocoa_window.h +++ b/dlls/winemac.drv/cocoa_window.h @@ -25,6 +25,7 @@ @interface WineWindow : NSPanel { NSUInteger normalStyleMask; BOOL disabled; + BOOL noActivate; } @end diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m index 848e49e0a32..dde77b3916a 100644 --- a/dlls/winemac.drv/cocoa_window.m +++ b/dlls/winemac.drv/cocoa_window.m @@ -61,6 +61,7 @@ @interface WineContentView : NSView @interface WineWindow () @property (nonatomic) BOOL disabled; +@property (nonatomic) BOOL noActivate; + (void) flipRect:(NSRect*)rect; @@ -79,7 +80,7 @@ - (BOOL) isFlipped @implementation WineWindow - @synthesize disabled; + @synthesize disabled, noActivate; + (WineWindow*) createWindowWithFeatures:(const struct macdrv_window_features*)wf windowFrame:(NSRect)window_frame @@ -147,6 +148,7 @@ - (void) setWindowFeatures:(const struct macdrv_window_features*)wf - (void) setMacDrvState:(const struct macdrv_window_state*)state { self.disabled = state->disabled; + self.noActivate = state->no_activate; } /* Returns whether or not the window was ordered in, which depends on if @@ -214,7 +216,8 @@ - (void) setDisabled:(BOOL)newValue */ - (BOOL) canBecomeKeyWindow { - return !self.disabled; + if (self.disabled || self.noActivate) return NO; + return YES; } - (BOOL) canBecomeMainWindow diff --git a/dlls/winemac.drv/macdrv_cocoa.h b/dlls/winemac.drv/macdrv_cocoa.h index e2a735bcf4d..d91cd1a43b7 100644 --- a/dlls/winemac.drv/macdrv_cocoa.h +++ b/dlls/winemac.drv/macdrv_cocoa.h @@ -127,6 +127,7 @@ struct macdrv_window_state { unsigned int disabled:1; + unsigned int no_activate:1; }; extern macdrv_window macdrv_create_cocoa_window(const struct macdrv_window_features* wf, diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index 8520afafb4b..b813cdc2b2c 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -73,6 +73,26 @@ static void get_cocoa_window_features(struct macdrv_win_data *data, } +/******************************************************************* + * can_activate_window + * + * Check if we can activate the specified window. + */ +static inline BOOL can_activate_window(HWND hwnd) +{ + LONG style = GetWindowLongW(hwnd, GWL_STYLE); + RECT rect; + + if (!(style & WS_VISIBLE)) return FALSE; + if ((style & (WS_POPUP|WS_CHILD)) == WS_CHILD) return FALSE; + if (style & WS_MINIMIZE) return FALSE; + if (GetWindowLongW(hwnd, GWL_EXSTYLE) & WS_EX_NOACTIVATE) return FALSE; + if (hwnd == GetDesktopWindow()) return FALSE; + if (GetWindowRect(hwnd, &rect) && IsRectEmpty(&rect)) return FALSE; + return !(style & WS_DISABLED); +} + + /*********************************************************************** * get_cocoa_window_state */ @@ -82,6 +102,7 @@ static void get_cocoa_window_state(struct macdrv_win_data *data, { memset(state, 0, sizeof(*state)); state->disabled = (style & WS_DISABLED) != 0; + state->no_activate = !can_activate_window(data->hwnd); }