SDL  2.0
SDL_sysvideo.h File Reference
#include "../SDL_internal.h"
#include "SDL_messagebox.h"
#include "SDL_shape.h"
#include "SDL_thread.h"
#include "SDL_vulkan_internal.h"
+ Include dependency graph for SDL_sysvideo.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SDL_WindowShaper
struct  SDL_ShapeDriver
struct  SDL_WindowUserData
struct  SDL_Window
 The type used to identify a window. More...
struct  SDL_VideoDisplay
struct  SDL_VideoDevice
struct  VideoBootStrap

Macros

#define FULLSCREEN_VISIBLE(W)
#define _THIS   SDL_VideoDevice *_this

Functions

SDL_VideoDeviceSDL_GetVideoDevice (void)
int SDL_AddBasicVideoDisplay (const SDL_DisplayMode *desktop_mode)
int SDL_AddVideoDisplay (const SDL_VideoDisplay *display)
SDL_bool SDL_AddDisplayMode (SDL_VideoDisplay *display, const SDL_DisplayMode *mode)
int SDL_GetIndexOfDisplay (SDL_VideoDisplay *display)
SDL_VideoDisplaySDL_GetDisplay (int displayIndex)
SDL_VideoDisplaySDL_GetDisplayForWindow (SDL_Window *window)
voidSDL_GetDisplayDriverData (int displayIndex)
void SDL_GL_DeduceMaxSupportedESProfile (int *major, int *minor)
int SDL_RecreateWindow (SDL_Window *window, Uint32 flags)
SDL_bool SDL_HasWindows (void)
void SDL_OnWindowShown (SDL_Window *window)
void SDL_OnWindowHidden (SDL_Window *window)
void SDL_OnWindowResized (SDL_Window *window)
void SDL_OnWindowMinimized (SDL_Window *window)
void SDL_OnWindowRestored (SDL_Window *window)
void SDL_OnWindowEnter (SDL_Window *window)
void SDL_OnWindowLeave (SDL_Window *window)
void SDL_OnWindowFocusGained (SDL_Window *window)
void SDL_OnWindowFocusLost (SDL_Window *window)
void SDL_UpdateWindowGrab (SDL_Window *window)
SDL_WindowSDL_GetFocusWindow (void)
SDL_bool SDL_ShouldAllowTopmost (void)
float SDL_ComputeDiagonalDPI (int hpix, int vpix, float hinches, float vinches)
void SDL_OnApplicationWillTerminate (void)
void SDL_OnApplicationDidReceiveMemoryWarning (void)
void SDL_OnApplicationWillResignActive (void)
void SDL_OnApplicationDidEnterBackground (void)
void SDL_OnApplicationWillEnterForeground (void)
void SDL_OnApplicationDidBecomeActive (void)
void SDL_ToggleDragAndDropSupport (void)

Variables

VideoBootStrap COCOA_bootstrap
VideoBootStrap X11_bootstrap
VideoBootStrap MIR_bootstrap
VideoBootStrap DirectFB_bootstrap
VideoBootStrap WINDOWS_bootstrap
VideoBootStrap WINRT_bootstrap
VideoBootStrap HAIKU_bootstrap
VideoBootStrap PND_bootstrap
VideoBootStrap UIKIT_bootstrap
VideoBootStrap Android_bootstrap
VideoBootStrap PSP_bootstrap
VideoBootStrap RPI_bootstrap
VideoBootStrap KMSDRM_bootstrap
VideoBootStrap DUMMY_bootstrap
VideoBootStrap Wayland_bootstrap
VideoBootStrap NACL_bootstrap
VideoBootStrap VIVANTE_bootstrap
VideoBootStrap Emscripten_bootstrap
VideoBootStrap QNX_bootstrap

Macro Definition Documentation

#define _THIS   SDL_VideoDevice *_this

Definition at line 146 of file SDL_sysvideo.h.

Function Documentation

int SDL_AddBasicVideoDisplay ( const SDL_DisplayMode desktop_mode)

Definition at line 592 of file SDL_video.c.

References SDL_VideoDisplay::current_mode, SDL_VideoDisplay::desktop_mode, SDL_AddVideoDisplay(), and SDL_zero.

{
SDL_zero(display);
if (desktop_mode) {
display.desktop_mode = *desktop_mode;
}
display.current_mode = display.desktop_mode;
return SDL_AddVideoDisplay(&display);
}
SDL_bool SDL_AddDisplayMode ( SDL_VideoDisplay display,
const SDL_DisplayMode mode 
)

Definition at line 754 of file SDL_video.c.

References cmpmodes(), SDL_VideoDisplay::display_modes, i, SDL_VideoDisplay::max_display_modes, SDL_VideoDisplay::num_display_modes, SDL_FALSE, SDL_qsort, SDL_realloc, and SDL_TRUE.

{
int i, nmodes;
/* Make sure we don't already have the mode in the list */
modes = display->display_modes;
nmodes = display->num_display_modes;
for (i = 0; i < nmodes; ++i) {
if (cmpmodes(mode, &modes[i]) == 0) {
return SDL_FALSE;
}
}
/* Go ahead and add the new mode */
if (nmodes == display->max_display_modes) {
modes =
SDL_realloc(modes,
(display->max_display_modes + 32) * sizeof(*modes));
if (!modes) {
return SDL_FALSE;
}
display->display_modes = modes;
display->max_display_modes += 32;
}
modes[nmodes] = *mode;
display->num_display_modes++;
/* Re-sort video modes */
return SDL_TRUE;
}
int SDL_AddVideoDisplay ( const SDL_VideoDisplay display)

Definition at line 606 of file SDL_video.c.

References _this, SDL_VideoDisplay::device, SDL_VideoDevice::displays, SDL_VideoDisplay::name, SDL_VideoDevice::num_displays, SDL_itoa, SDL_OutOfMemory, SDL_realloc, and SDL_strdup.

Referenced by SDL_AddBasicVideoDisplay(), and videoInit().

{
SDL_VideoDisplay *displays;
int index = -1;
displays =
(_this->num_displays + 1) * sizeof(*displays));
if (displays) {
index = _this->num_displays++;
displays[index] = *display;
displays[index].device = _this;
_this->displays = displays;
if (display->name) {
displays[index].name = SDL_strdup(display->name);
} else {
char name[32];
SDL_itoa(index, name, 10);
displays[index].name = SDL_strdup(name);
}
} else {
}
return index;
}
float SDL_ComputeDiagonalDPI ( int  hpix,
int  vpix,
float  hinches,
float  vinches 
)

Definition at line 3990 of file SDL_video.c.

References SDL_sqrt.

{
float den2 = hinches * hinches + vinches * vinches;
if (den2 <= 0.0f) {
return 0.0f;
}
return (float)(SDL_sqrt((double)hpix * (double)hpix + (double)vpix * (double)vpix) /
SDL_sqrt((double)den2));
}
SDL_VideoDisplay* SDL_GetDisplay ( int  displayIndex)

Definition at line 1024 of file SDL_video.c.

References CHECK_DISPLAY_INDEX, SDL_VideoDevice::displays, and NULL.

{
CHECK_DISPLAY_INDEX(displayIndex, NULL);
return &_this->displays[displayIndex];
}
void* SDL_GetDisplayDriverData ( int  displayIndex)

Definition at line 660 of file SDL_video.c.

References CHECK_DISPLAY_INDEX, SDL_VideoDevice::displays, SDL_VideoDisplay::driverdata, and NULL.

{
CHECK_DISPLAY_INDEX(displayIndex, NULL);
return _this->displays[displayIndex].driverdata;
}
SDL_VideoDisplay* SDL_GetDisplayForWindow ( SDL_Window window)

Definition at line 1092 of file SDL_video.c.

References SDL_VideoDevice::displays, NULL, and SDL_GetWindowDisplayIndex.

Referenced by SDL_CreateWindow(), SDL_DestroyWindow(), SDL_GetWindowDisplayMode(), SDL_GetWindowPixelFormat(), SDL_SetWindowDisplayMode(), and SDL_UpdateFullscreenMode().

{
int displayIndex = SDL_GetWindowDisplayIndex(window);
if (displayIndex >= 0) {
return &_this->displays[displayIndex];
} else {
return NULL;
}
}
SDL_Window* SDL_GetFocusWindow ( void  )

Definition at line 2671 of file SDL_video.c.

References SDL_Window::flags, SDL_Window::next, NULL, SDL_WINDOW_INPUT_FOCUS, and SDL_VideoDevice::windows.

Referenced by SDL_PromptAssertion(), SDL_StartTextInput(), and SDL_StopTextInput().

{
if (!_this) {
return NULL;
}
for (window = _this->windows; window; window = window->next) {
if (window->flags & SDL_WINDOW_INPUT_FOCUS) {
return window;
}
}
return NULL;
}
int SDL_GetIndexOfDisplay ( SDL_VideoDisplay display)

Definition at line 645 of file SDL_video.c.

References SDL_VideoDevice::displays, and SDL_VideoDevice::num_displays.

Referenced by SDL_CreateWindow(), and SDL_SendDisplayEvent().

{
int displayIndex;
for (displayIndex = 0; displayIndex < _this->num_displays; ++displayIndex) {
if (display == &_this->displays[displayIndex]) {
return displayIndex;
}
}
/* Couldn't find the display, just use index 0 */
return 0;
}
void SDL_GL_DeduceMaxSupportedESProfile ( int *  major,
int *  minor 
)

Definition at line 3019 of file SDL_video.c.

References SDL_GL_ExtensionSupported.

{
/* THIS REQUIRES AN EXISTING GL CONTEXT THAT HAS BEEN MADE CURRENT. */
/* Please refer to https://bugzilla.libsdl.org/show_bug.cgi?id=3725 for discussion. */
#if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
/* XXX This is fragile; it will break in the event of release of
* new versions of OpenGL ES.
*/
if (SDL_GL_ExtensionSupported("GL_ARB_ES3_2_compatibility")) {
*major = 3;
*minor = 2;
} else if (SDL_GL_ExtensionSupported("GL_ARB_ES3_1_compatibility")) {
*major = 3;
*minor = 1;
} else if (SDL_GL_ExtensionSupported("GL_ARB_ES3_compatibility")) {
*major = 3;
*minor = 0;
} else {
*major = 2;
*minor = 0;
}
#endif
}
SDL_bool SDL_HasWindows ( void  )

Definition at line 1707 of file SDL_video.c.

References NULL, and SDL_VideoDevice::windows.

Referenced by SDL_PrivateJoystickShouldIgnoreEvent().

{
return (_this && _this->windows != NULL);
}
void SDL_OnApplicationDidEnterBackground ( void  )
void SDL_OnApplicationDidReceiveMemoryWarning ( void  )

Definition at line 4009 of file SDL_video.c.

References SDL_APP_LOWMEMORY, and SDL_SendAppEvent().

void SDL_OnApplicationWillEnterForeground ( void  )
void SDL_OnApplicationWillTerminate ( void  )

Definition at line 4004 of file SDL_video.c.

References SDL_APP_TERMINATING, and SDL_SendAppEvent().

void SDL_OnWindowEnter ( SDL_Window window)

Definition at line 2607 of file SDL_video.c.

References SDL_VideoDevice::OnWindowEnter.

Referenced by SDL_SendWindowEvent().

{
}
}
void SDL_OnWindowFocusGained ( SDL_Window window)
void SDL_OnWindowHidden ( SDL_Window window)

Definition at line 2572 of file SDL_video.c.

References SDL_FALSE, and SDL_UpdateFullscreenMode().

Referenced by SDL_SendWindowEvent().

void SDL_OnWindowLeave ( SDL_Window window)

Definition at line 2615 of file SDL_video.c.

Referenced by SDL_SendWindowEvent().

{
}
void SDL_OnWindowMinimized ( SDL_Window window)

Definition at line 2585 of file SDL_video.c.

References SDL_FALSE, and SDL_UpdateFullscreenMode().

Referenced by SDL_SendWindowEvent().

void SDL_OnWindowRestored ( SDL_Window window)

Definition at line 2591 of file SDL_video.c.

References FULLSCREEN_VISIBLE, SDL_TRUE, and SDL_UpdateFullscreenMode().

Referenced by SDL_OnWindowShown(), and SDL_SendWindowEvent().

{
/*
* FIXME: Is this fine to just remove this, or should it be preserved just
* for the fullscreen case? In principle it seems like just hiding/showing
* windows shouldn't affect the stacking order; maybe the right fix is to
* re-decouple OnWindowShown and OnWindowRestored.
*/
/*SDL_RaiseWindow(window);*/
if (FULLSCREEN_VISIBLE(window)) {
}
}
void SDL_OnWindowShown ( SDL_Window window)

Definition at line 2566 of file SDL_video.c.

References SDL_OnWindowRestored().

Referenced by SDL_SendWindowEvent().

{
}
int SDL_RecreateWindow ( SDL_Window window,
Uint32  flags 
)

Definition at line 1617 of file SDL_video.c.

References CREATE_FLAGS, SDL_VideoDevice::CreateSDLWindow, SDL_VideoDevice::DestroyWindow, SDL_VideoDevice::DestroyWindowFramebuffer, SDL_Surface::flags, SDL_Window::flags, SDL_VideoDevice::GL_CreateContext, SDL_Window::hit_test, SDL_Window::icon, SDL_Window::is_destroying, SDL_Window::last_fullscreen_flags, SDL_VideoDevice::name, NULL, SDL_DONTFREE, SDL_FALSE, SDL_FinishWindowCreation(), SDL_FreeSurface, SDL_GL_LoadLibrary, SDL_GL_UnloadLibrary, SDL_HideWindow, SDL_SetError, SDL_TRUE, SDL_WINDOW_FOREIGN, SDL_WINDOW_HIDDEN, SDL_WINDOW_OPENGL, SDL_WINDOW_VULKAN, SDL_VideoDevice::SetWindowHitTest, SDL_VideoDevice::SetWindowIcon, SDL_VideoDevice::SetWindowTitle, SDL_Window::surface, and SDL_Window::title.

