mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-13 21:35:59 +00:00
Enable the SDL_HINT_MOUSE_DOUBLE_CLICK_TIME and SDL_HINT_MOUSE_DOUBLE_CLICK_RADIUS hints on macOS
Fixes https://github.com/libsdl-org/SDL/issues/4000
This commit is contained in:
@@ -1556,7 +1556,7 @@ static NSCursor *Cocoa_GetDesiredCursor(void)
|
|||||||
static void Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL_Window *window, Uint8 button, bool down)
|
static void Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL_Window *window, Uint8 button, bool down)
|
||||||
{
|
{
|
||||||
SDL_MouseID mouseID = SDL_DEFAULT_MOUSE_ID;
|
SDL_MouseID mouseID = SDL_DEFAULT_MOUSE_ID;
|
||||||
const int clicks = (int)[theEvent clickCount];
|
//const int clicks = (int)[theEvent clickCount];
|
||||||
SDL_Window *focus = SDL_GetKeyboardFocus();
|
SDL_Window *focus = SDL_GetKeyboardFocus();
|
||||||
|
|
||||||
// macOS will send non-left clicks to background windows without raising them, so we need to
|
// macOS will send non-left clicks to background windows without raising them, so we need to
|
||||||
@@ -1565,14 +1565,16 @@ static void Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL
|
|||||||
// event for the background window, this just makes sure the button is reported at the
|
// event for the background window, this just makes sure the button is reported at the
|
||||||
// correct position in its own event.
|
// correct position in its own event.
|
||||||
if (focus && ([theEvent window] == ((__bridge SDL_CocoaWindowData *)focus->internal).nswindow)) {
|
if (focus && ([theEvent window] == ((__bridge SDL_CocoaWindowData *)focus->internal).nswindow)) {
|
||||||
SDL_SendMouseButtonClicks(Cocoa_GetEventTimestamp([theEvent timestamp]), window, mouseID, button, down, clicks);
|
//SDL_SendMouseButtonClicks(Cocoa_GetEventTimestamp([theEvent timestamp]), window, mouseID, button, down, clicks);
|
||||||
|
SDL_SendMouseButton(Cocoa_GetEventTimestamp([theEvent timestamp]), window, mouseID, button, down);
|
||||||
} else {
|
} else {
|
||||||
const float orig_x = mouse->x;
|
const float orig_x = mouse->x;
|
||||||
const float orig_y = mouse->y;
|
const float orig_y = mouse->y;
|
||||||
const NSPoint point = [theEvent locationInWindow];
|
const NSPoint point = [theEvent locationInWindow];
|
||||||
mouse->x = (int)point.x;
|
mouse->x = (int)point.x;
|
||||||
mouse->y = (int)(window->h - point.y);
|
mouse->y = (int)(window->h - point.y);
|
||||||
SDL_SendMouseButtonClicks(Cocoa_GetEventTimestamp([theEvent timestamp]), window, mouseID, button, down, clicks);
|
//SDL_SendMouseButtonClicks(Cocoa_GetEventTimestamp([theEvent timestamp]), window, mouseID, button, down, clicks);
|
||||||
|
SDL_SendMouseButton(Cocoa_GetEventTimestamp([theEvent timestamp]), window, mouseID, button, down);
|
||||||
mouse->x = orig_x;
|
mouse->x = orig_x;
|
||||||
mouse->y = orig_y;
|
mouse->y = orig_y;
|
||||||
}
|
}
|
||||||
|
@@ -277,6 +277,8 @@ int main(int argc, char *argv[])
|
|||||||
SDL_RenderClear(renderer);
|
SDL_RenderClear(renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_StopTextInput(state->windows[0]);
|
||||||
|
SDL_StopTextInput(state->windows[0]);
|
||||||
/* Main render loop */
|
/* Main render loop */
|
||||||
done = 0;
|
done = 0;
|
||||||
#ifdef SDL_PLATFORM_EMSCRIPTEN
|
#ifdef SDL_PLATFORM_EMSCRIPTEN
|
||||||
|
Reference in New Issue
Block a user