Merged default into iOS-improvements iOS-improvements
authorAlex Szpakowski <slime73@gmail.com>
Wed, 08 Apr 2015 15:35:07 -0300
branchiOS-improvements
changeset 9537ff30c198864e
parent 9536 3c87b8f9dc58
parent 9479 daeaa68d7acf
child 9538 3f4340777b65
Merged default into iOS-improvements
src/video/SDL_video.c
src/video/uikit/SDL_uikitwindow.m
     1.1 --- a/CMakeLists.txt	Mon Apr 06 15:26:37 2015 -0300
     1.2 +++ b/CMakeLists.txt	Wed Apr 08 15:35:07 2015 -0300
     1.3 @@ -243,7 +243,7 @@
     1.4  set_option(VIDEO_DIRECTFB      "Use DirectFB video driver" OFF)
     1.5  dep_option(DIRECTFB_SHARED     "Dynamically load directfb support" ON "VIDEO_DIRECTFB" OFF)
     1.6  set_option(FUSIONSOUND         "Use FusionSound audio driver" OFF)
     1.7 -dep_option(FUSIONSOUND_SHARED  "Dynamically load fusionsound audio support" ON "FUSIONSOUND_SHARED" OFF)
     1.8 +dep_option(FUSIONSOUND_SHARED  "Dynamically load fusionsound audio support" ON "FUSIONSOUND" OFF)
     1.9  set_option(VIDEO_DUMMY         "Use dummy video driver" ON)
    1.10  set_option(VIDEO_OPENGL        "Include OpenGL support" ON)
    1.11  set_option(VIDEO_OPENGLES      "Include OpenGL ES support" ON)
     2.1 --- a/android-project/src/org/libsdl/app/SDLActivity.java	Mon Apr 06 15:26:37 2015 -0300
     2.2 +++ b/android-project/src/org/libsdl/app/SDLActivity.java	Wed Apr 08 15:35:07 2015 -0300
     2.3 @@ -114,6 +114,8 @@
     2.4      // Setup
     2.5      @Override
     2.6      protected void onCreate(Bundle savedInstanceState) {
     2.7 +        Log.v("SDL", "Device: " + android.os.Build.DEVICE);                     
     2.8 +        Log.v("SDL", "Model: " + android.os.Build.MODEL);
     2.9          Log.v("SDL", "onCreate():" + mSingleton);
    2.10          super.onCreate(savedInstanceState);
    2.11          
     3.1 --- a/cmake/macros.cmake	Mon Apr 06 15:26:37 2015 -0300
     3.2 +++ b/cmake/macros.cmake	Wed Apr 08 15:35:07 2015 -0300
     3.3 @@ -66,7 +66,7 @@
     3.4  
     3.5  macro(CHECK_OBJC_SOURCE_COMPILES SOURCE VAR)
     3.6    set(PREV_REQUIRED_DEFS "${CMAKE_REQUIRED_DEFINITIONS}")
     3.7 -  set(CMAKE_REQUIRED_DEFINITIONS "-ObjC ${PREV_REQUIRED_DEFS}")
     3.8 +  set(CMAKE_REQUIRED_DEFINITIONS "-x objective-c ${PREV_REQUIRED_DEFS}")
     3.9    CHECK_C_SOURCE_COMPILES(${SOURCE} ${VAR})
    3.10    set(CMAKE_REQUIRED_DEFINITIONS "${PREV_REQUIRED_DEFS}")
    3.11  endmacro()
     4.1 --- a/docs/README-gesture.md	Mon Apr 06 15:26:37 2015 -0300
     4.2 +++ b/docs/README-gesture.md	Wed Apr 08 15:35:07 2015 -0300
     4.3 @@ -1,6 +1,6 @@
     4.4  Dollar Gestures
     4.5  ===========================================================================
     4.6 -SDL Provides an implementation of the $1 gesture recognition system. This allows for recording, saving, loading, and performing single stroke gestures.
     4.7 +SDL provides an implementation of the $1 gesture recognition system. This allows for recording, saving, loading, and performing single stroke gestures.
     4.8  
     4.9  Gestures can be performed with any number of fingers (the centroid of the fingers must follow the path of the gesture), but the number of fingers must be constant (a finger cannot go down in the middle of a gesture). The path of a gesture is considered the path from the time when the final finger went down, to the first time any finger comes up. 
    4.10  
     5.1 --- a/include/SDL_assert.h	Mon Apr 06 15:26:37 2015 -0300
     5.2 +++ b/include/SDL_assert.h	Wed Apr 08 15:35:07 2015 -0300
     5.3 @@ -86,8 +86,10 @@
     5.4  disable assertions.
     5.5  */
     5.6  
     5.7 +/* "while (0,0)" fools Microsoft's compiler's /W4 warning level into thinking
     5.8 +    this condition isn't constant. And looks like an owl's face! */
     5.9  #ifdef _MSC_VER  /* stupid /W4 warnings. */
    5.10 -#define SDL_NULL_WHILE_LOOP_CONDITION (-1 == __LINE__)
    5.11 +#define SDL_NULL_WHILE_LOOP_CONDITION (0,0)
    5.12  #else
    5.13  #define SDL_NULL_WHILE_LOOP_CONDITION (0)
    5.14  #endif
     6.1 --- a/include/SDL_stdinc.h	Mon Apr 06 15:26:37 2015 -0300
     6.2 +++ b/include/SDL_stdinc.h	Wed Apr 08 15:35:07 2015 -0300
     6.3 @@ -226,7 +226,7 @@
     6.4  #define SDL_PRINTF_VARARG_FUNC( fmtargnumber )
     6.5  #define SDL_SCANF_VARARG_FUNC( fmtargnumber )
     6.6  #else
     6.7 -#if _MSC_VER >= 1600 /* VS 2010 and above */
     6.8 +#if defined(_MSC_VER) && (_MSC_VER >= 1600) /* VS 2010 and above */
     6.9  #include <sal.h>
    6.10  
    6.11  #define SDL_IN_BYTECAP(x) _In_bytecount_(x)
     7.1 --- a/src/core/linux/SDL_ibus.c	Mon Apr 06 15:26:37 2015 -0300
     7.2 +++ b/src/core/linux/SDL_ibus.c	Wed Apr 08 15:35:07 2015 -0300
     7.3 @@ -479,8 +479,10 @@
     7.4          inotify_wd = inotify_add_watch(inotify_fd, addr_file, IN_CREATE | IN_MODIFY);
     7.5          SDL_free(addr_file);
     7.6          
     7.7 -        result = IBus_SetupConnection(dbus, addr);
     7.8 -        SDL_free(addr);
     7.9 +        if (addr) {
    7.10 +            result = IBus_SetupConnection(dbus, addr);
    7.11 +            SDL_free(addr);
    7.12 +        }
    7.13      }
    7.14      
    7.15      return result;
     8.1 --- a/src/joystick/windows/SDL_dinputjoystick.c	Mon Apr 06 15:26:37 2015 -0300
     8.2 +++ b/src/joystick/windows/SDL_dinputjoystick.c	Wed Apr 08 15:35:07 2015 -0300
     8.3 @@ -340,6 +340,11 @@
     8.4  {
     8.5      JoyStick_DeviceData *pNewJoystick;
     8.6      JoyStick_DeviceData *pPrevJoystick = NULL;
     8.7 +    const DWORD devtype = (pdidInstance->dwDevType & 0xFF);
     8.8 +
     8.9 +    if ((devtype != DI8DEVTYPE_JOYSTICK) && (devtype != DI8DEVTYPE_GAMEPAD)) {
    8.10 +        return DIENUM_CONTINUE;  /* Ignore touchpads, etc. */
    8.11 +    }
    8.12  
    8.13      if (SDL_IsXInputDevice(&pdidInstance->guidProduct)) {
    8.14          return DIENUM_CONTINUE;  /* ignore XInput devices here, keep going. */
     9.1 --- a/src/video/SDL_video.c	Mon Apr 06 15:26:37 2015 -0300
     9.2 +++ b/src/video/SDL_video.c	Wed Apr 08 15:35:07 2015 -0300
     9.3 @@ -1265,6 +1265,12 @@
     9.4          h = 1;
     9.5      }
     9.6  
     9.7 +    /* Some platforms blow up if the windows are too large. Raise it later? */
     9.8 +    if ((w > 16384) || (h > 16384)) {
     9.9 +        SDL_SetError("Window is too large.");
    9.10 +        return NULL;
    9.11 +    }
    9.12 +
    9.13      /* Some platforms have OpenGL enabled by default */
    9.14  #if (SDL_VIDEO_OPENGL && __MACOSX__) || __IPHONEOS__ || __ANDROID__ || __NACL__
    9.15      flags |= SDL_WINDOW_OPENGL;
    9.16 @@ -1501,11 +1507,8 @@
    9.17          return;
    9.18      }
    9.19      SDL_free(window->title);
    9.20 -    if (title && *title) {
    9.21 -        window->title = SDL_strdup(title);
    9.22 -    } else {
    9.23 -        window->title = NULL;
    9.24 -    }
    9.25 +
    9.26 +    window->title = SDL_strdup(title ? title : "");
    9.27  
    9.28      if (_this->SetWindowTitle) {
    9.29          _this->SetWindowTitle(_this, window);
    10.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Mon Apr 06 15:26:37 2015 -0300
    10.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Wed Apr 08 15:35:07 2015 -0300
    10.3 @@ -1189,16 +1189,9 @@
    10.4  {
    10.5      NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    10.6      NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
    10.7 -    NSString *string;
    10.8 -
    10.9 -    if(window->title) {
   10.10 -        string = [[NSString alloc] initWithUTF8String:window->title];
   10.11 -    } else {
   10.12 -        string = [[NSString alloc] init];
   10.13 -    }
   10.14 +    NSString *string = [[NSString alloc] initWithUTF8String:window->title];
   10.15      [nswindow setTitle:string];
   10.16      [string release];
   10.17 -
   10.18      [pool release];
   10.19  }
   10.20  
    11.1 --- a/src/video/directfb/SDL_DirectFB_WM.c	Mon Apr 06 15:26:37 2015 -0300
    11.2 +++ b/src/video/directfb/SDL_DirectFB_WM.c	Wed Apr 08 15:35:07 2015 -0300
    11.3 @@ -161,7 +161,7 @@
    11.4                 y, w - 2 * d);
    11.5  
    11.6      /* Caption */
    11.7 -    if (window->title) {
    11.8 +    if (*window->title) {
    11.9          s->SetColor(s, COLOR_EXPAND(t->font_color));
   11.10          DrawCraption(_this, s, (x - w) / 2, t->top_size + d, window->title);
   11.11      }
    12.1 --- a/src/video/uikit/SDL_uikitwindow.m	Mon Apr 06 15:26:37 2015 -0300
    12.2 +++ b/src/video/uikit/SDL_uikitwindow.m	Wed Apr 08 15:35:07 2015 -0300
    12.3 @@ -222,11 +222,7 @@
    12.4  {
    12.5      @autoreleasepool {
    12.6          SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata;
    12.7 -        if (window->title) {
    12.8 -            data.viewcontroller.title = @(window->title);
    12.9 -        } else {
   12.10 -            data.viewcontroller.title = nil;
   12.11 -        }
   12.12 +        data.viewcontroller.title = @(window->title);
   12.13      }
   12.14  }
   12.15  
    13.1 --- a/src/video/wayland/SDL_waylandmouse.c	Mon Apr 06 15:26:37 2015 -0300
    13.2 +++ b/src/video/wayland/SDL_waylandmouse.c	Wed Apr 08 15:35:07 2015 -0300
    13.3 @@ -356,8 +356,7 @@
    13.4  static int
    13.5  Wayland_SetRelativeMouseMode(SDL_bool enabled)
    13.6  {
    13.7 -    SDL_Unsupported();
    13.8 -    return -1;
    13.9 +    return SDL_Unsupported();
   13.10  }
   13.11  
   13.12  void
    14.1 --- a/src/video/wayland/SDL_waylandvideo.c	Mon Apr 06 15:26:37 2015 -0300
    14.2 +++ b/src/video/wayland/SDL_waylandvideo.c	Wed Apr 08 15:35:07 2015 -0300
    14.3 @@ -43,11 +43,6 @@
    14.4  
    14.5  #define WAYLANDVID_DRIVER_NAME "wayland"
    14.6  
    14.7 -struct wayland_mode {
    14.8 -    SDL_DisplayMode mode;
    14.9 -    struct wl_list link;
   14.10 -};
   14.11 -
   14.12  /* Initialization/Query functions */
   14.13  static int
   14.14  Wayland_VideoInit(_THIS);
   14.15 @@ -87,7 +82,7 @@
   14.16  Wayland_CreateDevice(int devindex)
   14.17  {
   14.18      SDL_VideoDevice *device;
   14.19 -    
   14.20 +
   14.21      if (!SDL_WAYLAND_LoadSymbols()) {
   14.22          return NULL;
   14.23      }
   14.24 @@ -136,27 +131,6 @@
   14.25  };
   14.26  
   14.27  static void
   14.28 -wayland_add_mode(SDL_VideoData *d, SDL_DisplayMode m)
   14.29 -{
   14.30 -    struct wayland_mode *mode;
   14.31 -
   14.32 -    /* Check for duplicate mode */
   14.33 -    wl_list_for_each(mode, &d->modes_list, link)
   14.34 -        if (mode->mode.w == m.w && mode->mode.h == m.h &&
   14.35 -	    mode->mode.refresh_rate == m.refresh_rate)
   14.36 -	    return;
   14.37 -
   14.38 -    /* Add new mode to the list */
   14.39 -    mode = (struct wayland_mode *) SDL_calloc(1, sizeof *mode);
   14.40 -
   14.41 -    if (!mode)
   14.42 -	return;
   14.43 -
   14.44 -    mode->mode = m;
   14.45 -    WAYLAND_wl_list_insert(&d->modes_list, &mode->link);
   14.46 -}
   14.47 -
   14.48 -static void
   14.49  display_handle_geometry(void *data,
   14.50                          struct wl_output *output,
   14.51                          int x, int y,
   14.52 @@ -168,55 +142,80 @@
   14.53                          int transform)
   14.54  
   14.55  {
   14.56 -    SDL_VideoData *d = data;
   14.57 +    SDL_VideoDisplay *display = data;
   14.58  
   14.59 -    d->screen_allocation.x = x;
   14.60 -    d->screen_allocation.y = y;
   14.61 +    display->name = strdup(model);
   14.62 +    display->driverdata = output;
   14.63  }
   14.64  
   14.65  static void
   14.66  display_handle_mode(void *data,
   14.67 -                    struct wl_output *wl_output,
   14.68 +                    struct wl_output *output,
   14.69                      uint32_t flags,
   14.70                      int width,
   14.71                      int height,
   14.72                      int refresh)
   14.73  {
   14.74 -    SDL_VideoData *d = data;
   14.75 +    SDL_VideoDisplay *display = data;
   14.76      SDL_DisplayMode mode;
   14.77  
   14.78      SDL_zero(mode);
   14.79      mode.w = width;
   14.80      mode.h = height;
   14.81 -    mode.refresh_rate = refresh / 1000;
   14.82 -
   14.83 -    wayland_add_mode(d, mode);
   14.84 +    mode.refresh_rate = refresh / 1000; // mHz to Hz
   14.85 +    SDL_AddDisplayMode(display, &mode);
   14.86  
   14.87      if (flags & WL_OUTPUT_MODE_CURRENT) {
   14.88 -        d->screen_allocation.width = width;
   14.89 -        d->screen_allocation.height = height;
   14.90 +        display->current_mode = mode;
   14.91 +        display->desktop_mode = mode;
   14.92      }
   14.93  }
   14.94  
   14.95 +static void
   14.96 +display_handle_done(void *data,
   14.97 +                    struct wl_output *output)
   14.98 +{
   14.99 +    SDL_VideoDisplay *display = data;
  14.100 +    SDL_AddVideoDisplay(display);
  14.101 +    SDL_free(display->name);
  14.102 +    SDL_free(display);
  14.103 +}
  14.104 +
  14.105 +static void
  14.106 +display_handle_scale(void *data,
  14.107 +                     struct wl_output *output,
  14.108 +                     int32_t factor)
  14.109 +{
  14.110 +    // TODO: do HiDPI stuff.
  14.111 +}
  14.112 +
  14.113  static const struct wl_output_listener output_listener = {
  14.114      display_handle_geometry,
  14.115 -    display_handle_mode
  14.116 +    display_handle_mode,
  14.117 +    display_handle_done,
  14.118 +    display_handle_scale
  14.119  };
  14.120  
  14.121  static void
  14.122 -shm_handle_format(void *data,
  14.123 -                  struct wl_shm *shm,
  14.124 -                  uint32_t format)
  14.125 +Wayland_add_display(SDL_VideoData *d, uint32_t id)
  14.126  {
  14.127 -    SDL_VideoData *d = data;
  14.128 +    struct wl_output *output;
  14.129 +    SDL_VideoDisplay *display = SDL_malloc(sizeof *display);
  14.130 +    if (!display) {
  14.131 +        SDL_OutOfMemory();
  14.132 +        return;
  14.133 +    }
  14.134 +    SDL_zero(*display);
  14.135  
  14.136 -    d->shm_formats |= (1 << format);
  14.137 +    output = wl_registry_bind(d->registry, id, &wl_output_interface, 2);
  14.138 +    if (!output) {
  14.139 +        SDL_SetError("Failed to retrieve output.");
  14.140 +        return;
  14.141 +    }
  14.142 +
  14.143 +    wl_output_add_listener(output, &output_listener, display);
  14.144  }
  14.145  
  14.146 -static const struct wl_shm_listener shm_listener = {
  14.147 -    shm_handle_format
  14.148 -};
  14.149 -
  14.150  #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
  14.151  static void
  14.152  windowmanager_hints(void *data, struct qt_windowmanager *qt_windowmanager,
  14.153 @@ -238,15 +237,14 @@
  14.154  
  14.155  static void
  14.156  display_handle_global(void *data, struct wl_registry *registry, uint32_t id,
  14.157 -					const char *interface, uint32_t version)
  14.158 +                      const char *interface, uint32_t version)
  14.159  {
  14.160      SDL_VideoData *d = data;
  14.161 -    
  14.162 +
  14.163      if (strcmp(interface, "wl_compositor") == 0) {
  14.164          d->compositor = wl_registry_bind(d->registry, id, &wl_compositor_interface, 1);
  14.165      } else if (strcmp(interface, "wl_output") == 0) {
  14.166 -        d->output = wl_registry_bind(d->registry, id, &wl_output_interface, 1);
  14.167 -        wl_output_add_listener(d->output, &output_listener, d);
  14.168 +        Wayland_add_display(d, id);
  14.169      } else if (strcmp(interface, "wl_seat") == 0) {
  14.170          Wayland_display_add_input(d, id);
  14.171      } else if (strcmp(interface, "wl_shell") == 0) {
  14.172 @@ -255,8 +253,7 @@
  14.173          d->shm = wl_registry_bind(registry, id, &wl_shm_interface, 1);
  14.174          d->cursor_theme = WAYLAND_wl_cursor_theme_load(NULL, 32, d->shm);
  14.175          d->default_cursor = WAYLAND_wl_cursor_theme_get_cursor(d->cursor_theme, "left_ptr");
  14.176 -        wl_shm_add_listener(d->shm, &shm_listener, d);
  14.177 -    
  14.178 +
  14.179  #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
  14.180      } else if (strcmp(interface, "qt_touch_extension") == 0) {
  14.181          Wayland_touch_create(d, id);
  14.182 @@ -272,26 +269,19 @@
  14.183  }
  14.184  
  14.185  static const struct wl_registry_listener registry_listener = {
  14.186 -	display_handle_global
  14.187 +    display_handle_global
  14.188  };
  14.189  
  14.190  int
  14.191  Wayland_VideoInit(_THIS)
  14.192  {
  14.193 -    SDL_VideoData *data;
  14.194 -    SDL_VideoDisplay display;
  14.195 -    SDL_DisplayMode mode;
  14.196 -    int i;
  14.197 -    
  14.198 -    data = malloc(sizeof *data);
  14.199 +    SDL_VideoData *data = SDL_malloc(sizeof *data);
  14.200      if (data == NULL)
  14.201          return 0;
  14.202      memset(data, 0, sizeof *data);
  14.203  
  14.204      _this->driverdata = data;
  14.205  
  14.206 -    WAYLAND_wl_list_init(&data->modes_list);
  14.207 -    
  14.208      data->display = WAYLAND_wl_display_connect(NULL);
  14.209      if (data->display == NULL) {
  14.210          SDL_SetError("Failed to connect to a Wayland display");
  14.211 @@ -299,25 +289,18 @@
  14.212      }
  14.213  
  14.214      data->registry = wl_display_get_registry(data->display);
  14.215 -   
  14.216 -    if ( data->registry == NULL) {
  14.217 +    if (data->registry == NULL) {
  14.218          SDL_SetError("Failed to get the Wayland registry");
  14.219          return 0;
  14.220      }
  14.221 -    
  14.222 +
  14.223      wl_registry_add_listener(data->registry, &registry_listener, data);
  14.224  
  14.225 -    for (i=0; i < 100; i++) {
  14.226 -        if (data->screen_allocation.width != 0 || WAYLAND_wl_display_get_error(data->display) != 0) {
  14.227 -            break;
  14.228 -        }
  14.229 -        WAYLAND_wl_display_dispatch(data->display);
  14.230 -    }
  14.231 -    
  14.232 -    if (data->screen_allocation.width == 0) {
  14.233 -        SDL_SetError("Failed while waiting for screen allocation: %d ", WAYLAND_wl_display_get_error(data->display));
  14.234 -        return 0;
  14.235 -    }
  14.236 +    // First roundtrip to receive all registry objects.
  14.237 +    WAYLAND_wl_display_roundtrip(data->display);
  14.238 +
  14.239 +    // Second roundtrip to receive all output events.
  14.240 +    WAYLAND_wl_display_roundtrip(data->display);
  14.241  
  14.242      data->xkb_context = WAYLAND_xkb_context_new(0);
  14.243      if (!data->xkb_context) {
  14.244 @@ -325,20 +308,7 @@
  14.245          return 0;
  14.246      }
  14.247  
  14.248 -    /* Use a fake 32-bpp desktop mode */
  14.249 -    mode.format = SDL_PIXELFORMAT_RGB888;
  14.250 -    mode.w = data->screen_allocation.width;
  14.251 -    mode.h = data->screen_allocation.height;
  14.252 -    mode.refresh_rate = 0;
  14.253 -    mode.driverdata = NULL;
  14.254 -    wayland_add_mode(data, mode);
  14.255 -    SDL_zero(display);
  14.256 -    display.desktop_mode = mode;
  14.257 -    display.current_mode = mode;
  14.258 -    display.driverdata = NULL;
  14.259 -    SDL_AddVideoDisplay(&display);
  14.260 -
  14.261 -    Wayland_InitMouse ();
  14.262 +    Wayland_InitMouse();
  14.263  
  14.264      WAYLAND_wl_display_flush(data->display);
  14.265  
  14.266 @@ -348,46 +318,29 @@
  14.267  static void
  14.268  Wayland_GetDisplayModes(_THIS, SDL_VideoDisplay *sdl_display)
  14.269  {
  14.270 -    SDL_VideoData *data = _this->driverdata;
  14.271 -    SDL_DisplayMode mode;
  14.272 -    struct wayland_mode *m;
  14.273 -
  14.274 -    Wayland_PumpEvents(_this);
  14.275 -
  14.276 -    wl_list_for_each(m, &data->modes_list, link) {
  14.277 -        m->mode.format = SDL_PIXELFORMAT_RGB888;
  14.278 -        SDL_AddDisplayMode(sdl_display, &m->mode);
  14.279 -        m->mode.format = SDL_PIXELFORMAT_RGBA8888;
  14.280 -        SDL_AddDisplayMode(sdl_display, &m->mode);
  14.281 -    }
  14.282 -
  14.283 -    mode.w = data->screen_allocation.width;
  14.284 -    mode.h = data->screen_allocation.height;
  14.285 -    mode.refresh_rate = 0;
  14.286 -    mode.driverdata = NULL;
  14.287 -
  14.288 -    mode.format = SDL_PIXELFORMAT_RGB888;
  14.289 -    SDL_AddDisplayMode(sdl_display, &mode);
  14.290 -    mode.format = SDL_PIXELFORMAT_RGBA8888;
  14.291 -    SDL_AddDisplayMode(sdl_display, &mode);
  14.292 +    // Nothing to do here, everything was already done in the wl_output
  14.293 +    // callbacks.
  14.294  }
  14.295  
  14.296  static int
  14.297  Wayland_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
  14.298  {
  14.299 -    return 0;
  14.300 +    return SDL_Unsupported();
  14.301  }
  14.302  
  14.303  void
  14.304  Wayland_VideoQuit(_THIS)
  14.305  {
  14.306      SDL_VideoData *data = _this->driverdata;
  14.307 -    struct wayland_mode *t, *m;
  14.308 +    int i;
  14.309  
  14.310      Wayland_FiniMouse ();
  14.311  
  14.312 -    if (data->output)
  14.313 -        wl_output_destroy(data->output);
  14.314 +    for (i = 0; i < _this->num_displays; ++i) {
  14.315 +        SDL_VideoDisplay *display = &_this->displays[i];
  14.316 +        wl_output_destroy(display->driverdata);
  14.317 +        display->driverdata = NULL;
  14.318 +    }
  14.319  
  14.320      Wayland_display_destroy_input(data);
  14.321  
  14.322 @@ -417,16 +370,13 @@
  14.323      if (data->compositor)
  14.324          wl_compositor_destroy(data->compositor);
  14.325  
  14.326 +    if (data->registry)
  14.327 +        wl_registry_destroy(data->registry);
  14.328 +
  14.329      if (data->display) {
  14.330          WAYLAND_wl_display_flush(data->display);
  14.331          WAYLAND_wl_display_disconnect(data->display);
  14.332      }
  14.333 -    
  14.334 -    wl_list_for_each_safe(m, t, &data->modes_list, link) {
  14.335 -        WAYLAND_wl_list_remove(&m->link);
  14.336 -        free(m);
  14.337 -    }
  14.338 -
  14.339  
  14.340      free(data);
  14.341      _this->driverdata = NULL;
    15.1 --- a/src/video/wayland/SDL_waylandvideo.h	Mon Apr 06 15:26:37 2015 -0300
    15.2 +++ b/src/video/wayland/SDL_waylandvideo.h	Wed Apr 08 15:35:07 2015 -0300
    15.3 @@ -40,33 +40,24 @@
    15.4      struct wl_display *display;
    15.5      struct wl_registry *registry;
    15.6      struct wl_compositor *compositor;
    15.7 -    struct wl_output *output;
    15.8      struct wl_shm *shm;
    15.9      struct wl_cursor_theme *cursor_theme;
   15.10      struct wl_cursor *default_cursor;
   15.11      struct wl_pointer *pointer;
   15.12      struct wl_shell *shell;
   15.13  
   15.14 -    struct {
   15.15 -        int32_t x, y, width, height;
   15.16 -    } screen_allocation;
   15.17 -
   15.18 -    struct wl_list modes_list;
   15.19 -
   15.20      EGLDisplay edpy;
   15.21      EGLContext context;
   15.22      EGLConfig econf;
   15.23  
   15.24      struct xkb_context *xkb_context;
   15.25      struct SDL_WaylandInput *input;
   15.26 -    
   15.27 -#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH    
   15.28 +
   15.29 +#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
   15.30      struct SDL_WaylandTouch *touch;
   15.31      struct qt_surface_extension *surface_extension;
   15.32      struct qt_windowmanager *windowmanager;
   15.33  #endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
   15.34 -
   15.35 -    uint32_t shm_formats;
   15.36  } SDL_VideoData;
   15.37  
   15.38  #endif /* _SDL_waylandvideo_h */
    16.1 --- a/src/video/wayland/SDL_waylandwindow.c	Mon Apr 06 15:26:37 2015 -0300
    16.2 +++ b/src/video/wayland/SDL_waylandwindow.c	Wed Apr 08 15:35:07 2015 -0300
    16.3 @@ -116,7 +116,7 @@
    16.4      if (window->flags & SDL_WINDOW_FULLSCREEN)
    16.5          wl_shell_surface_set_fullscreen(wind->shell_surface,
    16.6                                          WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
    16.7 -                                        0, NULL);
    16.8 +                                        0, (struct wl_output *)window->fullscreen_mode.driverdata);
    16.9      else
   16.10          wl_shell_surface_set_toplevel(wind->shell_surface);
   16.11  
   16.12 @@ -132,7 +132,7 @@
   16.13      if (fullscreen)
   16.14          wl_shell_surface_set_fullscreen(wind->shell_surface,
   16.15                                          WL_SHELL_SURFACE_FULLSCREEN_METHOD_SCALE,
   16.16 -                                        0, NULL);
   16.17 +                                        0, (struct wl_output *)_display->driverdata);
   16.18      else
   16.19          wl_shell_surface_set_toplevel(wind->shell_surface);
   16.20  
   16.21 @@ -179,17 +179,6 @@
   16.22      }
   16.23  #endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
   16.24  
   16.25 -    /**
   16.26 -     * If the user specified 0x0 as the size (turned to 1x1 by SDL_CreateWindow
   16.27 -     * in SDL_video.c), we want to make the window fill the whole screen
   16.28 -     **/
   16.29 -    if (window->w == 1) {
   16.30 -        window->w = c->screen_allocation.width;
   16.31 -    }
   16.32 -    if (window->h == 1) {
   16.33 -        window->h = c->screen_allocation.height;
   16.34 -    }
   16.35 -
   16.36      data->egl_window = WAYLAND_wl_egl_window_create(data->surface,
   16.37                                              window->w, window->h);
   16.38  
   16.39 @@ -197,8 +186,7 @@
   16.40      data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) data->egl_window);
   16.41      
   16.42      if (data->egl_surface == EGL_NO_SURFACE) {
   16.43 -        SDL_SetError("failed to create a window surface");
   16.44 -        return -1;
   16.45 +        return SDL_SetError("failed to create a window surface");;
   16.46      }
   16.47  
   16.48      if (data->shell_surface) {
    17.1 --- a/src/video/windows/SDL_windowswindow.c	Mon Apr 06 15:26:37 2015 -0300
    17.2 +++ b/src/video/windows/SDL_windowswindow.c	Wed Apr 08 15:35:07 2015 -0300
    17.3 @@ -371,14 +371,8 @@
    17.4  WIN_SetWindowTitle(_THIS, SDL_Window * window)
    17.5  {
    17.6      HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
    17.7 -    LPTSTR title;
    17.8 -
    17.9 -    if (window->title) {
   17.10 -        title = WIN_UTF8ToString(window->title);
   17.11 -    } else {
   17.12 -        title = NULL;
   17.13 -    }
   17.14 -    SetWindowText(hwnd, title ? title : TEXT(""));
   17.15 +    LPTSTR title = WIN_UTF8ToString(window->title);
   17.16 +    SetWindowText(hwnd, title);
   17.17      SDL_free(title);
   17.18  }
   17.19  
    18.1 --- a/src/video/x11/SDL_x11window.c	Mon Apr 06 15:26:37 2015 -0300
    18.2 +++ b/src/video/x11/SDL_x11window.c	Wed Apr 08 15:35:07 2015 -0300
    18.3 @@ -333,7 +333,7 @@
    18.4  
    18.5          X11_XChangeProperty(display, window, WM_HINTS, WM_HINTS, 32,
    18.6                          PropModeReplace, (unsigned char *) &MWMHints,
    18.7 -                        sizeof(MWMHints) / 4);
    18.8 +                        sizeof(MWMHints) / sizeof(long));
    18.9      } else {  /* set the transient hints instead, if necessary */
   18.10          X11_XSetTransientForHint(display, window, RootWindow(display, screen));
   18.11      }
   18.12 @@ -656,67 +656,39 @@
   18.13  {
   18.14      SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
   18.15      Display *display = data->videodata->display;
   18.16 -    XTextProperty titleprop, iconprop;
   18.17 +    XTextProperty titleprop;
   18.18      Status status;
   18.19 -    const char *title = window->title;
   18.20 -    const char *icon = NULL;
   18.21 +    const char *title = window->title ? window->title : "";
   18.22 +    char *title_locale = NULL;
   18.23  
   18.24  #ifdef X_HAVE_UTF8_STRING
   18.25      Atom _NET_WM_NAME = data->videodata->_NET_WM_NAME;
   18.26 -    Atom _NET_WM_ICON_NAME = data->videodata->_NET_WM_ICON_NAME;
   18.27  #endif
   18.28  
   18.29 -    if (title != NULL) {
   18.30 -        char *title_locale = SDL_iconv_utf8_locale(title);
   18.31 -        if (!title_locale) {
   18.32 -            SDL_OutOfMemory();
   18.33 -            return;
   18.34 -        }
   18.35 -        status = X11_XStringListToTextProperty(&title_locale, 1, &titleprop);
   18.36 -        SDL_free(title_locale);
   18.37 -        if (status) {
   18.38 -            X11_XSetTextProperty(display, data->xwindow, &titleprop, XA_WM_NAME);
   18.39 +    title_locale = SDL_iconv_utf8_locale(title);
   18.40 +    if (!title_locale) {
   18.41 +        SDL_OutOfMemory();
   18.42 +        return;
   18.43 +    }
   18.44 +
   18.45 +    status = X11_XStringListToTextProperty(&title_locale, 1, &titleprop);
   18.46 +    SDL_free(title_locale);
   18.47 +    if (status) {
   18.48 +        X11_XSetTextProperty(display, data->xwindow, &titleprop, XA_WM_NAME);
   18.49 +        X11_XFree(titleprop.value);
   18.50 +    }
   18.51 +#ifdef X_HAVE_UTF8_STRING
   18.52 +    if (SDL_X11_HAVE_UTF8) {
   18.53 +        status = X11_Xutf8TextListToTextProperty(display, (char **) &title, 1,
   18.54 +                                            XUTF8StringStyle, &titleprop);
   18.55 +        if (status == Success) {
   18.56 +            X11_XSetTextProperty(display, data->xwindow, &titleprop,
   18.57 +                                 _NET_WM_NAME);
   18.58              X11_XFree(titleprop.value);
   18.59          }
   18.60 -#ifdef X_HAVE_UTF8_STRING
   18.61 -        if (SDL_X11_HAVE_UTF8) {
   18.62 -            status =
   18.63 -                X11_Xutf8TextListToTextProperty(display, (char **) &title, 1,
   18.64 -                                            XUTF8StringStyle, &titleprop);
   18.65 -            if (status == Success) {
   18.66 -                X11_XSetTextProperty(display, data->xwindow, &titleprop,
   18.67 -                                 _NET_WM_NAME);
   18.68 -                X11_XFree(titleprop.value);
   18.69 -            }
   18.70 -        }
   18.71 +    }
   18.72  #endif
   18.73 -    }
   18.74 -    if (icon != NULL) {
   18.75 -        char *icon_locale = SDL_iconv_utf8_locale(icon);
   18.76 -        if (!icon_locale) {
   18.77 -            SDL_OutOfMemory();
   18.78 -            return;
   18.79 -        }
   18.80 -        status = X11_XStringListToTextProperty(&icon_locale, 1, &iconprop);
   18.81 -        SDL_free(icon_locale);
   18.82 -        if (status) {
   18.83 -            X11_XSetTextProperty(display, data->xwindow, &iconprop,
   18.84 -                             XA_WM_ICON_NAME);
   18.85 -            X11_XFree(iconprop.value);
   18.86 -        }
   18.87 -#ifdef X_HAVE_UTF8_STRING
   18.88 -        if (SDL_X11_HAVE_UTF8) {
   18.89 -            status =
   18.90 -                X11_Xutf8TextListToTextProperty(display, (char **) &icon, 1,
   18.91 -                                            XUTF8StringStyle, &iconprop);
   18.92 -            if (status == Success) {
   18.93 -                X11_XSetTextProperty(display, data->xwindow, &iconprop,
   18.94 -                                 _NET_WM_ICON_NAME);
   18.95 -                X11_XFree(iconprop.value);
   18.96 -            }
   18.97 -        }
   18.98 -#endif
   18.99 -    }
  18.100 +
  18.101      X11_XFlush(display);
  18.102  }
  18.103