[PATCH 1/3] winemac.drv: Allow foregrounding WS_EX_NOACTIVATE windows.

Tim Clem tclem at codeweavers.com
Wed Jan 19 13:13:43 CST 2022


The previous behavior denies any attempt to focus such windows, which
is not in line with how they behave on Windows.

Rename the macdrv_window_state no_activate field to no_foreground
so it more accurately reflects its meaning.

Signed-off-by: Tim Clem <tclem at codeweavers.com>
---
 dlls/winemac.drv/cocoa_app.m    |  2 +-
 dlls/winemac.drv/cocoa_window.h |  4 ++--
 dlls/winemac.drv/cocoa_window.m | 14 +++++++-------
 dlls/winemac.drv/macdrv_cocoa.h |  2 +-
 dlls/winemac.drv/window.c       | 14 +++++++-------
 5 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m
index 1bb752d20b78..16a773e14703 100644
--- a/dlls/winemac.drv/cocoa_app.m
+++ b/dlls/winemac.drv/cocoa_app.m
@@ -1864,7 +1864,7 @@ - (void) handleMouseButton:(NSEvent*)theEvent
                     break;
                 }
             }
-            if (!process && ![windowBroughtForward isKeyWindow] && !windowBroughtForward.disabled && !windowBroughtForward.noActivate)
+            if (!process && ![windowBroughtForward isKeyWindow] && !windowBroughtForward.disabled && !windowBroughtForward.noForeground)
                 [self windowGotFocus:windowBroughtForward];
         }
 