{
SDL_bool loaded_opengl = SDL_FALSE;
return SDL_SetError("OpenGL support is either not configured in SDL "
"or not available in current SDL video driver "
"(%s) or platform", _this->name);
}
if (window->flags & SDL_WINDOW_FOREIGN) {
/* Can't destroy and re-create foreign windows, hrm */
} else {
}
/* Restore video mode, etc. */
SDL_HideWindow(window);
/* Tear down the old native window */
if (window->surface) {
window->surface->flags &= ~SDL_DONTFREE;
window->surface = NULL;
}
}
}
if ((window->flags & SDL_WINDOW_OPENGL) != (flags & SDL_WINDOW_OPENGL)) {
if (flags & SDL_WINDOW_OPENGL) {
return -1;
}
loaded_opengl = SDL_TRUE;
} else {
}
}
if ((window->flags & SDL_WINDOW_VULKAN) != (flags & SDL_WINDOW_VULKAN)) {
SDL_SetError("Can't change SDL_WINDOW_VULKAN window flag");
return -1;
}
if ((window->flags & SDL_WINDOW_VULKAN) && (flags & SDL_WINDOW_OPENGL)) {
SDL_SetError("Vulkan and OpenGL not supported on same window");
return -1;
}
window->last_fullscreen_flags = window->flags;
if (_this->CreateSDLWindow && !(flags & SDL_WINDOW_FOREIGN)) {
if (_this->CreateSDLWindow(_this, window) < 0) {
if (loaded_opengl) {
window->flags &= ~SDL_WINDOW_OPENGL;
}
return -1;
}
}
if (flags & SDL_WINDOW_FOREIGN) {
}
if (_this->SetWindowTitle && window->title) {
}
if (_this->SetWindowIcon && window->icon) {
_this->SetWindowIcon(_this, window, window->icon);
}
if (window->hit_test) {
}
return 0;
}
SDL_bool SDL_ShouldAllowTopmost ( void  )
void SDL_ToggleDragAndDropSupport ( void  )

Definition at line 1374 of file SDL_video.c.

References SDL_VideoDevice::AcceptDragAndDrop, IsAcceptingDragAndDrop(), SDL_Window::next, and SDL_VideoDevice::windows.

Referenced by SDL_EventState().

{
for (window = _this->windows; window; window = window->next) {
_this->AcceptDragAndDrop(window, enable);
}
}
}
void SDL_UpdateWindowGrab ( SDL_Window window)

Definition at line 2504 of file SDL_video.c.

References SDL_Window::flags, SDL_VideoDevice::grabbed_window, NULL, SDL_FALSE, SDL_GetMouse(), SDL_TRUE, SDL_WINDOW_INPUT_FOCUS, SDL_WINDOW_INPUT_GRABBED, and SDL_VideoDevice::SetWindowGrab.

Referenced by SDL_OnWindowFocusGained(), SDL_OnWindowFocusLost(), SDL_SetRelativeMouseMode(), and SDL_SetWindowGrab().

{
SDL_Window *grabbed_window;
SDL_bool grabbed;
if ((SDL_GetMouse()->relative_mode || (window->flags & SDL_WINDOW_INPUT_GRABBED)) &&
grabbed = SDL_TRUE;
} else {
grabbed = SDL_FALSE;
}
grabbed_window = _this->grabbed_window;
if (grabbed) {
if (grabbed_window && (grabbed_window != window)) {
/* stealing a grab from another window! */
grabbed_window->flags &= ~SDL_WINDOW_INPUT_GRABBED;
_this->SetWindowGrab(_this, grabbed_window, SDL_FALSE);
}
}
} else if (grabbed_window == window) {
_this->grabbed_window = NULL; /* ungrabbing. */
}
_this->SetWindowGrab(_this, window, grabbed);
}
}

Variable Documentation

VideoBootStrap Android_bootstrap
VideoBootStrap COCOA_bootstrap
VideoBootStrap DirectFB_bootstrap
VideoBootStrap DUMMY_bootstrap
VideoBootStrap Emscripten_bootstrap
VideoBootStrap HAIKU_bootstrap
VideoBootStrap KMSDRM_bootstrap
VideoBootStrap MIR_bootstrap
VideoBootStrap NACL_bootstrap
VideoBootStrap PND_bootstrap
VideoBootStrap PSP_bootstrap
VideoBootStrap QNX_bootstrap

Definition at line 361 of file video.c.

VideoBootStrap RPI_bootstrap
VideoBootStrap UIKIT_bootstrap
VideoBootStrap VIVANTE_bootstrap
VideoBootStrap Wayland_bootstrap
VideoBootStrap WINDOWS_bootstrap
VideoBootStrap WINRT_bootstrap
VideoBootStrap X11_bootstrap