diff options
Diffstat (limited to 'Source/3rdParty/SDL2/src/events')
-rw-r--r-- | Source/3rdParty/SDL2/src/events/SDL_displayevents.c | 60 | ||||
-rw-r--r-- | Source/3rdParty/SDL2/src/events/SDL_displayevents_c.h | 30 | ||||
-rw-r--r-- | Source/3rdParty/SDL2/src/events/SDL_events.c | 23 | ||||
-rw-r--r-- | Source/3rdParty/SDL2/src/events/SDL_events_c.h | 9 | ||||
-rw-r--r-- | Source/3rdParty/SDL2/src/events/SDL_mouse.c | 52 | ||||
-rw-r--r-- | Source/3rdParty/SDL2/src/events/SDL_mouse_c.h | 5 | ||||
-rw-r--r-- | Source/3rdParty/SDL2/src/events/SDL_windowevents.c | 25 | ||||
-rw-r--r-- | Source/3rdParty/SDL2/src/events/scancodes_xfree86.h | 6 |
8 files changed, 175 insertions, 35 deletions
diff --git a/Source/3rdParty/SDL2/src/events/SDL_displayevents.c b/Source/3rdParty/SDL2/src/events/SDL_displayevents.c new file mode 100644 index 0000000..6c696af --- /dev/null +++ b/Source/3rdParty/SDL2/src/events/SDL_displayevents.c @@ -0,0 +1,60 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../SDL_internal.h" + +/* Display event handling code for SDL */ + +#include "SDL_events.h" +#include "SDL_events_c.h" + + +int +SDL_SendDisplayEvent(SDL_VideoDisplay *display, Uint8 displayevent, int data1) +{ + int posted; + + if (!display) { + return 0; + } + switch (displayevent) { + case SDL_DISPLAYEVENT_ORIENTATION: + if (data1 == SDL_ORIENTATION_UNKNOWN || data1 == display->orientation) { + return 0; + } + display->orientation = (SDL_DisplayOrientation)data1; + break; + } + + /* Post the event, if desired */ + posted = 0; + if (SDL_GetEventState(SDL_DISPLAYEVENT) == SDL_ENABLE) { + SDL_Event event; + event.type = SDL_DISPLAYEVENT; + event.display.event = displayevent; + event.display.display = SDL_GetIndexOfDisplay(display); + event.display.data1 = data1; + posted = (SDL_PushEvent(&event) > 0); + } + + return (posted); +} + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/Source/3rdParty/SDL2/src/events/SDL_displayevents_c.h b/Source/3rdParty/SDL2/src/events/SDL_displayevents_c.h new file mode 100644 index 0000000..41def7b --- /dev/null +++ b/Source/3rdParty/SDL2/src/events/SDL_displayevents_c.h @@ -0,0 +1,30 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../SDL_internal.h" + +#ifndef SDL_displayevents_c_h_ +#define SDL_displayevents_c_h_ + +extern int SDL_SendDisplayEvent(SDL_VideoDisplay *display, Uint8 displayevent, int data1); + +#endif /* SDL_displayevents_c_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/Source/3rdParty/SDL2/src/events/SDL_events.c b/Source/3rdParty/SDL2/src/events/SDL_events.c index f2e5b62..25e8ac4 100644 --- a/Source/3rdParty/SDL2/src/events/SDL_events.c +++ b/Source/3rdParty/SDL2/src/events/SDL_events.c @@ -417,6 +417,10 @@ SDL_StartEventLoop(void) SDL_EventState(SDL_TEXTINPUT, SDL_DISABLE); SDL_EventState(SDL_TEXTEDITING, SDL_DISABLE); SDL_EventState(SDL_SYSWMEVENT, SDL_DISABLE); +#if 0 /* Leave these events enabled so apps can respond to items being dragged onto them at startup */ + SDL_EventState(SDL_DROPFILE, SDL_DISABLE); + SDL_EventState(SDL_DROPTEXT, SDL_DISABLE); +#endif SDL_AtomicSet(&SDL_EventQ.active, 1); @@ -604,6 +608,10 @@ SDL_FlushEvent(Uint32 type) void SDL_FlushEvents(Uint32 minType, Uint32 maxType) { + /* !!! FIXME: we need to manually SDL_free() the strings in TEXTINPUT and + drag'n'drop events if we're flushing them without passing them to the + app, but I don't know if this is the right place to do that. */ + /* Don't look after we've quit */ if (!SDL_AtomicGet(&SDL_EventQ.active)) { return; @@ -651,6 +659,13 @@ SDL_PumpEvents(void) } #endif +#if !SDL_SENSOR_DISABLED + /* Check for sensor state change */ + if (!SDL_disabled_events[SDL_SENSORUPDATE >> 8]) { + SDL_SensorUpdate(); + } +#endif + SDL_SendPendingQuit(); /* in case we had a signal handler fire, etc. */ } @@ -863,6 +878,8 @@ SDL_FilterEvents(SDL_EventFilter filter, void *userdata) Uint8 SDL_EventState(Uint32 type, int state) { + const SDL_bool isdnd = ((state == SDL_DISABLE) || (state == SDL_ENABLE)) && + ((type == SDL_DROPFILE) || (type == SDL_DROPTEXT)); Uint8 current_state; Uint8 hi = ((type >> 8) & 0xff); Uint8 lo = (type & 0xff); @@ -898,6 +915,12 @@ SDL_EventState(Uint32 type, int state) } } + /* turn off drag'n'drop support if we've disabled the events. + This might change some UI details at the OS level. */ + if (isdnd) { + SDL_ToggleDragAndDropSupport(); + } + return current_state; } diff --git a/Source/3rdParty/SDL2/src/events/SDL_events_c.h b/Source/3rdParty/SDL2/src/events/SDL_events_c.h index b1bd277..d9684b5 100644 --- a/Source/3rdParty/SDL2/src/events/SDL_events_c.h +++ b/Source/3rdParty/SDL2/src/events/SDL_events_c.h @@ -18,12 +18,19 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ + +#ifndef SDL_events_c_h_ +#define SDL_events_c_h_ + #include "../SDL_internal.h" /* Useful functions and variables from SDL_events.c */ #include "SDL_events.h" #include "SDL_thread.h" +#include "../video/SDL_sysvideo.h" + #include "SDL_clipboardevents_c.h" +#include "SDL_displayevents_c.h" #include "SDL_dropevents_c.h" #include "SDL_gesture_c.h" #include "SDL_keyboard_c.h" @@ -46,4 +53,6 @@ extern void SDL_QuitQuit(void); extern void SDL_SendPendingQuit(void); +#endif /* SDL_events_c_h_ */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/Source/3rdParty/SDL2/src/events/SDL_mouse.c b/Source/3rdParty/SDL2/src/events/SDL_mouse.c index 4f4e62f..ff23c5e 100644 --- a/Source/3rdParty/SDL2/src/events/SDL_mouse.c +++ b/Source/3rdParty/SDL2/src/events/SDL_mouse.c @@ -33,13 +33,39 @@ /* The mouse state */ static SDL_Mouse SDL_mouse; -static Uint32 SDL_double_click_time = 500; -static int SDL_double_click_radius = 1; static int SDL_PrivateSendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relative, int x, int y); static void SDLCALL +SDL_MouseDoubleClickTimeChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +{ + SDL_Mouse *mouse = (SDL_Mouse *)userdata; + + if (hint && *hint) { + mouse->double_click_time = SDL_atoi(hint); + } else { +#ifdef __WIN32__ + mouse->double_click_time = GetDoubleClickTime(); +#else + mouse->double_click_time = 500; +#endif + } +} + +static void SDLCALL +SDL_MouseDoubleClickRadiusChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +{ + SDL_Mouse *mouse = (SDL_Mouse *)userdata; + + if (hint && *hint) { + mouse->double_click_radius = SDL_atoi(hint); + } else { + mouse->double_click_radius = 32; /* 32 pixels seems about right for touch interfaces */ + } +} + +static void SDLCALL SDL_MouseNormalSpeedScaleChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_Mouse *mouse = (SDL_Mouse *)userdata; @@ -83,6 +109,12 @@ SDL_MouseInit(void) SDL_zerop(mouse); + SDL_AddHintCallback(SDL_HINT_MOUSE_DOUBLE_CLICK_TIME, + SDL_MouseDoubleClickTimeChanged, mouse); + + SDL_AddHintCallback(SDL_HINT_MOUSE_DOUBLE_CLICK_RADIUS, + SDL_MouseDoubleClickRadiusChanged, mouse); + SDL_AddHintCallback(SDL_HINT_MOUSE_NORMAL_SPEED_SCALE, SDL_MouseNormalSpeedScaleChanged, mouse); @@ -114,12 +146,6 @@ SDL_GetMouse(void) return &SDL_mouse; } -void -SDL_SetDoubleClickTime(Uint32 interval) -{ - SDL_double_click_time = interval; -} - SDL_Window * SDL_GetMouseFocus(void) { @@ -454,9 +480,9 @@ SDL_PrivateSendMouseButton(SDL_Window * window, SDL_MouseID mouseID, Uint8 state if (state == SDL_PRESSED) { Uint32 now = SDL_GetTicks(); - if (SDL_TICKS_PASSED(now, clickstate->last_timestamp + SDL_double_click_time) || - SDL_abs(mouse->x - clickstate->last_x) > SDL_double_click_radius || - SDL_abs(mouse->y - clickstate->last_y) > SDL_double_click_radius) { + if (SDL_TICKS_PASSED(now, clickstate->last_timestamp + mouse->double_click_time) || + SDL_abs(mouse->x - clickstate->last_x) > mouse->double_click_radius || + SDL_abs(mouse->y - clickstate->last_y) > mouse->double_click_radius) { clickstate->click_count = 0; } clickstate->last_timestamp = now; @@ -688,6 +714,7 @@ static SDL_bool ShouldUseRelativeModeWarp(SDL_Mouse *mouse) { if (!mouse->SetRelativeMouseMode) { + SDL_assert(mouse->WarpMouse); /* Need this functionality for relative mode warp implementation */ return SDL_TRUE; } @@ -720,6 +747,9 @@ SDL_SetRelativeMouseMode(SDL_bool enabled) } else if (mouse->SetRelativeMouseMode(enabled) < 0) { if (enabled) { /* Fall back to warp mode if native relative mode failed */ + if (!mouse->WarpMouse) { + return SDL_SetError("No relative mode implementation available"); + } mouse->relative_mode_warp = SDL_TRUE; } } diff --git a/Source/3rdParty/SDL2/src/events/SDL_mouse_c.h b/Source/3rdParty/SDL2/src/events/SDL_mouse_c.h index 28089e0..ad44492 100644 --- a/Source/3rdParty/SDL2/src/events/SDL_mouse_c.h +++ b/Source/3rdParty/SDL2/src/events/SDL_mouse_c.h @@ -90,6 +90,8 @@ typedef struct float relative_speed_scale; float scale_accum_x; float scale_accum_y; + Uint32 double_click_time; + int double_click_radius; SDL_bool touch_mouse_events; /* Data for double-click tracking */ @@ -112,9 +114,6 @@ extern int SDL_MouseInit(void); /* Get the mouse state structure */ SDL_Mouse *SDL_GetMouse(void); -/* Set the default double-click interval */ -extern void SDL_SetDoubleClickTime(Uint32 interval); - /* Set the default mouse cursor */ extern void SDL_SetDefaultCursor(SDL_Cursor * cursor); diff --git a/Source/3rdParty/SDL2/src/events/SDL_windowevents.c b/Source/3rdParty/SDL2/src/events/SDL_windowevents.c index 610fad5..1670841 100644 --- a/Source/3rdParty/SDL2/src/events/SDL_windowevents.c +++ b/Source/3rdParty/SDL2/src/events/SDL_windowevents.c @@ -25,30 +25,16 @@ #include "SDL_events.h" #include "SDL_events_c.h" #include "SDL_mouse_c.h" -#include "../video/SDL_sysvideo.h" static int SDLCALL -RemovePendingResizedEvents(void * userdata, SDL_Event *event) +RemovePendingSizeChangedAndResizedEvents(void * userdata, SDL_Event *event) { SDL_Event *new_event = (SDL_Event *)userdata; if (event->type == SDL_WINDOWEVENT && - event->window.event == SDL_WINDOWEVENT_RESIZED && - event->window.windowID == new_event->window.windowID) { - /* We're about to post a new size event, drop the old one */ - return 0; - } - return 1; -} - -static int SDLCALL -RemovePendingSizeChangedEvents(void * userdata, SDL_Event *event) -{ - SDL_Event *new_event = (SDL_Event *)userdata; - - if (event->type == SDL_WINDOWEVENT && - event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED && + (event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED || + event->window.event == SDL_WINDOWEVENT_RESIZED) && event->window.windowID == new_event->window.windowID) { /* We're about to post a new size event, drop the old one */ return 0; @@ -200,11 +186,8 @@ SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1, event.window.windowID = window->id; /* Fixes queue overflow with resize events that aren't processed */ - if (windowevent == SDL_WINDOWEVENT_RESIZED) { - SDL_FilterEvents(RemovePendingResizedEvents, &event); - } if (windowevent == SDL_WINDOWEVENT_SIZE_CHANGED) { - SDL_FilterEvents(RemovePendingSizeChangedEvents, &event); + SDL_FilterEvents(RemovePendingSizeChangedAndResizedEvents, &event); } if (windowevent == SDL_WINDOWEVENT_MOVED) { SDL_FilterEvents(RemovePendingMoveEvents, &event); diff --git a/Source/3rdParty/SDL2/src/events/scancodes_xfree86.h b/Source/3rdParty/SDL2/src/events/scancodes_xfree86.h index 7d1f844..6e65507 100644 --- a/Source/3rdParty/SDL2/src/events/scancodes_xfree86.h +++ b/Source/3rdParty/SDL2/src/events/scancodes_xfree86.h @@ -18,6 +18,10 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ + +#ifndef scancodes_xfree86_h_ +#define scancodes_xfree86_h_ + #include "../../include/SDL_scancode.h" /* XFree86 key code to SDL scancode mapping table @@ -503,4 +507,6 @@ static const SDL_Scancode xvnc_scancode_table[] = { /* 80 */ SDL_SCANCODE_F12, }; +#endif /* scancodes_xfree86_h_ */ + /* *INDENT-ON* */ |