diff --git a/dlls/winemac.drv/cocoa_window.h b/dlls/winemac.drv/cocoa_window.h
index 9a8bbb5e2557..c7bcaedfd970 100644
--- a/dlls/winemac.drv/cocoa_window.h
+++ b/dlls/winemac.drv/cocoa_window.h
@@ -27,7 +27,7 @@
 @interface WineWindow : NSPanel <NSWindowDelegate>
 {
     BOOL disabled;
-    BOOL noActivate;
+    BOOL noForeground;
     BOOL floating;
     BOOL resizable;
     BOOL maximized;
@@ -90,7 +90,7 @@ @interface WineWindow : NSPanel <NSWindowDelegate>
 
 @property (retain, readonly, nonatomic) WineEventQueue* queue;
 @property (readonly, nonatomic) BOOL disabled;
- at property (readonly, nonatomic) BOOL noActivate;
+ at property (readonly, nonatomic) BOOL noForeground;
 @property (readonly, nonatomic) BOOL floating;
 @property (readonly, getter=isFullscreen, nonatomic) BOOL fullscreen;
 @property (readonly, getter=isFakingClose, nonatomic) BOOL fakingClose;
diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m
index 7708157a9924..2e15ec8ce721 100644
--- a/dlls/winemac.drv/cocoa_window.m
+++ b/dlls/winemac.drv/cocoa_window.m
@@ -378,7 +378,7 @@ - (WineMetalView*) newMetalViewWithDevice:(id<MTLDevice>)device;
 @interface WineWindow ()
 
 @property (readwrite, nonatomic) BOOL disabled;
- at property (readwrite, nonatomic) BOOL noActivate;
+ at property (readwrite, nonatomic) BOOL noForeground;
 @property (readwrite, nonatomic) BOOL floating;
 @property (readwrite, nonatomic) BOOL drawnSinceShown;
 @property (readwrite, nonatomic) BOOL closing;
@@ -942,7 +942,7 @@ @implementation WineWindow
 
     static WineWindow* causing_becomeKeyWindow;
 
-    @synthesize disabled, noActivate, floating, fullscreen, fakingClose, closing, latentParentWindow, hwnd, queue;
+    @synthesize disabled, noForeground, floating, fullscreen, fakingClose, closing, latentParentWindow, hwnd, queue;
     @synthesize drawnSinceShown;
     @synthesize surface, surface_mutex;
     @synthesize shapeChangedSinceLastDraw;
@@ -1232,7 +1232,7 @@ - (void) setMacDrvState:(const struct macdrv_window_state*)state
         NSWindowCollectionBehavior behavior;
 
         self.disabled = state->disabled;
-        self.noActivate = state->no_activate;
+        self.noForeground = state->no_foreground;
 
         if (self.floating != state->floating)
         {
@@ -2338,7 +2338,7 @@ - (void) checkEmptyShaped
     - (BOOL) canBecomeKeyWindow
     {
         if (causing_becomeKeyWindow == self) return YES;
-        if (self.disabled || self.noActivate) return NO;
+        if (self.disabled || self.noForeground) return NO;
         if ([self isKeyWindow]) return YES;
 
         // If a window's collectionBehavior says it participates in cycling,
@@ -2406,7 +2406,7 @@ - (BOOL) validateMenuItem:(NSMenuItem *)menuItem
         BOOL ret = [super validateMenuItem:menuItem];
 
         if ([menuItem action] == @selector(makeKeyAndOrderFront:))
-            ret = [self isKeyWindow] || (!self.disabled && !self.noActivate);
+            ret = [self isKeyWindow] || (!self.disabled && !self.noForeground);
         if ([menuItem action] == @selector(toggleFullScreen:) && (self.disabled || maximized))
             ret = NO;
 
@@ -2421,7 +2421,7 @@ - (void) makeKeyAndOrderFront:(id)sender
         [self orderBelow:nil orAbove:nil activate:NO];
         [[self ancestorWineWindow] postBroughtForwardEvent];
 
-        if (![self isKeyWindow] && !self.disabled && !self.noActivate)
+        if (![self isKeyWindow] && !self.disabled && !self.noForeground)
             [[WineApplicationController sharedController] windowGotFocus:self];
     }
 
@@ -2815,7 +2815,7 @@ - (void)windowDidDeminiaturize:(NSNotification *)notification
         if (![self parentWindow])
             [self postBroughtForwardEvent];
 
-        if (!self.disabled && !self.noActivate)
+        if (!self.disabled && !self.noForeground)
         {
             causing_becomeKeyWindow = self;
             [self makeKeyWindow];
diff --git a/dlls/winemac.drv/macdrv_cocoa.h b/dlls/winemac.drv/macdrv_cocoa.h
index 2c903bfb12a3..2304f771bfa3 100644
--- a/dlls/winemac.drv/macdrv_cocoa.h
+++ b/dlls/winemac.drv/macdrv_cocoa.h
@@ -542,7 +542,7 @@ extern int macdrv_register_hot_key(macdrv_event_queue q, unsigned int vkey, unsi
 
 struct macdrv_window_state {
     unsigned int    disabled:1;
-    unsigned int    no_activate:1;
+    unsigned int    no_foreground:1;
     unsigned int    floating:1;
     unsigned int    excluded_by_expose:1;
     unsigned int    excluded_by_cycle:1;
diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c
index 07f04993ee81..6d735bb4ed22 100644
--- a/dlls/winemac.drv/window.c
+++ b/dlls/winemac.drv/window.c
@@ -90,17 +90,17 @@ static void get_cocoa_window_features(struct macdrv_win_data *data,
 
 
 /*******************************************************************
- *              can_activate_window
+ *              can_window_become_foreground
  *
- * Check if we can activate the specified window.
+ * Check if the specified window can become the foreground/key
+ * window.
  */
-static inline BOOL can_activate_window(HWND hwnd)
+static inline BOOL can_window_become_foreground(HWND hwnd)
 {
     LONG style = GetWindowLongW(hwnd, GWL_STYLE);
 
     if (!(style & WS_VISIBLE)) return FALSE;
     if ((style & (WS_POPUP|WS_CHILD)) == WS_CHILD) return FALSE;
-    if (GetWindowLongW(hwnd, GWL_EXSTYLE) & WS_EX_NOACTIVATE) return FALSE;
     if (hwnd == GetDesktopWindow()) return FALSE;
     return !(style & WS_DISABLED);
 }
@@ -115,7 +115,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);
+    state->no_foreground = !can_window_become_foreground(data->hwnd);
     state->floating = (ex_style & WS_EX_TOPMOST) != 0;
     state->excluded_by_expose = state->excluded_by_cycle =
         (!(ex_style & WS_EX_APPWINDOW) &&
@@ -2347,7 +2347,7 @@ void macdrv_window_got_focus(HWND hwnd, const macdrv_event *event)
           hwnd, event->window, event->window_got_focus.serial, IsWindowEnabled(hwnd),
           IsWindowVisible(hwnd), style, GetFocus(), GetActiveWindow(), GetForegroundWindow());
 
-    if (can_activate_window(hwnd) && !(style & WS_MINIMIZE))
+    if (can_window_become_foreground(hwnd) && !(style & WS_MINIMIZE))
     {
         /* simulate a mouse click on the menu to find out
          * whether the window wants to be activated */
@@ -2570,7 +2570,7 @@ void macdrv_window_drag_begin(HWND hwnd, const macdrv_event *event)
     data->drag_event = drag_event;
     release_win_data(data);
 
-    if (!event->window_drag_begin.no_activate && can_activate_window(hwnd) && GetForegroundWindow() != hwnd)
+    if (!event->window_drag_begin.no_activate && can_window_become_foreground(hwnd) && GetForegroundWindow() != hwnd)
     {
         /* ask whether the window wants to be activated */
         LRESULT ma = SendMessageW(hwnd, WM_MOUSEACTIVATE, (WPARAM)GetAncestor(hwnd, GA_ROOT),
-- 
2.34.1




More information about the wine-devel mailing list