SDL_WindowEvent
A structure that contains window state change event data.
Data Fields
Uint32 |
type |
SDL_WINDOWEVENT |
Uint32 |
timestamp |
timestamp of the event |
Uint32 |
windowID |
the associated window |
Uint8 |
event |
|
Sint32 |
data1 |
event dependent data |
Sint32 |
data2 |
event dependent data |
Code Examples
void PrintEvent(const SDL_Event * event)
{
if (event->type == SDL_WINDOWEVENT) {
switch (event->window.event) {
case SDL_WINDOWEVENT_SHOWN:
SDL_Log("Window %d shown", event->window.windowID);
break;
case SDL_WINDOWEVENT_HIDDEN:
SDL_Log("Window %d hidden", event->window.windowID);
break;
case SDL_WINDOWEVENT_EXPOSED:
SDL_Log("Window %d exposed", event->window.windowID);
break;
case SDL_WINDOWEVENT_MOVED:
SDL_Log("Window %d moved to %d,%d",
event->window.windowID, event->window.data1,
event->window.data2);
break;
case SDL_WINDOWEVENT_RESIZED:
SDL_Log("Window %d resized to %dx%d",
event->window.windowID, event->window.data1,
event->window.data2);
break;
case SDL_WINDOWEVENT_SIZE_CHANGED:
SDL_Log("Window %d size changed to %dx%d",
event->window.windowID, event->window.data1,
event->window.data2);
break;
case SDL_WINDOWEVENT_MINIMIZED:
SDL_Log("Window %d minimized", event->window.windowID);
break;
case SDL_WINDOWEVENT_MAXIMIZED:
SDL_Log("Window %d maximized", event->window.windowID);
break;
case SDL_WINDOWEVENT_RESTORED:
SDL_Log("Window %d restored", event->window.windowID);
break;
case SDL_WINDOWEVENT_ENTER:
SDL_Log("Mouse entered window %d",
event->window.windowID);
break;
case SDL_WINDOWEVENT_LEAVE:
SDL_Log("Mouse left window %d", event->window.windowID);
break;
case SDL_WINDOWEVENT_FOCUS_GAINED:
SDL_Log("Window %d gained keyboard focus",
event->window.windowID);
break;
case SDL_WINDOWEVENT_FOCUS_LOST:
SDL_Log("Window %d lost keyboard focus",
event->window.windowID);
break;
case SDL_WINDOWEVENT_CLOSE:
SDL_Log("Window %d closed", event->window.windowID);
break;
#if SDL_VERSION_ATLEAST(2, 0, 5)
case SDL_WINDOWEVENT_TAKE_FOCUS:
SDL_Log("Window %d is offered a focus", event->window.windowID);
break;
case SDL_WINDOWEVENT_HIT_TEST:
SDL_Log("Window %d has a special hit test", event->window.windowID);
break;
#endif
default:
SDL_Log("Window %d got unknown event %d",
event->window.windowID, event->window.event);
break;
}
}
}
Remarks
SDL_WindowEvent is a member of the SDL_Event union and is used when an event of type SDL_WINDOWEVENT is reported. You would access it through the event's window field.
Related Enumerations
Related Structures
CategoryStruct, CategoryEvents, CategoryVideo