Commit 49bb11fe authored by Ken Thomases's avatar Ken Thomases Committed by Alexandre Julliard

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: 's avatarKen Thomases <ken@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent af2690ab
......@@ -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);
}
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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;
......
......@@ -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;
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment