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:

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

◆ _THIS

#define _THIS   SDL_VideoDevice *_this

Definition at line 146 of file SDL_sysvideo.h.

◆ FULLSCREEN_VISIBLE

#define FULLSCREEN_VISIBLE (   W)
Value:
((W)->flags & SDL_WINDOW_SHOWN) && \
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d &reg2 endm macro vzip8 reg2 vzip d d &reg2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld [DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld W[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp local skip1 beq endif SRC MASK if dst_r_bpp DST_R else add endif PF add sub
GLbitfield flags

Definition at line 116 of file SDL_sysvideo.h.

Referenced by SDL_CreateWindow(), SDL_OnWindowRestored(), SDL_SetWindowDisplayMode(), SDL_SetWindowFullscreen(), SDL_SetWindowSize(), and SDL_UpdateFullscreenMode().

Function Documentation

◆ SDL_AddBasicVideoDisplay()

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.

593 {
594  SDL_VideoDisplay display;
595 
596  SDL_zero(display);
597  if (desktop_mode) {
598  display.desktop_mode = *desktop_mode;
599  }
600  display.current_mode = display.desktop_mode;
601 
602  return SDL_AddVideoDisplay(&display);
603 }
SDL_DisplayMode current_mode
Definition: SDL_sysvideo.h:132
#define SDL_zero(x)
Definition: SDL_stdinc.h:416
int SDL_AddVideoDisplay(const SDL_VideoDisplay *display)
Definition: SDL_video.c:606
SDL_DisplayMode desktop_mode
Definition: SDL_sysvideo.h:131

◆ SDL_AddDisplayMode()

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.

755 {
756  SDL_DisplayMode *modes;
757  int i, nmodes;
758 
759  /* Make sure we don't already have the mode in the list */
760  modes = display->display_modes;
761  nmodes = display->num_display_modes;
762  for (i = 0; i < nmodes; ++i) {
763  if (cmpmodes(mode, &modes[i]) == 0) {
764  return SDL_FALSE;
765  }
766  }
767 
768  /* Go ahead and add the new mode */
769  if (nmodes == display->max_display_modes) {
770  modes =
771  SDL_realloc(modes,
772  (display->max_display_modes + 32) * sizeof(*modes));
773  if (!modes) {
774  return SDL_FALSE;
775  }
776  display->display_modes = modes;
777  display->max_display_modes += 32;
778  }
779  modes[nmodes] = *mode;
780  display->num_display_modes++;
781 
782  /* Re-sort video modes */
783  SDL_qsort(display->display_modes, display->num_display_modes,
784  sizeof(SDL_DisplayMode), cmpmodes);
785 
786  return SDL_TRUE;
787 }
#define SDL_qsort
The structure that defines a display mode.
Definition: SDL_video.h:53
#define SDL_realloc
static int cmpmodes(const void *A, const void *B)
Definition: SDL_video.c:419
SDL_DisplayMode * display_modes
Definition: SDL_sysvideo.h:130
GLenum mode
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50

◆ SDL_AddVideoDisplay()

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().

607 {
608  SDL_VideoDisplay *displays;
609  int index = -1;
610 
611  displays =
613  (_this->num_displays + 1) * sizeof(*displays));
614  if (displays) {
615  index = _this->num_displays++;
616  displays[index] = *display;
617  displays[index].device = _this;
618  _this->displays = displays;
619 
620  if (display->name) {
621  displays[index].name = SDL_strdup(display->name);
622  } else {
623  char name[32];
624 
625  SDL_itoa(index, name, 10);
626  displays[index].name = SDL_strdup(name);
627  }
628  } else {
629  SDL_OutOfMemory();
630  }
631  return index;
632 }
#define SDL_itoa
#define SDL_realloc
GLuint const GLchar * name
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
SDL_VideoDevice * device
Definition: SDL_sysvideo.h:137
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:316
GLuint index
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
#define SDL_strdup

◆ SDL_ComputeDiagonalDPI()

float SDL_ComputeDiagonalDPI ( int  hpix,
int  vpix,
float  hinches,
float  vinches 
)

Definition at line 3990 of file SDL_video.c.

References SDL_sqrt.

3991 {
3992  float den2 = hinches * hinches + vinches * vinches;
3993  if (den2 <= 0.0f) {
3994  return 0.0f;
3995  }
3996 
3997  return (float)(SDL_sqrt((double)hpix * (double)hpix + (double)vpix * (double)vpix) /
3998  SDL_sqrt((double)den2));
3999 }
GLfloat f
#define SDL_sqrt

◆ SDL_GetDisplay()

SDL_VideoDisplay* SDL_GetDisplay ( int  displayIndex)

Definition at line 1024 of file SDL_video.c.

References CHECK_DISPLAY_INDEX, SDL_VideoDevice::displays, and NULL.

1025 {
1026  CHECK_DISPLAY_INDEX(displayIndex, NULL);
1027 
1028  return &_this->displays[displayIndex];
1029 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:316
#define NULL
Definition: begin_code.h:164
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:134

◆ SDL_GetDisplayDriverData()

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.

661 {
662  CHECK_DISPLAY_INDEX(displayIndex, NULL);
663 
664  return _this->displays[displayIndex].driverdata;
665 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:316
#define NULL
Definition: begin_code.h:164
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:134

◆ SDL_GetDisplayForWindow()

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().

1093 {
1094  int displayIndex = SDL_GetWindowDisplayIndex(window);
1095  if (displayIndex >= 0) {
1096  return &_this->displays[displayIndex];
1097  } else {
1098  return NULL;
1099  }
1100 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:316
#define NULL
Definition: begin_code.h:164
int SDL_GetWindowDisplayIndex(SDL_Window *window)
Get the display index associated with a window.
Definition: SDL_video.c:1032

◆ SDL_GetFocusWindow()

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().

2672 {
2673  SDL_Window *window;
2674 
2675  if (!_this) {
2676  return NULL;
2677  }
2678  for (window = _this->windows; window; window = window->next) {
2679  if (window->flags & SDL_WINDOW_INPUT_FOCUS) {
2680  return window;
2681  }
2682  }
2683  return NULL;
2684 }
SDL_Window * next
Definition: SDL_sysvideo.h:114
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
SDL_Window * windows
Definition: SDL_sysvideo.h:317
#define NULL
Definition: begin_code.h:164
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
The type used to identify a window.
Definition: SDL_sysvideo.h:73
Uint32 flags
Definition: SDL_sysvideo.h:83

◆ SDL_GetIndexOfDisplay()

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().

646 {
647  int displayIndex;
648 
649  for (displayIndex = 0; displayIndex < _this->num_displays; ++displayIndex) {
650  if (display == &_this->displays[displayIndex]) {
651  return displayIndex;
652  }
653  }
654 
655  /* Couldn't find the display, just use index 0 */
656  return 0;
657 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:316

◆ SDL_GetVideoDevice()

SDL_VideoDevice* SDL_GetVideoDevice ( void  )

Definition at line 586 of file SDL_video.c.

References _this.

Referenced by SDL_CreateShapedWindow(), SDL_GetClipboardText(), SDL_GetTouch(), SDL_HasClipboardText(), SDL_PumpEvents(), SDL_SetClipboardText(), SDL_SetKeyboardFocus(), and SDL_SetWindowShape().

587 {
588  return _this;
589 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121

◆ SDL_GL_DeduceMaxSupportedESProfile()

void SDL_GL_DeduceMaxSupportedESProfile ( int *  major,
int *  minor 
)

Definition at line 3019 of file SDL_video.c.

References SDL_GL_ExtensionSupported().

3020 {
3021 /* THIS REQUIRES AN EXISTING GL CONTEXT THAT HAS BEEN MADE CURRENT. */
3022 /* Please refer to https://bugzilla.libsdl.org/show_bug.cgi?id=3725 for discussion. */
3023 #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
3024  /* XXX This is fragile; it will break in the event of release of
3025  * new versions of OpenGL ES.
3026  */
3027  if (SDL_GL_ExtensionSupported("GL_ARB_ES3_2_compatibility")) {
3028  *major = 3;
3029  *minor = 2;
3030  } else if (SDL_GL_ExtensionSupported("GL_ARB_ES3_1_compatibility")) {
3031  *major = 3;
3032  *minor = 1;
3033  } else if (SDL_GL_ExtensionSupported("GL_ARB_ES3_compatibility")) {
3034  *major = 3;
3035  *minor = 0;
3036  } else {
3037  *major = 2;
3038  *minor = 0;
3039  }
3040 #endif
3041 }
SDL_bool SDL_GL_ExtensionSupported(const char *extension)
Return true if an OpenGL extension is supported for the current context.
Definition: SDL_video.c:2929

◆ SDL_HasWindows()

SDL_bool SDL_HasWindows ( void  )

Definition at line 1707 of file SDL_video.c.

References NULL, and SDL_VideoDevice::windows.

Referenced by SDL_PrivateJoystickShouldIgnoreEvent().

1708 {
1709  return (_this && _this->windows != NULL);
1710 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
SDL_Window * windows
Definition: SDL_sysvideo.h:317
#define NULL
Definition: begin_code.h:164

◆ SDL_OnApplicationDidBecomeActive()

void SDL_OnApplicationDidBecomeActive ( void  )

Definition at line 4036 of file SDL_video.c.

References SDL_Window::next, NULL, SDL_APP_DIDENTERFOREGROUND, SDL_SendAppEvent(), SDL_SendWindowEvent(), SDL_WINDOWEVENT_FOCUS_GAINED, SDL_WINDOWEVENT_RESTORED, and SDL_VideoDevice::windows.

4037 {
4039 
4040  if (_this) {
4041  SDL_Window *window;
4042  for (window = _this->windows; window != NULL; window = window->next) {
4045  }
4046  }
4047 }
SDL_Window * next
Definition: SDL_sysvideo.h:114
int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, int data2)
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
SDL_Window * windows
Definition: SDL_sysvideo.h:317
#define NULL
Definition: begin_code.h:164
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
The type used to identify a window.
Definition: SDL_sysvideo.h:73
int SDL_SendAppEvent(SDL_EventType eventType)
Definition: SDL_events.c:942

◆ SDL_OnApplicationDidEnterBackground()

void SDL_OnApplicationDidEnterBackground ( void  )

Definition at line 4026 of file SDL_video.c.

References SDL_APP_DIDENTERBACKGROUND, and SDL_SendAppEvent().

4027 {
4029 }
int SDL_SendAppEvent(SDL_EventType eventType)
Definition: SDL_events.c:942

◆ SDL_OnApplicationDidReceiveMemoryWarning()

void SDL_OnApplicationDidReceiveMemoryWarning ( void  )

Definition at line 4009 of file SDL_video.c.

References SDL_APP_LOWMEMORY, and SDL_SendAppEvent().

4010 {
4012 }
int SDL_SendAppEvent(SDL_EventType eventType)
Definition: SDL_events.c:942

◆ SDL_OnApplicationWillEnterForeground()

void SDL_OnApplicationWillEnterForeground ( void  )

Definition at line 4031 of file SDL_video.c.

References SDL_APP_WILLENTERFOREGROUND, and SDL_SendAppEvent().

4032 {
4034 }
int SDL_SendAppEvent(SDL_EventType eventType)
Definition: SDL_events.c:942

◆ SDL_OnApplicationWillResignActive()

void SDL_OnApplicationWillResignActive ( void  )

Definition at line 4014 of file SDL_video.c.

References SDL_Window::next, NULL, SDL_APP_WILLENTERBACKGROUND, SDL_SendAppEvent(), SDL_SendWindowEvent(), SDL_WINDOWEVENT_FOCUS_LOST, SDL_WINDOWEVENT_MINIMIZED, and SDL_VideoDevice::windows.

4015 {
4016  if (_this) {
4017  SDL_Window *window;
4018  for (window = _this->windows; window != NULL; window = window->next) {
4021  }
4022  }
4024 }
SDL_Window * next
Definition: SDL_sysvideo.h:114
int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, int data2)
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
SDL_Window * windows
Definition: SDL_sysvideo.h:317
#define NULL
Definition: begin_code.h:164
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
The type used to identify a window.
Definition: SDL_sysvideo.h:73
int SDL_SendAppEvent(SDL_EventType eventType)
Definition: SDL_events.c:942

◆ SDL_OnApplicationWillTerminate()

void SDL_OnApplicationWillTerminate ( void  )

Definition at line 4004 of file SDL_video.c.

References SDL_APP_TERMINATING, and SDL_SendAppEvent().

4005 {
4007 }
int SDL_SendAppEvent(SDL_EventType eventType)
Definition: SDL_events.c:942

◆ SDL_OnWindowEnter()

void SDL_OnWindowEnter ( SDL_Window window)

Definition at line 2607 of file SDL_video.c.

References SDL_VideoDevice::OnWindowEnter.

Referenced by SDL_SendWindowEvent().

2608 {
2609  if (_this->OnWindowEnter) {
2610  _this->OnWindowEnter(_this, window);
2611  }
2612 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
void(* OnWindowEnter)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:239

◆ SDL_OnWindowFocusGained()

void SDL_OnWindowFocusGained ( SDL_Window window)

Definition at line 2620 of file SDL_video.c.

References SDL_Window::gamma, SDL_Window::h, SDL_Mouse::relative_mode, SDL_GetMouse(), SDL_SetMouseFocus(), SDL_UpdateWindowGrab(), SDL_WarpMouseInWindow, SDL_VideoDevice::SetWindowGammaRamp, and SDL_Window::w.

Referenced by SDL_SendWindowEvent().

2621 {
2622  SDL_Mouse *mouse = SDL_GetMouse();
2623 
2624  if (window->gamma && _this->SetWindowGammaRamp) {
2625  _this->SetWindowGammaRamp(_this, window, window->gamma);
2626  }
2627 
2628  if (mouse && mouse->relative_mode) {
2629  SDL_SetMouseFocus(window);
2630  SDL_WarpMouseInWindow(window, window->w/2, window->h/2);
2631  }
2632 
2633  SDL_UpdateWindowGrab(window);
2634 }
SDL_Mouse * SDL_GetMouse(void)
Definition: SDL_mouse.c:144
void SDL_SetMouseFocus(SDL_Window *window)
Definition: SDL_mouse.c:177
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
SDL_bool relative_mode
Definition: SDL_mouse_c.h:87
void SDL_UpdateWindowGrab(SDL_Window *window)
Definition: SDL_video.c:2504
#define SDL_WarpMouseInWindow
Uint16 * gamma
Definition: SDL_sysvideo.h:94
int(* SetWindowGammaRamp)(_THIS, SDL_Window *window, const Uint16 *ramp)
Definition: SDL_sysvideo.h:232

◆ SDL_OnWindowFocusLost()

void SDL_OnWindowFocusLost ( SDL_Window window)

Definition at line 2655 of file SDL_video.c.

References SDL_Window::gamma, SDL_Window::saved_gamma, SDL_MinimizeWindow(), SDL_UpdateWindowGrab(), SDL_VideoDevice::SetWindowGammaRamp, and ShouldMinimizeOnFocusLoss().

Referenced by SDL_SendWindowEvent().

2656 {
2657  if (window->gamma && _this->SetWindowGammaRamp) {
2658  _this->SetWindowGammaRamp(_this, window, window->saved_gamma);
2659  }
2660 
2661  SDL_UpdateWindowGrab(window);
2662 
2663  if (ShouldMinimizeOnFocusLoss(window)) {
2664  SDL_MinimizeWindow(window);
2665  }
2666 }
Uint16 * saved_gamma
Definition: SDL_sysvideo.h:95
void SDL_MinimizeWindow(SDL_Window *window)
Minimize a window to an iconic representation.
Definition: SDL_video.c:2213
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
void SDL_UpdateWindowGrab(SDL_Window *window)
Definition: SDL_video.c:2504
Uint16 * gamma
Definition: SDL_sysvideo.h:94
int(* SetWindowGammaRamp)(_THIS, SDL_Window *window, const Uint16 *ramp)
Definition: SDL_sysvideo.h:232
static SDL_bool ShouldMinimizeOnFocusLoss(SDL_Window *window)
Definition: SDL_video.c:2637

◆ SDL_OnWindowHidden()

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().

2573 {
2575 }
static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
Definition: SDL_video.c:1186

◆ SDL_OnWindowLeave()

void SDL_OnWindowLeave ( SDL_Window window)

Definition at line 2615 of file SDL_video.c.

Referenced by SDL_SendWindowEvent().

2616 {
2617 }

◆ SDL_OnWindowMinimized()

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().

2586 {
2588 }
static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
Definition: SDL_video.c:1186

◆ SDL_OnWindowResized()

void SDL_OnWindowResized ( SDL_Window window)

Definition at line 2578 of file SDL_video.c.

References SDL_Window::h, SDL_FALSE, SDL_SendWindowEvent(), SDL_WINDOWEVENT_SIZE_CHANGED, SDL_Window::surface_valid, and SDL_Window::w.

Referenced by SDL_SendWindowEvent(), SDL_SetWindowSize(), and SDL_UpdateFullscreenMode().

2579 {
2580  window->surface_valid = SDL_FALSE;
2581  SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SIZE_CHANGED, window->w, window->h);
2582 }
int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, int data2)
SDL_bool surface_valid
Definition: SDL_sysvideo.h:98

◆ SDL_OnWindowRestored()

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().

2592 {
2593  /*
2594  * FIXME: Is this fine to just remove this, or should it be preserved just
2595  * for the fullscreen case? In principle it seems like just hiding/showing
2596  * windows shouldn't affect the stacking order; maybe the right fix is to
2597  * re-decouple OnWindowShown and OnWindowRestored.
2598  */
2599  /*SDL_RaiseWindow(window);*/
2600 
2601  if (FULLSCREEN_VISIBLE(window)) {
2603  }
2604 }
#define FULLSCREEN_VISIBLE(W)
Definition: SDL_sysvideo.h:116
static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
Definition: SDL_video.c:1186

◆ SDL_OnWindowShown()

void SDL_OnWindowShown ( SDL_Window window)

Definition at line 2566 of file SDL_video.c.

References SDL_OnWindowRestored().

Referenced by SDL_SendWindowEvent().

2567 {
2568  SDL_OnWindowRestored(window);
2569 }
void SDL_OnWindowRestored(SDL_Window *window)
Definition: SDL_video.c:2591

◆ SDL_RecreateWindow()

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.

1618 {
1619  SDL_bool loaded_opengl = SDL_FALSE;
1620 
1622  return SDL_SetError("OpenGL support is either not configured in SDL "
1623  "or not available in current SDL video driver "
1624  "(%s) or platform", _this->name);
1625  }
1626 
1627  if (window->flags & SDL_WINDOW_FOREIGN) {
1628  /* Can't destroy and re-create foreign windows, hrm */
1630  } else {
1632  }
1633 
1634  /* Restore video mode, etc. */
1635  SDL_HideWindow(window);
1636 
1637  /* Tear down the old native window */
1638  if (window->surface) {
1639  window->surface->flags &= ~SDL_DONTFREE;
1640  SDL_FreeSurface(window->surface);
1641  window->surface = NULL;
1642  }
1645  }
1647  _this->DestroyWindow(_this, window);
1648  }
1649 
1650  if ((window->flags & SDL_WINDOW_OPENGL) != (flags & SDL_WINDOW_OPENGL)) {
1651  if (flags & SDL_WINDOW_OPENGL) {
1652  if (SDL_GL_LoadLibrary(NULL) < 0) {
1653  return -1;
1654  }
1655  loaded_opengl = SDL_TRUE;
1656  } else {
1658  }
1659  }
1660 
1661  if ((window->flags & SDL_WINDOW_VULKAN) != (flags & SDL_WINDOW_VULKAN)) {
1662  SDL_SetError("Can't change SDL_WINDOW_VULKAN window flag");
1663  return -1;
1664  }
1665 
1666  if ((window->flags & SDL_WINDOW_VULKAN) && (flags & SDL_WINDOW_OPENGL)) {
1667  SDL_SetError("Vulkan and OpenGL not supported on same window");
1668  return -1;
1669  }
1670 
1671  window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN);
1672  window->last_fullscreen_flags = window->flags;
1673  window->is_destroying = SDL_FALSE;
1674 
1675  if (_this->CreateSDLWindow && !(flags & SDL_WINDOW_FOREIGN)) {
1676  if (_this->CreateSDLWindow(_this, window) < 0) {
1677  if (loaded_opengl) {
1679  window->flags &= ~SDL_WINDOW_OPENGL;
1680  }
1681  return -1;
1682  }
1683  }
1684 
1685  if (flags & SDL_WINDOW_FOREIGN) {
1686  window->flags |= SDL_WINDOW_FOREIGN;
1687  }
1688 
1689  if (_this->SetWindowTitle && window->title) {
1690  _this->SetWindowTitle(_this, window);
1691  }
1692 
1693  if (_this->SetWindowIcon && window->icon) {
1694  _this->SetWindowIcon(_this, window, window->icon);
1695  }
1696 
1697  if (window->hit_test) {
1698  _this->SetWindowHitTest(window, SDL_TRUE);
1699  }
1700 
1702 
1703  return 0;
1704 }
const char * name
Definition: SDL_sysvideo.h:152
int(* SetWindowHitTest)(SDL_Window *window, SDL_bool enabled)
Definition: SDL_sysvideo.h:306
int SDL_GL_LoadLibrary(const char *path)
Dynamically load an OpenGL library.
Definition: SDL_video.c:2853
#define SDL_DONTFREE
Definition: SDL_surface.h:55
SDL_bool is_destroying
Definition: SDL_sysvideo.h:101
void SDL_HideWindow(SDL_Window *window)
Hide a window.
Definition: SDL_video.c:2165
Uint32 flags
Definition: SDL_surface.h:71
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
#define CREATE_FLAGS
Definition: SDL_video.c:1350
SDL_GLContext(* GL_CreateContext)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:258
#define SDL_FreeSurface
void SDL_GL_UnloadLibrary(void)
Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary().
Definition: SDL_video.c:2904
void(* DestroyWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:235
void(* SetWindowIcon)(_THIS, SDL_Window *window, SDL_Surface *icon)
Definition: SDL_sysvideo.h:214
char * title
Definition: SDL_sysvideo.h:77
void(* DestroyWindowFramebuffer)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:238
#define NULL
Definition: begin_code.h:164
int(* CreateSDLWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:211
SDL_bool
Definition: SDL_stdinc.h:161
SDL_HitTest hit_test
Definition: SDL_sysvideo.h:106
Uint32 last_fullscreen_flags
Definition: SDL_sysvideo.h:84
#define SDL_SetError
GLbitfield flags
SDL_Surface * icon
Definition: SDL_sysvideo.h:78
static void SDL_FinishWindowCreation(SDL_Window *window, Uint32 flags)
Definition: SDL_video.c:1386
void(* SetWindowTitle)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:213
Uint32 flags
Definition: SDL_sysvideo.h:83
SDL_Surface * surface
Definition: SDL_sysvideo.h:97

◆ SDL_ShouldAllowTopmost()

SDL_bool SDL_ShouldAllowTopmost ( void  )

Definition at line 3967 of file SDL_video.c.

References SDL_GetHintBoolean, SDL_HINT_ALLOW_TOPMOST, and SDL_TRUE.

3968 {
3970 }
#define SDL_GetHintBoolean
#define SDL_HINT_ALLOW_TOPMOST
If set to "0" then never set the top most bit on a SDL Window, even if the video mode expects it...
Definition: SDL_hints.h:568

◆ SDL_ToggleDragAndDropSupport()

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().

1375 {
1376  if (_this && _this->AcceptDragAndDrop) {
1378  SDL_Window *window;
1379  for (window = _this->windows; window; window = window->next) {
1380  _this->AcceptDragAndDrop(window, enable);
1381  }
1382  }
1383 }
SDL_Window * next
Definition: SDL_sysvideo.h:114
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
static SDL_INLINE SDL_bool IsAcceptingDragAndDrop(void)
Definition: SDL_video.c:1354
SDL_Window * windows
Definition: SDL_sysvideo.h:317
SDL_bool
Definition: SDL_stdinc.h:161
GLboolean enable
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
The type used to identify a window.
Definition: SDL_sysvideo.h:73
void(* AcceptDragAndDrop)(SDL_Window *window, SDL_bool accept)
Definition: SDL_sysvideo.h:309

◆ SDL_UpdateWindowGrab()

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().

2505 {
2506  SDL_Window *grabbed_window;
2507  SDL_bool grabbed;
2508  if ((SDL_GetMouse()->relative_mode || (window->flags & SDL_WINDOW_INPUT_GRABBED)) &&
2509  (window->flags & SDL_WINDOW_INPUT_FOCUS)) {
2510  grabbed = SDL_TRUE;
2511  } else {
2512  grabbed = SDL_FALSE;
2513  }
2514 
2515  grabbed_window = _this->grabbed_window;
2516  if (grabbed) {
2517  if (grabbed_window && (grabbed_window != window)) {
2518  /* stealing a grab from another window! */
2519  grabbed_window->flags &= ~SDL_WINDOW_INPUT_GRABBED;
2520  if (_this->SetWindowGrab) {
2521  _this->SetWindowGrab(_this, grabbed_window, SDL_FALSE);
2522  }
2523  }
2525  } else if (grabbed_window == window) {
2526  _this->grabbed_window = NULL; /* ungrabbing. */
2527  }
2528 
2529  if (_this->SetWindowGrab) {
2530  _this->SetWindowGrab(_this, window, grabbed);
2531  }
2532 }
SDL_Mouse * SDL_GetMouse(void)
Definition: SDL_mouse.c:144
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
#define NULL
Definition: begin_code.h:164
SDL_bool
Definition: SDL_stdinc.h:161
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
The type used to identify a window.
Definition: SDL_sysvideo.h:73
SDL_Window * grabbed_window
Definition: SDL_sysvideo.h:318
Uint32 flags
Definition: SDL_sysvideo.h:83
void(* SetWindowGrab)(_THIS, SDL_Window *window, SDL_bool grabbed)
Definition: SDL_sysvideo.h:234

Variable Documentation

◆ Android_bootstrap

VideoBootStrap Android_bootstrap

◆ COCOA_bootstrap

VideoBootStrap COCOA_bootstrap

◆ DirectFB_bootstrap

VideoBootStrap DirectFB_bootstrap

◆ DUMMY_bootstrap

VideoBootStrap DUMMY_bootstrap

◆ Emscripten_bootstrap

VideoBootStrap Emscripten_bootstrap

◆ HAIKU_bootstrap

VideoBootStrap HAIKU_bootstrap

◆ KMSDRM_bootstrap

VideoBootStrap KMSDRM_bootstrap

◆ MIR_bootstrap

VideoBootStrap MIR_bootstrap

◆ NACL_bootstrap

VideoBootStrap NACL_bootstrap

◆ PND_bootstrap

VideoBootStrap PND_bootstrap

◆ PSP_bootstrap

VideoBootStrap PSP_bootstrap

◆ QNX_bootstrap

VideoBootStrap QNX_bootstrap

Definition at line 361 of file video.c.

◆ RPI_bootstrap

VideoBootStrap RPI_bootstrap

◆ UIKIT_bootstrap

VideoBootStrap UIKIT_bootstrap

◆ VIVANTE_bootstrap

VideoBootStrap VIVANTE_bootstrap

◆ Wayland_bootstrap

VideoBootStrap Wayland_bootstrap

◆ WINDOWS_bootstrap

VideoBootStrap WINDOWS_bootstrap

◆ WINRT_bootstrap

VideoBootStrap WINRT_bootstrap

◆ X11_bootstrap

VideoBootStrap X11_bootstrap