Made SDL_WINDOWEVENT_* and SDL_DISPLAYEVENT_* first class event types
Fixes https://github.com/libsdl-org/SDL/issues/6772main
parent
4676d1d31e
commit
909b513c33
|
@ -40,4 +40,5 @@ General:
|
||||||
* Added SDL_GetTicksNS() to return the number of nanoseconds since the SDL library initialized
|
* Added SDL_GetTicksNS() to return the number of nanoseconds since the SDL library initialized
|
||||||
* Added SDL_DelayNS() to specify a delay in nanoseconds, to the highest precision the system will support
|
* Added SDL_DelayNS() to specify a delay in nanoseconds, to the highest precision the system will support
|
||||||
* The timestamp member of the SDL_Event structure is now in nanoseconds, filled in with the time the event was generated, or the time it was queued if that's not available
|
* The timestamp member of the SDL_Event structure is now in nanoseconds, filled in with the time the event was generated, or the time it was queued if that's not available
|
||||||
|
* The `SDL_DISPLAYEVENT_*` and `SDL_WINDOWEVENT_*` events have been moved to top level events
|
||||||
* Intrinsic headers are no longer included in the public SDL headers
|
* Intrinsic headers are no longer included in the public SDL headers
|
||||||
|
|
|
@ -48,13 +48,17 @@ The following headers are no longer automatically included, and will need to be
|
||||||
|
|
||||||
## SDL_events.h
|
## SDL_events.h
|
||||||
|
|
||||||
The `timestamp` member of the SDL_Event structure now represents nanoseconds, and is populated with `SDL_GetTicksNS()`
|
The `timestamp` member of the `SDL_Event` structure now represents nanoseconds, and is populated with `SDL_GetTicksNS()`
|
||||||
|
|
||||||
The `timestamp_us` member of the sensor events has been renamed `sensor_timestamp` and now represents nanoseconds. This value is filled in from the hardware, if available, and may not be synchronized with values returned from SDL_GetTicksNS().
|
The `timestamp_us` member of the sensor events has been renamed `sensor_timestamp` and now represents nanoseconds. This value is filled in from the hardware, if available, and may not be synchronized with values returned from `SDL_GetTicksNS()`.
|
||||||
|
|
||||||
You should set the `event.common.timestamp` field before passing an event to `SDL_PushEvent()`. If the timestamp is 0 it will be filled in with `SDL_GetTicksNS()`.
|
You should set the `event.common.timestamp` field before passing an event to `SDL_PushEvent()`. If the timestamp is 0 it will be filled in with `SDL_GetTicksNS()`.
|
||||||
|
|
||||||
SDL_GetEventState used to be a macro, now it's a real function, but otherwise functions identically.
|
`SDL_GetEventState` used to be a macro, now it's a real function, but otherwise functions identically.
|
||||||
|
|
||||||
|
The `SDL_DISPLAYEVENT_*` events have been moved to top level events, and `SDL_DISPLAYEVENT` has been removed. In general, handling this change just means checking for the individual events instead of first checking for `SDL_DISPLAYEVENT` and then checking for display events. You can compare the event >= `SDL_DISPLAYEVENT_FIRST` and <= `SDL_DISPLAYEVENT_LAST` if you need to see whether it's a display event.
|
||||||
|
|
||||||
|
The `SDL_WINDOWEVENT_*` events have been moved to top level events, and `SDL_WINDOWEVENT` has been removed. In general, handling this change just means checking for the individual events instead of first checking for `SDL_WINDOWEVENT` and then checking for window events. You can compare the event >= `SDL_WINDOWEVENT_FIRST` and <= `SDL_WINDOWEVENT_LAST` if you need to see whether it's a window event.
|
||||||
|
|
||||||
|
|
||||||
## SDL_gamecontroller.h
|
## SDL_gamecontroller.h
|
||||||
|
|
|
@ -87,11 +87,40 @@ typedef enum
|
||||||
SDL_LOCALECHANGED, /**< The user's locale preferences have changed. */
|
SDL_LOCALECHANGED, /**< The user's locale preferences have changed. */
|
||||||
|
|
||||||
/* Display events */
|
/* Display events */
|
||||||
SDL_DISPLAYEVENT = 0x150, /**< Display state change */
|
SDL_DISPLAYEVENT_ORIENTATION = 0x150, /**< Display orientation has changed to data1 */
|
||||||
|
SDL_DISPLAYEVENT_CONNECTED, /**< Display has been added to the system */
|
||||||
|
SDL_DISPLAYEVENT_DISCONNECTED, /**< Display has been removed from the system */
|
||||||
|
SDL_DISPLAYEVENT_MOVED, /**< Display has changed position */
|
||||||
|
SDL_DISPLAYEVENT_FIRST = SDL_DISPLAYEVENT_ORIENTATION,
|
||||||
|
SDL_DISPLAYEVENT_LAST = SDL_DISPLAYEVENT_DISCONNECTED,
|
||||||
|
|
||||||
/* Window events */
|
/* Window events */
|
||||||
SDL_WINDOWEVENT = 0x200, /**< Window state change */
|
SDL_SYSWMEVENT = 0x201, /**< System specific event */
|
||||||
SDL_SYSWMEVENT, /**< System specific event */
|
SDL_WINDOWEVENT_SHOWN, /**< Window has been shown */
|
||||||
|
SDL_WINDOWEVENT_HIDDEN, /**< Window has been hidden */
|
||||||
|
SDL_WINDOWEVENT_EXPOSED, /**< Window has been exposed and should be
|
||||||
|
redrawn */
|
||||||
|
SDL_WINDOWEVENT_MOVED, /**< Window has been moved to data1, data2
|
||||||
|
*/
|
||||||
|
SDL_WINDOWEVENT_RESIZED, /**< Window has been resized to data1xdata2 */
|
||||||
|
SDL_WINDOWEVENT_SIZE_CHANGED, /**< The window size has changed, either as
|
||||||
|
a result of an API call or through the
|
||||||
|
system or user changing the window size. */
|
||||||
|
SDL_WINDOWEVENT_MINIMIZED, /**< Window has been minimized */
|
||||||
|
SDL_WINDOWEVENT_MAXIMIZED, /**< Window has been maximized */
|
||||||
|
SDL_WINDOWEVENT_RESTORED, /**< Window has been restored to normal size
|
||||||
|
and position */
|
||||||
|
SDL_WINDOWEVENT_ENTER, /**< Window has gained mouse focus */
|
||||||
|
SDL_WINDOWEVENT_LEAVE, /**< Window has lost mouse focus */
|
||||||
|
SDL_WINDOWEVENT_FOCUS_GAINED, /**< Window has gained keyboard focus */
|
||||||
|
SDL_WINDOWEVENT_FOCUS_LOST, /**< Window has lost keyboard focus */
|
||||||
|
SDL_WINDOWEVENT_CLOSE, /**< The window manager requests that the window be closed */
|
||||||
|
SDL_WINDOWEVENT_TAKE_FOCUS, /**< Window is being offered a focus (should SetWindowInputFocus() on itself or a subwindow, or ignore) */
|
||||||
|
SDL_WINDOWEVENT_HIT_TEST, /**< Window had a hit test that wasn't SDL_HITTEST_NORMAL. */
|
||||||
|
SDL_WINDOWEVENT_ICCPROF_CHANGED,/**< The ICC profile of the window's display has changed. */
|
||||||
|
SDL_WINDOWEVENT_DISPLAY_CHANGED,/**< Window has been moved to display data1. */
|
||||||
|
SDL_WINDOWEVENT_FIRST = SDL_WINDOWEVENT_SHOWN,
|
||||||
|
SDL_WINDOWEVENT_LAST = SDL_WINDOWEVENT_DISPLAY_CHANGED,
|
||||||
|
|
||||||
/* Keyboard events */
|
/* Keyboard events */
|
||||||
SDL_KEYDOWN = 0x300, /**< Key pressed */
|
SDL_KEYDOWN = 0x300, /**< Key pressed */
|
||||||
|
@ -185,13 +214,9 @@ typedef struct SDL_CommonEvent
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_DisplayEvent
|
typedef struct SDL_DisplayEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_DISPLAYEVENT */
|
Uint32 type; /**< ::SDL_DISPLAYEVENT_* */
|
||||||
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
|
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
|
||||||
Uint32 display; /**< The associated display index */
|
Uint32 display; /**< The associated display index */
|
||||||
Uint8 event; /**< ::SDL_DisplayEventID */
|
|
||||||
Uint8 padding1;
|
|
||||||
Uint8 padding2;
|
|
||||||
Uint8 padding3;
|
|
||||||
Sint32 data1; /**< event dependent data */
|
Sint32 data1; /**< event dependent data */
|
||||||
} SDL_DisplayEvent;
|
} SDL_DisplayEvent;
|
||||||
|
|
||||||
|
@ -200,13 +225,9 @@ typedef struct SDL_DisplayEvent
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_WindowEvent
|
typedef struct SDL_WindowEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_WINDOWEVENT */
|
Uint32 type; /**< ::SDL_WINDOWEVENT_* */
|
||||||
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
|
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
|
||||||
Uint32 windowID; /**< The associated window */
|
Uint32 windowID; /**< The associated window */
|
||||||
Uint8 event; /**< ::SDL_WindowEventID */
|
|
||||||
Uint8 padding1;
|
|
||||||
Uint8 padding2;
|
|
||||||
Uint8 padding3;
|
|
||||||
Sint32 data1; /**< event dependent data */
|
Sint32 data1; /**< event dependent data */
|
||||||
Sint32 data2; /**< event dependent data */
|
Sint32 data2; /**< event dependent data */
|
||||||
} SDL_WindowEvent;
|
} SDL_WindowEvent;
|
||||||
|
|
|
@ -148,49 +148,6 @@ typedef enum
|
||||||
#define SDL_WINDOWPOS_ISCENTERED(X) \
|
#define SDL_WINDOWPOS_ISCENTERED(X) \
|
||||||
(((X)&0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK)
|
(((X)&0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK)
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Event subtype for window events
|
|
||||||
*/
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
SDL_WINDOWEVENT_NONE, /**< Never used */
|
|
||||||
SDL_WINDOWEVENT_SHOWN, /**< Window has been shown */
|
|
||||||
SDL_WINDOWEVENT_HIDDEN, /**< Window has been hidden */
|
|
||||||
SDL_WINDOWEVENT_EXPOSED, /**< Window has been exposed and should be
|
|
||||||
redrawn */
|
|
||||||
SDL_WINDOWEVENT_MOVED, /**< Window has been moved to data1, data2
|
|
||||||
*/
|
|
||||||
SDL_WINDOWEVENT_RESIZED, /**< Window has been resized to data1xdata2 */
|
|
||||||
SDL_WINDOWEVENT_SIZE_CHANGED, /**< The window size has changed, either as
|
|
||||||
a result of an API call or through the
|
|
||||||
system or user changing the window size. */
|
|
||||||
SDL_WINDOWEVENT_MINIMIZED, /**< Window has been minimized */
|
|
||||||
SDL_WINDOWEVENT_MAXIMIZED, /**< Window has been maximized */
|
|
||||||
SDL_WINDOWEVENT_RESTORED, /**< Window has been restored to normal size
|
|
||||||
and position */
|
|
||||||
SDL_WINDOWEVENT_ENTER, /**< Window has gained mouse focus */
|
|
||||||
SDL_WINDOWEVENT_LEAVE, /**< Window has lost mouse focus */
|
|
||||||
SDL_WINDOWEVENT_FOCUS_GAINED, /**< Window has gained keyboard focus */
|
|
||||||
SDL_WINDOWEVENT_FOCUS_LOST, /**< Window has lost keyboard focus */
|
|
||||||
SDL_WINDOWEVENT_CLOSE, /**< The window manager requests that the window be closed */
|
|
||||||
SDL_WINDOWEVENT_TAKE_FOCUS, /**< Window is being offered a focus (should SetWindowInputFocus() on itself or a subwindow, or ignore) */
|
|
||||||
SDL_WINDOWEVENT_HIT_TEST, /**< Window had a hit test that wasn't SDL_HITTEST_NORMAL. */
|
|
||||||
SDL_WINDOWEVENT_ICCPROF_CHANGED,/**< The ICC profile of the window's display has changed. */
|
|
||||||
SDL_WINDOWEVENT_DISPLAY_CHANGED /**< Window has been moved to display data1. */
|
|
||||||
} SDL_WindowEventID;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Event subtype for display events
|
|
||||||
*/
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
SDL_DISPLAYEVENT_NONE, /**< Never used */
|
|
||||||
SDL_DISPLAYEVENT_ORIENTATION, /**< Display orientation has changed to data1 */
|
|
||||||
SDL_DISPLAYEVENT_CONNECTED, /**< Display has been added to the system */
|
|
||||||
SDL_DISPLAYEVENT_DISCONNECTED, /**< Display has been removed from the system */
|
|
||||||
SDL_DISPLAYEVENT_MOVED /**< Display has changed position */
|
|
||||||
} SDL_DisplayEventID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Display orientation
|
* \brief Display orientation
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -221,7 +221,7 @@ class SDL_BApp : public BApplication
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* Event management */
|
/* Event management */
|
||||||
void _HandleBasicWindowEvent(BMessage *msg, int32 sdlEventType)
|
void _HandleBasicWindowEvent(BMessage *msg, SDL_EventType sdlEventType)
|
||||||
{
|
{
|
||||||
SDL_Window *win;
|
SDL_Window *win;
|
||||||
int32 winID;
|
int32 winID;
|
||||||
|
|
|
@ -354,16 +354,11 @@ void SDL_WinRTApp::Run()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IsSDLWindowEventPending(SDL_WindowEventID windowEventID)
|
static bool IsSDLWindowEventPending(SDL_EventType windowEventID)
|
||||||
{
|
{
|
||||||
SDL_Event events[128];
|
SDL_Event events[128];
|
||||||
const int count = SDL_PeepEvents(events, sizeof(events) / sizeof(SDL_Event), SDL_PEEKEVENT, SDL_WINDOWEVENT, SDL_WINDOWEVENT);
|
const int count = SDL_PeepEvents(events, sizeof(events) / sizeof(SDL_Event), SDL_PEEKEVENT, windowEventID, windowEventID);
|
||||||
for (int i = 0; i < count; ++i) {
|
return (count > 0);
|
||||||
if (events[i].window.event == windowEventID) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SDL_WinRTApp::ShouldWaitForAppResumeEvents()
|
bool SDL_WinRTApp::ShouldWaitForAppResumeEvents()
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#include "SDL_events_c.h"
|
#include "SDL_events_c.h"
|
||||||
|
|
||||||
int SDL_SendDisplayEvent(SDL_VideoDisplay *display, Uint8 displayevent, int data1)
|
int SDL_SendDisplayEvent(SDL_VideoDisplay *display, SDL_EventType displayevent, int data1)
|
||||||
{
|
{
|
||||||
int posted;
|
int posted;
|
||||||
|
|
||||||
|
@ -38,15 +38,16 @@ int SDL_SendDisplayEvent(SDL_VideoDisplay *display, Uint8 displayevent, int data
|
||||||
}
|
}
|
||||||
display->orientation = (SDL_DisplayOrientation)data1;
|
display->orientation = (SDL_DisplayOrientation)data1;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Post the event, if desired */
|
/* Post the event, if desired */
|
||||||
posted = 0;
|
posted = 0;
|
||||||
if (SDL_GetEventState(SDL_DISPLAYEVENT) == SDL_ENABLE) {
|
if (SDL_GetEventState(displayevent) == SDL_ENABLE) {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
event.type = SDL_DISPLAYEVENT;
|
event.type = displayevent;
|
||||||
event.common.timestamp = 0;
|
event.common.timestamp = 0;
|
||||||
event.display.event = displayevent;
|
|
||||||
event.display.display = SDL_GetIndexOfDisplay(display);
|
event.display.display = SDL_GetIndexOfDisplay(display);
|
||||||
event.display.data1 = data1;
|
event.display.data1 = data1;
|
||||||
posted = (SDL_PushEvent(&event) > 0);
|
posted = (SDL_PushEvent(&event) > 0);
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#ifndef SDL_displayevents_c_h_
|
#ifndef SDL_displayevents_c_h_
|
||||||
#define SDL_displayevents_c_h_
|
#define SDL_displayevents_c_h_
|
||||||
|
|
||||||
extern int SDL_SendDisplayEvent(SDL_VideoDisplay *display, Uint8 displayevent, int data1);
|
extern int SDL_SendDisplayEvent(SDL_VideoDisplay *display, SDL_EventType displayevent, int data1);
|
||||||
|
|
||||||
#endif /* SDL_displayevents_c_h_ */
|
#endif /* SDL_displayevents_c_h_ */
|
||||||
|
|
||||||
|
|
|
@ -230,69 +230,43 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||||
SDL_EVENT_CASE(SDL_RENDER_DEVICE_RESET)
|
SDL_EVENT_CASE(SDL_RENDER_DEVICE_RESET)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
SDL_EVENT_CASE(SDL_DISPLAYEVENT)
|
|
||||||
{
|
|
||||||
char name2[64];
|
|
||||||
switch (event->display.event) {
|
|
||||||
case SDL_DISPLAYEVENT_NONE:
|
|
||||||
SDL_strlcpy(name2, "SDL_DISPLAYEVENT_NONE (THIS IS PROBABLY A BUG!)", sizeof(name2));
|
|
||||||
break;
|
|
||||||
#define SDL_DISPLAYEVENT_CASE(x) \
|
#define SDL_DISPLAYEVENT_CASE(x) \
|
||||||
case x: \
|
case x: \
|
||||||
SDL_strlcpy(name2, #x, sizeof(name2)); \
|
SDL_strlcpy(name, #x, sizeof(name)); \
|
||||||
|
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u display=%u event=%s data1=%d)", \
|
||||||
|
(uint)event->display.timestamp, (uint)event->display.display, name, (int)event->display.data1); \
|
||||||
break
|
break
|
||||||
SDL_DISPLAYEVENT_CASE(SDL_DISPLAYEVENT_ORIENTATION);
|
SDL_DISPLAYEVENT_CASE(SDL_DISPLAYEVENT_ORIENTATION);
|
||||||
SDL_DISPLAYEVENT_CASE(SDL_DISPLAYEVENT_CONNECTED);
|
SDL_DISPLAYEVENT_CASE(SDL_DISPLAYEVENT_CONNECTED);
|
||||||
SDL_DISPLAYEVENT_CASE(SDL_DISPLAYEVENT_DISCONNECTED);
|
SDL_DISPLAYEVENT_CASE(SDL_DISPLAYEVENT_DISCONNECTED);
|
||||||
SDL_DISPLAYEVENT_CASE(SDL_DISPLAYEVENT_MOVED);
|
SDL_DISPLAYEVENT_CASE(SDL_DISPLAYEVENT_MOVED);
|
||||||
#undef SDL_DISPLAYEVENT_CASE
|
#undef SDL_DISPLAYEVENT_CASE
|
||||||
default:
|
|
||||||
SDL_strlcpy(name2, "UNKNOWN (bug? fixme?)", sizeof(name2));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u display=%u event=%s data1=%d)",
|
|
||||||
(uint)event->display.timestamp, (uint)event->display.display, name2, (int)event->display.data1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_EVENT_CASE(SDL_WINDOWEVENT)
|
|
||||||
{
|
|
||||||
char name2[64];
|
|
||||||
switch (event->window.event) {
|
|
||||||
case SDL_WINDOWEVENT_NONE:
|
|
||||||
SDL_strlcpy(name2, "SDL_WINDOWEVENT_NONE (THIS IS PROBABLY A BUG!)", sizeof(name2));
|
|
||||||
break;
|
|
||||||
#define SDL_WINDOWEVENT_CASE(x) \
|
#define SDL_WINDOWEVENT_CASE(x) \
|
||||||
case x: \
|
case x: \
|
||||||
SDL_strlcpy(name2, #x, sizeof(name2)); \
|
SDL_strlcpy(name, #x, sizeof(name)); \
|
||||||
|
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u event=%s data1=%d data2=%d)", \
|
||||||
|
(uint)event->window.timestamp, (uint)event->window.windowID, name, (int)event->window.data1, (int)event->window.data2); \
|
||||||
break
|
break
|
||||||
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_SHOWN);
|
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_SHOWN);
|
||||||
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_HIDDEN);
|
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_HIDDEN);
|
||||||
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_EXPOSED);
|
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_EXPOSED);
|
||||||
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_MOVED);
|
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_MOVED);
|
||||||
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_RESIZED);
|
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_RESIZED);
|
||||||
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_SIZE_CHANGED);
|
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_SIZE_CHANGED);
|
||||||
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_MINIMIZED);
|
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_MINIMIZED);
|
||||||
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_MAXIMIZED);
|
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_MAXIMIZED);
|
||||||
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_RESTORED);
|
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_RESTORED);
|
||||||
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_ENTER);
|
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_ENTER);
|
||||||
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_LEAVE);
|
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_LEAVE);
|
||||||
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_FOCUS_GAINED);
|
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_FOCUS_GAINED);
|
||||||
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_FOCUS_LOST);
|
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_FOCUS_LOST);
|
||||||
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_CLOSE);
|
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_CLOSE);
|
||||||
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_TAKE_FOCUS);
|
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_TAKE_FOCUS);
|
||||||
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_HIT_TEST);
|
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_HIT_TEST);
|
||||||
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_ICCPROF_CHANGED);
|
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_ICCPROF_CHANGED);
|
||||||
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_DISPLAY_CHANGED);
|
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_DISPLAY_CHANGED);
|
||||||
#undef SDL_WINDOWEVENT_CASE
|
#undef SDL_WINDOWEVENT_CASE
|
||||||
default:
|
|
||||||
SDL_strlcpy(name2, "UNKNOWN (bug? fixme?)", sizeof(name2));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u event=%s data1=%d data2=%d)",
|
|
||||||
(uint)event->window.timestamp, (uint)event->window.windowID, name2, (int)event->window.data1, (int)event->window.data2);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_EVENT_CASE(SDL_SYSWMEVENT)
|
SDL_EVENT_CASE(SDL_SYSWMEVENT)
|
||||||
/* !!! FIXME: we don't delve further at the moment. */
|
/* !!! FIXME: we don't delve further at the moment. */
|
||||||
|
|
|
@ -36,12 +36,11 @@ static int SDLCALL RemovePendingSizeChangedAndResizedEvents(void *_userdata, SDL
|
||||||
RemovePendingSizeChangedAndResizedEvents_Data *userdata = (RemovePendingSizeChangedAndResizedEvents_Data *)_userdata;
|
RemovePendingSizeChangedAndResizedEvents_Data *userdata = (RemovePendingSizeChangedAndResizedEvents_Data *)_userdata;
|
||||||
const SDL_Event *new_event = userdata->new_event;
|
const SDL_Event *new_event = userdata->new_event;
|
||||||
|
|
||||||
if (event->type == SDL_WINDOWEVENT &&
|
if ((event->type == SDL_WINDOWEVENT_SIZE_CHANGED ||
|
||||||
(event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED ||
|
event->type == SDL_WINDOWEVENT_RESIZED) &&
|
||||||
event->window.event == SDL_WINDOWEVENT_RESIZED) &&
|
|
||||||
event->window.windowID == new_event->window.windowID) {
|
event->window.windowID == new_event->window.windowID) {
|
||||||
|
|
||||||
if (event->window.event == SDL_WINDOWEVENT_RESIZED) {
|
if (event->type == SDL_WINDOWEVENT_RESIZED) {
|
||||||
userdata->saw_resized = SDL_TRUE;
|
userdata->saw_resized = SDL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,8 +54,7 @@ static int SDLCALL RemovePendingMoveEvents(void *userdata, SDL_Event *event)
|
||||||
{
|
{
|
||||||
SDL_Event *new_event = (SDL_Event *)userdata;
|
SDL_Event *new_event = (SDL_Event *)userdata;
|
||||||
|
|
||||||
if (event->type == SDL_WINDOWEVENT &&
|
if (event->type == SDL_WINDOWEVENT_MOVED &&
|
||||||
event->window.event == SDL_WINDOWEVENT_MOVED &&
|
|
||||||
event->window.windowID == new_event->window.windowID) {
|
event->window.windowID == new_event->window.windowID) {
|
||||||
/* We're about to post a new move event, drop the old one */
|
/* We're about to post a new move event, drop the old one */
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -68,8 +66,7 @@ static int SDLCALL RemovePendingExposedEvents(void *userdata, SDL_Event *event)
|
||||||
{
|
{
|
||||||
SDL_Event *new_event = (SDL_Event *)userdata;
|
SDL_Event *new_event = (SDL_Event *)userdata;
|
||||||
|
|
||||||
if (event->type == SDL_WINDOWEVENT &&
|
if (event->type == SDL_WINDOWEVENT_EXPOSED &&
|
||||||
event->window.event == SDL_WINDOWEVENT_EXPOSED &&
|
|
||||||
event->window.windowID == new_event->window.windowID) {
|
event->window.windowID == new_event->window.windowID) {
|
||||||
/* We're about to post a new exposed event, drop the old one */
|
/* We're about to post a new exposed event, drop the old one */
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -77,8 +74,8 @@ static int SDLCALL RemovePendingExposedEvents(void *userdata, SDL_Event *event)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1,
|
int SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent,
|
||||||
int data2)
|
int data1, int data2)
|
||||||
{
|
{
|
||||||
int posted;
|
int posted;
|
||||||
|
|
||||||
|
@ -180,15 +177,16 @@ int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1,
|
||||||
window->flags &= ~SDL_WINDOW_INPUT_FOCUS;
|
window->flags &= ~SDL_WINDOW_INPUT_FOCUS;
|
||||||
SDL_OnWindowFocusLost(window);
|
SDL_OnWindowFocusLost(window);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Post the event, if desired */
|
/* Post the event, if desired */
|
||||||
posted = 0;
|
posted = 0;
|
||||||
if (SDL_GetEventState(SDL_WINDOWEVENT) == SDL_ENABLE) {
|
if (SDL_GetEventState(windowevent) == SDL_ENABLE) {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
event.type = SDL_WINDOWEVENT;
|
event.type = windowevent;
|
||||||
event.common.timestamp = 0;
|
event.common.timestamp = 0;
|
||||||
event.window.event = windowevent;
|
|
||||||
event.window.data1 = data1;
|
event.window.data1 = data1;
|
||||||
event.window.data2 = data2;
|
event.window.data2 = data2;
|
||||||
event.window.windowID = window->id;
|
event.window.windowID = window->id;
|
||||||
|
@ -201,11 +199,11 @@ int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1,
|
||||||
userdata.saw_resized = SDL_FALSE;
|
userdata.saw_resized = SDL_FALSE;
|
||||||
SDL_FilterEvents(RemovePendingSizeChangedAndResizedEvents, &userdata);
|
SDL_FilterEvents(RemovePendingSizeChangedAndResizedEvents, &userdata);
|
||||||
if (userdata.saw_resized) { /* if there was a pending resize, make sure one at the new dimensions remains. */
|
if (userdata.saw_resized) { /* if there was a pending resize, make sure one at the new dimensions remains. */
|
||||||
event.window.event = SDL_WINDOWEVENT_RESIZED;
|
event.type = SDL_WINDOWEVENT_RESIZED;
|
||||||
if (SDL_PushEvent(&event) <= 0) {
|
if (SDL_PushEvent(&event) <= 0) {
|
||||||
return 0; /* oh well. */
|
return 0; /* oh well. */
|
||||||
}
|
}
|
||||||
event.window.event = SDL_WINDOWEVENT_SIZE_CHANGED; /* then push the actual event next. */
|
event.type = SDL_WINDOWEVENT_SIZE_CHANGED; /* then push the actual event next. */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (windowevent == SDL_WINDOWEVENT_MOVED) {
|
if (windowevent == SDL_WINDOWEVENT_MOVED) {
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#ifndef SDL_windowevents_c_h_
|
#ifndef SDL_windowevents_c_h_
|
||||||
#define SDL_windowevents_c_h_
|
#define SDL_windowevents_c_h_
|
||||||
|
|
||||||
extern int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent,
|
extern int SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent,
|
||||||
int data1, int data2);
|
int data1, int data2);
|
||||||
|
|
||||||
#endif /* SDL_windowevents_c_h_ */
|
#endif /* SDL_windowevents_c_h_ */
|
||||||
|
|
|
@ -671,7 +671,7 @@ static int SDLCALL SDL_RendererEventWatch(void *userdata, SDL_Event *event)
|
||||||
{
|
{
|
||||||
SDL_Renderer *renderer = (SDL_Renderer *)userdata;
|
SDL_Renderer *renderer = (SDL_Renderer *)userdata;
|
||||||
|
|
||||||
if (event->type == SDL_WINDOWEVENT) {
|
if (event->type >= SDL_WINDOWEVENT_FIRST && event->type <= SDL_WINDOWEVENT_LAST) {
|
||||||
SDL_Window *window = SDL_GetWindowFromID(event->window.windowID);
|
SDL_Window *window = SDL_GetWindowFromID(event->window.windowID);
|
||||||
if (window == renderer->window) {
|
if (window == renderer->window) {
|
||||||
if (renderer->WindowEvent) {
|
if (renderer->WindowEvent) {
|
||||||
|
@ -682,8 +682,8 @@ static int SDLCALL SDL_RendererEventWatch(void *userdata, SDL_Event *event)
|
||||||
* window display changes as well! If the new display has a new DPI,
|
* window display changes as well! If the new display has a new DPI,
|
||||||
* we need to update the viewport for the new window/drawable ratio.
|
* we need to update the viewport for the new window/drawable ratio.
|
||||||
*/
|
*/
|
||||||
if (event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED ||
|
if (event->type == SDL_WINDOWEVENT_SIZE_CHANGED ||
|
||||||
event->window.event == SDL_WINDOWEVENT_DISPLAY_CHANGED) {
|
event->type == SDL_WINDOWEVENT_DISPLAY_CHANGED) {
|
||||||
/* Make sure we're operating on the default render target */
|
/* Make sure we're operating on the default render target */
|
||||||
SDL_Texture *saved_target = SDL_GetRenderTarget(renderer);
|
SDL_Texture *saved_target = SDL_GetRenderTarget(renderer);
|
||||||
if (saved_target) {
|
if (saved_target) {
|
||||||
|
@ -736,16 +736,16 @@ static int SDLCALL SDL_RendererEventWatch(void *userdata, SDL_Event *event)
|
||||||
if (saved_target) {
|
if (saved_target) {
|
||||||
SDL_SetRenderTarget(renderer, saved_target);
|
SDL_SetRenderTarget(renderer, saved_target);
|
||||||
}
|
}
|
||||||
} else if (event->window.event == SDL_WINDOWEVENT_HIDDEN) {
|
} else if (event->type == SDL_WINDOWEVENT_HIDDEN) {
|
||||||
renderer->hidden = SDL_TRUE;
|
renderer->hidden = SDL_TRUE;
|
||||||
} else if (event->window.event == SDL_WINDOWEVENT_SHOWN) {
|
} else if (event->type == SDL_WINDOWEVENT_SHOWN) {
|
||||||
if (!(SDL_GetWindowFlags(window) & SDL_WINDOW_MINIMIZED)) {
|
if (!(SDL_GetWindowFlags(window) & SDL_WINDOW_MINIMIZED)) {
|
||||||
renderer->hidden = SDL_FALSE;
|
renderer->hidden = SDL_FALSE;
|
||||||
}
|
}
|
||||||
} else if (event->window.event == SDL_WINDOWEVENT_MINIMIZED) {
|
} else if (event->type == SDL_WINDOWEVENT_MINIMIZED) {
|
||||||
renderer->hidden = SDL_TRUE;
|
renderer->hidden = SDL_TRUE;
|
||||||
} else if (event->window.event == SDL_WINDOWEVENT_RESTORED ||
|
} else if (event->type == SDL_WINDOWEVENT_RESTORED ||
|
||||||
event->window.event == SDL_WINDOWEVENT_MAXIMIZED) {
|
event->type == SDL_WINDOWEVENT_MAXIMIZED) {
|
||||||
if (!(SDL_GetWindowFlags(window) & SDL_WINDOW_HIDDEN)) {
|
if (!(SDL_GetWindowFlags(window) & SDL_WINDOW_HIDDEN)) {
|
||||||
renderer->hidden = SDL_FALSE;
|
renderer->hidden = SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -332,7 +332,7 @@ static void D3D_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event
|
||||||
{
|
{
|
||||||
D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
|
D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
|
||||||
|
|
||||||
if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) {
|
if (event->type == SDL_WINDOWEVENT_SIZE_CHANGED) {
|
||||||
data->updateSize = SDL_TRUE;
|
data->updateSize = SDL_TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1029,7 +1029,7 @@ void D3D11_Trim(SDL_Renderer *renderer)
|
||||||
|
|
||||||
static void D3D11_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event)
|
static void D3D11_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event)
|
||||||
{
|
{
|
||||||
if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) {
|
if (event->type == SDL_WINDOWEVENT_SIZE_CHANGED) {
|
||||||
D3D11_UpdateForWindowSizeChange(renderer);
|
D3D11_UpdateForWindowSizeChange(renderer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1377,7 +1377,7 @@ static HRESULT D3D12_UpdateForWindowSizeChange(SDL_Renderer *renderer)
|
||||||
|
|
||||||
static void D3D12_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event)
|
static void D3D12_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event)
|
||||||
{
|
{
|
||||||
if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) {
|
if (event->type == SDL_WINDOWEVENT_SIZE_CHANGED) {
|
||||||
D3D12_UpdateForWindowSizeChange(renderer);
|
D3D12_UpdateForWindowSizeChange(renderer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -324,8 +324,8 @@ static void GL_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event)
|
||||||
* changed behind our backs. x/y changes might seem weird but viewport
|
* changed behind our backs. x/y changes might seem weird but viewport
|
||||||
* resets have been observed on macOS at minimum!
|
* resets have been observed on macOS at minimum!
|
||||||
*/
|
*/
|
||||||
if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED ||
|
if (event->type == SDL_WINDOWEVENT_SIZE_CHANGED ||
|
||||||
event->event == SDL_WINDOWEVENT_MOVED) {
|
event->type == SDL_WINDOWEVENT_MOVED) {
|
||||||
GL_RenderData *data = (GL_RenderData *)renderer->driverdata;
|
GL_RenderData *data = (GL_RenderData *)renderer->driverdata;
|
||||||
data->drawstate.viewport_dirty = SDL_TRUE;
|
data->drawstate.viewport_dirty = SDL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -303,7 +303,7 @@ static void GLES2_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *eve
|
||||||
{
|
{
|
||||||
GLES2_RenderData *data = (GLES2_RenderData *)renderer->driverdata;
|
GLES2_RenderData *data = (GLES2_RenderData *)renderer->driverdata;
|
||||||
|
|
||||||
if (event->event == SDL_WINDOWEVENT_MINIMIZED) {
|
if (event->type == SDL_WINDOWEVENT_MINIMIZED) {
|
||||||
/* According to Apple documentation, we need to finish drawing NOW! */
|
/* According to Apple documentation, we need to finish drawing NOW! */
|
||||||
data->glFinish();
|
data->glFinish();
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ static void SW_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event)
|
||||||
{
|
{
|
||||||
SW_RenderData *data = (SW_RenderData *)renderer->driverdata;
|
SW_RenderData *data = (SW_RenderData *)renderer->driverdata;
|
||||||
|
|
||||||
if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) {
|
if (event->type == SDL_WINDOWEVENT_SIZE_CHANGED) {
|
||||||
data->surface = NULL;
|
data->surface = NULL;
|
||||||
data->window = NULL;
|
data->window = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1432,97 +1432,81 @@ static const char *ControllerButtonName(const SDL_GameControllerButton button)
|
||||||
static void SDLTest_PrintEvent(SDL_Event *event)
|
static void SDLTest_PrintEvent(SDL_Event *event)
|
||||||
{
|
{
|
||||||
switch (event->type) {
|
switch (event->type) {
|
||||||
case SDL_DISPLAYEVENT:
|
case SDL_DISPLAYEVENT_CONNECTED:
|
||||||
switch (event->display.event) {
|
SDL_Log("SDL EVENT: Display %" SDL_PRIu32 " connected",
|
||||||
case SDL_DISPLAYEVENT_CONNECTED:
|
event->display.display);
|
||||||
SDL_Log("SDL EVENT: Display %" SDL_PRIu32 " connected",
|
|
||||||
event->display.display);
|
|
||||||
break;
|
|
||||||
case SDL_DISPLAYEVENT_MOVED:
|
|
||||||
SDL_Log("SDL EVENT: Display %" SDL_PRIu32 " changed position",
|
|
||||||
event->display.display);
|
|
||||||
break;
|
|
||||||
case SDL_DISPLAYEVENT_ORIENTATION:
|
|
||||||
SDL_Log("SDL EVENT: Display %" SDL_PRIu32 " changed orientation to %s",
|
|
||||||
event->display.display, DisplayOrientationName(event->display.data1));
|
|
||||||
break;
|
|
||||||
case SDL_DISPLAYEVENT_DISCONNECTED:
|
|
||||||
SDL_Log("SDL EVENT: Display %" SDL_PRIu32 " disconnected",
|
|
||||||
event->display.display);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
SDL_Log("SDL EVENT: Display %" SDL_PRIu32 " got unknown event 0x%4.4x",
|
|
||||||
event->display.display, event->display.event);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT:
|
case SDL_DISPLAYEVENT_MOVED:
|
||||||
switch (event->window.event) {
|
SDL_Log("SDL EVENT: Display %" SDL_PRIu32 " changed position",
|
||||||
case SDL_WINDOWEVENT_SHOWN:
|
event->display.display);
|
||||||
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " shown", event->window.windowID);
|
break;
|
||||||
break;
|
case SDL_DISPLAYEVENT_ORIENTATION:
|
||||||
case SDL_WINDOWEVENT_HIDDEN:
|
SDL_Log("SDL EVENT: Display %" SDL_PRIu32 " changed orientation to %s",
|
||||||
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " hidden", event->window.windowID);
|
event->display.display, DisplayOrientationName(event->display.data1));
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_EXPOSED:
|
case SDL_DISPLAYEVENT_DISCONNECTED:
|
||||||
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " exposed", event->window.windowID);
|
SDL_Log("SDL EVENT: Display %" SDL_PRIu32 " disconnected",
|
||||||
break;
|
event->display.display);
|
||||||
case SDL_WINDOWEVENT_MOVED:
|
break;
|
||||||
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " moved to %" SDL_PRIs32 ",%" SDL_PRIs32,
|
case SDL_WINDOWEVENT_SHOWN:
|
||||||
event->window.windowID, event->window.data1, event->window.data2);
|
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " shown", event->window.windowID);
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_RESIZED:
|
case SDL_WINDOWEVENT_HIDDEN:
|
||||||
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " resized to %" SDL_PRIs32 "x%" SDL_PRIs32,
|
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " hidden", event->window.windowID);
|
||||||
event->window.windowID, event->window.data1, event->window.data2);
|
break;
|
||||||
break;
|
case SDL_WINDOWEVENT_EXPOSED:
|
||||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " exposed", event->window.windowID);
|
||||||
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " changed size to %" SDL_PRIs32 "x%" SDL_PRIs32,
|
break;
|
||||||
event->window.windowID, event->window.data1, event->window.data2);
|
case SDL_WINDOWEVENT_MOVED:
|
||||||
break;
|
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " moved to %" SDL_PRIs32 ",%" SDL_PRIs32,
|
||||||
case SDL_WINDOWEVENT_MINIMIZED:
|
event->window.windowID, event->window.data1, event->window.data2);
|
||||||
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " minimized", event->window.windowID);
|
break;
|
||||||
break;
|
case SDL_WINDOWEVENT_RESIZED:
|
||||||
case SDL_WINDOWEVENT_MAXIMIZED:
|
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " resized to %" SDL_PRIs32 "x%" SDL_PRIs32,
|
||||||
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " maximized", event->window.windowID);
|
event->window.windowID, event->window.data1, event->window.data2);
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_RESTORED:
|
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||||
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " restored", event->window.windowID);
|
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " changed size to %" SDL_PRIs32 "x%" SDL_PRIs32,
|
||||||
break;
|
event->window.windowID, event->window.data1, event->window.data2);
|
||||||
case SDL_WINDOWEVENT_ENTER:
|
break;
|
||||||
SDL_Log("SDL EVENT: Mouse entered window %" SDL_PRIu32 "",
|
case SDL_WINDOWEVENT_MINIMIZED:
|
||||||
event->window.windowID);
|
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " minimized", event->window.windowID);
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_LEAVE:
|
case SDL_WINDOWEVENT_MAXIMIZED:
|
||||||
SDL_Log("SDL EVENT: Mouse left window %" SDL_PRIu32 "", event->window.windowID);
|
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " maximized", event->window.windowID);
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
case SDL_WINDOWEVENT_RESTORED:
|
||||||
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " gained keyboard focus",
|
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " restored", event->window.windowID);
|
||||||
event->window.windowID);
|
break;
|
||||||
break;
|
case SDL_WINDOWEVENT_ENTER:
|
||||||
case SDL_WINDOWEVENT_FOCUS_LOST:
|
SDL_Log("SDL EVENT: Mouse entered window %" SDL_PRIu32 "",
|
||||||
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " lost keyboard focus",
|
event->window.windowID);
|
||||||
event->window.windowID);
|
break;
|
||||||
break;
|
case SDL_WINDOWEVENT_LEAVE:
|
||||||
case SDL_WINDOWEVENT_CLOSE:
|
SDL_Log("SDL EVENT: Mouse left window %" SDL_PRIu32 "", event->window.windowID);
|
||||||
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " closed", event->window.windowID);
|
break;
|
||||||
break;
|
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||||
case SDL_WINDOWEVENT_TAKE_FOCUS:
|
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " gained keyboard focus",
|
||||||
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " take focus", event->window.windowID);
|
event->window.windowID);
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_HIT_TEST:
|
case SDL_WINDOWEVENT_FOCUS_LOST:
|
||||||
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " hit test", event->window.windowID);
|
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " lost keyboard focus",
|
||||||
break;
|
event->window.windowID);
|
||||||
case SDL_WINDOWEVENT_ICCPROF_CHANGED:
|
break;
|
||||||
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " ICC profile changed", event->window.windowID);
|
case SDL_WINDOWEVENT_CLOSE:
|
||||||
break;
|
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " closed", event->window.windowID);
|
||||||
case SDL_WINDOWEVENT_DISPLAY_CHANGED:
|
break;
|
||||||
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " display changed to %" SDL_PRIs32 "", event->window.windowID, event->window.data1);
|
case SDL_WINDOWEVENT_TAKE_FOCUS:
|
||||||
break;
|
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " take focus", event->window.windowID);
|
||||||
default:
|
break;
|
||||||
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " got unknown event 0x%4.4x",
|
case SDL_WINDOWEVENT_HIT_TEST:
|
||||||
event->window.windowID, event->window.event);
|
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " hit test", event->window.windowID);
|
||||||
break;
|
break;
|
||||||
}
|
case SDL_WINDOWEVENT_ICCPROF_CHANGED:
|
||||||
|
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " ICC profile changed", event->window.windowID);
|
||||||
|
break;
|
||||||
|
case SDL_WINDOWEVENT_DISPLAY_CHANGED:
|
||||||
|
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " display changed to %" SDL_PRIs32 "", event->window.windowID, event->window.data1);
|
||||||
break;
|
break;
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
SDL_Log("SDL EVENT: Keyboard: key pressed in window %" SDL_PRIu32 ": scancode 0x%08X = %s, keycode 0x%08" SDL_PRIX32 " = %s",
|
SDL_Log("SDL EVENT: Keyboard: key pressed in window %" SDL_PRIu32 ": scancode 0x%08X = %s, keycode 0x%08" SDL_PRIX32 " = %s",
|
||||||
|
@ -1782,39 +1766,33 @@ void SDLTest_CommonEvent(SDLTest_CommonState *state, SDL_Event *event, int *done
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (event->type) {
|
switch (event->type) {
|
||||||
case SDL_WINDOWEVENT:
|
case SDL_WINDOWEVENT_CLOSE:
|
||||||
switch (event->window.event) {
|
{
|
||||||
case SDL_WINDOWEVENT_CLOSE:
|
SDL_Window *window = SDL_GetWindowFromID(event->window.windowID);
|
||||||
{
|
if (window) {
|
||||||
|
for (i = 0; i < state->num_windows; ++i) {
|
||||||
|
if (window == state->windows[i]) {
|
||||||
|
if (state->targets[i]) {
|
||||||
|
SDL_DestroyTexture(state->targets[i]);
|
||||||
|
state->targets[i] = NULL;
|
||||||
|
}
|
||||||
|
if (state->renderers[i]) {
|
||||||
|
SDL_DestroyRenderer(state->renderers[i]);
|
||||||
|
state->renderers[i] = NULL;
|
||||||
|
}
|
||||||
|
SDL_DestroyWindow(state->windows[i]);
|
||||||
|
state->windows[i] = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case SDL_WINDOWEVENT_FOCUS_LOST:
|
||||||
|
if (state->flash_on_focus_loss) {
|
||||||
SDL_Window *window = SDL_GetWindowFromID(event->window.windowID);
|
SDL_Window *window = SDL_GetWindowFromID(event->window.windowID);
|
||||||
if (window) {
|
if (window) {
|
||||||
for (i = 0; i < state->num_windows; ++i) {
|
SDL_FlashWindow(window, SDL_FLASH_UNTIL_FOCUSED);
|
||||||
if (window == state->windows[i]) {
|
|
||||||
if (state->targets[i]) {
|
|
||||||
SDL_DestroyTexture(state->targets[i]);
|
|
||||||
state->targets[i] = NULL;
|
|
||||||
}
|
|
||||||
if (state->renderers[i]) {
|
|
||||||
SDL_DestroyRenderer(state->renderers[i]);
|
|
||||||
state->renderers[i] = NULL;
|
|
||||||
}
|
|
||||||
SDL_DestroyWindow(state->windows[i]);
|
|
||||||
state->windows[i] = NULL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} break;
|
|
||||||
case SDL_WINDOWEVENT_FOCUS_LOST:
|
|
||||||
if (state->flash_on_focus_loss) {
|
|
||||||
SDL_Window *window = SDL_GetWindowFromID(event->window.windowID);
|
|
||||||
if (window) {
|
|
||||||
SDL_FlashWindow(window, SDL_FLASH_UNTIL_FOCUSED);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
|
|
|
@ -42,7 +42,7 @@ static int SDLCALL SDL_MetalViewEventWatch(void *userdata, SDL_Event *event)
|
||||||
* events don't always happen in the same frame (for example when a
|
* events don't always happen in the same frame (for example when a
|
||||||
* resizable window exits a fullscreen Space via the user pressing the OS
|
* resizable window exits a fullscreen Space via the user pressing the OS
|
||||||
* exit-space button). */
|
* exit-space button). */
|
||||||
if (event->type == SDL_WINDOWEVENT && event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
|
if (event->type == SDL_WINDOWEVENT_SIZE_CHANGED) {
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
SDL_cocoametalview *view = (__bridge SDL_cocoametalview *)userdata;
|
SDL_cocoametalview *view = (__bridge SDL_cocoametalview *)userdata;
|
||||||
if (view.sdlWindowID == event->window.windowID) {
|
if (view.sdlWindowID == event->window.windowID) {
|
||||||
|
|
|
@ -701,7 +701,7 @@ static EM_BOOL Emscripten_HandleMouseFocus(int eventType, const EmscriptenMouseE
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_SetMouseFocus(eventType == EMSCRIPTEN_EVENT_MOUSEENTER ? window_data->window : NULL);
|
SDL_SetMouseFocus(eventType == EMSCRIPTEN_EVENT_MOUSEENTER ? window_data->window : NULL);
|
||||||
return SDL_GetEventState(SDL_WINDOWEVENT) == SDL_ENABLE;
|
return SDL_GetEventState(SDL_MOUSEMOTION) == SDL_ENABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static EM_BOOL Emscripten_HandleWheel(int eventType, const EmscriptenWheelEvent *wheelEvent, void *userData)
|
static EM_BOOL Emscripten_HandleWheel(int eventType, const EmscriptenWheelEvent *wheelEvent, void *userData)
|
||||||
|
@ -729,14 +729,17 @@ static EM_BOOL Emscripten_HandleWheel(int eventType, const EmscriptenWheelEvent
|
||||||
static EM_BOOL Emscripten_HandleFocus(int eventType, const EmscriptenFocusEvent *wheelEvent, void *userData)
|
static EM_BOOL Emscripten_HandleFocus(int eventType, const EmscriptenFocusEvent *wheelEvent, void *userData)
|
||||||
{
|
{
|
||||||
SDL_WindowData *window_data = userData;
|
SDL_WindowData *window_data = userData;
|
||||||
|
SDL_EventType sdl_event_type;
|
||||||
|
|
||||||
/* If the user switches away while keys are pressed (such as
|
/* If the user switches away while keys are pressed (such as
|
||||||
* via Alt+Tab), key release events won't be received. */
|
* via Alt+Tab), key release events won't be received. */
|
||||||
if (eventType == EMSCRIPTEN_EVENT_BLUR) {
|
if (eventType == EMSCRIPTEN_EVENT_BLUR) {
|
||||||
SDL_ResetKeyboard();
|
SDL_ResetKeyboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_SendWindowEvent(window_data->window, eventType == EMSCRIPTEN_EVENT_FOCUS ? SDL_WINDOWEVENT_FOCUS_GAINED : SDL_WINDOWEVENT_FOCUS_LOST, 0, 0);
|
sdl_event_type = (eventType == EMSCRIPTEN_EVENT_FOCUS) ? SDL_WINDOWEVENT_FOCUS_GAINED : SDL_WINDOWEVENT_FOCUS_LOST;
|
||||||
return SDL_GetEventState(SDL_WINDOWEVENT) == SDL_ENABLE;
|
SDL_SendWindowEvent(window_data->window, sdl_event_type, 0, 0);
|
||||||
|
return SDL_GetEventState(sdl_event_type) == SDL_ENABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static EM_BOOL Emscripten_HandleTouch(int eventType, const EmscriptenTouchEvent *touchEvent, void *userData)
|
static EM_BOOL Emscripten_HandleTouch(int eventType, const EmscriptenTouchEvent *touchEvent, void *userData)
|
||||||
|
|
|
@ -56,7 +56,7 @@ void loop()
|
||||||
while (SDL_PollEvent(&e)) {
|
while (SDL_PollEvent(&e)) {
|
||||||
|
|
||||||
/* Re-create when window has been resized */
|
/* Re-create when window has been resized */
|
||||||
if ((e.type == SDL_WINDOWEVENT) && (e.window.event == SDL_WINDOWEVENT_SIZE_CHANGED)) {
|
if (e.type == SDL_WINDOWEVENT_SIZE_CHANGED) {
|
||||||
|
|
||||||
SDL_DestroyRenderer(renderer);
|
SDL_DestroyRenderer(renderer);
|
||||||
|
|
||||||
|
|
|
@ -283,26 +283,21 @@ int main(int argc, char *argv[])
|
||||||
/* Check for events */
|
/* Check for events */
|
||||||
++frames;
|
++frames;
|
||||||
while (SDL_PollEvent(&event)) {
|
while (SDL_PollEvent(&event)) {
|
||||||
switch (event.type) {
|
if (event.type == SDL_WINDOWEVENT_RESIZED) {
|
||||||
case SDL_WINDOWEVENT:
|
for (i = 0; i < state->num_windows; ++i) {
|
||||||
switch (event.window.event) {
|
if (event.window.windowID == SDL_GetWindowID(state->windows[i])) {
|
||||||
case SDL_WINDOWEVENT_RESIZED:
|
status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
|
||||||
for (i = 0; i < state->num_windows; ++i) {
|
if (status) {
|
||||||
if (event.window.windowID == SDL_GetWindowID(state->windows[i])) {
|
SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
|
||||||
status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
|
|
||||||
if (status) {
|
|
||||||
SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
/* Change view port to the new window dimensions */
|
|
||||||
glViewport(0, 0, event.window.data1, event.window.data2);
|
|
||||||
/* Update window content */
|
|
||||||
Render();
|
|
||||||
SDL_GL_SwapWindow(state->windows[i]);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
/* Change view port to the new window dimensions */
|
||||||
|
glViewport(0, 0, event.window.data1, event.window.data2);
|
||||||
|
/* Update window content */
|
||||||
|
Render();
|
||||||
|
SDL_GL_SwapWindow(state->windows[i]);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SDLTest_CommonEvent(state, &event, &done);
|
SDLTest_CommonEvent(state, &event, &done);
|
||||||
|
|
|
@ -567,7 +567,7 @@ loop_threaded()
|
||||||
|
|
||||||
/* Wait for events */
|
/* Wait for events */
|
||||||
while (SDL_WaitEvent(&event) && !done) {
|
while (SDL_WaitEvent(&event) && !done) {
|
||||||
if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE) {
|
if (event.type == SDL_WINDOWEVENT_CLOSE) {
|
||||||
SDL_Window *window = SDL_GetWindowFromID(event.window.windowID);
|
SDL_Window *window = SDL_GetWindowFromID(event.window.windowID);
|
||||||
if (window) {
|
if (window) {
|
||||||
for (i = 0; i < state->num_windows; ++i) {
|
for (i = 0; i < state->num_windows; ++i) {
|
||||||
|
|
|
@ -355,30 +355,30 @@ void loop()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SDL_WINDOWEVENT:
|
case SDL_WINDOWEVENT_RESIZED:
|
||||||
switch (event.window.event) {
|
for (i = 0; i < state->num_windows; ++i) {
|
||||||
case SDL_WINDOWEVENT_RESIZED:
|
if (event.window.windowID == SDL_GetWindowID(state->windows[i])) {
|
||||||
for (i = 0; i < state->num_windows; ++i) {
|
int w, h;
|
||||||
if (event.window.windowID == SDL_GetWindowID(state->windows[i])) {
|
status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
|
||||||
int w, h;
|
if (status) {
|
||||||
status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
|
SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
|
||||||
if (status) {
|
|
||||||
SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
/* Change view port to the new window dimensions */
|
|
||||||
SDL_GL_GetDrawableSize(state->windows[i], &w, &h);
|
|
||||||
ctx.glViewport(0, 0, w, h);
|
|
||||||
state->window_w = event.window.data1;
|
|
||||||
state->window_h = event.window.data2;
|
|
||||||
/* Update window content */
|
|
||||||
Render(event.window.data1, event.window.data2, &datas[i]);
|
|
||||||
SDL_GL_SwapWindow(state->windows[i]);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
/* Change view port to the new window dimensions */
|
||||||
|
SDL_GL_GetDrawableSize(state->windows[i], &w, &h);
|
||||||
|
ctx.glViewport(0, 0, w, h);
|
||||||
|
state->window_w = event.window.data1;
|
||||||
|
state->window_h = event.window.data2;
|
||||||
|
/* Update window content */
|
||||||
|
Render(event.window.data1, event.window.data2, &datas[i]);
|
||||||
|
SDL_GL_SwapWindow(state->windows[i]);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
SDLTest_CommonEvent(state, &event, &done);
|
SDLTest_CommonEvent(state, &event, &done);
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,10 +107,8 @@ int main(int argc, char **argv)
|
||||||
SDL_Log("button up!\n");
|
SDL_Log("button up!\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_WINDOWEVENT:
|
case SDL_WINDOWEVENT_MOVED:
|
||||||
if (e.window.event == SDL_WINDOWEVENT_MOVED) {
|
SDL_Log("Window event moved to (%d, %d)!\n", (int)e.window.data1, (int)e.window.data2);
|
||||||
SDL_Log("Window event moved to (%d, %d)!\n", (int)e.window.data1, (int)e.window.data2);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
|
|
|
@ -180,13 +180,9 @@ int main(int argc, char *argv[])
|
||||||
/* Check for events */
|
/* Check for events */
|
||||||
while (SDL_PollEvent(&event)) {
|
while (SDL_PollEvent(&event)) {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case SDL_WINDOWEVENT:
|
case SDL_WINDOWEVENT_EXPOSED:
|
||||||
switch (event.window.event) {
|
SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
|
||||||
case SDL_WINDOWEVENT_EXPOSED:
|
SDL_RenderClear(renderer);
|
||||||
SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
|
|
||||||
SDL_RenderClear(renderer);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
done = 1;
|
done = 1;
|
||||||
|
|
|
@ -229,12 +229,10 @@ void loop()
|
||||||
SDLTest_CommonEvent(state, &event, &done);
|
SDLTest_CommonEvent(state, &event, &done);
|
||||||
|
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case SDL_WINDOWEVENT:
|
case SDL_WINDOWEVENT_RESIZED:
|
||||||
if (event.window.event == SDL_WINDOWEVENT_RESIZED) {
|
SDL_RenderSetViewport(renderer, NULL);
|
||||||
SDL_RenderSetViewport(renderer, NULL);
|
displayrect.w = window_w = event.window.data1;
|
||||||
displayrect.w = window_w = event.window.data1;
|
displayrect.h = window_h = event.window.data2;
|
||||||
displayrect.h = window_h = event.window.data2;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
displayrect.x = event.button.x - window_w / 2;
|
displayrect.x = event.button.x - window_w / 2;
|
||||||
|
|
|
@ -151,36 +151,34 @@ void loop()
|
||||||
while (SDL_PollEvent(&event)) {
|
while (SDL_PollEvent(&event)) {
|
||||||
SDLTest_CommonEvent(state, &event, &done);
|
SDLTest_CommonEvent(state, &event, &done);
|
||||||
|
|
||||||
if (event.type == SDL_WINDOWEVENT) {
|
if (event.type == SDL_WINDOWEVENT_RESIZED) {
|
||||||
if (event.window.event == SDL_WINDOWEVENT_RESIZED) {
|
SDL_Window *window = SDL_GetWindowFromID(event.window.windowID);
|
||||||
SDL_Window *window = SDL_GetWindowFromID(event.window.windowID);
|
if (window) {
|
||||||
if (window) {
|
SDL_Log("Window %" SDL_PRIu32 " resized to %" SDL_PRIs32 "x%" SDL_PRIs32 "\n",
|
||||||
SDL_Log("Window %" SDL_PRIu32 " resized to %" SDL_PRIs32 "x%" SDL_PRIs32 "\n",
|
event.window.windowID,
|
||||||
event.window.windowID,
|
event.window.data1,
|
||||||
event.window.data1,
|
event.window.data2);
|
||||||
event.window.data2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (event.window.event == SDL_WINDOWEVENT_MOVED) {
|
}
|
||||||
SDL_Window *window = SDL_GetWindowFromID(event.window.windowID);
|
if (event.type == SDL_WINDOWEVENT_MOVED) {
|
||||||
if (window) {
|
SDL_Window *window = SDL_GetWindowFromID(event.window.windowID);
|
||||||
SDL_Log("Window %" SDL_PRIu32 " moved to %" SDL_PRIs32 ",%" SDL_PRIs32 " (display %s)\n",
|
if (window) {
|
||||||
event.window.windowID,
|
SDL_Log("Window %" SDL_PRIu32 " moved to %" SDL_PRIs32 ",%" SDL_PRIs32 " (display %s)\n",
|
||||||
event.window.data1,
|
event.window.windowID,
|
||||||
event.window.data2,
|
event.window.data1,
|
||||||
SDL_GetDisplayName(SDL_GetWindowDisplayIndex(window)));
|
event.window.data2,
|
||||||
}
|
SDL_GetDisplayName(SDL_GetWindowDisplayIndex(window)));
|
||||||
}
|
}
|
||||||
if (event.window.event == SDL_WINDOWEVENT_FOCUS_LOST) {
|
}
|
||||||
relative_mode = SDL_GetRelativeMouseMode();
|
if (event.type == SDL_WINDOWEVENT_FOCUS_LOST) {
|
||||||
if (relative_mode) {
|
relative_mode = SDL_GetRelativeMouseMode();
|
||||||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
if (relative_mode) {
|
||||||
}
|
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||||
}
|
}
|
||||||
if (event.window.event == SDL_WINDOWEVENT_FOCUS_GAINED) {
|
}
|
||||||
if (relative_mode) {
|
if (event.type == SDL_WINDOWEVENT_FOCUS_GAINED) {
|
||||||
SDL_SetRelativeMouseMode(SDL_TRUE);
|
if (relative_mode) {
|
||||||
}
|
SDL_SetRelativeMouseMode(SDL_TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (event.type == SDL_KEYUP) {
|
if (event.type == SDL_KEYUP) {
|
||||||
|
|
Loading…
Reference in New Issue