SDL  2.0
SDL_sysvideo.h
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2018 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 #include "SDL_vulkan_internal.h"
31 
32 /* The SDL video driver */
33 
34 typedef struct SDL_WindowShaper SDL_WindowShaper;
35 typedef struct SDL_ShapeDriver SDL_ShapeDriver;
36 typedef struct SDL_VideoDisplay SDL_VideoDisplay;
37 typedef struct SDL_VideoDevice SDL_VideoDevice;
38 
39 /* Define the SDL window-shaper structure */
41 {
42  /* The window associated with the shaper */
44 
45  /* The user's specified coordinates for the window, for once we give it a shape. */
47 
48  /* The parameters for shape calculation. */
50 
51  /* Has this window been assigned a shape? */
53 
54  void *driverdata;
55 };
56 
57 /* Define the SDL shape driver structure */
59 {
60  SDL_WindowShaper *(*CreateShaper)(SDL_Window * window);
61  int (*SetWindowShape)(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode);
63 };
64 
65 typedef struct SDL_WindowUserData
66 {
67  char *name;
68  void *data;
71 
72 /* Define the SDL window structure, corresponding to toplevel windows */
73 struct SDL_Window
74 {
75  const void *magic;
77  char *title;
79  int x, y;
80  int w, h;
81  int min_w, min_h;
82  int max_w, max_h;
85 
86  /* Stored position and size for windowed mode */
88 
90 
91  float opacity;
92 
93  float brightness;
95  Uint16 *saved_gamma; /* (just offset into gamma) */
96 
99 
102  SDL_bool is_dropping; /* drag/drop in progress, expecting SDL_SendDropComplete(). */
103 
105 
108 
110 
111  void *driverdata;
112 
115 };
116 #define FULLSCREEN_VISIBLE(W) \
117  (((W)->flags & SDL_WINDOW_FULLSCREEN) && \
118  ((W)->flags & SDL_WINDOW_SHOWN) && \
119  !((W)->flags & SDL_WINDOW_MINIMIZED))
120 
121 /*
122  * Define the SDL display structure.
123  * This corresponds to physical monitors attached to the system.
124  */
126 {
127  char *name;
134 
136 
138 
139  void *driverdata;
140 };
141 
142 /* Forward declaration */
143 struct SDL_SysWMinfo;
144 
145 /* Define the SDL video driver structure */
146 #define _THIS SDL_VideoDevice *_this
147 
149 {
150  /* * * */
151  /* The name of this video driver */
152  const char *name;
153 
154  /* * * */
155  /* Initialization/Query functions */
156 
157  /*
158  * Initialize the native video subsystem, filling in the list of
159  * displays for this driver, returning 0 or -1 if there's an error.
160  */
161  int (*VideoInit) (_THIS);
162 
163  /*
164  * Reverse the effects VideoInit() -- called if VideoInit() fails or
165  * if the application is shutting down the video subsystem.
166  */
168 
169  /*
170  * Reinitialize the touch devices -- called if an unknown touch ID occurs.
171  */
173 
174  /* * * */
175  /*
176  * Display functions
177  */
178 
179  /*
180  * Get the bounds of a display
181  */
183 
184  /*
185  * Get the usable bounds of a display (bounds minus menubar or whatever)
186  */
188 
189  /*
190  * Get the dots/pixels-per-inch of a display
191  */
192  int (*GetDisplayDPI) (_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdpi, float * vdpi);
193 
194  /*
195  * Get a list of the available display modes for a display.
196  */
198 
199  /*
200  * Setting the display mode is independent of creating windows, so
201  * when the display mode is changed, all existing windows should have
202  * their data updated accordingly, including the display surfaces
203  * associated with them.
204  */
206 
207  /* * * */
208  /*
209  * Window functions
210  */
212  int (*CreateSDLWindowFrom) (_THIS, SDL_Window * window, const void *data);
219  int (*GetWindowBordersSize) (_THIS, SDL_Window * window, int *top, int *left, int *bottom, int *right);
220  int (*SetWindowOpacity) (_THIS, SDL_Window * window, float opacity);
221  int (*SetWindowModalFor) (_THIS, SDL_Window * modal_window, SDL_Window * parent_window);
232  int (*SetWindowGammaRamp) (_THIS, SDL_Window * window, const Uint16 * ramp);
236  int (*CreateWindowFramebuffer) (_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch);
237  int (*UpdateWindowFramebuffer) (_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects);
240 
241  /* * * */
242  /*
243  * Shaped-window functions
244  */
246 
247  /* Get some platform dependent window information */
249  struct SDL_SysWMinfo * info);
250 
251  /* * * */
252  /*
253  * OpenGL support
254  */
255  int (*GL_LoadLibrary) (_THIS, const char *path);
256  void *(*GL_GetProcAddress) (_THIS, const char *proc);
261  int (*GL_SetSwapInterval) (_THIS, int interval);
265  void (*GL_DefaultProfileConfig) (_THIS, int *mask, int *major, int *minor);
266 
267  /* * * */
268  /*
269  * Vulkan support
270  */
271  int (*Vulkan_LoadLibrary) (_THIS, const char *path);
274  SDL_bool (*Vulkan_CreateSurface) (_THIS, SDL_Window *window, VkInstance instance, VkSurfaceKHR *surface);
276 
277  /* * * */
278  /*
279  * Event manager functions
280  */
282 
283  /* Suspend the screensaver */
285 
286  /* Text input */
290 
291  /* Screen keyboard */
296 
297  /* Clipboard */
298  int (*SetClipboardText) (_THIS, const char *text);
299  char * (*GetClipboardText) (_THIS);
301 
302  /* MessageBox */
303  int (*ShowMessageBox) (_THIS, const SDL_MessageBoxData *messageboxdata, int *buttonid);
304 
305  /* Hit-testing */
307 
308  /* Tell window that app enabled drag'n'drop events */
310 
311  /* * * */
312  /* Data common to all drivers */
322 
323  /* * * */
324  /* Data used by the GL drivers */
325  struct
326  {
327  int red_size;
339  int stereo;
345  int flags;
351  int no_error;
354  char driver_path[256];
355  void *dll_handle;
356  } gl_config;
357 
358  /* * * */
359  /* Cache current GL context; don't call the OS when it hasn't changed. */
360  /* We have the global pointers here so Cocoa continues to work the way
361  it always has, and the thread-local storage for the general case.
362  */
367 
368  /* * * */
369  /* Data used by the Vulkan drivers */
370  struct
371  {
375  char loader_path[256];
377  } vulkan_config;
378 
379  /* * * */
380  /* Data private to this driver */
381  void *driverdata;
383 
384 #if SDL_VIDEO_OPENGL_EGL
385  struct SDL_EGL_VideoData *egl_data;
386 #endif
387 
388 #if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
389  struct SDL_PrivateGLESData *gles_data;
390 #endif
391 
392  /* * * */
393  /* The function used to dispose of this structure */
395 };
396 
397 typedef struct VideoBootStrap
398 {
399  const char *name;
400  const char *desc;
401  int (*available) (void);
402  SDL_VideoDevice *(*create) (int devindex);
404 
405 /* Not all of these are available in a given build. Use #ifdefs, etc. */
425 
426 extern SDL_VideoDevice *SDL_GetVideoDevice(void);
427 extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
428 extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display);
430 extern int SDL_GetIndexOfDisplay(SDL_VideoDisplay *display);
431 extern SDL_VideoDisplay *SDL_GetDisplay(int displayIndex);
433 extern void *SDL_GetDisplayDriverData( int displayIndex );
434 
435 extern void SDL_GL_DeduceMaxSupportedESProfile(int* major, int* minor);
436 
438 extern SDL_bool SDL_HasWindows(void);
439 
440 extern void SDL_OnWindowShown(SDL_Window * window);
441 extern void SDL_OnWindowHidden(SDL_Window * window);
442 extern void SDL_OnWindowResized(SDL_Window * window);
444 extern void SDL_OnWindowRestored(SDL_Window * window);
445 extern void SDL_OnWindowEnter(SDL_Window * window);
446 extern void SDL_OnWindowLeave(SDL_Window * window);
449 extern void SDL_UpdateWindowGrab(SDL_Window * window);
450 extern SDL_Window * SDL_GetFocusWindow(void);
451 
452 extern SDL_bool SDL_ShouldAllowTopmost(void);
453 
454 extern float SDL_ComputeDiagonalDPI(int hpix, int vpix, float hinches, float vinches);
455 
456 extern void SDL_OnApplicationWillTerminate(void);
458 extern void SDL_OnApplicationWillResignActive(void);
459 extern void SDL_OnApplicationDidEnterBackground(void);
460 extern void SDL_OnApplicationWillEnterForeground(void);
461 extern void SDL_OnApplicationDidBecomeActive(void);
462 
463 extern void SDL_ToggleDragAndDropSupport(void);
464 
465 #endif /* SDL_sysvideo_h_ */
466 
467 /* vi: set ts=4 sw=4 expandtab: */