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@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Tim Clem 2022-01-19 11:13:43 -08:00 committed by Alexandre Julliard
parent b59335af2a
commit 4b4ebef412
5 changed files with 18 additions and 18 deletions

View File

@ -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];
}

View File

@ -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;
@property (readonly, nonatomic) BOOL noActivate;
@property (readonly, nonatomic) BOOL noForeground;
@property (readonly, nonatomic) BOOL floating;
@property (readonly, getter=isFullscreen, nonatomic) BOOL fullscreen;
@property (readonly, getter=isFakingClose, nonatomic) BOOL fakingClose;

View File

@ -378,7 +378,7 @@ - (WineMetalView*) newMetalViewWithDevice:(id<MTLDevice>)device;
@interface WineWindow ()
@property (readwrite, nonatomic) BOOL disabled;
@property (readwrite, nonatomic) BOOL noActivate;
@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];

View File

@ -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;

View File

@ -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),