2 Simple DirectMedia Layer
3 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
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.
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:
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.
21 #include "../SDL_internal.h"
23 #ifndef _SDL_sysvideo_h
24 #define _SDL_sysvideo_h
26 #include "SDL_messagebox.h"
27 #include "SDL_shape.h"
28 #include "SDL_thread.h"
30 /* The SDL video driver */
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;
37 /* Define the SDL window-shaper structure */
38 struct SDL_WindowShaper
40 /* The window associated with the shaper */
43 /* The user's specified coordinates for the window, for once we give it a shape. */
46 /* The parameters for shape calculation. */
47 SDL_WindowShapeMode mode;
49 /* Has this window been assigned a shape? */
55 /* Define the SDL shape driver structure */
56 struct SDL_ShapeDriver
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);
63 typedef struct SDL_WindowUserData
67 struct SDL_WindowUserData *next;
70 /* Define the SDL window structure, corresponding to toplevel windows */
82 Uint32 last_fullscreen_flags;
84 /* Stored position and size for windowed mode */
87 SDL_DisplayMode fullscreen_mode;
91 Uint16 *saved_gamma; /* (just offset into gamma) */
94 SDL_bool surface_valid;
97 SDL_bool is_destroying;
99 SDL_WindowShaper *shaper;
101 SDL_HitTest hit_test;
104 SDL_WindowUserData *data;
111 #define FULLSCREEN_VISIBLE(W) \
112 (((W)->flags & SDL_WINDOW_FULLSCREEN) && \
113 ((W)->flags & SDL_WINDOW_SHOWN) && \
114 !((W)->flags & SDL_WINDOW_MINIMIZED))
117 * Define the SDL display structure This corresponds to physical monitors
118 * attached to the system.
120 struct SDL_VideoDisplay
123 int max_display_modes;
124 int num_display_modes;
125 SDL_DisplayMode *display_modes;
126 SDL_DisplayMode desktop_mode;
127 SDL_DisplayMode current_mode;
129 SDL_Window *fullscreen_window;
131 SDL_VideoDevice *device;
136 /* Forward declaration */
137 struct SDL_SysWMinfo;
139 /* Define the SDL video driver structure */
140 #define _THIS SDL_VideoDevice *_this
142 struct SDL_VideoDevice
145 /* The name of this video driver */
149 /* Initialization/Query functions */
152 * Initialize the native video subsystem, filling in the list of
153 * displays for this driver, returning 0 or -1 if there's an error.
155 int (*VideoInit) (_THIS);
158 * Reverse the effects VideoInit() -- called if VideoInit() fails or
159 * if the application is shutting down the video subsystem.
161 void (*VideoQuit) (_THIS);
169 * Get the bounds of a display
171 int (*GetDisplayBounds) (_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
174 * Get the dots/pixels-per-inch of a display
176 int (*GetDisplayDPI) (_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdpi, float * vdpi);
179 * Get a list of the available display modes for a display.
181 void (*GetDisplayModes) (_THIS, SDL_VideoDisplay * display);
184 * Setting the display mode is independent of creating windows, so
185 * when the display mode is changed, all existing windows should have
186 * their data updated accordingly, including the display surfaces
187 * associated with them.
189 int (*SetDisplayMode) (_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
195 int (*CreateWindow) (_THIS, SDL_Window * window);
196 int (*CreateWindowFrom) (_THIS, SDL_Window * window, const void *data);
197 void (*SetWindowTitle) (_THIS, SDL_Window * window);
198 void (*SetWindowIcon) (_THIS, SDL_Window * window, SDL_Surface * icon);
199 void (*SetWindowPosition) (_THIS, SDL_Window * window);
200 void (*SetWindowSize) (_THIS, SDL_Window * window);
201 void (*SetWindowMinimumSize) (_THIS, SDL_Window * window);
202 void (*SetWindowMaximumSize) (_THIS, SDL_Window * window);
203 void (*ShowWindow) (_THIS, SDL_Window * window);
204 void (*HideWindow) (_THIS, SDL_Window * window);
205 void (*RaiseWindow) (_THIS, SDL_Window * window);
206 void (*MaximizeWindow) (_THIS, SDL_Window * window);
207 void (*MinimizeWindow) (_THIS, SDL_Window * window);
208 void (*RestoreWindow) (_THIS, SDL_Window * window);
209 void (*SetWindowBordered) (_THIS, SDL_Window * window, SDL_bool bordered);
210 void (*SetWindowFullscreen) (_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
211 int (*SetWindowGammaRamp) (_THIS, SDL_Window * window, const Uint16 * ramp);
212 int (*GetWindowGammaRamp) (_THIS, SDL_Window * window, Uint16 * ramp);
213 void (*SetWindowGrab) (_THIS, SDL_Window * window, SDL_bool grabbed);
214 void (*DestroyWindow) (_THIS, SDL_Window * window);
215 int (*CreateWindowFramebuffer) (_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch);
216 int (*UpdateWindowFramebuffer) (_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects);
217 void (*DestroyWindowFramebuffer) (_THIS, SDL_Window * window);
218 void (*OnWindowEnter) (_THIS, SDL_Window * window);
222 * Shaped-window functions
224 SDL_ShapeDriver shape_driver;
226 /* Get some platform dependent window information */
227 SDL_bool(*GetWindowWMInfo) (_THIS, SDL_Window * window,
228 struct SDL_SysWMinfo * info);
234 int (*GL_LoadLibrary) (_THIS, const char *path);
235 void *(*GL_GetProcAddress) (_THIS, const char *proc);
236 void (*GL_UnloadLibrary) (_THIS);
237 SDL_GLContext(*GL_CreateContext) (_THIS, SDL_Window * window);
238 int (*GL_MakeCurrent) (_THIS, SDL_Window * window, SDL_GLContext context);
239 void (*GL_GetDrawableSize) (_THIS, SDL_Window * window, int *w, int *h);
240 int (*GL_SetSwapInterval) (_THIS, int interval);
241 int (*GL_GetSwapInterval) (_THIS);
242 void (*GL_SwapWindow) (_THIS, SDL_Window * window);
243 void (*GL_DeleteContext) (_THIS, SDL_GLContext context);
247 * Event manager functions
249 void (*PumpEvents) (_THIS);
251 /* Suspend the screensaver */
252 void (*SuspendScreenSaver) (_THIS);
255 void (*StartTextInput) (_THIS);
256 void (*StopTextInput) (_THIS);
257 void (*SetTextInputRect) (_THIS, SDL_Rect *rect);
259 /* Screen keyboard */
260 SDL_bool (*HasScreenKeyboardSupport) (_THIS);
261 void (*ShowScreenKeyboard) (_THIS, SDL_Window *window);
262 void (*HideScreenKeyboard) (_THIS, SDL_Window *window);
263 SDL_bool (*IsScreenKeyboardShown) (_THIS, SDL_Window *window);
266 int (*SetClipboardText) (_THIS, const char *text);
267 char * (*GetClipboardText) (_THIS);
268 SDL_bool (*HasClipboardText) (_THIS);
271 int (*ShowMessageBox) (_THIS, const SDL_MessageBoxData *messageboxdata, int *buttonid);
274 int (*SetWindowHitTest)(SDL_Window * window, SDL_bool enabled);
277 /* Data common to all drivers */
278 SDL_bool suspend_screensaver;
280 SDL_VideoDisplay *displays;
282 SDL_Window *grabbed_window;
284 Uint32 next_object_id;
285 char * clipboard_text;
288 /* Data used by the GL drivers */
300 int accum_green_size;
302 int accum_alpha_size;
304 int multisamplebuffers;
305 int multisamplesamples;
311 int share_with_current_context;
312 int release_behavior;
313 int framebuffer_srgb_capable;
314 int retained_backing;
316 char driver_path[256];
319 int context_priority_level;
324 /* Cache current GL context; don't call the OS when it hasn't changed. */
325 /* We have the global pointers here so Cocoa continues to work the way
326 it always has, and the thread-local storage for the general case.
328 SDL_Window *current_glwin;
329 SDL_GLContext current_glctx;
330 SDL_TLSID current_glwin_tls;
331 SDL_TLSID current_glctx_tls;
334 /* Data private to this driver */
336 struct SDL_GLDriverData *gl_data;
338 #if SDL_VIDEO_OPENGL_EGL
339 struct SDL_EGL_VideoData *egl_data;
342 #if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
343 struct SDL_PrivateGLESData *gles_data;
347 /* The function used to dispose of this structure */
348 void (*free) (_THIS);
351 /* Data used by the Vulkan drivers */
356 SDL_bool (*vulkan_GetInstanceExtensions) (_THIS, const char* driver, unsigned int* count, char** names);
357 SDL_bool (*vulkan_CreateSurface) (_THIS, SDL_Window* window, SDL_vulkanInstance instance, SDL_vulkanSurface* surface);
358 int (*vulkan_LoadLibrary) (_THIS, const char *path);
361 struct SDL_vulkan_Data *vk_data;
365 void (*GetWindowSize) (_THIS, SDL_Window * window, int *w, int *h);
369 typedef struct VideoBootStrap
373 int (*available) (void);
374 SDL_VideoDevice *(*create) (int devindex);
377 #if SDL_VIDEO_DRIVER_COCOA
378 extern VideoBootStrap COCOA_bootstrap;
380 #if SDL_VIDEO_DRIVER_X11
381 extern VideoBootStrap X11_bootstrap;
383 #if SDL_VIDEO_DRIVER_MIR
384 extern VideoBootStrap MIR_bootstrap;
386 #if SDL_VIDEO_DRIVER_DIRECTFB
387 extern VideoBootStrap DirectFB_bootstrap;
389 #if SDL_VIDEO_DRIVER_WINDOWS
390 extern VideoBootStrap WINDOWS_bootstrap;
392 #if SDL_VIDEO_DRIVER_WINRT
393 extern VideoBootStrap WINRT_bootstrap;
395 #if SDL_VIDEO_DRIVER_HAIKU
396 extern VideoBootStrap HAIKU_bootstrap;
398 #if SDL_VIDEO_DRIVER_PANDORA
399 extern VideoBootStrap PND_bootstrap;
401 #if SDL_VIDEO_DRIVER_UIKIT
402 extern VideoBootStrap UIKIT_bootstrap;
404 #if SDL_VIDEO_DRIVER_ANDROID
405 extern VideoBootStrap Android_bootstrap;
407 #if SDL_VIDEO_DRIVER_PSP
408 extern VideoBootStrap PSP_bootstrap;
410 #if SDL_VIDEO_DRIVER_RPI
411 extern VideoBootStrap RPI_bootstrap;
413 #if SDL_VIDEO_DRIVER_DUMMY
414 extern VideoBootStrap DUMMY_bootstrap;
416 #if SDL_VIDEO_DRIVER_WAYLAND
417 extern VideoBootStrap Wayland_bootstrap;
419 #if SDL_VIDEO_DRIVER_NACL
420 extern VideoBootStrap NACL_bootstrap;
422 #if SDL_VIDEO_DRIVER_VIVANTE
423 extern VideoBootStrap VIVANTE_bootstrap;
425 #if SDL_VIDEO_DRIVER_EMSCRIPTEN
426 extern VideoBootStrap Emscripten_bootstrap;
428 #if SDL_VIDEO_DRIVER_TIZEN
429 extern VideoBootStrap TIZEN_bootstrap;
432 extern SDL_VideoDevice *SDL_GetVideoDevice(void);
433 extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
434 extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display);
435 extern SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode * mode);
436 extern SDL_VideoDisplay *SDL_GetDisplayForWindow(SDL_Window *window);
437 extern void *SDL_GetDisplayDriverData( int displayIndex );
439 extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
441 extern void SDL_OnWindowShown(SDL_Window * window);
442 extern void SDL_OnWindowHidden(SDL_Window * window);
443 extern void SDL_OnWindowResized(SDL_Window * window);
444 extern void SDL_OnWindowMinimized(SDL_Window * window);
445 extern void SDL_OnWindowRestored(SDL_Window * window);
446 extern void SDL_OnWindowEnter(SDL_Window * window);
447 extern void SDL_OnWindowLeave(SDL_Window * window);
448 extern void SDL_OnWindowFocusGained(SDL_Window * window);
449 extern void SDL_OnWindowFocusLost(SDL_Window * window);
450 extern void SDL_UpdateWindowGrab(SDL_Window * window);
451 extern SDL_Window * SDL_GetFocusWindow(void);
453 extern SDL_bool SDL_ShouldAllowTopmost(void);
455 extern float SDL_ComputeDiagonalDPI(int hpix, int vpix, float hinches, float vinches);
457 #endif /* _SDL_sysvideo_h */
459 /* vi: set ts=4 sw=4 expandtab: */