SDL_windowevents_c.h File Reference
`#include "../SDL_internal.h"`
Include dependency graph for SDL_windowevents_c.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Functions

int | SDL_SendWindowEvent (SDL_Window *window, Uint8 windowevent, int data1, int data2)

## Function Documentation

## SDL_SendWindowEvent()

int SDL_SendWindowEvent | ( | SDL_Window * | window,
|  | Uint8 | windowevent,
|  | int | data1,
|  | int | data2
| ) |  |

Definition at line 88 of file SDL_windowevents.c.

References SDL_Window::flags, SDL_Rect::h, SDL_Window::h, SDL_Window::id, SDL_Window::next, SDL_Window::prev, RemovePendingExposedEvents(), RemovePendingMoveEvents(), RemovePendingResizedEvents(), RemovePendingSizeChangedEvents(), SDL_ENABLE, SDL_FilterEvents, SDL_GetEventState, SDL_OnWindowEnter(), SDL_OnWindowFocusGained(), SDL_OnWindowFocusLost(), SDL_OnWindowHidden(), SDL_OnWindowLeave(), SDL_OnWindowMinimized(), SDL_OnWindowResized(), SDL_OnWindowRestored(), SDL_OnWindowShown(), SDL_PushEvent, SDL_SendQuit(), SDL_WINDOW_FULLSCREEN, SDL_WINDOW_HIDDEN, SDL_WINDOW_INPUT_FOCUS, SDL_WINDOW_MAXIMIZED, SDL_WINDOW_MINIMIZED, SDL_WINDOW_MOUSE_FOCUS, SDL_WINDOW_SHOWN, SDL_WINDOWEVENT, SDL_WINDOWEVENT_CLOSE, SDL_WINDOWEVENT_ENTER, SDL_WINDOWEVENT_EXPOSED, SDL_WINDOWEVENT_FOCUS_GAINED, SDL_WINDOWEVENT_FOCUS_LOST, SDL_WINDOWEVENT_HIDDEN, SDL_WINDOWEVENT_LEAVE, SDL_WINDOWEVENT_MAXIMIZED, SDL_WINDOWEVENT_MINIMIZED, SDL_WINDOWEVENT_MOVED, SDL_WINDOWEVENT_RESIZED, SDL_WINDOWEVENT_RESTORED, SDL_WINDOWEVENT_SHOWN, SDL_WINDOWEVENT_SIZE_CHANGED, SDL_WINDOWPOS_ISUNDEFINED, SDL_Rect::w, SDL_Window::w, SDL_Window::windowed, SDL_Rect::x, SDL_Window::x, SDL_Rect::y, and SDL_Window::y.

Referenced by SDL_BApp::_HandleBasicWindowEvent(), SDL_BApp::_HandleWindowMoved(), SDL_BApp::_HandleWindowResized(), IsSDLWindowEventPending(), SDL_HideWindow(), SDL_OnApplicationDidBecomeActive(), SDL_OnApplicationWillResignActive(), SDL_OnWindowResized(), SDL_SetKeyboardFocus(), SDL_SetMouseFocus(), SDL_SetWindowPosition(), SDL_ShowWindow(), SDL_UpdateFullscreenMode(), and WINRT_ProcessWindowSizeChange().

