SDL  2.0
SDL_sysvideo.h
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 #include "../SDL_internal.h"
22 
23 #ifndef _SDL_sysvideo_h
24 #define _SDL_sysvideo_h
25 
26 #include "SDL_messagebox.h"
27 #include "SDL_shape.h"
28 #include "SDL_thread.h"
29 
30 /* The SDL video driver */
31 
32 typedef struct SDL_WindowShaper SDL_WindowShaper;
33 typedef struct SDL_ShapeDriver SDL_ShapeDriver;
34 typedef struct SDL_VideoDisplay SDL_VideoDisplay;
35 typedef struct SDL_VideoDevice SDL_VideoDevice;
36 
37 /* Define the SDL window-shaper structure */
39 {
40  /* The window associated with the shaper */
42 
43  /* The user's specified coordinates for the window, for once we give it a shape. */
45 
46  /* The parameters for shape calculation. */
48 
49  /* Has this window been assigned a shape? */
51 
52  void *driverdata;
53 };
54 
55 /* Define the SDL shape driver structure */
57 {
58  SDL_WindowShaper *(*CreateShaper)(SDL_Window * window);
59  int (*SetWindowShape)(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode);
60  int (*ResizeWindowShape)(SDL_Window *window);
61 };
62 
63 typedef struct SDL_WindowUserData
64 {
65  char *name;
66  void *data;
69 
70 /* Define the SDL window structure, corresponding to toplevel windows */
71 struct SDL_Window
72 {
73  const void *magic;
75  char *title;
77  int x, y;
78  int w, h;
79  int min_w, min_h;
80  int max_w, max_h;
83 
84  /* Stored position and size for windowed mode */
86 
88 
89  float opacity;
90 
91  float brightness;
93  Uint16 *saved_gamma; /* (just offset into gamma) */
94 
97 
100  SDL_bool is_dropping; /* drag/drop in progress, expecting SDL_SendDropComplete(). */
101 
103 
106 
108 
109  void *driverdata;
110 
113 };
114 #define FULLSCREEN_VISIBLE(W) \
115  (((W)->flags & SDL_WINDOW_FULLSCREEN) && \
116  ((W)->flags & SDL_WINDOW_SHOWN) && \
117  !((W)->flags & SDL_WINDOW_MINIMIZED))
118 
119 /*
120  * Define the SDL display structure This corresponds to physical monitors
121  * attached to the system.
122  */
124 {
125  char *name;
131 
133 
135 
136  void *driverdata;
137 };
138 
139 /* Forward declaration */
140 struct SDL_SysWMinfo;
141 
142 /* Define the SDL video driver structure */
143 #define _THIS SDL_VideoDevice *_this
144 
146 {
147  /* * * */
148  /* The name of this video driver */
149  const char *name;
150 
151  /* * * */
152  /* Initialization/Query functions */
153 
154  /*
155  * Initialize the native video subsystem, filling in the list of
156  * displays for this driver, returning 0 or -1 if there's an error.
157  */
158  int (*VideoInit) (_THIS);
159 
160  /*
161  * Reverse the effects VideoInit() -- called if VideoInit() fails or
162  * if the application is shutting down the video subsystem.
163  */
164  void (*VideoQuit) (_THIS);
165 
166  /* * * */
167  /*
168  * Display functions
169  */
170 
171  /*
172  * Get the bounds of a display
173  */
174  int (*GetDisplayBounds) (_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
175 
176  /*
177  * Get the dots/pixels-per-inch of a display
178  */
179  int (*GetDisplayDPI) (_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdpi, float * vdpi);
180 
181  /*
182  * Get the usable bounds of a display (bounds minus menubar or whatever)
183  */
184  int (*GetDisplayUsableBounds) (_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
185 
186  /*
187  * Get a list of the available display modes for a display.
188  */
189  void (*GetDisplayModes) (_THIS, SDL_VideoDisplay * display);
190 
191  /*
192  * Setting the display mode is independent of creating windows, so
193  * when the display mode is changed, all existing windows should have
194  * their data updated accordingly, including the display surfaces
195  * associated with them.
196  */
197  int (*SetDisplayMode) (_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
198 
199  /* * * */
200  /*
201  * Window functions
202  */
203  int (*CreateWindow) (_THIS, SDL_Window * window);
204  int (*CreateWindowFrom) (_THIS, SDL_Window * window, const void *data);
205  void (*SetWindowTitle) (_THIS, SDL_Window * window);
206  void (*SetWindowIcon) (_THIS, SDL_Window * window, SDL_Surface * icon);
207  void (*SetWindowPosition) (_THIS, SDL_Window * window);
208  void (*SetWindowSize) (_THIS, SDL_Window * window);
209  void (*SetWindowMinimumSize) (_THIS, SDL_Window * window);
210  void (*SetWindowMaximumSize) (_THIS, SDL_Window * window);
211  int (*GetWindowBordersSize) (_THIS, SDL_Window * window, int *top, int *left, int *bottom, int *right);
212  int (*SetWindowOpacity) (_THIS, SDL_Window * window, float opacity);
213  int (*SetWindowModalFor) (_THIS, SDL_Window * modal_window, SDL_Window * parent_window);
214  int (*SetWindowInputFocus) (_THIS, SDL_Window * window);
215  void (*ShowWindow) (_THIS, SDL_Window * window);
216  void (*HideWindow) (_THIS, SDL_Window * window);
217  void (*RaiseWindow) (_THIS, SDL_Window * window);
218  void (*MaximizeWindow) (_THIS, SDL_Window * window);
219  void (*MinimizeWindow) (_THIS, SDL_Window * window);
220  void (*RestoreWindow) (_THIS, SDL_Window * window);
221  void (*SetWindowBordered) (_THIS, SDL_Window * window, SDL_bool bordered);
222  void (*SetWindowResizable) (_THIS, SDL_Window * window, SDL_bool resizable);
223  void (*SetWindowFullscreen) (_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
224  int (*SetWindowGammaRamp) (_THIS, SDL_Window * window, const Uint16 * ramp);
225  int (*GetWindowGammaRamp) (_THIS, SDL_Window * window, Uint16 * ramp);
226  void (*SetWindowGrab) (_THIS, SDL_Window * window, SDL_bool grabbed);
227  void (*DestroyWindow) (_THIS, SDL_Window * window);
228  int (*CreateWindowFramebuffer) (_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch);
229  int (*UpdateWindowFramebuffer) (_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects);
230  void (*DestroyWindowFramebuffer) (_THIS, SDL_Window * window);
231  void (*OnWindowEnter) (_THIS, SDL_Window * window);
232 
233  /* * * */
234  /*
235  * Shaped-window functions
236  */
238 
239  /* Get some platform dependent window information */
240  SDL_bool(*GetWindowWMInfo) (_THIS, SDL_Window * window,
241  struct SDL_SysWMinfo * info);
242 
243  /* * * */
244  /*
245  * OpenGL support
246  */
247  int (*GL_LoadLibrary) (_THIS, const char *path);
248  void *(*GL_GetProcAddress) (_THIS, const char *proc);
249  void (*GL_UnloadLibrary) (_THIS);
250  SDL_GLContext(*GL_CreateContext) (_THIS, SDL_Window * window);
251  int (*GL_MakeCurrent) (_THIS, SDL_Window * window, SDL_GLContext context);
252  void (*GL_GetDrawableSize) (_THIS, SDL_Window * window, int *w, int *h);
253  int (*GL_SetSwapInterval) (_THIS, int interval);
254  int (*GL_GetSwapInterval) (_THIS);
255  void (*GL_SwapWindow) (_THIS, SDL_Window * window);
256  void (*GL_DeleteContext) (_THIS, SDL_GLContext context);
257 
258  /* * * */
259  /*
260  * Event manager functions
261  */
262  void (*PumpEvents) (_THIS);
263 
264  /* Suspend the screensaver */
265  void (*SuspendScreenSaver) (_THIS);
266 
267  /* Text input */
268  void (*StartTextInput) (_THIS);
269  void (*StopTextInput) (_THIS);
270  void (*SetTextInputRect) (_THIS, SDL_Rect *rect);
271 
272  /* Screen keyboard */
273  SDL_bool (*HasScreenKeyboardSupport) (_THIS);
274  void (*ShowScreenKeyboard) (_THIS, SDL_Window *window);
275  void (*HideScreenKeyboard) (_THIS, SDL_Window *window);
276  SDL_bool (*IsScreenKeyboardShown) (_THIS, SDL_Window *window);
277 
278  /* Clipboard */
279  int (*SetClipboardText) (_THIS, const char *text);
280  char * (*GetClipboardText) (_THIS);
281  SDL_bool (*HasClipboardText) (_THIS);
282 
283  /* MessageBox */
284  int (*ShowMessageBox) (_THIS, const SDL_MessageBoxData *messageboxdata, int *buttonid);
285 
286  /* Hit-testing */
287  int (*SetWindowHitTest)(SDL_Window * window, SDL_bool enabled);
288 
289  /* * * */
290  /* Data common to all drivers */
299 
300  /* * * */
301  /* Data used by the GL drivers */
302  struct
303  {
304  int red_size;
316  int stereo;
322  int flags;
329  char driver_path[256];
330  void *dll_handle;
331  } gl_config;
332 
333  /* * * */
334  /* Cache current GL context; don't call the OS when it hasn't changed. */
335  /* We have the global pointers here so Cocoa continues to work the way
336  it always has, and the thread-local storage for the general case.
337  */
342 
343  /* * * */
344  /* Data private to this driver */
345  void *driverdata;
347 
348 #if SDL_VIDEO_OPENGL_EGL
349  struct SDL_EGL_VideoData *egl_data;
350 #endif
351 
352 #if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
353  struct SDL_PrivateGLESData *gles_data;
354 #endif
355 
356  /* * * */
357  /* The function used to dispose of this structure */
359 };
360 
361 typedef struct VideoBootStrap
362 {
363  const char *name;
364  const char *desc;
365  int (*available) (void);
366  SDL_VideoDevice *(*create) (int devindex);
368 
369 #if SDL_VIDEO_DRIVER_COCOA
370 extern VideoBootStrap COCOA_bootstrap;
371 #endif
372 #if SDL_VIDEO_DRIVER_X11
373 extern VideoBootStrap X11_bootstrap;
374 #endif
375 #if SDL_VIDEO_DRIVER_MIR
376 extern VideoBootStrap MIR_bootstrap;
377 #endif
378 #if SDL_VIDEO_DRIVER_DIRECTFB
379 extern VideoBootStrap DirectFB_bootstrap;
380 #endif
381 #if SDL_VIDEO_DRIVER_WINDOWS
382 extern VideoBootStrap WINDOWS_bootstrap;
383 #endif
384 #if SDL_VIDEO_DRIVER_WINRT
385 extern VideoBootStrap WINRT_bootstrap;
386 #endif
387 #if SDL_VIDEO_DRIVER_HAIKU
388 extern VideoBootStrap HAIKU_bootstrap;
389 #endif
390 #if SDL_VIDEO_DRIVER_PANDORA
391 extern VideoBootStrap PND_bootstrap;
392 #endif
393 #if SDL_VIDEO_DRIVER_UIKIT
394 extern VideoBootStrap UIKIT_bootstrap;
395 #endif
396 #if SDL_VIDEO_DRIVER_ANDROID
397 extern VideoBootStrap Android_bootstrap;
398 #endif
399 #if SDL_VIDEO_DRIVER_PSP
400 extern VideoBootStrap PSP_bootstrap;
401 #endif
402 #if SDL_VIDEO_DRIVER_RPI
403 extern VideoBootStrap RPI_bootstrap;
404 #endif
405 #if SDL_VIDEO_DRIVER_DUMMY
406 extern VideoBootStrap DUMMY_bootstrap;
407 #endif
408 #if SDL_VIDEO_DRIVER_WAYLAND
409 extern VideoBootStrap Wayland_bootstrap;
410 #endif
411 #if SDL_VIDEO_DRIVER_NACL
412 extern VideoBootStrap NACL_bootstrap;
413 #endif
414 #if SDL_VIDEO_DRIVER_VIVANTE
415 extern VideoBootStrap VIVANTE_bootstrap;
416 #endif
417 #if SDL_VIDEO_DRIVER_EMSCRIPTEN
418 extern VideoBootStrap Emscripten_bootstrap;
419 #endif
420 
421 extern SDL_VideoDevice *SDL_GetVideoDevice(void);
422 extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
423 extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display);
426 extern void *SDL_GetDisplayDriverData( int displayIndex );
427 
429 
430 extern void SDL_OnWindowShown(SDL_Window * window);
431 extern void SDL_OnWindowHidden(SDL_Window * window);
432 extern void SDL_OnWindowResized(SDL_Window * window);
434 extern void SDL_OnWindowRestored(SDL_Window * window);
435 extern void SDL_OnWindowEnter(SDL_Window * window);
436 extern void SDL_OnWindowLeave(SDL_Window * window);
439 extern void SDL_UpdateWindowGrab(SDL_Window * window);
440 extern SDL_Window * SDL_GetFocusWindow(void);
441 
442 extern SDL_bool SDL_ShouldAllowTopmost(void);
443 
444 extern float SDL_ComputeDiagonalDPI(int hpix, int vpix, float hinches, float vinches);
445 
446 #endif /* _SDL_sysvideo_h */
447 
448 /* vi: set ts=4 sw=4 expandtab: */
SDL_Window * next
Definition: SDL_sysvideo.h:112
const char * name
Definition: SDL_sysvideo.h:149
void SDL_UpdateWindowGrab(SDL_Window *window)
Definition: SDL_video.c:2369
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: SDL_opengl.h:1565
SDL_DisplayMode fullscreen_mode
Definition: SDL_sysvideo.h:87
GLdouble GLdouble right
void * hit_test_data
Definition: SDL_sysvideo.h:105
#define _THIS
Definition: SDL_sysvideo.h:143
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
const char * desc
Definition: SDL_sysvideo.h:364
const void * magic
Definition: SDL_sysvideo.h:73
SDL_Rect rect
Definition: testrelative.c:27
SDL_TLSID current_glwin_tls
Definition: SDL_sysvideo.h:340
SDL_bool hasshape
Definition: SDL_sysvideo.h:50
SDL_EventEntry * free
Definition: SDL_events.c:81
int SDL_AddBasicVideoDisplay(const SDL_DisplayMode *desktop_mode)
Definition: SDL_video.c:577
A collection of pixels used in software blitting.
Definition: SDL_surface.h:69
void SDL_OnWindowResized(SDL_Window *window)
Definition: SDL_video.c:2443
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1967
The structure that defines a display mode.
Definition: SDL_video.h:53
SDL_bool is_dropping
Definition: SDL_sysvideo.h:100
SDL_HitTestResult(* SDL_HitTest)(SDL_Window *win, const SDL_Point *area, void *data)
Callback used for hit-testing.
Definition: SDL_video.h:986
SDL_bool is_destroying
Definition: SDL_sysvideo.h:99
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: SDL_opengl.h:1565
Uint16 * saved_gamma
Definition: SDL_sysvideo.h:93
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:159
void SDL_OnWindowEnter(SDL_Window *window)
Definition: SDL_video.c:2472
GLdouble GLdouble GLdouble GLdouble top
SDL_Rect windowed
Definition: SDL_sysvideo.h:85
int SDL_AddVideoDisplay(const SDL_VideoDisplay *display)
Definition: SDL_video.c:591
unsigned int SDL_TLSID
Definition: SDL_thread.h:52
struct SDL_GLDriverData * gl_data
Definition: SDL_sysvideo.h:346
void * SDL_GetDisplayDriverData(int displayIndex)
Definition: SDL_video.c:645
void SDL_OnWindowHidden(SDL_Window *window)
Definition: SDL_video.c:2437
struct SDL_WindowUserData * next
Definition: SDL_sysvideo.h:67
void SDL_OnWindowMinimized(SDL_Window *window)
Definition: SDL_video.c:2450
SDL_VideoDevice * device
Definition: SDL_sysvideo.h:134
float opacity
Definition: SDL_sysvideo.h:89
SDL_WindowShapeMode mode
Definition: SDL_sysvideo.h:47
void * SDL_GLContext
An opaque handle to an OpenGL context.
Definition: SDL_video.h:172
SDL_GLContext current_glctx
Definition: SDL_sysvideo.h:339
GLint left
int SDL_RecreateWindow(SDL_Window *window, Uint32 flags)
Definition: SDL_video.c:1509
SDL_WindowShaper * shaper
Definition: SDL_sysvideo.h:102
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:143
SDL_Window * window
Definition: SDL_sysvideo.h:41
SDL_Window * SDL_GetFocusWindow(void)
Definition: SDL_video.c:2534
SDL_DisplayMode * display_modes
Definition: SDL_sysvideo.h:128
SDL_DisplayMode current_mode
Definition: SDL_sysvideo.h:130
GLenum mode
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:293
void SDL_OnWindowLeave(SDL_Window *window)
Definition: SDL_video.c:2480
char * title
Definition: SDL_sysvideo.h:75
SDL_Window * windows
Definition: SDL_sysvideo.h:294
int framebuffer_srgb_capable
Definition: SDL_sysvideo.h:326
MessageBox structure containing title, text, window, etc.
float brightness
Definition: SDL_sysvideo.h:91
GLenum GLenum GLsizei const GLuint GLboolean enabled
SDL_Window * fullscreen_window
Definition: SDL_sysvideo.h:132
int share_with_current_context
Definition: SDL_sysvideo.h:324
SDL_bool SDL_ShouldAllowTopmost(void)
Definition: SDL_video.c:3761
SDL_bool
Definition: SDL_stdinc.h:130
SDL_DisplayMode desktop_mode
Definition: SDL_sysvideo.h:129
SDL_HitTest hit_test
Definition: SDL_sysvideo.h:104
Uint32 last_fullscreen_flags
Definition: SDL_sysvideo.h:82
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:47
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 void
SDL_Surface * icon
Definition: SDL_sysvideo.h:76
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
Definition: SDL_video.c:1058
SDL_Window * prev
Definition: SDL_sysvideo.h:111
SDL_TLSID current_glctx_tls
Definition: SDL_sysvideo.h:341
The type used to identify a window.
Definition: SDL_sysvideo.h:71
SDL_Rect rects[MAX_RECTS]
Uint32 id
Definition: SDL_sysvideo.h:74
GLint GLint bottom
void SDL_OnWindowFocusLost(SDL_Window *window)
Definition: SDL_video.c:2518
const char * name
Definition: SDL_sysvideo.h:363
uint16_t Uint16
An unsigned 16-bit integer type.
Definition: SDL_stdinc.h:151
SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode)
Definition: SDL_video.c:728
SDL_Window * grabbed_window
Definition: SDL_sysvideo.h:295
SDL_VideoDevice * SDL_GetVideoDevice(void)
Definition: SDL_video.c:571
SDL_ShapeDriver shape_driver
Definition: SDL_sysvideo.h:237
SDL_bool suspend_screensaver
Definition: SDL_sysvideo.h:291
union SDL_SysWMinfo::@18 info
GLbitfield flags
void SDL_OnWindowRestored(SDL_Window *window)
Definition: SDL_video.c:2456
void SDL_OnWindowShown(SDL_Window *window)
Definition: SDL_video.c:2431
A struct that tags the SDL_WindowShapeParams union with an enum describing the type of its contents...
Definition: SDL_shape.h:100
GLsizei const GLchar *const * path
GLubyte GLubyte GLubyte GLubyte w
Uint16 * gamma
Definition: SDL_sysvideo.h:92
void * driverdata
Definition: SDL_sysvideo.h:109
SDL_bool surface_valid
Definition: SDL_sysvideo.h:96
Uint32 flags
Definition: SDL_sysvideo.h:81
Uint32 next_object_id
Definition: SDL_sysvideo.h:297
SDL_Surface * surface
Definition: SDL_sysvideo.h:95
SDL_Window * current_glwin
Definition: SDL_sysvideo.h:338
float SDL_ComputeDiagonalDPI(int hpix, int vpix, float hinches, float vinches)
Definition: SDL_video.c:3783
GLfloat GLfloat GLfloat GLfloat h
SDL_WindowUserData * data
Definition: SDL_sysvideo.h:107
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64
char * clipboard_text
Definition: SDL_sysvideo.h:298
SDL_bool is_hiding
Definition: SDL_sysvideo.h:98
void SDL_OnWindowFocusGained(SDL_Window *window)
Definition: SDL_video.c:2485