From c9d602307c4e062b480f857009aef6a048cf3bb5 Mon Sep 17 00:00:00 2001 From: Frank Praznik Date: Wed, 15 Jan 2025 15:14:04 -0500 Subject: [PATCH] cocoa: Only process hit tests on left clicks Otherwise, right-click events over drag areas will be eaten. --- src/video/cocoa/SDL_cocoawindow.m | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index daa544f7a4..48cc065ec4 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -1668,11 +1668,6 @@ static void Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL } } - if ([self processHitTest:theEvent]) { - SDL_SendWindowEvent(_data.window, SDL_EVENT_WINDOW_HIT_TEST, 0, 0); - return; // dragging, drop event. - } - switch ([theEvent buttonNumber]) { case 0: if (([theEvent modifierFlags] & NSEventModifierFlagControl) && @@ -1695,6 +1690,11 @@ static void Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL break; } + if (button == SDL_BUTTON_LEFT && [self processHitTest:theEvent]) { + SDL_SendWindowEvent(_data.window, SDL_EVENT_WINDOW_HIT_TEST, 0, 0); + return; // dragging, drop event. + } + Cocoa_SendMouseButtonClicks(mouse, theEvent, _data.window, button, true); } @@ -1721,11 +1721,6 @@ static void Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL return; } - if ([self processHitTest:theEvent]) { - SDL_SendWindowEvent(_data.window, SDL_EVENT_WINDOW_HIT_TEST, 0, 0); - return; // stopped dragging, drop event. - } - switch ([theEvent buttonNumber]) { case 0: if (wasCtrlLeft) { @@ -1746,6 +1741,11 @@ static void Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL break; } + if (button == SDL_BUTTON_LEFT && [self processHitTest:theEvent]) { + SDL_SendWindowEvent(_data.window, SDL_EVENT_WINDOW_HIT_TEST, 0, 0); + return; // stopped dragging, drop event. + } + Cocoa_SendMouseButtonClicks(mouse, theEvent, _data.window, button, false); }