{
int posted;
if (!window) {
return 0;
}
switch (windowevent) {
case SDL_WINDOWEVENT_SHOWN:
if (window->flags & SDL_WINDOW_SHOWN) {
return 0;
}
window->flags &= ~SDL_WINDOW_HIDDEN;
window->flags |= SDL_WINDOW_SHOWN;
SDL_OnWindowShown(window);
break;
case SDL_WINDOWEVENT_HIDDEN:
if (!(window->flags & SDL_WINDOW_SHOWN)) {
return 0;
}
window->flags &= ~SDL_WINDOW_SHOWN;
window->flags |= SDL_WINDOW_HIDDEN;
SDL_OnWindowHidden(window);
break;
case SDL_WINDOWEVENT_MOVED:
if (SDL_WINDOWPOS_ISUNDEFINED(data1) ||
SDL_WINDOWPOS_ISUNDEFINED(data2)) {
return 0;
}
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
window->windowed.x = data1;
window->windowed.y = data2;
}
if (data1 == window->x && data2 == window->y) {
return 0;
}
window->x = data1;
window->y = data2;
break;
case SDL_WINDOWEVENT_RESIZED:
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
window->windowed.w = data1;
window->windowed.h = data2;
}
if (data1 == window->w && data2 == window->h) {
return 0;
}
window->w = data1;
window->h = data2;
SDL_OnWindowResized(window);
break;
case SDL_WINDOWEVENT_MINIMIZED:
if (window->flags & SDL_WINDOW_MINIMIZED) {
return 0;
}
window->flags &= ~SDL_WINDOW_MAXIMIZED;
window->flags |= SDL_WINDOW_MINIMIZED;
SDL_OnWindowMinimized(window);
break;
case SDL_WINDOWEVENT_MAXIMIZED:
if (window->flags & SDL_WINDOW_MAXIMIZED) {
return 0;
}
window->flags &= ~SDL_WINDOW_MINIMIZED;
window->flags |= SDL_WINDOW_MAXIMIZED;
break;
case SDL_WINDOWEVENT_RESTORED:
if (!(window->flags & (SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED))) {
return 0;
}
window->flags &= ~(SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED);
SDL_OnWindowRestored(window);
break;
case SDL_WINDOWEVENT_ENTER:
if (window->flags & SDL_WINDOW_MOUSE_FOCUS) {
return 0;
}
window->flags |= SDL_WINDOW_MOUSE_FOCUS;
SDL_OnWindowEnter(window);
break;
case SDL_WINDOWEVENT_LEAVE:
if (!(window->flags & SDL_WINDOW_MOUSE_FOCUS)) {
return 0;
}
window->flags &= ~SDL_WINDOW_MOUSE_FOCUS;
SDL_OnWindowLeave(window);
break;
case SDL_WINDOWEVENT_FOCUS_GAINED:
if (window->flags & SDL_WINDOW_INPUT_FOCUS) {
return 0;
}
window->flags |= SDL_WINDOW_INPUT_FOCUS;
SDL_OnWindowFocusGained(window);
break;
case SDL_WINDOWEVENT_FOCUS_LOST:
if (!(window->flags & SDL_WINDOW_INPUT_FOCUS)) {
return 0;
}
window->flags &= ~SDL_WINDOW_INPUT_FOCUS;
SDL_OnWindowFocusLost(window);
break;
}
/* Post the event, if desired */
posted = 0;
if (SDL_GetEventState(SDL_WINDOWEVENT) == SDL_ENABLE) {
SDL_Event event;
event.type = SDL_WINDOWEVENT;
event.window.event = windowevent;
event.window.data1 = data1;
event.window.data2 = data2;
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);
}
if (windowevent == SDL_WINDOWEVENT_MOVED) {
SDL_FilterEvents(RemovePendingMoveEvents, &event);
}
if (windowevent == SDL_WINDOWEVENT_EXPOSED) {
SDL_FilterEvents(RemovePendingExposedEvents, &event);
}
posted = (SDL_PushEvent(&event) > 0);
}
if (windowevent == SDL_WINDOWEVENT_CLOSE) {
if ( !window->prev && !window->next ) {
/* This is the last window in the list so send the SDL_QUIT event */
SDL_SendQuit();
}
}
return (posted);
}
SDL_WINDOWPOS_ISUNDEFINED
#define SDL_WINDOWPOS_ISUNDEFINED(X)
Definition: SDL_video.h:131
SDL_Window::next
SDL_Window * next
Definition: SDL_sysvideo.h:114
SDL_WINDOWEVENT_MINIMIZED
Definition: SDL_video.h:159
SDL_WINDOW_MOUSE_FOCUS
Definition: SDL_video.h:110
SDL_Window::w
int w
Definition: SDL_sysvideo.h:80
SDL_Window::x
int x
Definition: SDL_sysvideo.h:79
RemovePendingExposedEvents
static int RemovePendingExposedEvents(void *userdata, SDL_Event *event)
Definition: SDL_windowevents.c:74
SDL_OnWindowResized
void SDL_OnWindowResized(SDL_Window *window)
Definition: SDL_video.c:2501
SDL_ENABLE
#define SDL_ENABLE
Definition: SDL_events.h:722
SDL_WINDOWEVENT_MAXIMIZED
Definition: SDL_video.h:160
SDL_OnWindowEnter
void SDL_OnWindowEnter(SDL_Window *window)
Definition: SDL_video.c:2530
SDL_WINDOWEVENT_SIZE_CHANGED
Definition: SDL_video.h:156
SDL_WINDOW_HIDDEN
Definition: SDL_video.h:103
SDL_Window::windowed
SDL_Rect windowed
Definition: SDL_sysvideo.h:87
RemovePendingSizeChangedEvents
static int RemovePendingSizeChangedEvents(void *userdata, SDL_Event *event)
Definition: SDL_windowevents.c:46
RemovePendingResizedEvents
static int RemovePendingResizedEvents(void *userdata, SDL_Event *event)
Definition: SDL_windowevents.c:32
SDL_WINDOWEVENT_HIDDEN
Definition: SDL_video.h:150
SDL_WINDOW_SHOWN
Definition: SDL_video.h:102
SDL_OnWindowHidden
void SDL_OnWindowHidden(SDL_Window *window)
Definition: SDL_video.c:2495
SDL_WINDOWEVENT_FOCUS_GAINED
Definition: SDL_video.h:165
SDL_OnWindowMinimized
void SDL_OnWindowMinimized(SDL_Window *window)
Definition: SDL_video.c:2508
SDL_GetEventState
#define SDL_GetEventState(type)
Definition: SDL_events.h:735
SDL_WINDOWEVENT_RESTORED
Definition: SDL_video.h:161
event
struct _cl_event * event
Definition: SDL_opengl_glext.h:2649
SDL_PushEvent
#define SDL_PushEvent
Definition: SDL_dynapi_overrides.h:125
SDL_WINDOWEVENT_FOCUS_LOST
Definition: SDL_video.h:166
SDL_WINDOWEVENT
Definition: SDL_events.h:89
SDL_OnWindowLeave
void SDL_OnWindowLeave(SDL_Window *window)
Definition: SDL_video.c:2538
SDL_WINDOW_MINIMIZED
Definition: SDL_video.h:106
SDL_Window::y
int y
Definition: SDL_sysvideo.h:79
SDL_Rect::x
int x
Definition: SDL_rect.h:66
SDL_WINDOWEVENT_LEAVE
Definition: SDL_video.h:164
SDL_Rect::w
int w
Definition: SDL_rect.h:67
SDL_WINDOWEVENT_CLOSE
Definition: SDL_video.h:167
SDL_Window::h
int h
Definition: SDL_sysvideo.h:80
SDL_WINDOW_INPUT_FOCUS
Definition: SDL_video.h:109
SDL_WINDOWEVENT_SHOWN
Definition: SDL_video.h:149
SDL_Window::prev
SDL_Window * prev
Definition: SDL_sysvideo.h:113
SDL_Rect::h
int h
Definition: SDL_rect.h:67
SDL_WINDOW_MAXIMIZED
Definition: SDL_video.h:107
SDL_Window::id
Uint32 id
Definition: SDL_sysvideo.h:76
SDL_FilterEvents
#define SDL_FilterEvents
Definition: SDL_dynapi_overrides.h:130
SDL_WINDOW_FULLSCREEN
Definition: SDL_video.h:100
SDL_WINDOWEVENT_ENTER
Definition: SDL_video.h:163
SDL_OnWindowFocusLost
void SDL_OnWindowFocusLost(SDL_Window *window)
Definition: SDL_video.c:2578
SDL_WINDOWEVENT_EXPOSED
Definition: SDL_video.h:151
SDL_OnWindowRestored
void SDL_OnWindowRestored(SDL_Window *window)
Definition: SDL_video.c:2514
SDL_Event
General event structure.
Definition: SDL_events.h:525
SDL_OnWindowShown
void SDL_OnWindowShown(SDL_Window *window)
Definition: SDL_video.c:2489
SDL_WINDOWEVENT_RESIZED
Definition: SDL_video.h:155
SDL_Window::flags
Uint32 flags
Definition: SDL_sysvideo.h:83
SDL_WINDOWEVENT_MOVED
Definition: SDL_video.h:153
SDL_Rect::y
int y
Definition: SDL_rect.h:66
RemovePendingMoveEvents
static int RemovePendingMoveEvents(void *userdata, SDL_Event *event)
Definition: SDL_windowevents.c:60
SDL_SendQuit
int SDL_SendQuit(void)
Definition: SDL_quit.c:137
SDL_OnWindowFocusGained
void SDL_OnWindowFocusGained(SDL_Window *window)
Definition: SDL_video.c:2543