winemac.drv: Also stop dragging if we receive a mouse up event.

We rely on AppKit-internal events to know when a window is being
dragged. In Catalina, AppKit stopped sending the "drag ended" event when
no drag actually took place, though it still sends "drag started" events
when the title bar is clicked. Ironically, this caused us to think the
window was still being dragged. In that case, waiting for the mouse
button to come back up should allow us to determine when the drag should
end.

Signed-off-by: Chip Davis <cdavis@codeweavers.com>
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Chip Davis 2019-11-24 20:14:51 -06:00 committed by Alexandre Julliard
parent 153db6a757
commit 5cf64084fb
1 changed files with 32 additions and 26 deletions

View File

@ -1577,6 +1577,34 @@ - (void) windowWillOrderOut:(WineWindow*)window
}
}
- (void) handleWindowDrag:(NSEvent*)anEvent begin:(BOOL)begin
{
WineWindow* window = (WineWindow*)[anEvent window];
if ([window isKindOfClass:[WineWindow class]])
{
macdrv_event* event;
int eventType;
if (begin)
{
[windowsBeingDragged addObject:window];
eventType = WINDOW_DRAG_BEGIN;
}
else
{
[windowsBeingDragged removeObject:window];
eventType = WINDOW_DRAG_END;
}
[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);
}
}
- (void) handleMouseMove:(NSEvent*)anEvent
{
WineWindow* targetWindow;
@ -1731,6 +1759,9 @@ - (void) handleMouseButton:(NSEvent*)theEvent
WineWindow* windowBroughtForward = nil;
BOOL process = FALSE;
if (type == NSLeftMouseUp && [windowsBeingDragged count])
[self handleWindowDrag:theEvent begin:NO];
if ([window isKindOfClass:[WineWindow class]] &&
type == NSLeftMouseDown &&
![theEvent wine_commandKeyDown])
@ -2083,32 +2114,7 @@ - (BOOL) handleEvent:(NSEvent*)anEvent
// "a window is being dragged" and "a window is no longer being
// dragged", respectively.
if (subtype == 20 || subtype == 21)
{
WineWindow* window = (WineWindow*)[anEvent window];
if ([window isKindOfClass:[WineWindow class]])
{
macdrv_event* event;
int eventType;
if (subtype == 20)
{
[windowsBeingDragged addObject:window];
eventType = WINDOW_DRAG_BEGIN;
}
else
{
[windowsBeingDragged removeObject:window];
eventType = WINDOW_DRAG_END;
}
[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);
}
}
[self handleWindowDrag:anEvent begin:(subtype == 20)];
}
return ret;