Ken Thomases : winemac: Move a window to the front when its Mac title bar is clicked.
Alexandre Julliard
julliard at winehq.org
Mon Apr 24 16:11:24 CDT 2017
Module: wine
Branch: master
Commit: 49bb11fef2ddc8c6c70bf28aefad0818eefca576
URL: http://source.winehq.org/git/wine.git/?a=commit;h=49bb11fef2ddc8c6c70bf28aefad0818eefca576
Author: Ken Thomases <ken at codeweavers.com>
Date: Mon Apr 24 13:07:10 2017 -0500
winemac: Move a window to the front when its Mac title bar is clicked.
Cocoa does this automatically for non-owned windows and informs the back end
via a different mechanism (WINDOW_BROUGHT_FORWARD). However, for owned windows
(child windows in Cocoa parlance), Cocoa does not change their z-order relative
to the owner (parent) or sibling owned windows when clicked. So, we have to
move the window in user32's z-order so that it gets moved appropriately on
screen in response.
Signed-off-by: Ken Thomases <ken at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/winemac.drv/cocoa_app.m | 2 ++
dlls/winemac.drv/cocoa_window.m | 7 ++++---
dlls/winemac.drv/event.c | 2 +-
dlls/winemac.drv/macdrv.h | 2 +-
dlls/winemac.drv/macdrv_cocoa.h | 3 +++
dlls/winemac.drv/window.c | 14 +++++++++++++-
6 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m
index f13e496..0caca9e 100644
--- a/dlls/winemac.drv/cocoa_app.m
+++ b/dlls/winemac.drv/cocoa_app.m
@@ -2023,6 +2023,8 @@ static NSString* WineLocalizedString(unsigned int stringID)
[self updateCursorClippingState];
event = macdrv_create_event(eventType, window);
+ if (eventType == WINDOW_DRAG_BEGIN)
+ event->window_drag_begin.no_activate = [NSEvent wine_commandKeyDown];
[window.queue postEvent:event];
macdrv_release_event(event);
}
diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m
index c67dd07..6257169 100644
--- a/dlls/winemac.drv/cocoa_window.m
+++ b/dlls/winemac.drv/cocoa_window.m
@@ -2236,9 +2236,10 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
if (draggingPhase == 2)
{
- macdrv_event* event = macdrv_create_event(WINDOW_DRAG_BEGIN, self);
- [queue postEvent:event];
- macdrv_release_event(event);
+ macdrv_event* mevent = macdrv_create_event(WINDOW_DRAG_BEGIN, self);
+ mevent->window_drag_begin.no_activate = [event wine_commandKeyDown];
+ [queue postEvent:mevent];
+ macdrv_release_event(mevent);
draggingPhase = 3;
}
diff --git a/dlls/winemac.drv/event.c b/dlls/winemac.drv/event.c
index 26d2b64..7ec59c0 100644
--- a/dlls/winemac.drv/event.c
+++ b/dlls/winemac.drv/event.c
@@ -279,7 +279,7 @@ void macdrv_handle_event(const macdrv_event *event)
macdrv_window_did_unminimize(hwnd);
break;
case WINDOW_DRAG_BEGIN:
- macdrv_window_drag_begin(hwnd);
+ macdrv_window_drag_begin(hwnd, event);
break;
case WINDOW_DRAG_END:
macdrv_window_drag_end(hwnd);
diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h
index bffd555..53dcd87 100644
--- a/dlls/winemac.drv/macdrv.h
+++ b/dlls/winemac.drv/macdrv.h
@@ -174,7 +174,7 @@ extern void macdrv_window_did_unminimize(HWND hwnd) DECLSPEC_HIDDEN;
extern void macdrv_window_brought_forward(HWND hwnd) DECLSPEC_HIDDEN;
extern void macdrv_window_resize_ended(HWND hwnd) DECLSPEC_HIDDEN;
extern void macdrv_window_restore_requested(HWND hwnd, const macdrv_event *event) DECLSPEC_HIDDEN;
-extern void macdrv_window_drag_begin(HWND hwnd) DECLSPEC_HIDDEN;
+extern void macdrv_window_drag_begin(HWND hwnd, const macdrv_event *event) DECLSPEC_HIDDEN;
extern void macdrv_window_drag_end(HWND hwnd) DECLSPEC_HIDDEN;
extern void macdrv_reassert_window_position(HWND hwnd) DECLSPEC_HIDDEN;
extern BOOL query_resize_size(HWND hwnd, macdrv_query *query) DECLSPEC_HIDDEN;
diff --git a/dlls/winemac.drv/macdrv_cocoa.h b/dlls/winemac.drv/macdrv_cocoa.h
index e016b3e..3ffeb01 100644
--- a/dlls/winemac.drv/macdrv_cocoa.h
+++ b/dlls/winemac.drv/macdrv_cocoa.h
@@ -376,6 +376,9 @@ typedef struct macdrv_event {
macdrv_status_item item;
} status_item_mouse_move;
struct {
+ int no_activate;
+ } window_drag_begin;
+ struct {
CGRect frame;
int fullscreen;
int in_resize;
diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c
index 83c77a9..e2de40d 100644
--- a/dlls/winemac.drv/window.c
+++ b/dlls/winemac.drv/window.c
@@ -2482,7 +2482,7 @@ void macdrv_window_restore_requested(HWND hwnd, const macdrv_event *event)
*
* Handler for WINDOW_DRAG_BEGIN events.
*/
-void macdrv_window_drag_begin(HWND hwnd)
+void macdrv_window_drag_begin(HWND hwnd, const macdrv_event *event)
{
DWORD style = GetWindowLongW(hwnd, GWL_STYLE);
struct macdrv_win_data *data;
@@ -2499,6 +2499,18 @@ void macdrv_window_drag_begin(HWND hwnd)
data->being_dragged = TRUE;
release_win_data(data);
+ if (!event->window_drag_begin.no_activate && can_activate_window(hwnd) && GetForegroundWindow() != hwnd)
+ {
+ /* ask whether the window wants to be activated */
+ LRESULT ma = SendMessageW(hwnd, WM_MOUSEACTIVATE, (WPARAM)GetAncestor(hwnd, GA_ROOT),
+ MAKELONG(HTCAPTION, WM_LBUTTONDOWN));
+ if (ma != MA_NOACTIVATEANDEAT && ma != MA_NOACTIVATE)
+ {
+ TRACE("setting foreground window to %p\n", hwnd);
+ SetForegroundWindow(hwnd);
+ }
+ }
+
ClipCursor(NULL);
SendMessageW(hwnd, WM_ENTERSIZEMOVE, 0, 0);
ReleaseCapture();
More information about the wine-cvs
mailing list