winemac: Also activate if a window is ordered front shortly after tray icon clicked.

... in addition to if one is focused.
This commit is contained in:
Ken Thomases 2013-06-19 19:09:18 -05:00 committed by Alexandre Julliard
parent 92a67d4259
commit 1d10457aee
4 changed files with 16 additions and 5 deletions

View File

@ -761,7 +761,7 @@ - (void) order:(NSWindowOrderingMode)mode childWindow:(WineWindow*)child relativ
/* Returns whether or not the window was ordered in, which depends on if
its frame intersects any screen. */
- (BOOL) orderBelow:(WineWindow*)prev orAbove:(WineWindow*)next
- (BOOL) orderBelow:(WineWindow*)prev orAbove:(WineWindow*)next activate:(BOOL)activate
{
WineApplicationController* controller = [WineApplicationController sharedController];
BOOL on_screen = frame_intersects_screens([self frame], [NSScreen screens]);
@ -772,6 +772,9 @@ - (BOOL) orderBelow:(WineWindow*)prev orAbove:(WineWindow*)next
[controller transformProcessToForeground];
if (activate)
[NSApp activateIgnoringOtherApps:YES];
NSDisableScreenUpdates();
if (latentParentWindow)
@ -1627,14 +1630,15 @@ void macdrv_set_cocoa_window_title(macdrv_window w, const unsigned short* title,
* (i.e. if its frame intersects with a screen). Otherwise, false.
*/
int macdrv_order_cocoa_window(macdrv_window w, macdrv_window prev,
macdrv_window next)
macdrv_window next, int activate)
{
WineWindow* window = (WineWindow*)w;
__block BOOL on_screen;
OnMainThread(^{
on_screen = [window orderBelow:(WineWindow*)prev
orAbove:(WineWindow*)next];
orAbove:(WineWindow*)next
activate:activate];
});
return on_screen;

View File

@ -162,6 +162,7 @@ static inline RECT rect_from_cgrect(CGRect cgrect)
extern void macdrv_mouse_button(HWND hwnd, const macdrv_event *event) DECLSPEC_HIDDEN;
extern void macdrv_mouse_moved(HWND hwnd, const macdrv_event *event) DECLSPEC_HIDDEN;
extern void macdrv_mouse_scroll(HWND hwnd, const macdrv_event *event) DECLSPEC_HIDDEN;
extern void macdrv_release_capture(HWND hwnd, const macdrv_event *event) DECLSPEC_HIDDEN;
extern void macdrv_compute_keyboard_layout(struct macdrv_thread_data *thread_data) DECLSPEC_HIDDEN;
extern void macdrv_keyboard_changed(const macdrv_event *event) DECLSPEC_HIDDEN;

View File

@ -350,7 +350,7 @@ extern void macdrv_set_cocoa_window_state(macdrv_window w,
extern void macdrv_set_cocoa_window_title(macdrv_window w, const UniChar* title,
size_t length) DECLSPEC_HIDDEN;
extern int macdrv_order_cocoa_window(macdrv_window w, macdrv_window prev,
macdrv_window next) DECLSPEC_HIDDEN;
macdrv_window next, int activate) 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_get_cocoa_window_frame(macdrv_window w, CGRect* out_frame) DECLSPEC_HIDDEN;

View File

@ -587,6 +587,7 @@ static void show_window(struct macdrv_win_data *data)
HWND next = NULL;
macdrv_window prev_window = NULL;
macdrv_window next_window = NULL;
BOOL activate = FALSE;
/* find window that this one must be after */
prev = GetWindow(data->hwnd, GW_HWNDPREV);
@ -605,12 +606,16 @@ static void show_window(struct macdrv_win_data *data)
TRACE("win %p/%p below %p/%p above %p/%p\n",
data->hwnd, data->cocoa_window, prev, prev_window, next, next_window);
data->on_screen = macdrv_order_cocoa_window(data->cocoa_window, prev_window, next_window);
if (!prev_window)
activate = activate_on_focus_time && (GetTickCount() - activate_on_focus_time < 2000);
data->on_screen = macdrv_order_cocoa_window(data->cocoa_window, prev_window, next_window, activate);
if (data->on_screen)
{
HWND hwndFocus = GetFocus();
if (hwndFocus && (data->hwnd == hwndFocus || IsChild(data->hwnd, hwndFocus)))
macdrv_SetFocus(hwndFocus);
if (activate)
activate_on_focus_time = 0;
}
}
@ -861,6 +866,7 @@ void CDECL macdrv_SetFocus(HWND hwnd)
BOOL activate = activate_on_focus_time && (GetTickCount() - activate_on_focus_time < 2000);
/* Set Mac focus */
macdrv_give_cocoa_window_focus(data->cocoa_window, activate);
activate_on_focus_time = 0;
}
release_win_data(data);