Tim Clem : winemac.drv: Allow foregrounding WS_EX_NOACTIVATE windows.
Alexandre Julliard
julliard at winehq.org
Wed Jan 19 15:57:47 CST 2022
Module: wine
Branch: master
Commit: 4b4ebef412c43705b1af3054daa89aa28edab985
URL: https://source.winehq.org/git/wine.git/?a=commit;h=4b4ebef412c43705b1af3054daa89aa28edab985
Author: Tim Clem <tclem at codeweavers.com>
Date: Wed Jan 19 11:13:43 2022 -0800
winemac.drv: Allow foregrounding WS_EX_NOACTIVATE windows.
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>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
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 1bb752d20b7..16a773e1470 100644
--- a/dlls/winemac.drv/cocoa_app.m
+++ b/dlls/winemac.drv/cocoa_app.m
@@ -1864,7 +1864,7 @@ static NSString* WineLocalizedString(unsigned int stringID)
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 9a8bbb5e255..c7bcaedfd97 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 @@
@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 7708157a992..2e15ec8ce72 100644
--- a/dlls/winemac.drv/cocoa_window.m
+++ b/dlls/winemac.drv/cocoa_window.m
@@ -378,7 +378,7 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
@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 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
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 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
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 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
- (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 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
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 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
[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 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
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 2c903bfb12a..2304f771bfa 100644
--- a/dlls/winemac.drv/macdrv_cocoa.h
+++ b/dlls/winemac.drv/macdrv_cocoa.h
@@ -542,7 +542,7 @@ struct macdrv_window_features {
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 07f04993ee8..6d735bb4ed2 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),
More information about the wine-cvs
mailing list