src/video/x11/SDL_x11video.h
author Ryan C. Gordon <icculus@icculus.org>
Thu, 09 Apr 2015 22:28:37 -0400
changeset 9541 cf8fab52e33b
parent 9319 ad4f430cc9f5
child 9619 b94b6d0bff0f
permissions -rw-r--r--
Merged Alex Szpakowski's iOS-improvement branch to default.

Fixes Bugzilla #2798.
Fixes Bugzilla #2212.
Fixes Bugzilla #2826.
Fixes Bugzilla #2661.
Fixes Bugzilla #1885.
Fixes Bugzilla #1578.
Fixes Bugzilla #2751.

(whew!)

Notable changes, from Alex's notes:

- The SDL_WINDOW_ALLOW_HIGHDPI flag is now needed (along with SDL_GL_GetDrawableSize or SDL_GetRendererOutputSize) to use Retina / high DPI resolutions, bringing SDL’s Retina-related behavior on iOS in line with Mac OS X. Window dimensions and display modes are now in the “points” (non-high DPI) coordinate system rather than pixels, whereas SDL_GL_GetDrawableSize is in pixels.

- Reworked the custom extended launch screen code:
- It now hides after the first SDL_PumpEvents call rather than SDL_CreateWindow, and it fades out in a similar manner to the system launch screen behavior.
- It now mirrors the system launch screen behavior when deciding which image to display: it falls back to using the Launch Images dictionary in Info.plist if the iOS 8+ launch screen nib isn’t available, and if the Launch Images dictionary doesn’t exist it uses the old standard launch image names.
- The extended launch screen can now be disabled via the SDL_IPHONE_LAUNCHSCREEN define in SDL_config_iphoneos.h.

- Added support for SDL_HINT_ACCELEROMETER_AS_JOYSTICK.

- Added access to a window view's renderbuffer and framebuffer to syswm.

- Added OpenGL ES debug labels for the Renderbuffer and Framebuffer Objects created with SDL_GL_CreateContext.

- Added support for sRGB OpenGL ES contexts on iOS 7+.

- Updated OpenGL ES contexts to support native-resolution rendering (when SDL_WINDOW_ALLOW_HIGHDPI is enabled) on the iPhone 6 Plus, i.e. 1080x1920 rather than 1242x2208.

- Updated SDL_GL_CreateContext, SDL_GL_SwapWindow, SDL_GL_MakeCurrent, and SDL_GL_DeleteContext to be more robust.

- Updated SDL windows to display a UIView at all times, even when an OpenGL context is not active. This allows rotation, touch events, and other windowing-related events to work properly without an active OpenGL context. It also makes it easier to use SDL_GetWindowWMInfo after creating a SDL window.

- Updated the iOS-specific Objective-C code to use cleaner and more modern language features and APIs, including ARC instead of manual reference counting.

- Updated SDL_HINT_ORIENTATIONS to allow disabling custom orientations if the hint is set with no valid orientation names.

- Fixed several rotation and orientation bugs with windows and display modes, especially in iOS 8+.

- Fixed SDL_SetWindowFullscreen failing to update the status bar visibility on iOS 7+.

- Fixed the orientation of the offset applied to the window’s view when the onscreen keyboard is shown in iOS 8+.

- Fixed SDL_IsScreenKeyboardShown (patch by Phil Hassey.)

- Fixed several major memory leaks caused by missing autorelease pool blocks in the iOS-specific Objective-C code.

- Removed several dead code paths.

- The iOS 7 SDK (Xcode 5) or newer is now required to build SDL for iOS.
     1 /*
     2   Simple DirectMedia Layer
     3   Copyright (C) 1997-2014 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_x11video_h
    24 #define _SDL_x11video_h
    25 
    26 #include "SDL_keycode.h"
    27 
    28 #include "../SDL_sysvideo.h"
    29 
    30 #include <X11/Xlib.h>
    31 #include <X11/Xutil.h>
    32 #include <X11/Xatom.h>
    33 
    34 #if SDL_VIDEO_DRIVER_X11_XCURSOR
    35 #include <X11/Xcursor/Xcursor.h>
    36 #endif
    37 #if SDL_VIDEO_DRIVER_X11_XINERAMA
    38 #include <X11/extensions/Xinerama.h>
    39 #endif
    40 #if SDL_VIDEO_DRIVER_X11_XINPUT2
    41 #include <X11/extensions/XInput2.h>
    42 #endif
    43 #if SDL_VIDEO_DRIVER_X11_XRANDR
    44 #include <X11/extensions/Xrandr.h>
    45 #endif
    46 #if SDL_VIDEO_DRIVER_X11_XSCRNSAVER
    47 #include <X11/extensions/scrnsaver.h>
    48 #endif
    49 #if SDL_VIDEO_DRIVER_X11_XSHAPE
    50 #include <X11/extensions/shape.h>
    51 #endif
    52 #if SDL_VIDEO_DRIVER_X11_XVIDMODE
    53 #include <X11/extensions/xf86vmode.h>
    54 #endif
    55 
    56 #include "../../core/linux/SDL_dbus.h"
    57 #include "../../core/linux/SDL_ibus.h"
    58 
    59 #include "SDL_x11dyn.h"
    60 
    61 #include "SDL_x11clipboard.h"
    62 #include "SDL_x11events.h"
    63 #include "SDL_x11keyboard.h"
    64 #include "SDL_x11modes.h"
    65 #include "SDL_x11mouse.h"
    66 #include "SDL_x11opengl.h"
    67 #include "SDL_x11window.h"
    68 
    69 /* Private display data */
    70 
    71 typedef struct SDL_VideoData
    72 {
    73     Display *display;
    74     char *classname;
    75     pid_t pid;
    76     XIM im;
    77     Uint32 screensaver_activity;
    78     int numwindows;
    79     SDL_WindowData **windowlist;
    80     int windowlistlength;
    81 
    82     /* This is true for ICCCM2.0-compliant window managers */
    83     SDL_bool net_wm;
    84 
    85     /* Useful atoms */
    86     Atom WM_PROTOCOLS;
    87     Atom WM_DELETE_WINDOW;
    88     Atom _NET_WM_STATE;
    89     Atom _NET_WM_STATE_HIDDEN;
    90     Atom _NET_WM_STATE_FOCUSED;
    91     Atom _NET_WM_STATE_MAXIMIZED_VERT;
    92     Atom _NET_WM_STATE_MAXIMIZED_HORZ;
    93     Atom _NET_WM_STATE_FULLSCREEN;
    94     Atom _NET_WM_ALLOWED_ACTIONS;
    95     Atom _NET_WM_ACTION_FULLSCREEN;
    96     Atom _NET_WM_NAME;
    97     Atom _NET_WM_ICON_NAME;
    98     Atom _NET_WM_ICON;
    99     Atom _NET_WM_PING;
   100     Atom _NET_ACTIVE_WINDOW;
   101     Atom UTF8_STRING;
   102     Atom PRIMARY;
   103     Atom XdndEnter;
   104     Atom XdndPosition;
   105     Atom XdndStatus;
   106     Atom XdndTypeList;
   107     Atom XdndActionCopy;
   108     Atom XdndDrop;
   109     Atom XdndFinished;
   110     Atom XdndSelection;
   111 
   112     SDL_Scancode key_layout[256];
   113     SDL_bool selection_waiting;
   114 
   115     Uint32 last_mode_change_deadline;
   116 } SDL_VideoData;
   117 
   118 extern SDL_bool X11_UseDirectColorVisuals(void);
   119 
   120 #endif /* _SDL_x11video_h */
   121 
   122 /* vi: set ts=4 sw=4 expandtab: */