← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/SDL2 into lp:widelands

 

GunChleoc has proposed merging lp:~widelands-dev/widelands/SDL2 into lp:widelands.

Requested reviews:
  SirVer (sirver)
Related bugs:
  Bug #1380048 in widelands: "Port to SDL2"
  https://bugs.launchpad.net/widelands/+bug/1380048

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/SDL2/+merge/239865

As discussed in the bug, this is done for merging.

I still have 3 NOCOM comments in the code that need checking out by a Mac user.
-- 
https://code.launchpad.net/~widelands-dev/widelands/SDL2/+merge/239865
Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/SDL2.
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt	2014-10-16 04:54:10 +0000
+++ CMakeLists.txt	2014-10-28 15:04:08 +0000
@@ -51,12 +51,12 @@
 find_package(Gettext REQUIRED)
 find_package(OpenGL REQUIRED)
 find_package(PNG REQUIRED)
-find_package(SDL REQUIRED)
-find_package(SDL_gfx REQUIRED)
-find_package(SDL_image REQUIRED)
-find_package(SDL_mixer REQUIRED)
-find_package(SDL_net REQUIRED)
-find_package(SDL_ttf REQUIRED)
+find_package(SDL2 REQUIRED)
+find_package(SDL2_gfx REQUIRED)
+find_package(SDL2_image REQUIRED)
+find_package(SDL2_mixer REQUIRED)
+find_package(SDL2_net REQUIRED)
+find_package(SDL2_ttf REQUIRED)
 find_package(ZLIB REQUIRED)
 
 if (APPLE OR WIN32 OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")

=== modified file 'CREDITS'
--- CREDITS	2014-07-14 10:45:44 +0000
+++ CREDITS	2014-10-28 15:04:08 +0000
@@ -8,12 +8,12 @@
 
 The Widelands Development Team thanks the following projects:
 
-    libSDL
-    libSDL_mixer
-    libSDL_net
-    libSDL_image
-    libSDL_ttf
-    * All files from SDL-Project
+    libSDL2
+    libSDL2_mixer
+    libSDL2_net
+    libSDL2_image
+    libSDL2_ttf
+    * All files from SDL2-Project
     * Project can be found at http://www.libsdl.org/
 
 

=== removed file 'cmake/Modules/FindSDL.cmake'
--- cmake/Modules/FindSDL.cmake	2010-03-28 19:12:31 +0000
+++ cmake/Modules/FindSDL.cmake	1970-01-01 00:00:00 +0000
@@ -1,186 +0,0 @@
-# Locate SDL library
-# This module defines
-# SDL_LIBRARY, the name of the library to link against
-# SDL_FOUND, if false, do not try to link to SDL
-# SDL_INCLUDE_DIR, where to find SDL.h
-#
-# This module responds to the the flag:
-# SDL_BUILDING_LIBRARY
-# If this is defined, then no SDL_main will be linked in because 
-# only applications need main().
-# Otherwise, it is assumed you are building an application and this
-# module will attempt to locate and set the the proper link flags
-# as part of the returned SDL_LIBRARY variable.
-#
-# Don't forget to include SDLmain.h and SDLmain.m your project for the 
-# OS X framework based version. (Other versions link to -lSDLmain which
-# this module will try to find on your behalf.) Also for OS X, this 
-# module will automatically add the -framework Cocoa on your behalf.
-#
-#
-# Additional Note: If you see an empty SDL_LIBRARY_TEMP in your configuration
-# and no SDL_LIBRARY, it means CMake did not find your SDL library 
-# (SDL.dll, libsdl.so, SDL.framework, etc). 
-# Set SDL_LIBRARY_TEMP to point to your SDL library, and configure again. 
-# Similarly, if you see an empty SDLMAIN_LIBRARY, you should set this value
-# as appropriate. These values are used to generate the final SDL_LIBRARY
-# variable, but when these values are unset, SDL_LIBRARY does not get created.
-#
-#
-# $SDLDIR is an environment variable that would
-# correspond to the ./configure --prefix=$SDLDIR
-# used in building SDL.
-# l.e.galup  9-20-02
-#
-# Modified by Eric Wing. 
-# Added code to assist with automated building by using environmental variables
-# and providing a more controlled/consistent search behavior.
-# Added new modifications to recognize OS X frameworks and 
-# additional Unix paths (FreeBSD, etc). 
-# Also corrected the header search path to follow "proper" SDL guidelines.
-# Added a search for SDLmain which is needed by some platforms.
-# Added a search for threads which is needed by some platforms.
-# Added needed compile switches for MinGW.
-#
-# On OSX, this will prefer the Framework version (if found) over others.
-# People will have to manually change the cache values of 
-# SDL_LIBRARY to override this selection or set the CMake environment
-# CMAKE_INCLUDE_PATH to modify the search paths.
-#
-# Note that the header path has changed from SDL/SDL.h to just SDL.h
-# This needed to change because "proper" SDL convention
-# is #include "SDL.h", not <SDL/SDL.h>. This is done for portability
-# reasons because not all systems place things in SDL/ (see FreeBSD).
-
-#=============================================================================
-# Copyright 2003-2009 Kitware, Inc.
-#
-# Distributed under the OSI-approved BSD License (the "License");
-# see accompanying file Copyright.txt for details.
-#
-# This software is distributed WITHOUT ANY WARRANTY; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the License for more information.
-#=============================================================================
-# (To distributed this file outside of CMake, substitute the full
-#  License text for the above reference.)
-
-FIND_PATH(SDL_INCLUDE_DIR SDL.h
-  HINTS
-  $ENV{SDLDIR}
-  PATH_SUFFIXES include/SDL include
-  PATHS
-  ~/Library/Frameworks
-  /Library/Frameworks
-  /usr/local/include/SDL12
-  /usr/local/include/SDL11 # FreeBSD ports
-  /usr/include/SDL12
-  /usr/include/SDL11
-  /sw # Fink
-  /opt/local # DarwinPorts
-  /opt/csw # Blastwave
-  /opt
-  C:/MinGW #Win32
-)
-#MESSAGE("SDL_INCLUDE_DIR is ${SDL_INCLUDE_DIR}")
-
-# SDL-1.1 is the name used by FreeBSD ports...
-# don't confuse it for the version number.
-FIND_LIBRARY(SDL_LIBRARY_TEMP 
-  NAMES SDL SDL-1.1
-  HINTS
-  $ENV{SDLDIR}
-  PATH_SUFFIXES lib64 lib
-  PATHS
-  /sw
-  /opt/local
-  /opt/csw
-  /opt
-  C:/MinGW
-)
-
-#MESSAGE(STATUS "SDL_LIBRARY_TEMP is ${SDL_LIBRARY_TEMP}")
-
-IF(NOT ${SDL_INCLUDE_DIR} MATCHES ".framework")
-# Non-OS X framework versions expect you to also dynamically link to 
-# SDLmain. This is mainly for Windows and OS X. Other (Unix) platforms 
-# seem to provide SDLmain for compatibility even though they don't
-# necessarily need it.
-FIND_LIBRARY(SDLMAIN_LIBRARY 
-  NAMES SDLmain SDLmain-1.1
-  HINTS
-  $ENV{SDLDIR}
-  PATH_SUFFIXES lib64 lib
-  PATHS
-  /sw
-  /opt/local
-  /opt/csw
-  /opt
-  C:/MinGW
-)
-ENDIF(NOT ${SDL_INCLUDE_DIR} MATCHES ".framework")
-
-MESSAGE(STATUS "SDLMAIN_LIBRARY is ${SDLMAIN_LIBRARY}")
-
-
-# SDL may require threads on your system.
-# The Apple build may not need an explicit flag because one of the 
-# frameworks may already provide it. 
-# But for non-OSX systems, I will use the CMake Threads package.
-IF(NOT APPLE)
-  FIND_PACKAGE(Threads)
-ENDIF(NOT APPLE)
-
-# MinGW needs an additional library, mwindows
-# It's total link flags should look like -lmingw32 -lSDLmain -lSDL -lmwindows
-# (Actually on second look, I think it only needs one of the m* libraries.)
-IF(MINGW)
-  SET(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW")
-ENDIF(MINGW)
-
-SET(SDL_FOUND "NO")
-IF(SDL_LIBRARY_TEMP)
-  # For SDLmain
-  IF(NOT SDL_BUILDING_LIBRARY)
-    IF(SDLMAIN_LIBRARY)
-      SET(SDL_LIBRARY_TEMP ${SDLMAIN_LIBRARY} ${SDL_LIBRARY_TEMP})
-    ENDIF(SDLMAIN_LIBRARY)
-  ENDIF(NOT SDL_BUILDING_LIBRARY)
-
-  # For OS X, SDL uses Cocoa as a backend so it must link to Cocoa.
-  # CMake doesn't display the -framework Cocoa string in the UI even 
-  # though it actually is there if I modify a pre-used variable.
-  # I think it has something to do with the CACHE STRING.
-  # So I use a temporary variable until the end so I can set the 
-  # "real" variable in one-shot.
-  IF(APPLE)
-    SET(SDL_LIBRARY_TEMP ${SDL_LIBRARY_TEMP} "-framework Cocoa")
-  ENDIF(APPLE)
-    
-  # For threads, as mentioned Apple doesn't need this.
-  # In fact, there seems to be a problem if I used the Threads package
-  # and try using this line, so I'm just skipping it entirely for OS X.
-  IF(NOT APPLE)
-    SET(SDL_LIBRARY_TEMP ${SDL_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT})
-  ENDIF(NOT APPLE)
-
-  # For MinGW library
-  IF(MINGW)
-    SET(SDL_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL_LIBRARY_TEMP})
-  ENDIF(MINGW)
-
-  # Set the final string here so the GUI reflects the final state.
-  SET(SDL_LIBRARY ${SDL_LIBRARY_TEMP} CACHE STRING "Where the SDL Library can be found")
-  # Set the temp variable to INTERNAL so it is not seen in the CMake GUI
-  SET(SDL_LIBRARY_TEMP "${SDL_LIBRARY_TEMP}" CACHE INTERNAL "")
-  IF(NOT SDLMAIN_LIBRARY)
-    IF(WIN32)
-      MESSAGE(FATAL_ERROR "$Could NOT find SDL (missing: SDLmain)")
-    ENDIF(WIN32)
-  ENDIF(NOT SDLMAIN_LIBRARY)
-
-  SET(SDL_FOUND "YES")
-ENDIF(SDL_LIBRARY_TEMP)
-
-#MESSAGE(STATUS "SDL_LIBRARY is ${SDL_LIBRARY}")
-

=== added file 'cmake/Modules/FindSDL2.cmake'
--- cmake/Modules/FindSDL2.cmake	1970-01-01 00:00:00 +0000
+++ cmake/Modules/FindSDL2.cmake	2014-10-28 15:04:08 +0000
@@ -0,0 +1,190 @@
+# Locate SDL2 library
+# This module defines
+# SDL2_LIBRARY, the name of the library to link against
+# SDL2_FOUND, if false, do not try to link to SDL
+# SDL2_INCLUDE_DIR, where to find SDL.h
+#
+# This module responds to the the flag:
+# SDL2_BUILDING_LIBRARY
+# If this is defined, then no SDL_main will be linked in because 
+# only applications need main().
+# Otherwise, it is assumed you are building an application and this
+# module will attempt to locate and set the the proper link flags
+# as part of the returned SDL_LIBRARY variable.
+#
+# Don't forget to include SDLmain.h and SDLmain.m your project for the 
+# OS X framework based version. (Other versions link to -lSDL2main which
+# this module will try to find on your behalf.) Also for OS X, this 
+# module will automatically add the -framework Cocoa on your behalf.
+#
+#
+# Additional Note: If you see an empty SDL2_LIBRARY_TEMP in your configuration
+# and no SDL2_LIBRARY, it means CMake did not find your SDL library 
+# (SDL.dll, libsdl.so, SDL.framework, etc). 
+# Set SDL_LIBRARY_TEMP to point to your SDL library, and configure again. 
+# Similarly, if you see an empty SDLMAIN_LIBRARY, you should set this value
+# as appropriate. These values are used to generate the final SDL_LIBRARY
+# variable, but when these values are unset, SDL_LIBRARY does not get created.
+#
+#
+# $SDL2DIR is an environment variable that would
+# correspond to the ./configure --prefix=$SDL2DIR
+# used in building SDL.
+# l.e.galup  9-20-02
+#
+# Modified by Eric Wing. 
+# Added code to assist with automated building by using environmental variables
+# and providing a more controlled/consistent search behavior.
+# Added new modifications to recognize OS X frameworks and 
+# additional Unix paths (FreeBSD, etc). 
+# Also corrected the header search path to follow "proper" SDL guidelines.
+# Added a search for SDLmain which is needed by some platforms.
+# Added a search for threads which is needed by some platforms.
+# Added needed compile switches for MinGW.
+#
+# On OSX, this will prefer the Framework version (if found) over others.
+# People will have to manually change the cache values of 
+# SDL_LIBRARY to override this selection or set the CMake environment
+# CMAKE_INCLUDE_PATH to modify the search paths.
+#
+# Note that the header path has changed from SDL/SDL.h to just SDL.h
+# This needed to change because "proper" SDL convention
+# is #include "SDL.h", not <SDL/SDL.h>. This is done for portability
+# reasons because not all systems place things in SDL/ (see FreeBSD).
+
+#=============================================================================
+# Copyright 2003-2009 Kitware, Inc.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distributed this file outside of CMake, substitute the full
+#  License text for the above reference.)
+
+FIND_PATH(SDL2_INCLUDE_DIR SDL.h
+  HINTS
+  $ENV{SDL2DIR}
+  PATH_SUFFIXES include/SDL2 include
+  PATHS
+  ~/Library/Frameworks
+  /Library/Frameworks
+  /usr/local/include/SDL2
+  /sw # Fink
+  /opt/local # DarwinPorts
+  /opt/csw # Blastwave
+  /opt
+  C:/MinGW #Win32
+)
+MESSAGE("SDL2_INCLUDE_DIR is ${SDL2_INCLUDE_DIR}")
+
+FIND_LIBRARY(SDL2_LIBRARY_TEMP 
+  NAMES SDL2
+  HINTS
+  $ENV{SDL2DIR}
+  PATH_SUFFIXES lib64 lib
+  PATHS
+  /sw
+  /opt/local
+  /opt/csw
+  /opt
+  C:/MinGW
+)
+
+#MESSAGE(STATUS "SDL2_LIBRARY_TEMP is ${SDL2_LIBRARY_TEMP}")
+
+IF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
+# Non-OS X framework versions expect you to also dynamically link to 
+# SDLmain. This is mainly for Windows and OS X. Other (Unix) platforms 
+# seem to provide SDLmain for compatibility even though they don't
+# necessarily need it.
+FIND_LIBRARY(SDL2MAIN_LIBRARY 
+  NAMES SDL2main 
+  HINTS
+  $ENV{SDL2DIR}
+  PATH_SUFFIXES lib64 lib
+  PATHS
+  /sw
+  /opt/local
+  /opt/csw
+  /opt
+  C:/MinGW
+)
+ENDIF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
+
+MESSAGE(STATUS "SDL2MAIN_LIBRARY is ${SDL2MAIN_LIBRARY}")
+
+
+# SDL may require threads on your system.
+# The Apple build may not need an explicit flag because one of the 
+# frameworks may already provide it. 
+# But for non-OSX systems, I will use the CMake Threads package.
+IF(NOT APPLE)
+  FIND_PACKAGE(Threads)
+ENDIF(NOT APPLE)
+
+# MinGW needs an additional library, mwindows
+# It's total link flags should look like -lmingw32 -lSDLmain -lSDL -lmwindows
+# (Actually on second look, I think it only needs one of the m* libraries.)
+IF(MINGW)
+  SET(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW")
+ENDIF(MINGW)
+
+
+SET(SDL2_FOUND "NO")
+IF(SDL2_LIBRARY_TEMP)
+  # For SDLmain
+  IF(NOT SDL2_BUILDING_LIBRARY)
+    IF(SDL2MAIN_LIBRARY)
+      SET(SDL2_LIBRARY_TEMP ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY_TEMP})
+    ENDIF(SDL2MAIN_LIBRARY)
+  ENDIF(NOT SDL2_BUILDING_LIBRARY)
+
+  # For OS X, SDL uses Cocoa as a backend so it must link to Cocoa.
+  # CMake doesn't display the -framework Cocoa string in the UI even 
+  # though it actually is there if I modify a pre-used variable.
+  # I think it has something to do with the CACHE STRING.
+  # So I use a temporary variable until the end so I can set the 
+  # "real" variable in one-shot.
+  IF(APPLE)
+    SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa")
+  ENDIF(APPLE)
+    
+  # For threads, as mentioned Apple doesn't need this.
+  # In fact, there seems to be a problem if I used the Threads package
+  # and try using this line, so I'm just skipping it entirely for OS X.
+  IF(NOT APPLE)
+    SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT})
+  ENDIF(NOT APPLE)
+
+  # For MinGW library
+  IF(MINGW)
+    SET(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP})
+  ENDIF(MINGW)
+
+  # Set the final string here so the GUI reflects the final state.
+  SET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found")
+  SET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP})
+
+  # Set the temp variable to INTERNAL so it is not seen in the CMake GUI
+  SET(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "")
+  IF(NOT SDL2MAIN_LIBRARY)
+    IF(WIN32)
+      MESSAGE(FATAL_ERROR "$Could NOT find SDL2 (missing: SDL2main)")
+    ENDIF(WIN32)
+  ENDIF(NOT SDL2MAIN_LIBRARY)
+  
+  IF(NOT SDL2_LIBRARY)
+    IF(WIN32)
+      MESSAGE(FATAL_ERROR "$Could NOT find SDL2 (missing: SDL2)")
+    ENDIF(WIN32)
+  ENDIF(NOT SDL2_LIBRARY)
+
+  SET(SDL2_FOUND "YES")
+ENDIF(SDL2_LIBRARY_TEMP)
+
+#MESSAGE(STATUS "SDL2_LIBRARY is ${SDL2_LIBRARY}")
+

=== added file 'cmake/Modules/FindSDL2_gfx.cmake'
--- cmake/Modules/FindSDL2_gfx.cmake	1970-01-01 00:00:00 +0000
+++ cmake/Modules/FindSDL2_gfx.cmake	2014-10-28 15:04:08 +0000
@@ -0,0 +1,60 @@
+# Locate SDL2_gfx library
+# This module defines
+# SDL2GFX_LIBRARY, the name of the library to link against
+# SDL2GFX_FOUND, if false, do not try to link to SDL2
+# SDL2GFX_INCLUDE_DIR, where to find SDL2/SDL.h
+#
+# $SDLDIR is an environment variable that would
+# correspond to the ./configure --prefix=$SDL2DIR
+# used in building SDL2.
+#
+# Created by Eric Wing. This was influenced by the FindSDL.cmake 
+# module, but with modifications to recognize OS X frameworks and 
+# additional Unix paths (FreeBSD, etc).
+
+FIND_PATH(SDL2GFX_INCLUDE_DIR SDL2_framerate.h 
+  SDL2_gfxPrimitives.h 
+  SDL2_imageFilter.h SDL2_rotozoom.h
+  HINTS
+  $ENV{SDL2GFXDIR}
+  $ENV{SDL2DIR}
+  PATH_SUFFIXES include SDL2
+  PATHS
+  ~/Library/Frameworks
+  /Library/Frameworks
+  /usr/local/include/SDL2
+  /usr/include/SDL2
+  /usr/local/include
+  /usr/include
+  /sw/include/SDL2 # Fink
+  /sw/include
+  /opt/local/include/SDL2 # DarwinPorts
+  /opt/local/include
+  /opt/csw/include/SDL2 # Blastwave
+  /opt/csw/include 
+  /opt/include/SDL2
+  /opt/include
+)
+
+FIND_LIBRARY(SDL2GFX_LIBRARY 
+  NAMES SDL2_gfx
+  HINTS
+  $ENV{SDL2GFXDIR}
+  $ENV{SDL2DIR}
+  PATH_SUFFIXES lib64 lib
+  PATHS
+  ~/Library/Frameworks
+  /Library/Frameworks
+  /usr/local
+  /usr
+  /sw
+  /opt/local
+  /opt/csw
+  /opt
+)
+
+SET(SDL2GFX_FOUND "NO")
+IF(SDL2GFX_LIBRARY AND SDL2GFX_INCLUDE_DIR)
+  SET(SDL2GFX_FOUND "YES")
+ENDIF(SDL2GFX_LIBRARY AND SDL2GFX_INCLUDE_DIR)
+

=== added file 'cmake/Modules/FindSDL2_image.cmake'
--- cmake/Modules/FindSDL2_image.cmake	1970-01-01 00:00:00 +0000
+++ cmake/Modules/FindSDL2_image.cmake	2014-10-28 15:04:08 +0000
@@ -0,0 +1,88 @@
+# - Locate SDL2_image library
+# This module defines:
+#  SDL2_IMAGE_LIBRARIES, the name of the library to link against
+#  SDL2_IMAGE_INCLUDE_DIRS, where to find the headers
+#  SDL2_IMAGE_FOUND, if false, do not try to link against
+#  SDL2_IMAGE_VERSION_STRING - human-readable string containing the version of SDL_image
+#
+# For backward compatiblity the following variables are also set:
+#  SDL2IMAGE_LIBRARY (same value as SDL2_IMAGE_LIBRARIES)
+#  SDL2IMAGE_INCLUDE_DIR (same value as SDL2_IMAGE_INCLUDE_DIRS)
+#  SDL2IMAGE_FOUND (same value as SDL2_IMAGE_FOUND)
+#
+# $SDL2DIR is an environment variable that would
+# correspond to the ./configure --prefix=$SDL2DIR
+# used in building SDL2.
+#
+# Created by Eric Wing. This was influenced by the FindSDL.cmake
+# module, but with modifications to recognize OS X frameworks and
+# additional Unix paths (FreeBSD, etc).
+
+#=============================================================================
+# Copyright 2005-2009 Kitware, Inc.
+# Copyright 2012 Benjamin Eikel
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+#  License text for the above reference.)
+
+if(NOT SDL2_IMAGE_INCLUDE_DIR AND SDL2IMAGE_INCLUDE_DIR)
+  set(SDL2_IMAGE_INCLUDE_DIR ${SDL2IMAGE_INCLUDE_DIR} CACHE PATH "directory cache
+entry initialized from old variable name")
+endif()
+find_path(SDL2_IMAGE_INCLUDE_DIR SDL_image.h
+  HINTS
+    ENV SDL2IMAGEDIR
+    ENV SDL2DIR
+  PATH_SUFFIXES include/SDL2 include
+)
+
+if(NOT SDL2_IMAGE_LIBRARY AND SDL2IMAGE_LIBRARY)
+  set(SDL2_IMAGE_LIBRARY ${SDL2IMAGE_LIBRARY} CACHE FILEPATH "file cache entry
+initialized from old variable name")
+endif()
+find_library(SDL2_IMAGE_LIBRARY
+  NAMES SDL2_image
+  HINTS
+    ENV SDL2IMAGEDIR
+    ENV SDL2DIR
+  PATH_SUFFIXES lib
+)
+
+if(SDL2_IMAGE_INCLUDE_DIR AND EXISTS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h")
+  file(STRINGS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h" SDL_IMAGE_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_IMAGE_MAJOR_VERSION[ \t]+[0-9]+$")
+  file(STRINGS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h" SDL_IMAGE_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_IMAGE_MINOR_VERSION[ \t]+[0-9]+$")
+  file(STRINGS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h" SDL_IMAGE_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_IMAGE_PATCHLEVEL[ \t]+[0-9]+$")
+  string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_IMAGE_VERSION_MAJOR "${SDL_IMAGE_VERSION_MAJOR_LINE}")
+  string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_IMAGE_VERSION_MINOR "${SDL_IMAGE_VERSION_MINOR_LINE}")
+  string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL_IMAGE_VERSION_PATCH "${SDL_IMAGE_VERSION_PATCH_LINE}")
+  set(SDL_IMAGE_VERSION_STRING ${SDL_IMAGE_VERSION_MAJOR}.${SDL_IMAGE_VERSION_MINOR}.${SDL_IMAGE_VERSION_PATCH})
+  unset(SDL_IMAGE_VERSION_MAJOR_LINE)
+  unset(SDL_IMAGE_VERSION_MINOR_LINE)
+  unset(SDL_IMAGE_VERSION_PATCH_LINE)
+  unset(SDL_IMAGE_VERSION_MAJOR)
+  unset(SDL_IMAGE_VERSION_MINOR)
+  unset(SDL_IMAGE_VERSION_PATCH)
+endif()
+
+set(SDL2_IMAGE_LIBRARIES ${SDL2_IMAGE_LIBRARY})
+set(SDL2_IMAGE_INCLUDE_DIRS ${SDL2_IMAGE_INCLUDE_DIR})
+
+# include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_image
+                                  REQUIRED_VARS SDL2_IMAGE_LIBRARIES SDL2_IMAGE_INCLUDE_DIRS
+                                  VERSION_VAR SDL2_IMAGE_VERSION_STRING)
+
+# for backward compatiblity
+set(SDL2IMAGE_LIBRARY ${SDL2_IMAGE_LIBRARIES})
+set(SDL2IMAGE_INCLUDE_DIR ${SDL2_IMAGE_INCLUDE_DIRS})
+set(SDL2IMAGE_FOUND ${SDL2_IMAGE_FOUND})
+
+mark_as_advanced(SDL2_IMAGE_LIBRARY SDL2_IMAGE_INCLUDE_DIR)

=== added file 'cmake/Modules/FindSDL2_mixer.cmake'
--- cmake/Modules/FindSDL2_mixer.cmake	1970-01-01 00:00:00 +0000
+++ cmake/Modules/FindSDL2_mixer.cmake	2014-10-28 15:04:08 +0000
@@ -0,0 +1,88 @@
+# - Locate SDL2_mixer library
+# This module defines:
+#  SDL2_MIXER_LIBRARIES, the name of the library to link against
+#  SDL2_MIXER_INCLUDE_DIRS, where to find the headers
+#  SDL2_MIXER_FOUND, if false, do not try to link against
+#  SDL2_MIXER_VERSION_STRING - human-readable string containing the version of SDL_mixer
+#
+# For backward compatiblity the following variables are also set:
+#  SDL2MIXER_LIBRARY (same value as SDL2_MIXER_LIBRARIES)
+#  SDL2MIXER_INCLUDE_DIR (same value as SDL2_MIXER_INCLUDE_DIRS)
+#  SDL2MIXER_FOUND (same value as SDL2_MIXER_FOUND)
+#
+# $SDL2DIR is an environment variable that would
+# correspond to the ./configure --prefix=$SDL2DIR
+# used in building SDL2.
+#
+# Created by Eric Wing. This was influenced by the FindSDL2.cmake
+# module, but with modifications to recognize OS X frameworks and
+# additional Unix paths (FreeBSD, etc).
+
+#=============================================================================
+# Copyright 2005-2009 Kitware, Inc.
+# Copyright 2012 Benjamin Eikel
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+#  License text for the above reference.)
+
+if(NOT SDL2_MIXER_INCLUDE_DIR AND SDL2MIXER_INCLUDE_DIR)
+  set(SDL2_MIXER_INCLUDE_DIR ${SDL2MIXER_INCLUDE_DIR} CACHE PATH "directory cache
+entry initialized from old variable name")
+endif()
+find_path(SDL2_MIXER_INCLUDE_DIR SDL_mixer.h
+  HINTS
+    ENV SDL2MIXERDIR
+    ENV SDL2DIR
+  PATH_SUFFIXES include/SDL2 include
+)
+
+if(NOT SDL2_MIXER_LIBRARY AND SDL2MIXER_LIBRARY)
+  set(SDL2_MIXER_LIBRARY ${SDL2MIXER_LIBRARY} CACHE FILEPATH "file cache entry
+initialized from old variable name")
+endif()
+find_library(SDL2_MIXER_LIBRARY
+  NAMES SDL2_mixer
+  HINTS
+    ENV SDL2MIXERDIR
+    ENV SDL2DIR
+  PATH_SUFFIXES lib
+)
+
+if(SDL2_MIXER_INCLUDE_DIR AND EXISTS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h")
+  file(STRINGS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h" SDL_MIXER_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_MIXER_MAJOR_VERSION[ \t]+[0-9]+$")
+  file(STRINGS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h" SDL_MIXER_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_MIXER_MINOR_VERSION[ \t]+[0-9]+$")
+  file(STRINGS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h" SDL_MIXER_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_MIXER_PATCHLEVEL[ \t]+[0-9]+$")
+  string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_MIXER_VERSION_MAJOR "${SDL_MIXER_VERSION_MAJOR_LINE}")
+  string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_MIXER_VERSION_MINOR "${SDL_MIXER_VERSION_MINOR_LINE}")
+  string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL_MIXER_VERSION_PATCH "${SDL_MIXER_VERSION_PATCH_LINE}")
+  set(SDL2_MIXER_VERSION_STRING ${SDL_MIXER_VERSION_MAJOR}.${SDL_MIXER_VERSION_MINOR}.${SDL_MIXER_VERSION_PATCH})
+  unset(SDL_MIXER_VERSION_MAJOR_LINE)
+  unset(SDL_MIXER_VERSION_MINOR_LINE)
+  unset(SDL_MIXER_VERSION_PATCH_LINE)
+  unset(SDL_MIXER_VERSION_MAJOR)
+  unset(SDL_MIXER_VERSION_MINOR)
+  unset(SDL_MIXER_VERSION_PATCH)
+endif()
+
+set(SDL2_MIXER_LIBRARIES ${SDL2_MIXER_LIBRARY})
+set(SDL2_MIXER_INCLUDE_DIRS ${SDL2_MIXER_INCLUDE_DIR})
+
+# include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_mixer
+                                  REQUIRED_VARS SDL2_MIXER_LIBRARIES SDL2_MIXER_INCLUDE_DIRS
+                                  VERSION_VAR SDL2_MIXER_VERSION_STRING)
+
+# for backward compatiblity
+set(SDL2MIXER_LIBRARY ${SDL2_MIXER_LIBRARIES})
+set(SDL2MIXER_INCLUDE_DIR ${SDL2_MIXER_INCLUDE_DIRS})
+set(SDL2MIXER_FOUND ${SDL2_MIXER_FOUND})
+
+mark_as_advanced(SDL2_MIXER_LIBRARY SDL2_MIXER_INCLUDE_DIR)

=== added file 'cmake/Modules/FindSDL2_net.cmake'
--- cmake/Modules/FindSDL2_net.cmake	1970-01-01 00:00:00 +0000
+++ cmake/Modules/FindSDL2_net.cmake	2014-10-28 15:04:08 +0000
@@ -0,0 +1,88 @@
+# - Locate SDL2_net library
+# This module defines:
+#  SDL2_NET_LIBRARIES, the name of the library to link against
+#  SDL2_NET_INCLUDE_DIRS, where to find the headers
+#  SDL2_NET_FOUND, if false, do not try to link against
+#  SDL2_NET_VERSION_STRING - human-readable string containing the version of SDL2_net
+#
+# For backward compatiblity the following variables are also set:
+#  SDL2NET_LIBRARY (same value as SDL2_NET_LIBRARIES)
+#  SDL2NET_INCLUDE_DIR (same value as SDL2_NET_INCLUDE_DIRS)
+#  SDL2NET_FOUND (same value as SDL2_NET_FOUND)
+#
+# $SDL2DIR is an environment variable that would
+# correspond to the ./configure --prefix=$SDL2DIR
+# used in building SDL2.
+#
+# Created by Eric Wing. This was influenced by the FindSDL2.cmake
+# module, but with modifications to recognize OS X frameworks and
+# additional Unix paths (FreeBSD, etc).
+
+#=============================================================================
+# Copyright 2005-2009 Kitware, Inc.
+# Copyright 2012 Benjamin Eikel
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+#  License text for the above reference.)
+
+if(NOT SDL2_NET_INCLUDE_DIR AND SDL2NET_INCLUDE_DIR)
+  set(SDL2_NET_INCLUDE_DIR ${SDL2NET_INCLUDE_DIR} CACHE PATH "directory cache
+entry initialized from old variable name")
+endif()
+find_path(SDL2_NET_INCLUDE_DIR SDL_net.h
+  HINTS
+    ENV SDL2NETDIR
+    ENV SDL2DIR
+  PATH_SUFFIXES include/SDL2 include
+)
+
+if(NOT SDL2_NET_LIBRARY AND SDL2NET_LIBRARY)
+  set(SDL2_NET_LIBRARY ${SDL2NET_LIBRARY} CACHE FILEPATH "file cache entry
+initialized from old variable name")
+endif()
+find_library(SDL2_NET_LIBRARY
+  NAMES SDL2_net
+  HINTS
+    ENV SDL2NETDIR
+    ENV SDL2DIR
+  PATH_SUFFIXES lib
+)
+
+if(SDL2_NET_INCLUDE_DIR AND EXISTS "${SDL2_NET_INCLUDE_DIR}/SDL_net.h")
+  file(STRINGS "${SDL2_NET_INCLUDE_DIR}/SDL_net.h" SDL_NET_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_NET_MAJOR_VERSION[ \t]+[0-9]+$")
+  file(STRINGS "${SDL2_NET_INCLUDE_DIR}/SDL_net.h" SDL_NET_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_NET_MINOR_VERSION[ \t]+[0-9]+$")
+  file(STRINGS "${SDL2_NET_INCLUDE_DIR}/SDL_net.h" SDL_NET_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_NET_PATCHLEVEL[ \t]+[0-9]+$")
+  string(REGEX REPLACE "^#define[ \t]+SDL_NET_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_NET_VERSION_MAJOR "${SDL_NET_VERSION_MAJOR_LINE}")
+  string(REGEX REPLACE "^#define[ \t]+SDL_NET_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_NET_VERSION_MINOR "${SDL_NET_VERSION_MINOR_LINE}")
+  string(REGEX REPLACE "^#define[ \t]+SDL_NET_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL_NET_VERSION_PATCH "${SDL_NET_VERSION_PATCH_LINE}")
+  set(SDL2_NET_VERSION_STRING ${SDL_NET_VERSION_MAJOR}.${SDL_NET_VERSION_MINOR}.${SDL_NET_VERSION_PATCH})
+  unset(SDL_NET_VERSION_MAJOR_LINE)
+  unset(SDL_NET_VERSION_MINOR_LINE)
+  unset(SDL_NET_VERSION_PATCH_LINE)
+  unset(SDL_NET_VERSION_MAJOR)
+  unset(SDL_NET_VERSION_MINOR)
+  unset(SDL_NET_VERSION_PATCH)
+endif()
+
+set(SDL2_NET_LIBRARIES ${SDL2_NET_LIBRARY})
+set(SDL2_NET_INCLUDE_DIRS ${SDL2_NET_INCLUDE_DIR})
+
+# include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_net
+                                  REQUIRED_VARS SDL2_NET_LIBRARIES SDL2_NET_INCLUDE_DIRS
+                                  VERSION_VAR SDL2_NET_VERSION_STRING)
+
+# for backward compatiblity
+set(SDL2NET_LIBRARY ${SDL2_NET_LIBRARIES})
+set(SDL2NET_INCLUDE_DIR ${SDL2_NET_INCLUDE_DIRS})
+set(SDL2NET_FOUND ${SDL2_NET_FOUND})
+
+mark_as_advanced(SDL2_NET_LIBRARY SDL2_NET_INCLUDE_DIR)

=== added file 'cmake/Modules/FindSDL2_ttf.cmake'
--- cmake/Modules/FindSDL2_ttf.cmake	1970-01-01 00:00:00 +0000
+++ cmake/Modules/FindSDL2_ttf.cmake	2014-10-28 15:04:08 +0000
@@ -0,0 +1,88 @@
+# - Locate SDL2_ttf library
+# This module defines:
+#  SDL2_TTF_LIBRARIES, the name of the library to link against
+#  SDL2_TTF_INCLUDE_DIRS, where to find the headers
+#  SDL2_TTF_FOUND, if false, do not try to link against
+#  SDL2_TTF_VERSION_STRING - human-readable string containing the version of SDL2_ttf
+#
+# For backward compatiblity the following variables are also set:
+#  SDL2TTF_LIBRARY (same value as SDL2_TTF_LIBRARIES)
+#  SDL2TTF_INCLUDE_DIR (same value as SDL2_TTF_INCLUDE_DIRS)
+#  SDL2TTF_FOUND (same value as SDL2_TTF_FOUND)
+#
+# $SDL2DIR is an environment variable that would
+# correspond to the ./configure --prefix=$SDL2DIR
+# used in building SDL2.
+#
+# Created by Eric Wing. This was influenced by the FindSDL2.cmake
+# module, but with modifications to recognize OS X frameworks and
+# additional Unix paths (FreeBSD, etc).
+
+#=============================================================================
+# Copyright 2005-2009 Kitware, Inc.
+# Copyright 2012 Benjamin Eikel
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+#  License text for the above reference.)
+
+if(NOT SDL2_TTF_INCLUDE_DIR AND SDL2TTF_INCLUDE_DIR)
+  set(SDL2_TTF_INCLUDE_DIR ${SDL2TTF_INCLUDE_DIR} CACHE PATH "directory cache
+entry initialized from old variable name")
+endif()
+find_path(SDL2_TTF_INCLUDE_DIR SDL_ttf.h
+  HINTS
+    ENV SDL2TTFDIR
+    ENV SDL2DIR
+  PATH_SUFFIXES include/SDL2 include
+)
+
+if(NOT SDL2_TTF_LIBRARY AND SDL2TTF_LIBRARY)
+  set(SDL2_TTF_LIBRARY ${SDL2TTF_LIBRARY} CACHE FILEPATH "file cache entry
+initialized from old variable name")
+endif()
+find_library(SDL2_TTF_LIBRARY
+  NAMES SDL2_ttf
+  HINTS
+    ENV SDL2TTFDIR
+    ENV SDL2DIR
+  PATH_SUFFIXES lib
+)
+
+if(SDL2_TTF_INCLUDE_DIR AND EXISTS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h")
+  file(STRINGS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL_TTF_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_TTF_MAJOR_VERSION[ \t]+[0-9]+$")
+  file(STRINGS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL_TTF_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_TTF_MINOR_VERSION[ \t]+[0-9]+$")
+  file(STRINGS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL_TTF_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_TTF_PATCHLEVEL[ \t]+[0-9]+$")
+  string(REGEX REPLACE "^#define[ \t]+SDL_TTF_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_TTF_VERSION_MAJOR "${SDL_TTF_VERSION_MAJOR_LINE}")
+  string(REGEX REPLACE "^#define[ \t]+SDL_TTF_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_TTF_VERSION_MINOR "${SDL_TTF_VERSION_MINOR_LINE}")
+  string(REGEX REPLACE "^#define[ \t]+SDL_TTF_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL_TTF_VERSION_PATCH "${SDL_TTF_VERSION_PATCH_LINE}")
+  set(SDL2_TTF_VERSION_STRING ${SDL_TTF_VERSION_MAJOR}.${SDL_TTF_VERSION_MINOR}.${SDL_TTF_VERSION_PATCH})
+  unset(SDL_TTF_VERSION_MAJOR_LINE)
+  unset(SDL_TTF_VERSION_MINOR_LINE)
+  unset(SDL_TTF_VERSION_PATCH_LINE)
+  unset(SDL_TTF_VERSION_MAJOR)
+  unset(SDL_TTF_VERSION_MINOR)
+  unset(SDL_TTF_VERSION_PATCH)
+endif()
+
+set(SDL2_TTF_LIBRARIES ${SDL2_TTF_LIBRARY})
+set(SDL2_TTF_INCLUDE_DIRS ${SDL2_TTF_INCLUDE_DIR})
+
+# include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_ttf
+                                  REQUIRED_VARS SDL2_TTF_LIBRARIES SDL2_TTF_INCLUDE_DIRS
+                                  VERSION_VAR SDL2_TTF_VERSION_STRING)
+
+# for backward compatiblity
+set(SDL2TTF_LIBRARY ${SDL2_TTF_LIBRARIES})
+set(SDL2TTF_INCLUDE_DIR ${SDL2_TTF_INCLUDE_DIRS})
+set(SDL2TTF_FOUND ${SDL2_TTF_FOUND})
+
+mark_as_advanced(SDL2_TTF_LIBRARY SDL2_TTF_INCLUDE_DIR)

=== removed file 'cmake/Modules/FindSDL_gfx.cmake'
--- cmake/Modules/FindSDL_gfx.cmake	2013-01-24 11:42:08 +0000
+++ cmake/Modules/FindSDL_gfx.cmake	1970-01-01 00:00:00 +0000
@@ -1,64 +0,0 @@
-# Locate SDL_gfx library
-# This module defines
-# SDLGFX_LIBRARY, the name of the library to link against
-# SDLGFX_FOUND, if false, do not try to link to SDL
-# SDLGFX_INCLUDE_DIR, where to find SDL/SDL.h
-#
-# $SDLDIR is an environment variable that would
-# correspond to the ./configure --prefix=$SDLDIR
-# used in building SDL.
-#
-# Created by Eric Wing. This was influenced by the FindSDL.cmake 
-# module, but with modifications to recognize OS X frameworks and 
-# additional Unix paths (FreeBSD, etc).
-
-FIND_PATH(SDLGFX_INCLUDE_DIR SDL_framerate.h SDL_gfxBlitFunc.h
-  SDL_gfxPrimitives.h SDL_gfxPrimitives_font.h
-  SDL_imageFilter.h SDL_rotozoom.h
-  HINTS
-  $ENV{SDLGFXDIR}
-  $ENV{SDLDIR}
-  PATH_SUFFIXES include SDL
-  PATHS
-  ~/Library/Frameworks
-  /Library/Frameworks
-  /usr/local/include/SDL
-  /usr/include/SDL
-  /usr/local/include/SDL12
-  /usr/local/include/SDL11 # FreeBSD ports
-  /usr/include/SDL12
-  /usr/include/SDL11
-  /usr/local/include
-  /usr/include
-  /sw/include/SDL # Fink
-  /sw/include
-  /opt/local/include/SDL # DarwinPorts
-  /opt/local/include
-  /opt/csw/include/SDL # Blastwave
-  /opt/csw/include 
-  /opt/include/SDL
-  /opt/include
-)
-
-FIND_LIBRARY(SDLGFX_LIBRARY 
-  NAMES SDL_gfx
-  HINTS
-  $ENV{SDLGFXDIR}
-  $ENV{SDLDIR}
-  PATH_SUFFIXES lib64 lib
-  PATHS
-  ~/Library/Frameworks
-  /Library/Frameworks
-  /usr/local
-  /usr
-  /sw
-  /opt/local
-  /opt/csw
-  /opt
-)
-
-SET(SDLGFX_FOUND "NO")
-IF(SDLGFX_LIBRARY AND SDLGFX_INCLUDE_DIR)
-  SET(SDLGFX_FOUND "YES")
-ENDIF(SDLGFX_LIBRARY AND SDLGFX_INCLUDE_DIR)
-

=== modified file 'cmake/WlFunctions.cmake'
--- cmake/WlFunctions.cmake	2014-07-17 14:34:32 +0000
+++ cmake/WlFunctions.cmake	2014-10-28 15:04:08 +0000
@@ -9,12 +9,12 @@
     USES_INTL
     USES_OPENGL
     USES_PNG
-    USES_SDL
-    USES_SDL_GFX
-    USES_SDL_IMAGE
-    USES_SDL_MIXER
-    USES_SDL_NET
-    USES_SDL_TTF
+    USES_SDL2
+    USES_SDL2_GFX
+    USES_SDL2_IMAGE
+    USES_SDL2_MIXER
+    USES_SDL2_NET
+    USES_SDL2_TTF
     USES_ZLIB
   )
   set(ONE_VALUE_ARG )
@@ -98,34 +98,34 @@
     target_link_libraries(${NAME} ${PNG_LIBRARY})
   endif()
 
-  if(ARG_USES_SDL)
-    wl_include_system_directories(${NAME} ${SDL_INCLUDE_DIR})
-    target_link_libraries(${NAME} ${SDL_LIBRARY})
-  endif()
-
-  if(ARG_USES_SDL_MIXER)
-    wl_include_system_directories(${NAME} ${SDLMIXER_INCLUDE_DIR})
-    target_link_libraries(${NAME} ${SDLMIXER_LIBRARY})
-  endif()
-
-  if(ARG_USES_SDL_NET)
-    wl_include_system_directories(${NAME} ${SDLNET_INCLUDE_DIR})
-    target_link_libraries(${NAME} ${SDLNET_LIBRARY})
-  endif()
-
-  if(ARG_USES_SDL_IMAGE)
-    wl_include_system_directories(${NAME} ${SDLIMAGE_INCLUDE_DIR})
-    target_link_libraries(${NAME} ${SDLIMAGE_LIBRARY})
-  endif()
-
-  if(ARG_USES_SDL_GFX)
-    wl_include_system_directories(${NAME} ${SDLGFX_INCLUDE_DIR})
-    target_link_libraries(${NAME} ${SDLGFX_LIBRARY})
-  endif()
-
-  if(ARG_USES_SDL_TTF)
-    wl_include_system_directories(${NAME} ${SDLTTF_INCLUDE_DIR})
-    target_link_libraries(${NAME} ${SDLTTF_LIBRARY})
+  if(ARG_USES_SDL2)
+    wl_include_system_directories(${NAME} ${SDL2_INCLUDE_DIR})
+    target_link_libraries(${NAME} ${SDL2_LIBRARY})
+  endif()
+
+  if(ARG_USES_SDL2_MIXER)
+    wl_include_system_directories(${NAME} ${SDL2MIXER_INCLUDE_DIR})
+    target_link_libraries(${NAME} ${SDL2MIXER_LIBRARY})
+  endif()
+
+  if(ARG_USES_SDL2_NET)
+    wl_include_system_directories(${NAME} ${SDL2NET_INCLUDE_DIR})
+    target_link_libraries(${NAME} ${SDL2NET_LIBRARY})
+  endif()
+
+  if(ARG_USES_SDL2_IMAGE)
+    wl_include_system_directories(${NAME} ${SDL2IMAGE_INCLUDE_DIR})
+    target_link_libraries(${NAME} ${SDL2IMAGE_LIBRARY})
+  endif()
+
+  if(ARG_USES_SDL2_GFX)
+    wl_include_system_directories(${NAME} ${SDL2GFX_INCLUDE_DIR})
+    target_link_libraries(${NAME} ${SDL2GFX_LIBRARY})
+  endif()
+
+  if(ARG_USES_SDL2_TTF)
+    wl_include_system_directories(${NAME} ${SDL2TTF_INCLUDE_DIR})
+    target_link_libraries(${NAME} ${SDL2TTF_LIBRARY})
   endif()
 
   if (ARG_USES_INTL)
@@ -176,10 +176,10 @@
   endif()
   target_link_libraries(${NAME} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
 
-  # Tests need to link with SDL library without main.
-  set(SDL_LIBRARY_TEMP ${SDL_LIBRARY})
-  list(REMOVE_ITEM SDL_LIBRARY_TEMP ${SDLMAIN_LIBRARY})
-  target_link_libraries(${NAME} ${SDL_LIBRARY_TEMP})
+  # Tests need to link with SDL2 library without main.
+  set(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY})
+  list(REMOVE_ITEM SDL2_LIBRARY_TEMP ${SDL2MAIN_LIBRARY})
+  target_link_libraries(${NAME} ${SDL2_LIBRARY_TEMP})
 
   _common_compile_tasks()
 

=== modified file 'cmake/codecheck/rules/correct_include_order'
--- cmake/codecheck/rules/correct_include_order	2013-07-26 20:19:36 +0000
+++ cmake/codecheck/rules/correct_include_order	2014-10-28 15:04:08 +0000
@@ -70,7 +70,7 @@
         if blocks and blocks[0][0][1] == "<":  # library includes.
             for lineno, delimiter, header in blocks[0]:
                 if '.h' not in header or delimiter != "<":
-                    errors.append((fn, lineno, "This include block must only contain library headers (e.g. SDL)."))
+                    errors.append((fn, lineno, "This include block must only contain library headers (e.g. SDL2)."))
                     return errors
             blocks.pop(0)
 
@@ -95,7 +95,7 @@
 allowed = [
 """#include <memory>
 
-#include <SDL.h>
+#include <SDL2.h>
 """,
 
 """
@@ -120,7 +120,7 @@
 ###################
 forbidden = [
 """
-#include <SDL.h>
+#include <SDL2.h>
 
 #include <memory>
 """,
@@ -133,7 +133,7 @@
 
 """
 #include <memory>
-#include <SDL.h>
+#include <SDL2.h>
 """
 
 ]

=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt	2014-09-16 09:54:41 +0000
+++ src/CMakeLists.txt	2014-10-28 15:04:08 +0000
@@ -43,7 +43,7 @@
     SRCS
       main.cc
       ${WIN32_ICON_O}
-    USES_SDL
+    USES_SDL2
     DEPENDS
       base_log
       base_exceptions
@@ -54,7 +54,7 @@
   wl_binary(widelands
     SRCS
       main.cc
-    USES_SDL
+    USES_SDL2
     DEPENDS
       base_log
       base_exceptions
@@ -92,7 +92,7 @@
     wlapplication.h
     wlapplication_messages.cc
     wlapplication_messages.h
-  USES_SDL
+  USES_SDL2
   DEPENDS
     base_exceptions
     base_geometry
@@ -122,7 +122,7 @@
   SRCS
     helper.cc
     helper.h
-  USES_SDL
+  USES_SDL2
   DEPENDS
     base_exceptions
 )

=== modified file 'src/base/CMakeLists.txt'
--- src/base/CMakeLists.txt	2014-08-28 06:58:29 +0000
+++ src/base/CMakeLists.txt	2014-10-28 15:04:08 +0000
@@ -58,7 +58,7 @@
   SRCS
     scoped_timer.h
     scoped_timer.cc
-  USES_SDL
+  USES_SDL2
   DEPENDS
     base_log
     base_macros

=== modified file 'src/editor/CMakeLists.txt'
--- src/editor/CMakeLists.txt	2014-07-05 13:14:42 +0000
+++ src/editor/CMakeLists.txt	2014-10-28 15:04:08 +0000
@@ -83,7 +83,7 @@
     ui_menus/editor_tool_set_terrain_options_menu.h
     ui_menus/editor_toolsize_menu.cc
     ui_menus/editor_toolsize_menu.h
-  USES_SDL
+  USES_SDL2
   DEPENDS
     base_exceptions
     base_i18n

=== modified file 'src/editor/editorinteractive.cc'
--- src/editor/editorinteractive.cc	2014-09-19 12:54:54 +0000
+++ src/editor/editorinteractive.cc	2014-10-28 15:04:08 +0000
@@ -23,7 +23,7 @@
 #include <string>
 #include <vector>
 
-#include <SDL_keysym.h>
+#include <SDL_keycode.h>
 #include <boost/format.hpp>
 
 #include "base/i18n.h"
@@ -344,7 +344,7 @@
 }
 
 
-bool EditorInteractive::handle_key(bool const down, SDL_keysym const code) {
+bool EditorInteractive::handle_key(bool const down, SDL_Keysym const code) {
 	bool handled = InteractiveBase::handle_key(down, code);
 
 	if (down) {
@@ -393,16 +393,16 @@
 			handled = true;
 			break;
 
-		case SDLK_LSHIFT:
-		case SDLK_RSHIFT:
+		case SDL_SCANCODE_LSHIFT:
+		case SDL_SCANCODE_RSHIFT:
 			if (tools.use_tool == EditorTool::First)
 				select_tool(tools.current(), EditorTool::Second);
 			handled = true;
 			break;
 
-		case SDLK_LALT:
-		case SDLK_RALT:
-		case SDLK_MODE:
+		case SDL_SCANCODE_LALT:
+		case SDL_SCANCODE_RALT:
+		case SDL_SCANCODE_MODE:
 			if (tools.use_tool == EditorTool::First)
 				select_tool(tools.current(), EditorTool::Third);
 			handled = true;
@@ -481,11 +481,11 @@
 	} else {
 		// key up events
 		switch (code.sym) {
-		case SDLK_LSHIFT:
-		case SDLK_RSHIFT:
-		case SDLK_LALT:
-		case SDLK_RALT:
-		case SDLK_MODE:
+		case SDL_SCANCODE_LSHIFT:
+		case SDL_SCANCODE_RSHIFT:
+		case SDL_SCANCODE_LALT:
+		case SDL_SCANCODE_RALT:
+		case SDL_SCANCODE_MODE:
 			if (tools.use_tool != EditorTool::First)
 				select_tool(tools.current(), EditorTool::First);
 			handled = true;

=== modified file 'src/editor/editorinteractive.h'
--- src/editor/editorinteractive.h	2014-09-14 11:31:58 +0000
+++ src/editor/editorinteractive.h	2014-10-28 15:04:08 +0000
@@ -66,7 +66,7 @@
 	void set_sel_radius_and_update_menu(uint32_t);
 
 	//  Handle UI elements.
-	bool handle_key(bool down, SDL_keysym) override;
+	bool handle_key(bool down, SDL_Keysym) override;
 	bool handle_mousepress(uint8_t btn, int32_t x, int32_t y) override;
 	bool handle_mouserelease(uint8_t btn, int32_t x, int32_t y) override;
 

=== modified file 'src/editor/ui_menus/categorized_item_selection_menu.h'
--- src/editor/ui_menus/categorized_item_selection_menu.h	2014-09-10 14:48:40 +0000
+++ src/editor/ui_menus/categorized_item_selection_menu.h	2014-10-28 15:04:08 +0000
@@ -144,7 +144,7 @@
 	//  TODO(unknown): This code is erroneous. It checks the current key state. What it
 	//  needs is the key state at the time the mouse was clicked. See the
 	//  usage comment for get_key_state.
-	const bool multiselect = get_key_state(SDLK_LCTRL) | get_key_state(SDLK_RCTRL);
+	const bool multiselect = get_key_state(SDL_SCANCODE_LCTRL) | get_key_state(SDL_SCANCODE_RCTRL);
 	if (!t && (!multiselect || tool_->get_nr_enabled() == 1))
 		checkboxes_[n]->set_state(true);
 	else {

=== modified file 'src/editor/ui_menus/editor_main_menu_load_map.cc'
--- src/editor/ui_menus/editor_main_menu_load_map.cc	2014-10-28 08:16:53 +0000
+++ src/editor/ui_menus/editor_main_menu_load_map.cc	2014-10-28 15:04:08 +0000
@@ -65,6 +65,7 @@
 		 get_inner_w() / 2 - spacing, get_inner_h() - spacing - offsy - 40);
 	m_ls->selected.connect(boost::bind(&MainMenuLoadMap::selected, this, _1));
 	m_ls->double_clicked.connect(boost::bind(&MainMenuLoadMap::double_clicked, this, _1));
+	m_ls->focus();
 
 	posx = get_inner_w() / 2 + spacing;
 	new UI::Textarea

=== modified file 'src/editor/ui_menus/editor_main_menu_save_map.cc'
--- src/editor/ui_menus/editor_main_menu_save_map.cc	2014-10-28 08:16:53 +0000
+++ src/editor/ui_menus/editor_main_menu_save_map.cc	2014-10-28 15:04:08 +0000
@@ -67,6 +67,7 @@
 			 get_inner_w() / 2 - spacing, get_inner_h() - spacing - offsy - 60);
 	m_ls->clicked.connect(boost::bind(&MainMenuSaveMap::clicked_item, this, _1));
 	m_ls->double_clicked.connect(boost::bind(&MainMenuSaveMap::double_clicked_item, this, _1));
+	m_ls->focus();
 	m_editbox =
 		new UI::EditBox
 			(this,

=== modified file 'src/editor/ui_menus/editor_tool_place_bob_options_menu.cc'
--- src/editor/ui_menus/editor_tool_place_bob_options_menu.cc	2014-09-10 14:08:25 +0000
+++ src/editor/ui_menus/editor_tool_place_bob_options_menu.cc	2014-10-28 15:04:08 +0000
@@ -19,7 +19,7 @@
 
 #include "editor/ui_menus/editor_tool_place_bob_options_menu.h"
 
-#include <SDL_keysym.h>
+#include <SDL_keycode.h>
 
 #include "base/i18n.h"
 #include "base/macros.h"
@@ -124,7 +124,7 @@
 	//  TODO(unknown): needs is the key state at the time the mouse was clicked. See the
 	//  TODO(unknown): usage comment for get_key_state.
 	const bool multiselect =
-		get_key_state(SDLK_LCTRL) | get_key_state(SDLK_RCTRL);
+		get_key_state(SDL_SCANCODE_LCTRL) | get_key_state(SDL_SCANCODE_RCTRL);
 	if (!t && (!multiselect || m_pit.get_nr_enabled() == 1)) {
 		m_checkboxes[n]->set_state(true);
 		return;

=== modified file 'src/editor/ui_menus/editor_tool_place_immovable_options_menu.cc'
--- src/editor/ui_menus/editor_tool_place_immovable_options_menu.cc	2014-09-10 14:08:25 +0000
+++ src/editor/ui_menus/editor_tool_place_immovable_options_menu.cc	2014-10-28 15:04:08 +0000
@@ -19,7 +19,7 @@
 
 #include "editor/ui_menus/editor_tool_place_immovable_options_menu.h"
 
-#include <SDL_keysym.h>
+#include <SDL_keycode.h>
 
 #include "base/i18n.h"
 #include "editor/editorinteractive.h"

=== modified file 'src/editor/ui_menus/editor_tool_set_terrain_options_menu.cc'
--- src/editor/ui_menus/editor_tool_set_terrain_options_menu.cc	2014-10-27 10:14:10 +0000
+++ src/editor/ui_menus/editor_tool_set_terrain_options_menu.cc	2014-10-28 15:04:08 +0000
@@ -21,7 +21,7 @@
 
 #include <memory>
 
-#include <SDL_keysym.h>
+#include <SDL_keycode.h>
 #include <boost/format.hpp>
 
 #include "base/i18n.h"

=== modified file 'src/graphic/CMakeLists.txt'
--- src/graphic/CMakeLists.txt	2014-07-15 05:12:37 +0000
+++ src/graphic/CMakeLists.txt	2014-10-28 15:04:08 +0000
@@ -4,7 +4,7 @@
   SRCS
     color.h
     color.cc
-  USES_SDL
+  USES_SDL2
 )
 
 wl_library(graphic_image_io
@@ -12,8 +12,8 @@
     image_io.h
     image_io.cc
   USES_PNG
-  USES_SDL
-  USES_SDL_IMAGE
+  USES_SDL2
+  USES_SDL2_IMAGE
   DEPENDS
     base_exceptions
     graphic_surface
@@ -27,8 +27,8 @@
     image.h
     image_cache.cc
     image_cache.h
-  USES_SDL
-  USES_SDL_IMAGE
+  USES_SDL2
+  USES_SDL2_IMAGE
   DEPENDS
     base_log
     base_macros
@@ -56,7 +56,7 @@
     surface_cache.cc
     surface_cache.h
   USES_OPENGL
-  USES_SDL
+  USES_SDL2
   DEPENDS
     base_macros
     base_exceptions
@@ -110,10 +110,10 @@
     wordwrap.cc
     wordwrap.h
   USES_OPENGL
-  USES_SDL
-  USES_SDL_GFX
-  USES_SDL_IMAGE
-  USES_SDL_TTF
+  USES_SDL2
+  USES_SDL2_GFX
+  USES_SDL2_IMAGE
+  USES_SDL2_TTF
   DEPENDS
     base_deprecated
     base_exceptions

=== modified file 'src/graphic/font_handler.cc'
--- src/graphic/font_handler.cc	2014-09-14 11:31:58 +0000
+++ src/graphic/font_handler.cc	2014-10-28 15:04:08 +0000
@@ -175,7 +175,7 @@
 void FontHandler::Data::render_line(LineCacheEntry & lce)
 {
 	TTF_Font * font = lce.style.font->get_ttf_font();
-	SDL_Color sdl_fg = {lce.style.fg.r, lce.style.fg.g, lce.style.fg.b, 0};
+	SDL_Color sdl_fg = {lce.style.fg.r, lce.style.fg.g, lce.style.fg.b, SDL_ALPHA_OPAQUE};
 
 	// Work around an Issue in SDL_TTF that dies when the surface
 	// has zero width

=== modified file 'src/graphic/graphic.cc'
--- src/graphic/graphic.cc	2014-09-20 09:37:47 +0000
+++ src/graphic/graphic.cc	2014-10-28 15:04:08 +0000
@@ -54,9 +54,8 @@
 Graphic * g_gr;
 bool g_opengl;
 
-#define FALLBACK_GRAPHICS_WIDTH 800
-#define FALLBACK_GRAPHICS_HEIGHT 600
-#define FALLBACK_GRAPHICS_DEPTH 32
+constexpr int kFallbackGraphicsWidth = 800;
+constexpr int kFallbackGraphicsHeight = 600;
 
 namespace  {
 
@@ -71,9 +70,8 @@
 */
 Graphic::Graphic()
 	:
-	m_fallback_settings_in_effect (false),
-	m_nr_update_rects  (0),
-	m_update_fullscreen(true),
+	m_fallback_settings_in_effect(false),
+	m_update(true),
 	surface_cache_(create_surface_cache(TRANSIENT_SURFACE_CACHE_SIZE)),
 	image_cache_(new ImageCache(surface_cache_.get())),
 	animation_manager_(new AnimationManager())
@@ -85,9 +83,11 @@
 #else
 	const std::string icon_name = "pics/wl-ico-32.png";
 #endif
-	SDL_Surface* s = load_image_as_sdl_surface(icon_name, g_fs);
-	SDL_WM_SetIcon(s, nullptr);
-	SDL_FreeSurface(s);
+	m_sdlwindow = nullptr;
+	m_sdl_screen = nullptr;
+	m_sdl_renderer = nullptr;
+	m_sdl_texture = nullptr;
+	m_glcontext = nullptr;
 }
 
 void Graphic::initialize(int32_t w, int32_t h, bool fullscreen, bool opengl) {
@@ -96,64 +96,84 @@
 	// Set video mode using SDL. First collect the flags
 	int32_t flags = 0;
 	g_opengl = false;
-	SDL_Surface * sdlsurface = nullptr;
 
 	if (opengl) {
 		log("Graphics: Trying opengl\n");
 		SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
-		flags |= SDL_OPENGL;
+		flags |= SDL_WINDOW_OPENGL;
 	}
 
 	if (fullscreen) {
-		flags |= SDL_FULLSCREEN;
+		flags |= SDL_WINDOW_FULLSCREEN;
 		log("Graphics: Trying FULLSCREEN\n");
 	}
 
 	log("Graphics: Try to set Videomode %ux%u 32 Bit\n", w, h);
 	// Here we actually set the video mode
-	sdlsurface = SDL_SetVideoMode(w, h, 32, flags);
-
+	m_sdlwindow = SDL_CreateWindow("Widelands Window",
+											 SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w, h, flags);
+	if (opengl) {
+		// TODO(sirver): this context needs to be created also for fallback settings,
+		// otherwise SDL_GetWindowFlags() will return SDL_WINDOW_OPENGL,
+		// though if you call any gl function, the system crashes.
+		m_glcontext = SDL_GL_CreateContext(m_sdlwindow);
+		if (m_glcontext) {
+			SDL_GL_MakeCurrent(m_sdlwindow, m_glcontext);
+		}
+	}
 	// If we tried opengl and it was not successful try without opengl
-	if (!sdlsurface && opengl)
+	if ((!m_sdlwindow || !m_glcontext) && opengl)
 	{
 		log("Graphics: Could not set videomode: %s, trying without opengl\n", SDL_GetError());
-		flags &= ~SDL_OPENGL;
-		sdlsurface = SDL_SetVideoMode(w, h, 32, flags);
+		flags &= ~SDL_WINDOW_OPENGL;
+		m_sdlwindow = SDL_CreateWindow("Widelands Window",
+												 SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w, h, flags);
 	}
 
-	if (!sdlsurface)
-	{
+	if (!m_sdlwindow) {
 		log
 			("Graphics: Could not set videomode: %s, trying minimum graphics settings\n",
 			 SDL_GetError());
-		flags &= ~SDL_FULLSCREEN;
-		sdlsurface = SDL_SetVideoMode
-			(FALLBACK_GRAPHICS_WIDTH, FALLBACK_GRAPHICS_HEIGHT, FALLBACK_GRAPHICS_DEPTH, flags);
+		flags &= ~SDL_WINDOW_FULLSCREEN;
+		m_sdlwindow = SDL_CreateWindow("Widelands Window",
+												 SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
+												 kFallbackGraphicsWidth, kFallbackGraphicsHeight, flags);
 		m_fallback_settings_in_effect = true;
-		if (!sdlsurface)
+		if (!m_sdlwindow) {
 			throw wexception
 				("Graphics: could not set video mode: %s", SDL_GetError());
+		}
 	}
 
+#ifndef _WIN32
+	const std::string icon_name = "pics/wl-ico-128.png";
+#else
+	const std::string icon_name = "pics/wl-ico-32.png";
+#endif
+	SDL_Surface* s = load_image_as_sdl_surface(icon_name, g_fs);
+	SDL_SetWindowIcon(m_sdlwindow, s);
+	SDL_FreeSurface(s);
+
 	// setting the videomode was successful. Print some information now
 	log("Graphics: Setting video mode was successful\n");
 
-	if (opengl && 0 != (sdlsurface->flags & SDL_GL_DOUBLEBUFFER))
+	if (opengl && 0 != (SDL_GetWindowFlags(m_sdlwindow) & SDL_GL_DOUBLEBUFFER))
 		log("Graphics: OPENGL DOUBLE BUFFERING ENABLED\n");
-	if (0 != (sdlsurface->flags & SDL_FULLSCREEN))
+	if (0 != (SDL_GetWindowFlags(m_sdlwindow) & SDL_WINDOW_FULLSCREEN))
 		log("Graphics: FULLSCREEN ENABLED\n");
 
 	bool use_arb = true;
 	const char * extensions = nullptr;
 
-	if (0 != (sdlsurface->flags & SDL_OPENGL)) {
+	if (opengl && 0 != (SDL_GetWindowFlags(m_sdlwindow) & SDL_WINDOW_OPENGL)) {
 		//  We have successful opened an opengl screen. Print some information
 		//  about opengl and set the rendering capabilities.
 		log ("Graphics: OpenGL: OpenGL enabled\n");
 
 		GLenum err = glewInit();
 		if (err != GLEW_OK) {
-			log("glewInit returns %i\nYour OpenGL installation must be __very__ broken.\n", err);
+			log("glewInit returns %i\nYour OpenGL installation must be __very__ broken. %s\n",
+				 err, glewGetErrorString(err));
 			throw wexception("glewInit returns %i: Broken OpenGL installation.", err);
 		}
 
@@ -168,23 +188,22 @@
 			("Graphics: Neither GL_ARB_framebuffer_object or GL_EXT_framebuffer_object supported! "
 			"Switching off OpenGL!\n"
 			);
-			flags &= ~SDL_OPENGL;
-			m_fallback_settings_in_effect = true;
-
-			// One must never free the screen surface of SDL (using
-			// SDL_FreeSurface) as it is owned by SDL itself, therefore the next
-			// call does not leak memory.
-			sdlsurface = SDL_SetVideoMode
-				(FALLBACK_GRAPHICS_WIDTH, FALLBACK_GRAPHICS_HEIGHT, FALLBACK_GRAPHICS_DEPTH, flags);
-			m_fallback_settings_in_effect = true;
-			if (!sdlsurface)
+			flags &= ~SDL_WINDOW_OPENGL;
+			m_fallback_settings_in_effect = true;
+			SDL_DestroyWindow(m_sdlwindow);
+			m_sdlwindow = SDL_CreateWindow("Widelands Window",
+													 SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
+													 kFallbackGraphicsWidth, kFallbackGraphicsHeight, flags);
+			m_fallback_settings_in_effect = true;
+			if (!m_sdlwindow) {
 				throw wexception("Graphics: could not set video mode: %s", SDL_GetError());
+			}
 		}
 	}
 	Surface::display_format_is_now_defined();
 
 	// Redoing the check, because fallback settings might mean we no longer use OpenGL.
-	if (0 != (sdlsurface->flags & SDL_OPENGL)) {
+	if (opengl && 0 != (SDL_GetWindowFlags(m_sdlwindow) & SDL_WINDOW_OPENGL)) {
 		//  We now really have a working opengl screen...
 		g_opengl = true;
 
@@ -239,48 +258,26 @@
 	}
 
 	/* Information about the video capabilities. */
-	const SDL_VideoInfo* info = SDL_GetVideoInfo();
-	char videodrvused[16];
-	SDL_VideoDriverName(videodrvused, 16);
+	SDL_DisplayMode disp_mode;
+	SDL_GetWindowDisplayMode(m_sdlwindow, &disp_mode);
+	const char * videodrvused = SDL_GetCurrentVideoDriver();
 	log
 		("**** GRAPHICS REPORT ****\n"
 		 " VIDEO DRIVER %s\n"
-		 " hw surface possible %d\n"
-		 " window manager available %d\n"
-		 " blitz_hw %d\n"
-		 " blitz_hw_CC %d\n"
-		 " blitz_hw_A %d\n"
-		 " blitz_sw %d\n"
-		 " blitz_sw_CC %d\n"
-		 " blitz_sw_A %d\n"
-		 " blitz_fill %d\n"
-		 " video_mem %d\n"
-		 " vfmt %p\n"
+		 " pixel fmt %u\n"
 		 " size %d %d\n"
 		 "**** END GRAPHICS REPORT ****\n",
 		 videodrvused,
-		 info->hw_available,
-		 info->wm_available,
-		 info->blit_hw,
-		 info->blit_hw_CC,
-		 info->blit_hw_A,
-		 info->blit_sw,
-		 info->blit_sw_CC,
-		 info->blit_sw_A,
-		 info->blit_fill,
-		 info->video_mem,
-		 info->vfmt,
-		 info->current_w, info->current_h);
+		 disp_mode.format,
+		 disp_mode.w, disp_mode.h);
 
-	log("Graphics: flags: %x\n", sdlsurface->flags);
+	log("Graphics: flags: %u\n", SDL_GetWindowFlags(m_sdlwindow));
 
 	assert
-		(sdlsurface->format->BytesPerPixel == 2 ||
-		 sdlsurface->format->BytesPerPixel == 4);
+			(SDL_BYTESPERPIXEL(disp_mode.format) == 2 ||
+			 SDL_BYTESPERPIXEL(disp_mode.format) == 4);
 
-	SDL_WM_SetCaption
-		(("Widelands " + build_id() + '(' + build_type() + ')').c_str(),
-		 "Widelands");
+	SDL_SetWindowTitle(m_sdlwindow, ("Widelands " + build_id() + '(' + build_type() + ')').c_str());
 
 	if (g_opengl) {
 		glViewport(0, 0, w, h);
@@ -306,7 +303,8 @@
 		// Clear the screen before running the game.
 		glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
 		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-		SDL_GL_SwapBuffers();
+		SDL_GL_SetSwapInterval(1);
+		SDL_GL_SwapWindow(m_sdlwindow);
 		glEnable(GL_TEXTURE_2D);
 
 		GLSurfaceTexture::initialize(use_arb);
@@ -316,12 +314,18 @@
 	{
 		screen_.reset(new GLSurfaceScreen(w, h));
 	}
-	else
-	{
-		screen_.reset(new SDLSurface(sdlsurface, false));
+	else {
+		m_sdl_renderer =  SDL_CreateRenderer(m_sdlwindow, -1, 0);
+		uint32_t rmask, gmask, bmask, amask;
+		int bpp;
+		SDL_PixelFormatEnumToMasks(SDL_PIXELFORMAT_ARGB8888, &bpp, &rmask, &gmask, &bmask, &amask);
+		m_sdl_screen = SDL_CreateRGBSurface(0, w, h, bpp, rmask, gmask, bmask, amask);
+		m_sdl_texture = SDL_CreateTexture(m_sdl_renderer,
+													 SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING,
+													 w, h);
+		screen_.reset(new SDLSurface(m_sdl_screen, false));
 	}
 
-	m_sdl_screen = sdlsurface;
 	m_rendertarget.reset(new RenderTarget(screen_.get()));
 
 	pic_road_normal_.reset(load_image("world/pics/roadt_normal.png"));
@@ -340,8 +344,25 @@
 	if (UI::g_fh)
 		UI::g_fh->flush();
 
-	if (g_opengl)
+	if (g_opengl) {
 		GLSurfaceTexture::cleanup();
+	}
+	if (m_sdl_texture) {
+		SDL_DestroyTexture(m_sdl_texture);
+		m_sdl_texture = nullptr;
+	}
+	if (m_sdl_screen) {
+		SDL_FreeSurface(m_sdl_screen);
+		m_sdl_screen = nullptr;
+	}
+	if (m_sdlwindow) {
+		SDL_DestroyWindow(m_sdlwindow);
+		m_sdlwindow = nullptr;
+	}
+	if (m_glcontext) {
+		SDL_GL_DeleteContext(m_glcontext);
+		m_glcontext = nullptr;
+	}
 }
 
 Graphic::~Graphic()
@@ -367,7 +388,7 @@
 
 bool Graphic::is_fullscreen()
 {
-	return m_sdl_screen->flags & SDL_FULLSCREEN;
+	return SDL_GetWindowFlags(m_sdlwindow) & SDL_WINDOW_FULLSCREEN;
 }
 
 /**
@@ -393,32 +414,17 @@
 	// Note: Not all Images are cached in the ImageCache, at time of me writing
 	// this, only InMemoryImage does not safe itself in the ImageCache. And this
 	// should only be a problem for Images loaded from maps.
-	SDL_WM_ToggleFullScreen(m_sdl_screen);
-}
-
-/**
- * Mark the entire screen for refreshing
-*/
-void Graphic::update_fullscreen()
-{
-	m_update_fullscreen = true;
-}
-
-/**
- * Mark a rectangle for refreshing
-*/
-void Graphic::update_rectangle(int32_t x, int32_t y, int32_t w, int32_t h)
-{
-	if (m_nr_update_rects >= MAX_RECTS) {
-		m_update_fullscreen = true;
-		return;
+	// NOCOM: Is this still a todo?
+	if (SDL_GetWindowFlags(m_sdlwindow) & SDL_WINDOW_FULLSCREEN) {
+		SDL_SetWindowFullscreen(m_sdlwindow, 0);
+	} else {
+		SDL_SetWindowFullscreen(m_sdlwindow, SDL_WINDOW_FULLSCREEN);
 	}
-	m_update_fullscreen = true;
-	m_update_rects[m_nr_update_rects].x = x;
-	m_update_rects[m_nr_update_rects].y = y;
-	m_update_rects[m_nr_update_rects].w = w;
-	m_update_rects[m_nr_update_rects].h = h;
-	++m_nr_update_rects;
+}
+
+
+void Graphic::update() {
+	m_update = true;
 }
 
 /**
@@ -426,7 +432,7 @@
 */
 bool Graphic::need_update() const
 {
-	return m_nr_update_rects || m_update_fullscreen;
+	return  m_update;
 }
 
 /**
@@ -434,24 +440,19 @@
  *
  * \param force update whole screen
 */
-void Graphic::refresh(bool force)
+void Graphic::refresh()
 {
 	if (g_opengl) {
-		SDL_GL_SwapBuffers();
-		m_update_fullscreen = false;
-		m_nr_update_rects = 0;
+		SDL_GL_SwapWindow(m_sdlwindow);
+		m_update = false;
 		return;
 	}
 
-	if (force || m_update_fullscreen) {
-		//flip defaults to SDL_UpdateRect(m_surface, 0, 0, 0, 0);
-		SDL_Flip(m_sdl_screen);
-	} else
-		SDL_UpdateRects
-			(m_sdl_screen, m_nr_update_rects, m_update_rects);
-
-	m_update_fullscreen = false;
-	m_nr_update_rects = 0;
+	SDL_UpdateTexture(m_sdl_texture, nullptr, m_sdl_screen->pixels, m_sdl_screen->pitch);
+	SDL_RenderClear(m_sdl_renderer);
+	SDL_RenderCopy(m_sdl_renderer, m_sdl_texture, nullptr, nullptr);
+	SDL_RenderPresent(m_sdl_renderer);
+	m_update = false;
 }
 
 
@@ -467,7 +468,11 @@
 
 uint32_t Graphic::new_maptexture(const std::vector<std::string>& texture_files, const uint32_t frametime)
 {
-	m_maptextures.emplace_back(new Texture(texture_files, frametime, *m_sdl_screen->format));
+	SDL_PixelFormat* pixel_fmt = SDL_AllocFormat(SDL_PIXELFORMAT_ARGB8888);
+	m_maptextures.emplace_back(new Texture(texture_files, frametime, *pixel_fmt));
+	if (pixel_fmt) {
+		SDL_FreeFormat(pixel_fmt);
+	}
 	return m_maptextures.size(); // ID 1 is at m_maptextures[0]
 }
 

=== modified file 'src/graphic/graphic.h'
--- src/graphic/graphic.h	2014-07-14 10:45:44 +0000
+++ src/graphic/graphic.h	2014-10-28 15:04:08 +0000
@@ -93,13 +93,10 @@
 
 	RenderTarget * get_render_target();
 	void toggle_fullscreen();
-	void update_fullscreen();
-	void update_rectangle(int32_t x, int32_t y, int32_t w, int32_t h);
-	void update_rectangle(const Rect& rect) {
-		update_rectangle (rect.x, rect.y, rect.w, rect.h);
-	}
+	void update();
 	bool need_update() const;
-	void refresh(bool force = true);
+	void refresh();
+	SDL_Window* get_sdlwindow() {return m_sdlwindow;}
 
 	SurfaceCache& surfaces() const {return *surface_cache_.get();}
 	ImageCache& images() const {return *image_cache_.get();}
@@ -134,15 +131,14 @@
 	/// opengl rendering as the SurfaceOpenGL does not use it. It allows
 	/// manipulation the screen context.
 	SDL_Surface * m_sdl_screen;
+	SDL_Renderer * m_sdl_renderer;
+	SDL_Window * m_sdlwindow;
+	SDL_Texture * m_sdl_texture;
+	SDL_GLContext m_glcontext;
 	/// A RenderTarget for screen_. This is initialized during init()
 	std::unique_ptr<RenderTarget> m_rendertarget;
-	/// keeps track which screen regions needs to be redrawn during the next
-	/// update(). Only used for SDL rendering.
-	SDL_Rect m_update_rects[MAX_RECTS];
-	/// saves how many screen regions need updating. @see m_update_rects
-	int32_t m_nr_update_rects;
-	/// This marks the komplete screen for updating.
-	bool m_update_fullscreen;
+	/// This marks the complete screen for updating.
+	bool m_update;
 	/// stores which features the current renderer has
 	GraphicCaps m_caps;
 

=== modified file 'src/graphic/image_transformations.cc'
--- src/graphic/image_transformations.cc	2014-07-26 10:43:23 +0000
+++ src/graphic/image_transformations.cc	2014-10-28 15:04:08 +0000
@@ -22,7 +22,7 @@
 #include <string>
 
 #include <SDL.h>
-#include <SDL_rotozoom.h>
+#include <SDL2_rotozoom.h>
 #include <boost/format.hpp>
 
 #include "base/macros.h"
@@ -129,7 +129,8 @@
 			 static_cast<uint16_t>(zoomed->w), static_cast<uint16_t>(zoomed->h)
 			};  // For some reason SDL_Surface and SDL_Rect express w,h in different types
 		SDL_Rect dstrc = {0, 0, 0, 0};
-		SDL_SetAlpha(zoomed, 0, 0);
+		SDL_SetSurfaceAlphaMod(zoomed,  SDL_ALPHA_TRANSPARENT);
+		SDL_SetSurfaceBlendMode(zoomed, SDL_BLENDMODE_NONE);
 		SDL_BlitSurface(zoomed, &srcrc, placed, &dstrc); // Updates dstrc
 
 		uint32_t fillcolor = SDL_MapRGBA(zoomed->format, 0, 0, 0, 255);

=== modified file 'src/graphic/render/gl_surface_texture.cc'
--- src/graphic/render/gl_surface_texture.cc	2014-09-20 09:37:47 +0000
+++ src/graphic/render/gl_surface_texture.cc	2014-10-28 15:04:08 +0000
@@ -85,7 +85,7 @@
 	uint8_t bpp = surface->format->BytesPerPixel;
 
 	if
-		(surface->format->palette || (surface->format->colorkey > 0) ||
+		(surface->format->palette ||
 		 m_tex_w != static_cast<uint32_t>(surface->w) ||
 		 m_tex_h != static_cast<uint32_t>(surface->h) ||
 		 (bpp != 3 && bpp != 4))
@@ -94,8 +94,10 @@
 			(SDL_SWSURFACE, m_tex_w, m_tex_h,
 			 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000);
 		assert(converted);
-		SDL_SetAlpha(converted, 0, 0);
-		SDL_SetAlpha(surface, 0, 0);
+		SDL_SetSurfaceAlphaMod(converted,  SDL_ALPHA_OPAQUE);
+		SDL_SetSurfaceBlendMode(converted, SDL_BLENDMODE_NONE);
+		SDL_SetSurfaceAlphaMod(surface,  SDL_ALPHA_OPAQUE);
+		SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_NONE);
 		SDL_BlitSurface(surface, nullptr, converted, nullptr);
 		SDL_FreeSurface(surface);
 		surface = converted;

=== modified file 'src/graphic/render/sdl_surface.cc'
--- src/graphic/render/sdl_surface.cc	2014-07-14 10:45:44 +0000
+++ src/graphic/render/sdl_surface.cc	2014-10-28 15:04:08 +0000
@@ -338,14 +338,18 @@
 	bool alpha = false;
 	uint8_t alphaval = 0;
 	if (cm == CM_Solid || cm == CM_Copy) {
-		alpha = sdlsurf->flags & SDL_SRCALPHA;
-		alphaval = sdlsurf->format->alpha;
-		SDL_SetAlpha(sdlsurf, 0, 0);
+		SDL_BlendMode bm;
+		SDL_GetSurfaceBlendMode(sdlsurf, &bm);
+		alpha = bm & SDL_BLENDMODE_BLEND;
+		SDL_GetSurfaceAlphaMod(sdlsurf, &alphaval);
+		SDL_SetSurfaceAlphaMod(sdlsurf, 255);
+		SDL_SetSurfaceBlendMode(sdlsurf, SDL_BLENDMODE_NONE);
 	}
 
 	SDL_BlitSurface(sdlsurf, &srcrect, m_surface, &dstrect);
 
 	if (cm == CM_Solid || cm == CM_Copy) {
-		SDL_SetAlpha(sdlsurf, alpha ? SDL_SRCALPHA : 0, alphaval);
+		SDL_SetSurfaceAlphaMod(sdlsurf, alphaval);
+		SDL_SetSurfaceBlendMode(sdlsurf, alpha ? SDL_BLENDMODE_BLEND : SDL_BLENDMODE_NONE);
 	}
 }

=== modified file 'src/graphic/render/sdl_surface.h'
--- src/graphic/render/sdl_surface.h	2014-07-26 10:43:23 +0000
+++ src/graphic/render/sdl_surface.h	2014-10-28 15:04:08 +0000
@@ -20,6 +20,8 @@
 #ifndef WL_GRAPHIC_RENDER_SDL_SURFACE_H
 #define WL_GRAPHIC_RENDER_SDL_SURFACE_H
 
+#include <SDL_render.h>
+
 #include "base/rect.h"
 #include "graphic/color.h"
 #include "graphic/surface.h"

=== modified file 'src/graphic/surface.cc'
--- src/graphic/surface.cc	2014-07-17 13:26:23 +0000
+++ src/graphic/surface.cc	2014-10-28 15:04:08 +0000
@@ -35,7 +35,7 @@
 	if (!s_is_diplay_format_defined) {
 		return surface;
 	}
-	SDL_Surface * converted = SDL_DisplayFormatAlpha(surface);
+	SDL_Surface * converted = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888, 0);
 	SDL_FreeSurface(surface);
 	return converted;
 }

=== modified file 'src/graphic/text/CMakeLists.txt'
--- src/graphic/text/CMakeLists.txt	2014-07-14 10:45:44 +0000
+++ src/graphic/text/CMakeLists.txt	2014-10-28 15:04:08 +0000
@@ -14,9 +14,9 @@
     sdl_ttf_font.h
     textstream.cc
     textstream.h
-  USES_SDL
-  USES_SDL_TTF
-  USES_SDL_GFX
+  USES_SDL2
+  USES_SDL2_TTF
+  USES_SDL2_GFX
   DEPENDS
     base_exceptions
     base_geometry

=== modified file 'src/graphic/text/sdl_ttf_font.cc'
--- src/graphic/text/sdl_ttf_font.cc	2014-09-10 16:57:31 +0000
+++ src/graphic/text/sdl_ttf_font.cc	2014-10-28 15:04:08 +0000
@@ -19,6 +19,7 @@
 
 #include "graphic/text/sdl_ttf_font.h"
 
+#include <SDL.h>
 #include <SDL_ttf.h>
 #include <boost/format.hpp>
 
@@ -70,20 +71,21 @@
 
 	SDL_Surface * text_surface = nullptr;
 
-	SDL_Color sdlclr = {clr.r, clr.g, clr.b, 0};
+	SDL_Color sdlclr = {clr.r, clr.g, clr.b, SDL_ALPHA_OPAQUE};
 	if (style & SHADOW) {
 		SDL_Surface * tsurf = TTF_RenderUTF8_Blended(font_, txt.c_str(), sdlclr);
 		SDL_Surface * shadow = TTF_RenderUTF8_Blended(font_, txt.c_str(), SHADOW_CLR);
 		text_surface = empty_sdl_surface(shadow->w + SHADOW_OFFSET, shadow->h + SHADOW_OFFSET);
 		SDL_FillRect(text_surface,
 		             NULL,
-		             SDL_MapRGBA(text_surface->format, 255, 255, 255, SDL_ALPHA_TRANSPARENT));
+						 SDL_MapRGBA(text_surface->format, 255, 255, 255, SDL_ALPHA_TRANSPARENT));
 
 		if (text_surface->format->BitsPerPixel != 32)
 			throw RenderError("SDL_TTF did not return a 32 bit surface for shadow text. Giving up!");
 
 		SDL_Rect dstrct1 = {0, 0, 0, 0};
-		SDL_SetAlpha(shadow, 0, SDL_ALPHA_OPAQUE);
+		SDL_SetSurfaceAlphaMod(shadow, SDL_ALPHA_OPAQUE);
+		SDL_SetSurfaceBlendMode(shadow, SDL_BLENDMODE_NONE);
 		SDL_BlitSurface(shadow, nullptr, text_surface, &dstrct1);
 
 		uint32_t* spix = static_cast<uint32_t*>(tsurf->pixels);

=== modified file 'src/io/CMakeLists.txt'
--- src/io/CMakeLists.txt	2014-07-26 16:16:21 +0000
+++ src/io/CMakeLists.txt	2014-10-28 15:04:08 +0000
@@ -7,7 +7,7 @@
     streamread.h
     streamwrite.cc
     streamwrite.h
-  USES_SDL
+  USES_SDL2
   DEPENDS
     base_exceptions
     base_macros

=== modified file 'src/logic/CMakeLists.txt'
--- src/logic/CMakeLists.txt	2014-09-18 18:56:20 +0000
+++ src/logic/CMakeLists.txt	2014-10-28 15:04:08 +0000
@@ -1,7 +1,7 @@
 wl_binary(wl_map_info
   SRCS
     map_info.cc
-  USES_SDL
+  USES_SDL2
   DEPENDS
     base_log
     graphic
@@ -211,8 +211,8 @@
     world/terrain_description.h
     world/world.cc
     world/world.h
-  # TODO(sirver): Uses SDL only on WIN32 for a dirty hack.
-  USES_SDL
+  # TODO(sirver): Uses SDL2 only on WIN32 for a dirty hack.
+  USES_SDL2
   DEPENDS
     ai
     base_deprecated

=== modified file 'src/map_io/CMakeLists.txt'
--- src/map_io/CMakeLists.txt	2014-09-10 07:57:29 +0000
+++ src/map_io/CMakeLists.txt	2014-10-28 15:04:08 +0000
@@ -84,7 +84,7 @@
     map_terrain_packet.h
     map_version_packet.cc
     map_version_packet.h
-  USES_SDL_IMAGE
+  USES_SDL2_IMAGE
   DEPENDS
     base_deprecated
     base_exceptions

=== modified file 'src/network/CMakeLists.txt'
--- src/network/CMakeLists.txt	2014-07-16 06:41:27 +0000
+++ src/network/CMakeLists.txt	2014-10-28 15:04:08 +0000
@@ -20,7 +20,7 @@
     network_player_settings_backend.h
     network_protocol.h
     network_system.h
-  USES_SDL_NET
+  USES_SDL2_NET
   DEPENDS
     ai
     base_deprecated

=== modified file 'src/sound/CMakeLists.txt'
--- src/sound/CMakeLists.txt	2014-07-14 10:45:44 +0000
+++ src/sound/CMakeLists.txt	2014-10-28 15:04:08 +0000
@@ -7,8 +7,8 @@
     sound_handler.cc
     sound_handler.h
   USES_BOOST_REGEX
-  USES_SDL
-  USES_SDL_MIXER
+  USES_SDL2
+  USES_SDL2_MIXER
   DEPENDS
     base_deprecated
     base_i18n

=== modified file 'src/sound/songset.cc'
--- src/sound/songset.cc	2014-09-20 09:37:47 +0000
+++ src/sound/songset.cc	2014-10-28 15:04:08 +0000
@@ -26,20 +26,6 @@
 #include "io/filesystem/layered_filesystem.h"
 #include "sound/sound_handler.h"
 
-namespace {
-	// The behaviour of whether SDL_Mixer frees the RW it uses was
-	// changed with SDL_Mixer version 1.2.12, this
-	// check is so that we don't have a memory leak in the new version.
-	// TODO(unknown): Once we can demand that everyone use
-	// SDL_Mixer version >= 1.2.12, this function should be removed,
-	// and all usages replaced supposing it's true.
-	bool have_to_free_rw() {
-		return
-			SDL_VERSIONNUM(SDL_MIXER_MAJOR_VERSION, SDL_MIXER_MINOR_VERSION, SDL_MIXER_PATCHLEVEL) >=
-			SDL_VERSIONNUM(1, 2, 12);
-	}
-}
-
 /// Prepare infrastructure for reading song files from disk
 Songset::Songset() : m_(nullptr), rwops_(nullptr) {}
 
@@ -52,8 +38,7 @@
 		Mix_FreeMusic(m_);
 
 	if (rwops_) {
-		if (have_to_free_rw())
-			SDL_FreeRW(rwops_);
+		SDL_FreeRW(rwops_);
 		fr_.close();
 	}
 }
@@ -98,8 +83,7 @@
 	}
 
 	if (rwops_) {
-		if (have_to_free_rw())
-			SDL_FreeRW(rwops_);
+		SDL_FreeRW(rwops_);
 		rwops_ = nullptr;
 		fr_.close();
 	}
@@ -115,7 +99,7 @@
 		return nullptr;
 
 	if (rwops_)
-		m_ = Mix_LoadMUS_RW(rwops_);
+		m_ = Mix_LoadMUS_RW(rwops_, 0);
 
 	if (m_)
 		log("SoundHandler: loaded song \"%s\"\n", filename.c_str());

=== modified file 'src/sound/sound_handler.cc'
--- src/sound/sound_handler.cc	2014-09-20 09:37:47 +0000
+++ src/sound/sound_handler.cc	2014-10-28 15:04:08 +0000
@@ -164,11 +164,8 @@
 	if (SDL_InitSubSystem(SDL_INIT_AUDIO) == -1) {
 		log ("audio error %s\n", SDL_GetError());
 	}
-	char * text = new char[21];
-	SDL_AudioDriverName(text, 20);
-	log("SDL_AUDIODRIVER %s\n", text);
-	delete[] text;
-	text = nullptr;
+
+	log("SDL_AUDIODRIVER %s\n", SDL_GetCurrentAudioDriver());
 
 	if (numtimesopened != 1) {
 		log ("PROBLEM: sound device opened multiple times, trying to close");

=== modified file 'src/ui_basic/CMakeLists.txt'
--- src/ui_basic/CMakeLists.txt	2014-07-15 10:02:22 +0000
+++ src/ui_basic/CMakeLists.txt	2014-10-28 15:04:08 +0000
@@ -51,7 +51,7 @@
     window.cc
     window.h
   USES_BOOST_REGEX
-  USES_SDL
+  USES_SDL2
   DEPENDS
     base_deprecated
     base_exceptions

=== modified file 'src/ui_basic/button.cc'
--- src/ui_basic/button.cc	2014-07-25 18:56:22 +0000
+++ src/ui_basic/button.cc	2014-10-28 15:04:08 +0000
@@ -341,6 +341,7 @@
 	}
 	return true;
 }
+
 bool Button::handle_mousemove(const uint8_t, int32_t, int32_t, int32_t, int32_t) {
 	return true; // We handle this always by lighting up
 }

=== modified file 'src/ui_basic/editbox.cc'
--- src/ui_basic/editbox.cc	2014-09-19 09:07:14 +0000
+++ src/ui_basic/editbox.cc	2014-10-28 15:04:08 +0000
@@ -21,7 +21,7 @@
 
 #include <limits>
 
-#include <SDL_keysym.h>
+#include <SDL_keycode.h>
 
 #include "graphic/font.h"
 #include "graphic/font_handler.h"
@@ -87,6 +87,7 @@
 
 	set_handle_mouse(true);
 	set_can_focus(true);
+	set_handle_textinput(true);
 
 	// Initialize history as empty string
 	for (uint8_t i = 0; i < CHAT_HISTORY_SIZE; ++i)
@@ -220,7 +221,7 @@
 // TODO(unknown): Text input works only because code.unicode happens to map to ASCII for
 // ASCII characters (--> //HERE). Instead, all user editable strings should be
 // real unicode.
-bool EditBox::handle_key(bool const down, SDL_keysym const code)
+bool EditBox::handle_key(bool const down, SDL_Keysym const code)
 {
 	if (down) {
 		switch (code.sym) {
@@ -232,7 +233,7 @@
 			//let the panel handle the tab key
 			return false;
 
-		case SDLK_KP_ENTER:
+		case SDL_SCANCODE_KP_ENTER:
 		case SDLK_RETURN:
 			// Save history if active and text is not empty
 			if (m_history_active) {
@@ -246,9 +247,8 @@
 			ok();
 			return true;
 
-		case SDLK_KP_PERIOD:
+		case SDL_SCANCODE_KP_PERIOD:
 			if (code.mod & KMOD_NUM) {
-				insert(code);
 				break;
 			}
 			/* no break */
@@ -270,13 +270,12 @@
 			}
 			return true;
 
-		case SDLK_KP4:
+		case SDL_SCANCODE_KP_4:
 			if (code.mod & KMOD_NUM) {
-				insert(code);
 				break;
 			}
 			/* no break */
-		case SDLK_LEFT:
+		case SDL_SCANCODE_LEFT:
 			if (m->caret > 0) {
 				while ((m->text[--m->caret] & 0xc0) == 0x80) {};
 				if (code.mod & (KMOD_LCTRL | KMOD_RCTRL))
@@ -290,13 +289,12 @@
 			}
 			return true;
 
-		case SDLK_KP6:
+		case SDL_SCANCODE_KP_6:
 			if (code.mod & KMOD_NUM) {
-				insert(code);
 				break;
 			}
 			/* no break */
-		case SDLK_RIGHT:
+		case SDL_SCANCODE_RIGHT:
 			if (m->caret < m->text.size()) {
 				while ((m->text[++m->caret] & 0xc0) == 0x80) {};
 				if (code.mod & (KMOD_LCTRL | KMOD_RCTRL))
@@ -315,9 +313,8 @@
 			}
 			return true;
 
-		case SDLK_KP7:
+		case SDL_SCANCODE_KP_7:
 			if (code.mod & KMOD_NUM) {
-				insert(code);
 				break;
 			}
 			/* no break */
@@ -330,9 +327,8 @@
 			}
 			return true;
 
-		case SDLK_KP1:
+		case SDL_SCANCODE_KP_1:
 			if (code.mod & KMOD_NUM) {
-				insert(code);
 				break;
 			}
 			/* no break */
@@ -344,13 +340,12 @@
 			}
 			return true;
 
-		case SDLK_KP8:
+		case SDL_SCANCODE_KP_8:
 			if (code.mod & KMOD_NUM) {
-				insert(code);
 				break;
 			}
 			/* no break */
-		case SDLK_UP:
+		case SDL_SCANCODE_UP:
 			// Load entry from history if active and text is not empty
 			if (m_history_active) {
 				if (m_history_position > CHAT_HISTORY_SIZE - 2)
@@ -364,13 +359,12 @@
 			}
 			return true;
 
-		case SDLK_KP2:
+		case SDL_SCANCODE_KP_2:
 			if (code.mod & KMOD_NUM) {
-				insert(code);
 				break;
 			}
 			/* no break */
-		case SDLK_DOWN:
+		case SDL_SCANCODE_DOWN:
 			// Load entry from history if active and text is not equivalent to the current one
 			if (m_history_active) {
 				if (m_history_position < 1)
@@ -389,11 +383,13 @@
 			// Nullbytes happen on MacOS X when entering Multiline Chars, like for
 			// example ~ + o results in a o with a tilde over it. The ~ is reported
 			// as a 0 on keystroke, the o then as the unicode character. We simply
-			// ignore the 0.
-			if (is_printable(code) && code.unicode) {
+			// ignore the 0. NOCOM: Is this still true for Macs?
+			/*
+				if (is_printable(code) && code.unicode) {
 				insert(code);
 				return true;
 			}
+			*/
 			break;
 		}
 	}
@@ -401,31 +397,16 @@
 	return false;
 }
 
-/**
- * Insert the utf8 character according to the specified key code
- */
-void EditBox::insert(SDL_keysym const code)
-{
-	if (m->text.size() < m->maxLength) {
-		if (code.unicode < 0x80) // 1 byte char
-			m->text.insert(m->text.begin() + m->caret++, 1, code.unicode);
-		else if (code.unicode < 0x800) { // 2 byte char
-			m->text.insert
-				(m->text.begin() + m->caret++, (((code.unicode & 0x7c0) >> 6) | 0xc0));
-			m->text.insert
-				(m->text.begin() + m->caret++, ((code.unicode & 0x3f) | 0x80));
-		} else { // 3 byte char
-			m->text.insert
-				(m->text.begin() + m->caret++, (((code.unicode & 0xf000) >> 12) | 0xe0));
-			m->text.insert
-				(m->text.begin() + m->caret++, (((code.unicode & 0xfc0) >> 6) | 0x80));
-			m->text.insert
-				(m->text.begin() + m->caret++, ((code.unicode & 0x3f) | 0x80));
-		}
+bool EditBox::handle_textinput(const char * ntext) {
+	const std::string help(ntext);
+	if ((m->text.size() +  help.length()) < m->maxLength) {
+		m->text.insert(m->caret, help);
+		m->caret += help.length();
 		check_caret();
 		changed();
 		update();
 	}
+	return true;
 }
 
 void EditBox::draw(RenderTarget & odst)

=== modified file 'src/ui_basic/editbox.h'
--- src/ui_basic/editbox.h	2014-09-19 09:07:14 +0000
+++ src/ui_basic/editbox.h	2014-10-28 15:04:08 +0000
@@ -61,7 +61,8 @@
 
 	bool handle_mousepress(uint8_t btn, int32_t x, int32_t y) override;
 	bool handle_mouserelease(uint8_t btn, int32_t x, int32_t y) override;
-	bool handle_key(bool down, SDL_keysym) override;
+	bool handle_key(bool down, SDL_Keysym) override;
+	bool handle_textinput(const char* text);
 
 	void draw(RenderTarget &) override;
 
@@ -69,7 +70,6 @@
 	std::unique_ptr<EditBoxImpl> m;
 
 	void check_caret();
-	void insert(SDL_keysym code);
 
 	bool        m_history_active;
 	int16_t     m_history_position;

=== modified file 'src/ui_basic/is_printable.cc'
--- src/ui_basic/is_printable.cc	2014-07-03 20:11:14 +0000
+++ src/ui_basic/is_printable.cc	2014-10-28 15:04:08 +0000
@@ -21,10 +21,9 @@
 
 namespace UI {
 
-bool is_printable(SDL_keysym k) {
+bool is_printable(SDL_Keysym k) {
 	return (k.sym == SDLK_TAB) || ((k.sym >= SDLK_SPACE) && (k.sym <= SDLK_z)) ||
-	       ((k.sym >= SDLK_WORLD_0) && (k.sym <= SDLK_WORLD_95)) ||
-	       ((k.sym >= SDLK_KP0) && (k.sym <= SDLK_KP_EQUALS));
+			 ((k.sym >= SDL_SCANCODE_KP_0) && (k.sym <= SDL_SCANCODE_KP_EQUALS));
 }
 
 }  // namespace UI

=== modified file 'src/ui_basic/is_printable.h'
--- src/ui_basic/is_printable.h	2014-07-23 14:49:10 +0000
+++ src/ui_basic/is_printable.h	2014-10-28 15:04:08 +0000
@@ -36,7 +36,7 @@
 // WLApplication::init_hardware()) instead of k.sym. Doing so needs to take the
 // current locale into account; perhaps there already is a fitting gettext
 // function?
-bool is_printable(SDL_keysym k);
+bool is_printable(SDL_Keysym k);
 
 }  // namespace UI
 

=== modified file 'src/ui_basic/listselect.cc'
--- src/ui_basic/listselect.cc	2014-10-27 10:31:04 +0000
+++ src/ui_basic/listselect.cc	2014-10-28 15:04:08 +0000
@@ -416,14 +416,19 @@
 }
 
 /**
+ * Handle mouse wheel events
+ */
+bool BaseListselect::handle_mousewheel(uint32_t which, int32_t x, int32_t y) {
+	return m_scrollbar.handle_mousewheel(which, x, y);
+}
+
+/**
  * Handle mouse presses: select the appropriate entry
  */
 bool BaseListselect::handle_mousepress(const uint8_t btn, int32_t, int32_t y)
 {
 	switch (btn) {
-	case SDL_BUTTON_WHEELDOWN:
-	case SDL_BUTTON_WHEELUP:
-		return m_scrollbar.handle_mousepress(btn, 0, y);
+
 	case SDL_BUTTON_LEFT: {
 		int32_t const time = WLApplication::get()->get_time();
 
@@ -471,15 +476,15 @@
 	return true;
 }
 
-bool BaseListselect::handle_key(bool const down, SDL_keysym const code) {
+bool BaseListselect::handle_key(bool const down, SDL_Keysym const code) {
 	if (down) {
 		uint32_t selected_idx;
 		switch (code.sym) {
-		case SDLK_KP2:
+		case SDL_SCANCODE_KP_2:
 			if (code.mod & KMOD_NUM)
 				break;
 			/* no break */
-		case SDLK_DOWN:
+		case SDL_SCANCODE_DOWN:
 			selected_idx = selection_index() + 1;
 			if (selected_idx < size())
 				select(selected_idx);
@@ -489,11 +494,11 @@
 				m_scrollbar.set_scrollpos(m_scrollpos);
 			}
 			return true;
-		case SDLK_KP8:
+		case SDL_SCANCODE_KP_8:
 			if (code.mod & KMOD_NUM)
 				break;
 			/* no break */
-		case SDLK_UP:
+		case SDL_SCANCODE_UP:
 			selected_idx = selection_index();
 			if (selected_idx > 0)
 				select(selected_idx - 1);

=== modified file 'src/ui_basic/listselect.h'
--- src/ui_basic/listselect.h	2014-10-27 10:31:04 +0000
+++ src/ui_basic/listselect.h	2014-10-28 15:04:08 +0000
@@ -117,7 +117,8 @@
 	bool handle_mousepress  (uint8_t btn,   int32_t x, int32_t y) override;
 	bool handle_mouserelease(uint8_t btn,   int32_t x, int32_t y) override;
 	bool handle_mousemove   (uint8_t state, int32_t x, int32_t y, int32_t xdiff, int32_t ydiff) override;
-	bool handle_key(bool down, SDL_keysym) override;
+	bool handle_mousewheel(uint32_t which, int32_t x, int32_t y) override;
+	bool handle_key(bool down, SDL_Keysym) override;
 
 private:
 	static const int32_t DOUBLE_CLICK_INTERVAL = 500; // half a second

=== modified file 'src/ui_basic/messagebox.cc'
--- src/ui_basic/messagebox.cc	2014-09-19 09:07:14 +0000
+++ src/ui_basic/messagebox.cc	2014-10-28 15:04:08 +0000
@@ -133,14 +133,14 @@
 	return true;
 }
 
-bool WLMessageBox::handle_key(bool down, SDL_keysym code)
+bool WLMessageBox::handle_key(bool down, SDL_Keysym code)
 {
 	if (!down) {
 		return false;
 	}
 
 	switch (code.sym) {
-		case SDLK_KP_ENTER:
+		case SDL_SCANCODE_KP_ENTER:
 		case SDLK_RETURN:
 			pressed_yes();
 			pressed_ok();

=== modified file 'src/ui_basic/messagebox.h'
--- src/ui_basic/messagebox.h	2014-09-19 09:07:14 +0000
+++ src/ui_basic/messagebox.h	2014-10-28 15:04:08 +0000
@@ -69,7 +69,7 @@
 
 	bool handle_mousepress  (uint8_t btn, int32_t mx, int32_t my) override;
 	bool handle_mouserelease(uint8_t btn, int32_t mx, int32_t my) override;
-	bool handle_key(bool down, SDL_keysym code) override;
+	bool handle_key(bool down, SDL_Keysym code) override;
 
 protected:
 	virtual void pressed_ok();

=== modified file 'src/ui_basic/multilineeditbox.cc'
--- src/ui_basic/multilineeditbox.cc	2014-09-10 14:48:40 +0000
+++ src/ui_basic/multilineeditbox.cc	2014-10-28 15:04:08 +0000
@@ -89,6 +89,7 @@
 	set_handle_mouse(true);
 	set_can_focus(true);
 	set_think(false);
+	set_handle_textinput(true);
 
 	set_text(text);
 }
@@ -245,27 +246,15 @@
 	return cursor;
 }
 
-/**
- * Insert the utf8 character according to the specified key code
- */
-void MultilineEditbox::insert(SDL_keysym const code)
-{
-	std::string utf8 = Utf8::unicode_to_utf8(code.unicode);
-
-	if (d->text.size() + utf8.size() <= d->maxbytes) {
-		d->insert(d->cursor_pos, utf8);
-		changed();
-	}
-}
 
 /**
  * This is called by the UI code whenever a key press or release arrives
  */
-bool MultilineEditbox::handle_key(bool const down, SDL_keysym const code)
+bool MultilineEditbox::handle_key(bool const down, SDL_Keysym const code)
 {
 	if (down) {
 		switch (code.sym) {
-		case SDLK_KP_PERIOD:
+		case SDL_SCANCODE_KP_PERIOD:
 			if (code.mod & KMOD_NUM)
 				break;
 			/* no break */
@@ -283,13 +272,12 @@
 			}
 			break;
 
-		case SDLK_KP4:
+		case SDL_SCANCODE_KP_4:
 			if (code.mod & KMOD_NUM) {
-				insert(code);
 				break;
 			}
 			/* no break */
-		case SDLK_LEFT: {
+		case SDL_SCANCODE_LEFT: {
 			if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
 				uint32_t newpos = d->prev_char(d->cursor_pos);
 				while (newpos > 0 && isspace(d->text[newpos]))
@@ -307,13 +295,12 @@
 			break;
 		}
 
-		case SDLK_KP6:
+		case SDL_SCANCODE_KP_6:
 			if (code.mod & KMOD_NUM) {
-				insert(code);
 				break;
 			}
 			/* no break */
-		case SDLK_RIGHT:
+		case SDL_SCANCODE_RIGHT:
 			if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
 				uint32_t newpos = d->next_char(d->cursor_pos);
 				while (newpos < d->text.size() && isspace(d->text[newpos]))
@@ -326,13 +313,12 @@
 			}
 			break;
 
-		case SDLK_KP2:
+		case SDL_SCANCODE_KP_2:
 			if (code.mod & KMOD_NUM) {
-				insert(code);
 				break;
 			}
 			/* no break */
-		case SDLK_DOWN:
+		case SDL_SCANCODE_DOWN:
 			if (d->cursor_pos < d->text.size()) {
 				d->refresh_ww();
 
@@ -356,13 +342,12 @@
 			}
 			break;
 
-		case SDLK_KP8:
+		case SDL_SCANCODE_KP_8:
 			if (code.mod & KMOD_NUM) {
-				insert(code);
 				break;
 			}
 			/* no break */
-		case SDLK_UP:
+		case SDL_SCANCODE_UP:
 			if (d->cursor_pos > 0) {
 				d->refresh_ww();
 
@@ -384,9 +369,8 @@
 			}
 			break;
 
-		case SDLK_KP7:
+		case SDL_SCANCODE_KP_7:
 			if (code.mod & KMOD_NUM) {
-				insert(code);
 				break;
 			}
 			/* no break */
@@ -403,9 +387,8 @@
 			}
 			break;
 
-		case SDLK_KP1:
+		case SDL_SCANCODE_KP_1:
 			if (code.mod & KMOD_NUM) {
-				insert(code);
 				break;
 			}
 			/* no break */
@@ -425,7 +408,7 @@
 			}
 			break;
 
-		case SDLK_KP_ENTER:
+		case SDL_SCANCODE_KP_ENTER:
 		case SDLK_RETURN:
 			d->insert(d->cursor_pos, "\n");
 			changed();
@@ -435,10 +418,12 @@
 			// Nullbytes happen on MacOS X when entering Multiline Chars, like for
 			// example ~ + o results in a o with a tilde over it. The ~ is reported
 			// as a 0 on keystroke, the o then as the unicode character. We simply
-			// ignore the 0.
+			// ignore the 0. NOCOM: Is this still true for Macs?
+				/*
 			if (is_printable(code) && code.unicode) {
 				insert(code);
 			}
+			*/
 			break;
 		}
 		return true;
@@ -447,12 +432,21 @@
 	return Panel::handle_key(down, code);
 }
 
+
+bool MultilineEditbox::handle_textinput(const char * ntext) {
+	const std::string help(ntext);
+	if (d->text.size() + help.size() <= d->maxbytes) {
+		d->insert(d->cursor_pos, help);
+		changed();
+	}
+	return true;
+}
+
 /**
  * Grab the focus and redraw.
  */
-void MultilineEditbox::focus() {
-	Panel::focus();
-
+void MultilineEditbox::focus(bool topcaller) {
+	Panel::focus(topcaller);
 	update();
 }
 

=== modified file 'src/ui_basic/multilineeditbox.h'
--- src/ui_basic/multilineeditbox.h	2014-09-10 14:48:40 +0000
+++ src/ui_basic/multilineeditbox.h	2014-10-28 15:04:08 +0000
@@ -47,16 +47,16 @@
 	void set_maximum_bytes(uint32_t n);
 	uint32_t get_maximum_bytes() const;
 
-	void focus() override;
+	void focus(bool topcaller = true) override;
 
 protected:
 	void draw(RenderTarget &) override;
 
-	bool handle_key(bool down, SDL_keysym) override;
+	bool handle_key(bool down, SDL_Keysym) override;
+	bool handle_textinput(const char* text);
 
 private:
 	void scrollpos_changed(int32_t);
-	void insert(SDL_keysym code);
 
 	struct Data;
 	std::unique_ptr<Data> d;

=== modified file 'src/ui_basic/multilinetextarea.cc'
--- src/ui_basic/multilinetextarea.cc	2014-10-05 13:37:03 +0000
+++ src/ui_basic/multilinetextarea.cc	2014-10-28 15:04:08 +0000
@@ -190,12 +190,9 @@
 	}
 }
 
-bool MultilineTextarea::handle_mousepress
-	(uint8_t const btn, int32_t const x, int32_t const y)
-{
-	return
-		btn == SDL_BUTTON_WHEELUP || btn == SDL_BUTTON_WHEELDOWN ?
-		m_scrollbar.handle_mousepress(btn, x, y) : false;
+
+bool MultilineTextarea::handle_mousewheel(uint32_t which, int32_t x, int32_t y) {
+	return m_scrollbar.handle_mousewheel(which, x, y);
 }
 
 void MultilineTextarea::scroll_to_top() {

=== modified file 'src/ui_basic/multilinetextarea.h'
--- src/ui_basic/multilinetextarea.h	2014-10-05 13:37:03 +0000
+++ src/ui_basic/multilinetextarea.h	2014-10-28 15:04:08 +0000
@@ -64,7 +64,7 @@
 	// Drawing and event handlers
 	void draw(RenderTarget &) override;
 
-	bool handle_mousepress  (uint8_t btn, int32_t x, int32_t y) override;
+	bool handle_mousewheel(uint32_t which, int32_t x, int32_t y) override;
 	void scroll_to_top();
 
 	const char *  get_font_name() {return m_fontname.c_str();}

=== modified file 'src/ui_basic/panel.cc'
--- src/ui_basic/panel.cc	2014-10-18 13:39:27 +0000
+++ src/ui_basic/panel.cc	2014-10-28 15:04:08 +0000
@@ -189,7 +189,7 @@
 
 	// Panel-specific startup code. This might call end_modal()!
 	start();
-	g_gr->update_fullscreen();
+	g_gr->update();
 
 	uint32_t minTime;
 	{
@@ -206,7 +206,9 @@
 			Panel::ui_mousepress,
 			Panel::ui_mouserelease,
 			Panel::ui_mousemove,
-			Panel::ui_key
+			Panel::ui_key,
+			Panel::ui_textinput,
+			Panel::ui_mousewheel
 		};
 
 		app->handle_input(&icb);
@@ -240,7 +242,7 @@
 			SDL_Delay(minTime - diffTime);
 		}
 	}
-	g_gr->update_fullscreen();
+	g_gr->update();
 	end();
 
 	// Done
@@ -531,7 +533,7 @@
 		if (h <= 0)
 			return;
 
-		g_gr->update_rectangle(x, y, w, h);
+		g_gr->update();
 	}
 }
 
@@ -665,6 +667,18 @@
 }
 
 /**
+ * Called whenever the user moves the mouse wheel.
+ * If the panel doesn't process the mouse-wheel, it is handed to the panel's
+ * parent.
+ *
+ * \return true if the mouseclick was processed, false otherwise
+ */
+bool Panel::handle_mousewheel(uint32_t, int32_t, int32_t) {
+	return false;
+}
+
+
+/**
  * Called when the mouse is moved while inside the panel
  */
 bool Panel::handle_mousemove(const uint8_t, int32_t, int32_t, int32_t, int32_t)
@@ -672,14 +686,8 @@
 	return !_tooltip.empty();
 }
 
-/**
- * Receive a keypress or keyrelease event.
- * code is one of the KEY_xxx constants, c is the corresponding printable
- * character or 0 for special, unprintable keys.
- *
- * \return true if the event was processed, false otherwise
-*/
-bool Panel::handle_key(bool down, SDL_keysym code)
+
+bool Panel::handle_key(bool down, SDL_Keysym code)
 {
 	if (down) {
 		if (_focus) {
@@ -710,6 +718,12 @@
 	return false;
 }
 
+
+bool Panel::handle_textinput(const char *) {
+	return false;
+}
+
+
 /**
  * Called whenever a tooltip could be drawn.
  * Return true if the tooltip has been drawn,
@@ -783,15 +797,24 @@
 }
 
 /**
- * Grab the keyboard focus, if it can
+ * Grabs the keyboard focus, if it can,
+ * topcaller identifies widget at the beginning of the recursion
  */
-void Panel::focus()
+void Panel::focus(bool topcaller)
 {
 	// this assert was deleted, because
 	// it happens, that a child can focus, but a parent
 	// can't. but focus is called recursivly
 	// assert(get_can_focus());
 
+	if (topcaller) {
+		if (get_handle_textinput()) {
+			if (!SDL_IsTextInputActive()) SDL_StartTextInput();
+		} else {
+			if (SDL_IsTextInputActive()) SDL_StopTextInput();
+		}
+	}
+
 	if (!_parent || this == _modal) {
 		return;
 	}
@@ -799,7 +822,7 @@
 		return;
 
 	_parent->_focus = this;
-	_parent->focus();
+	_parent->focus(false);
 }
 
 /**
@@ -1008,8 +1031,8 @@
 	//  Some window managers use alt-drag, so we can't only use the alt keys
 	if
 		((!_g_mousegrab) && (btn == SDL_BUTTON_LEFT) &&
-		 ((get_key_state(SDLK_LALT) | get_key_state(SDLK_RALT) |
-		   get_key_state(SDLK_MODE) | get_key_state(SDLK_LSHIFT))))
+		 ((get_key_state(SDL_SCANCODE_LALT) | get_key_state(SDL_SCANCODE_RALT) |
+			get_key_state(SDL_SCANCODE_MODE) | get_key_state(SDL_SCANCODE_LSHIFT))))
 		if (handle_alt_drag(x, y))
 			return true;
 
@@ -1024,6 +1047,26 @@
 			}
 	return handle_mousepress(btn, x, y);
 }
+
+
+bool Panel::do_mousewheel(uint32_t which, int32_t x, int32_t y) {
+	if (!_g_allow_user_input) {
+		return true;
+	}
+
+	// TODO(GunChleoc): This is just a hack for focussed panels
+	// We need to find the actualy scrollable panel beneaththe mouse cursor,
+	// so we can have multiple scrollable elements on the same screen
+	// e.g. load map with a long desctiprion has 2 of them.
+	if (_focus) {
+		if (_focus->do_mousewheel(which, x, y))
+			return true;
+	}
+
+	return handle_mousewheel(which, x, y);
+}
+
+
 bool Panel::do_mouserelease(const uint8_t btn, int32_t x, int32_t y) {
 	if (!_g_allow_user_input)
 		return true;
@@ -1070,7 +1113,7 @@
  * Pass the key event to the focused child.
  * If it doesn't process the key, we'll see if we can use the event.
  */
-bool Panel::do_key(bool const down, SDL_keysym const code)
+bool Panel::do_key(bool const down, SDL_Keysym const code)
 {
 	if (!_g_allow_user_input)
 		return true;
@@ -1083,6 +1126,20 @@
 	return handle_key(down, code);
 }
 
+
+bool Panel::do_textinput(const char * text) {
+	if (!_g_allow_user_input) {
+		return true;
+	}
+	if (_focus) {
+		if (_focus->do_textinput(text)) {
+			return true;
+		}
+	}
+	return handle_textinput(text);
+}
+
+
 bool Panel::do_tooltip()
 {
 	if (_mousein && _mousein->do_tooltip()) {
@@ -1094,7 +1151,7 @@
 /**
  * \return \c true if the given key is currently pressed, or \c false otherwise
  */
-bool Panel::get_key_state(const SDLKey key) const
+bool Panel::get_key_state(const SDL_Scancode key) const
 {
 	return WLApplication::get()->get_key_state(key);
 }
@@ -1175,11 +1232,8 @@
 		return;
 
 	Panel * p;
-	uint16_t w = s_default_cursor->width();
-	uint16_t h = s_default_cursor->height();
 
-	g_gr->update_rectangle(x - xdiff, y - ydiff, w, h);
-	g_gr->update_rectangle(x, y, w, h);
+	g_gr->update();
 
 	p = ui_trackmouse(x, y);
 	if (!p)
@@ -1189,9 +1243,32 @@
 }
 
 /**
+ * Input callback function. Pass the mousewheel event to the currently modal
+ * panel.
+*/
+void Panel::ui_mousewheel(uint32_t which, int32_t x, int32_t y) {
+	if (!_g_allow_user_input) {
+		return;
+	}
+	if (!x && !y) {
+		return;
+	}
+	Panel* p = nullptr;
+	if (_g_mousein) {
+		p = _g_mousein;
+	} else {
+		p = _g_mousegrab ? _g_mousegrab : _modal;
+	}
+	if (p) {
+		p->do_mousewheel(which, x, y);
+	}
+}
+
+
+/**
  * Input callback function. Pass the key event to the currently modal panel
  */
-void Panel::ui_key(bool const down, SDL_keysym const code)
+void Panel::ui_key(bool const down, SDL_Keysym const code)
 {
 	if (!_g_allow_user_input)
 		return;
@@ -1199,14 +1276,25 @@
 	_modal->do_key(down, code);
 }
 
+
+/**
+ * Input callback function. Pass the textinput event to the currently modal panel
+ */
+void Panel::ui_textinput(const char * text) {
+	if (!_g_allow_user_input) {
+		return;
+	}
+	_modal->do_textinput(text);
+}
+
 /**
  * Draw the tooltip. Return true on success
  */
 bool Panel::draw_tooltip(RenderTarget & dst, const std::string & text)
 {
-	if (text.empty())
+	if (text.empty()) {
 		return false;
-
+	}
 	std::string text_to_render = text;
 	if (!is_richtext(text_to_render)) {
 		text_to_render = as_tooltip(text);
@@ -1214,9 +1302,9 @@
 
 	static const uint32_t TIP_WIDTH_MAX = 360;
 	const Image* rendered_text = g_fh1->render(text_to_render, TIP_WIDTH_MAX);
-	if (!rendered_text)
+	if (!rendered_text) {
 		return false;
-
+	}
 	uint16_t tip_width = rendered_text->width() + 4;
 	uint16_t tip_height = rendered_text->height() + 4;
 

=== modified file 'src/ui_basic/panel.h'
--- src/ui_basic/panel.h	2014-07-23 14:49:10 +0000
+++ src/ui_basic/panel.h	2014-10-28 15:04:08 +0000
@@ -74,6 +74,8 @@
 		pf_layout_toplevel = 512,
 		/// whether widget panels should be cached when possible
 		pf_cache = 1024,
+		/// whether widget wants to receive unicode textinput messages
+		pf_textinput = 2048,
 	}; // TODO(unknown): Turn this into separate bool flags
 
 	Panel
@@ -186,21 +188,23 @@
 	virtual bool handle_mouserelease(uint8_t btn, int32_t x, int32_t y);
 	virtual bool handle_mousemove
 		(uint8_t state, int32_t x, int32_t y, int32_t xdiff, int32_t ydiff);
-	virtual bool handle_key(bool down, SDL_keysym code);
+	virtual bool handle_mousewheel(uint32_t which, int32_t x, int32_t y);
+	virtual bool handle_key(bool down, SDL_Keysym);
+	virtual bool handle_textinput(const char* text);
 	virtual bool handle_alt_drag(int32_t x, int32_t y);
 	virtual bool handle_tooltip();
 
 	/// \returns whether a certain given is currently down.
 	///
 	/// \note Never call this function from a keyboard event handler (a function
-	/// that overrides bool handle_key(bool, SDL_keysym code)) to get the state
+	/// that overrides bool handle_key(bool, SDL_Keysym code)) to get the state
 	/// of a modifier key. In that case code.mod must be used. It contains the
 	/// state of the modifier keys at the time of the event. Unfortunately there
 	/// is no information about modifier key states in mouse events (tracker
 	/// item #1916453). That is "a huge oversight" in SDL 1.2 and a fix is
 	/// promised in SDL 1.3:
 	/// http://lists.libsdl.org/pipermail/sdl-libsdl.org/2008-March/064560.html
-	bool get_key_state(SDLKey) const;
+	bool get_key_state(SDL_Scancode) const;
 
 	void set_handle_mouse(bool yes);
 	bool get_handle_mouse() const {return _flags & pf_handle_mouse;}
@@ -212,7 +216,7 @@
 		assert(get_can_focus());
 		return (_parent->_focus == this);
 	}
-	virtual void focus();
+	virtual void focus(bool topcaller = true);
 
 	void set_think(bool yes);
 	bool get_think() const {return _flags & pf_think;}
@@ -231,6 +235,11 @@
 	void set_tooltip(const std::string& text) {_tooltip = text;}
 	const std::string& tooltip() const {return _tooltip;}
 
+	void set_handle_textinput(bool on) {
+		on ? _flags |= pf_textinput : _flags &= ~pf_textinput;
+	}
+	bool get_handle_textinput() const {return _flags & pf_textinput;}
+
 	///\return the current set UI font
 	std::string ui_fn();
 
@@ -263,7 +272,9 @@
 	bool do_mouserelease(const uint8_t btn, int32_t x, int32_t y);
 	bool do_mousemove
 		(const uint8_t state, int32_t x, int32_t y, int32_t xdiff, int32_t ydiff);
-	bool do_key(bool down, SDL_keysym code);
+	bool do_mousewheel(uint32_t which, int32_t x, int32_t y);
+	bool do_key(bool down, SDL_Keysym code);
+	bool do_textinput(const char* text);
 	bool do_tooltip();
 
 	static Panel * ui_trackmouse(int32_t & x, int32_t & y);
@@ -271,8 +282,9 @@
 	static void ui_mouserelease(const uint8_t button, int32_t x, int32_t y);
 	static void ui_mousemove
 		(const uint8_t state, int32_t x, int32_t y, int32_t xdiff, int32_t ydiff);
-	static void ui_key(bool down, SDL_keysym code);
-
+	static void ui_mousewheel(uint32_t which, int32_t x, int32_t y);
+	static void ui_key(bool down, SDL_Keysym code);
+	static void ui_textinput(const char* text);
 
 	Panel * _parent;
 	Panel * _next, * _prev;

=== modified file 'src/ui_basic/progresswindow.cc'
--- src/ui_basic/progresswindow.cc	2014-09-20 09:37:47 +0000
+++ src/ui_basic/progresswindow.cc	2014-10-28 15:04:08 +0000
@@ -117,7 +117,7 @@
 	UI::TextStyle ts(UI::TextStyle::ui_small());
 	ts.fg = PROGRESS_FONT_COLOR_FG;
 	UI::g_fh->draw_text(rt, ts, m_label_center, description, Align_Center);
-	g_gr->update_rectangle(m_label_rectangle);
+	g_gr->update();
 
 #ifdef _WIN32
 		// Pump events to prevent "not responding" on windows
@@ -131,7 +131,7 @@
 	for (IProgressVisualization * visualization : m_visualizations) {
 		visualization->update(repaint); //  let visualizations do their work
 	}
-	g_gr->refresh(false);
+	g_gr->refresh();
 }
 
 /**

=== modified file 'src/ui_basic/scrollbar.cc'
--- src/ui_basic/scrollbar.cc	2014-07-14 10:45:44 +0000
+++ src/ui_basic/scrollbar.cc	2014-10-28 15:04:08 +0000
@@ -391,6 +391,16 @@
 }
 
 
+bool Scrollbar::handle_mousewheel(uint32_t, int32_t, int32_t y) {
+	if (y < 0) {
+		action(Plus);
+	} else {
+		action(Minus);
+	}
+	return true;
+}
+
+
 bool Scrollbar::handle_mousepress(const uint8_t btn, int32_t x, int32_t y) {
 	bool result = false;
 
@@ -410,15 +420,6 @@
 		result = true;
 		break;
 
-	case SDL_BUTTON_WHEELUP:
-		action(Minus);
-		result = true;
-		break;
-
-	case SDL_BUTTON_WHEELDOWN:
-		action(Plus);
-		result = true;
-		break;
 	default:
 		break;
 	}
@@ -437,13 +438,6 @@
 		result = true;
 		break;
 
-	case SDL_BUTTON_WHEELUP:
-		result = true;
-		break;
-
-	case SDL_BUTTON_WHEELDOWN:
-		result = true;
-		break;
 	default:
 		break;
 	}

=== modified file 'src/ui_basic/scrollbar.h'
--- src/ui_basic/scrollbar.h	2014-07-14 10:45:44 +0000
+++ src/ui_basic/scrollbar.h	2014-10-28 15:04:08 +0000
@@ -62,7 +62,8 @@
 	uint32_t get_pagesize() const {return m_pagesize;}
 	uint32_t get_scrollpos() const {return m_pos;}
 
-	bool handle_mousepress  (uint8_t btn, int32_t x, int32_t y) override;
+	bool handle_mousepress(uint8_t btn, int32_t x, int32_t y) override;
+	bool handle_mousewheel(uint32_t, int32_t, int32_t y) override;
 
 	void set_force_draw(bool const t) {m_force_draw = t;}
 

=== modified file 'src/ui_basic/table.cc'
--- src/ui_basic/table.cc	2014-09-30 19:36:00 +0000
+++ src/ui_basic/table.cc	2014-10-28 15:04:08 +0000
@@ -324,17 +324,17 @@
 /**
  * handle key presses
  */
-bool Table<void *>::handle_key(bool down, SDL_keysym code)
+bool Table<void *>::handle_key(bool down, SDL_Keysym code)
 {
 	if (down) {
 		switch (code.sym) {
-		case SDLK_UP:
-		case SDLK_KP8:
+		case SDL_SCANCODE_UP:
+		case SDL_SCANCODE_KP_8:
 			move_selection(-1);
 			return true;
 
-		case SDLK_DOWN:
-		case SDLK_KP2:
+		case SDL_SCANCODE_DOWN:
+		case SDL_SCANCODE_KP_2:
 			move_selection(1);
 			return true;
 
@@ -346,6 +346,11 @@
 	return UI::Panel::handle_key(down, code);
 }
 
+
+bool Table<void *>::handle_mousewheel(uint32_t which, int32_t x, int32_t y) {
+	return m_scrollbar->handle_mousewheel(which, x, y);
+}
+
 /**
  * Handle mouse presses: select the appropriate entry
  */
@@ -356,9 +361,6 @@
 		focus();
 
 	switch (btn) {
-	case SDL_BUTTON_WHEELDOWN:
-	case SDL_BUTTON_WHEELUP:
-		return m_scrollbar ? m_scrollbar->handle_mousepress(btn, 0, y) : false;
 	case SDL_BUTTON_LEFT: {
 		int32_t const time = WLApplication::get()->get_time();
 

=== modified file 'src/ui_basic/table.h'
--- src/ui_basic/table.h	2014-09-30 19:36:00 +0000
+++ src/ui_basic/table.h	2014-10-28 15:04:08 +0000
@@ -107,7 +107,8 @@
 	void draw(RenderTarget &);
 	bool handle_mousepress  (uint8_t btn, int32_t x, int32_t y);
 	bool handle_mouserelease(uint8_t btn, int32_t x, int32_t y);
-	virtual bool handle_key(bool down, SDL_keysym code);
+	bool handle_mousewheel(uint32_t which, int32_t x, int32_t y) override;
+	virtual bool handle_key(bool down, SDL_Keysym code);
 };
 
 template <> class Table<void *> : public Panel {
@@ -243,7 +244,8 @@
 	void draw(RenderTarget &) override;
 	bool handle_mousepress  (uint8_t btn, int32_t x, int32_t y) override;
 	bool handle_mouserelease(uint8_t btn, int32_t x, int32_t y) override;
-	bool handle_key(bool down, SDL_keysym code) override;
+	bool handle_mousewheel(uint32_t which, int32_t x, int32_t y) override;
+	bool handle_key(bool down, SDL_Keysym code) override;
 
 private:
 	bool default_compare_checkbox(uint32_t column, uint32_t a, uint32_t b);

=== modified file 'src/ui_basic/window.cc'
--- src/ui_basic/window.cc	2014-07-25 22:17:48 +0000
+++ src/ui_basic/window.cc	2014-10-28 15:04:08 +0000
@@ -19,7 +19,7 @@
 
 #include "ui_basic/window.h"
 
-#include <SDL_keysym.h>
+#include <SDL_keycode.h>
 
 #include "base/log.h"
 #include "graphic/font.h"
@@ -436,7 +436,7 @@
 	//  needs is the key state at the time the mouse was clicked. See the
 	//  usage comment for get_key_state.
 	if
-		(((get_key_state(SDLK_LCTRL) | get_key_state(SDLK_RCTRL))
+		(((get_key_state(SDL_SCANCODE_LCTRL) | get_key_state(SDL_SCANCODE_RCTRL))
 		  &&
 		  btn == SDL_BUTTON_LEFT)
 		 ||

=== modified file 'src/ui_fsmenu/intro.cc'
--- src/ui_fsmenu/intro.cc	2014-09-10 14:08:25 +0000
+++ src/ui_fsmenu/intro.cc	2014-10-28 15:04:08 +0000
@@ -45,7 +45,7 @@
 	return true;
 }
 
-bool FullscreenMenuIntro::handle_key(bool const down, SDL_keysym const code)
+bool FullscreenMenuIntro::handle_key(bool const down, SDL_Keysym const code)
 {
 	if (down && code.sym == SDLK_ESCAPE)
 		end_modal(0);

=== modified file 'src/ui_fsmenu/intro.h'
--- src/ui_fsmenu/intro.h	2014-09-10 14:08:25 +0000
+++ src/ui_fsmenu/intro.h	2014-10-28 15:04:08 +0000
@@ -34,7 +34,7 @@
 protected:
 	bool handle_mousepress  (uint8_t btn, int32_t x, int32_t y) override;
 	bool handle_mouserelease(uint8_t btn, int32_t x, int32_t y) override;
-	bool handle_key(bool down, SDL_keysym) override;
+	bool handle_key(bool down, SDL_Keysym) override;
 private:
 	UI::Textarea m_message;
 };

=== modified file 'src/ui_fsmenu/load_map_or_game.cc'
--- src/ui_fsmenu/load_map_or_game.cc	2014-10-13 09:50:55 +0000
+++ src/ui_fsmenu/load_map_or_game.cc	2014-10-28 15:04:08 +0000
@@ -67,14 +67,14 @@
 		m_table(this, m_tablex, m_tabley, m_tablew, m_tableh, sort_descending)
 	{}
 
-bool FullscreenMenuLoadMapOrGame::handle_key(bool down, SDL_keysym code) {
+bool FullscreenMenuLoadMapOrGame::handle_key(bool down, SDL_Keysym code) {
 
 	if (!down)
 		return false;
 
 	switch (code.sym)
 	{
-		case SDLK_KP_ENTER:
+		case SDL_SCANCODE_KP_ENTER:
 		case SDLK_RETURN:
 			clicked_ok();
 			return true;

=== modified file 'src/ui_fsmenu/load_map_or_game.h'
--- src/ui_fsmenu/load_map_or_game.h	2014-10-13 09:50:55 +0000
+++ src/ui_fsmenu/load_map_or_game.h	2014-10-28 15:04:08 +0000
@@ -75,7 +75,7 @@
 struct FullscreenMenuLoadMapOrGame : public FullscreenMenuBase {
 	FullscreenMenuLoadMapOrGame(bool sortdesc = false);
 
-	bool handle_key(bool down, SDL_keysym code) override;
+	bool handle_key(bool down, SDL_Keysym code) override;
 
 protected:
 	virtual void clicked_ok() {end_modal(1);}

=== modified file 'src/ui_fsmenu/loadgame.cc'
--- src/ui_fsmenu/loadgame.cc	2014-10-28 08:16:53 +0000
+++ src/ui_fsmenu/loadgame.cc	2014-10-28 15:04:08 +0000
@@ -532,14 +532,14 @@
 	set_has_selection();
 }
 
-bool FullscreenMenuLoadGame::handle_key(bool down, SDL_keysym code)
+bool FullscreenMenuLoadGame::handle_key(bool down, SDL_Keysym code)
 {
 	if (!down)
 		return false;
 
 	switch (code.sym)
 	{
-		case SDLK_KP_PERIOD:
+		case SDL_SCANCODE_KP_PERIOD:
 			if (code.mod & KMOD_NUM)
 				break;
 			/* no break */

=== modified file 'src/ui_fsmenu/loadgame.h'
--- src/ui_fsmenu/loadgame.h	2014-10-17 08:27:50 +0000
+++ src/ui_fsmenu/loadgame.h	2014-10-28 15:04:08 +0000
@@ -76,7 +76,7 @@
 
 	void think();
 
-	bool handle_key(bool down, SDL_keysym code) override;
+	bool handle_key(bool down, SDL_Keysym code) override;
 
 protected:
 	void clicked_ok() override;

=== modified file 'src/ui_fsmenu/options.cc'
--- src/ui_fsmenu/options.cc	2014-10-27 10:31:04 +0000
+++ src/ui_fsmenu/options.cc	2014-10-28 15:04:08 +0000
@@ -335,24 +335,18 @@
 	m_snap_win_overlap_only          .set_state(opt.snap_win_overlap_only);
 	m_dock_windows_to_edges          .set_state(opt.dock_windows_to_edges);
 
-	//  GRAPHIC_TODO(unknown): this shouldn't be here List all resolutions
-	// take a copy to not change real video info structure
-	SDL_PixelFormat fmt = *SDL_GetVideoInfo()->vfmt;
-	fmt.BitsPerPixel = 32;
-	for
-		(const SDL_Rect * const * modes = SDL_ListModes(&fmt, SDL_SWSURFACE | SDL_FULLSCREEN);
-		 modes && *modes;
-		 ++modes)
-	{
-		const SDL_Rect & mode = **modes;
-		if (800 <= mode.w && 600 <= mode.h)
-		{
-			const ScreenResolution this_res = {mode.w, mode.h};
-			if
-				(m_resolutions.empty()
+	for (int modes = 0; modes < SDL_GetNumDisplayModes(0); ++modes) {
+		SDL_DisplayMode  mode;
+		SDL_GetDisplayMode(0, modes, & mode);
+		if (800 <= mode.w && 600 <= mode.h &&
+			 (SDL_BITSPERPIXEL(mode.format) == 32 ||
+			  SDL_BITSPERPIXEL(mode.format) == 24)) {
+			ScreenResolution this_res = {
+			   mode.w, mode.h, static_cast<int32_t>(SDL_BITSPERPIXEL(mode.format))};
+			if (this_res.depth == 24) this_res.depth = 32;
+			if (m_resolutions.empty()
 				 || this_res.xres != m_resolutions.rbegin()->xres
-				 || this_res.yres != m_resolutions.rbegin()->yres)
-			{
+				 || this_res.yres != m_resolutions.rbegin()->yres) {
 				m_resolutions.push_back(this_res);
 			}
 		}
@@ -391,6 +385,8 @@
 		 nullptr, "en" == opt.language);
 
 	add_languages_to_list(&m_language_list, opt.language);
+
+	m_language_list.focus();
 }
 
 void FullscreenMenuOptions::update_sb_autosave_unit() {
@@ -409,11 +405,11 @@
 	}
 }
 
-bool FullscreenMenuOptions::handle_key(bool down, SDL_keysym code)
+bool FullscreenMenuOptions::handle_key(bool down, SDL_Keysym code)
 {
 	if (down) {
 		switch (code.sym) {
-			case SDLK_KP_ENTER:
+			case SDL_SCANCODE_KP_ENTER:
 			case SDLK_RETURN:
 				end_modal(static_cast<int32_t>(om_ok));
 				return true;
@@ -618,6 +614,7 @@
 		did_select_a_font |= cmpbool;
 		m_ui_font_list.add
 			("Widelands", UI_FONT_NAME_WIDELANDS, nullptr, cmpbool);
+		m_ui_font_list.focus();
 
 		// Fill with all left *.ttf files we find in fonts
 		FilenameSet files =
@@ -648,11 +645,11 @@
 	}
 }
 
-bool FullscreenMenuAdvancedOptions::handle_key(bool down, SDL_keysym code)
+bool FullscreenMenuAdvancedOptions::handle_key(bool down, SDL_Keysym code)
 {
 	if (down) {
 		switch (code.sym) {
-			case SDLK_KP_ENTER:
+			case SDL_SCANCODE_KP_ENTER:
 			case SDLK_RETURN:
 				end_modal(static_cast<int32_t>(om_ok));
 				return true;

=== modified file 'src/ui_fsmenu/options.h'
--- src/ui_fsmenu/options.h	2014-09-27 11:23:37 +0000
+++ src/ui_fsmenu/options.h	2014-10-28 15:04:08 +0000
@@ -90,7 +90,7 @@
 	};
 
 	/// Handle keypresses
-	bool handle_key(bool down, SDL_keysym code) override;
+	bool handle_key(bool down, SDL_Keysym code) override;
 
 private:
 	uint32_t const              m_vbutw;
@@ -147,6 +147,7 @@
 	public:
 		int32_t xres;
 		int32_t yres;
+		int32_t depth;
 	};
 
 	/// All supported screen resolutions.
@@ -167,7 +168,7 @@
 	};
 
 	/// Handle keypresses
-	bool handle_key(bool down, SDL_keysym code) override;
+	bool handle_key(bool down, SDL_Keysym code) override;
 
 private:
 	void update_sb_dis_panel_unit();

=== modified file 'src/wlapplication.cc'
--- src/wlapplication.cc	2014-10-28 08:16:53 +0000
+++ src/wlapplication.cc	2014-10-28 15:04:08 +0000
@@ -489,10 +489,6 @@
 			g_sound_handler.change_music();
 		break;
 
-	case SDL_VIDEOEXPOSE:
-		// log ("SDL Video Window expose event: %i\n", ev.expose.type);
-		g_gr->update_fullscreen();
-		break;
 	default:
 		break;
 	}
@@ -510,15 +506,15 @@
 		case SDL_KEYDOWN:
 		case SDL_KEYUP:
 			if
-				(ev.key.keysym.sym == SDLK_F10 &&
-				 (get_key_state(SDLK_LCTRL) || get_key_state(SDLK_RCTRL)))
+				(ev.key.keysym.sym == SDL_SCANCODE_F10 &&
+				 (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)))
 			{
 				//  get out of here quick
 				if (ev.type == SDL_KEYDOWN)
 					m_should_die = true;
 				break;
 			}
-			if (ev.key.keysym.sym == SDLK_F11) { //  take screenshot
+			if (ev.key.keysym.sym == SDL_SCANCODE_F11) { //  take screenshot
 				if (ev.type == SDL_KEYDOWN)
 				{
 					if (g_fs->disk_space() < MINIMUM_DISK_SPACE) {
@@ -544,11 +540,20 @@
 			}
 			break;
 
+		case SDL_TEXTINPUT:
+			if (cb && cb->textinput) {
+				cb->textinput(ev.text.text);
+			}
+			break;
 		case SDL_MOUSEBUTTONDOWN:
 		case SDL_MOUSEBUTTONUP:
 			_handle_mousebutton(ev, cb);
 			break;
-
+		case SDL_MOUSEWHEEL:
+			if (cb && cb->mouse_wheel) {
+				cb->mouse_wheel(ev.wheel.which, ev.wheel.x, ev.wheel.y);
+			}
+			break;
 		case SDL_MOUSEMOTION:
 			m_mouse_position = Point(ev.motion.x, ev.motion.y);
 
@@ -558,7 +563,6 @@
 					 ev.motion.x,    ev.motion.y,
 					 ev.motion.xrel, ev.motion.yrel);
 			break;
-
 		case SDL_QUIT:
 			m_should_die = true;
 			break;
@@ -594,7 +598,7 @@
 		//  mouse button.
 		if
 			(ev.button.button == SDL_BUTTON_MIDDLE &&
-			 (get_key_state(SDLK_LALT) || get_key_state(SDLK_RALT)))
+			 (get_key_state(SDL_SCANCODE_LALT) || get_key_state(SDL_SCANCODE_RALT)))
 		{
 			ev.button.button = SDL_BUTTON_LEFT;
 			m_faking_middle_mouse_button = true;
@@ -627,8 +631,8 @@
 
 /// Instantaneously move the mouse cursor without creating a motion event.
 ///
-/// SDL_WarpMouse() *will* create a mousemotion event, which we do not want. As
-/// a workaround, we store the delta in m_mouse_compensate_warp and use that to
+/// SDL_WarpMouseInWindow() *will* create a mousemotion event, which we do not want.
+/// As a workaround, we store the delta in m_mouse_compensate_warp and use that to
 /// eliminate the motion event in poll_event()
 ///
 /// \param position The new mouse position
@@ -640,7 +644,10 @@
 	SDL_GetMouseState(&cur_position.x, &cur_position.y);
 	if (cur_position != position) {
 		m_mouse_compensate_warp += cur_position - position;
-		SDL_WarpMouse(position.x, position.y);
+		SDL_Window* sdl_window = g_gr->get_sdlwindow();
+		if (sdl_window) {
+			SDL_WarpMouseInWindow(sdl_window, position.x, position.y);
+		}
 	}
 }
 
@@ -655,10 +662,18 @@
  */
 void WLApplication::set_input_grab(bool grab)
 {
+	if (!g_gr) {
+		return;
+	}
+	SDL_Window * sdl_window = g_gr->get_sdlwindow();
 	if (grab) {
-		SDL_WM_GrabInput(SDL_GRAB_ON);
+		if (sdl_window) {
+			SDL_SetWindowGrab(sdl_window, SDL_TRUE);
+		}
 	} else {
-		SDL_WM_GrabInput(SDL_GRAB_OFF);
+		if (sdl_window) {
+			SDL_SetWindowGrab(sdl_window, SDL_FALSE);
+		}
 		warp_mouse(m_mouse_position); //TODO(unknown): is this redundant?
 	}
 }
@@ -700,6 +715,8 @@
 		 s.get_int("yres", DEFAULT_RESOLUTION_H),
 		 s.get_bool("fullscreen", false),
 		 s.get_bool("opengl", true));
+	// does only work with a window
+	set_input_grab(s.get_bool("inputgrab", false));
 }
 
 /**
@@ -715,7 +732,6 @@
 	//then parse the commandline - overwrites conffile settings
 	handle_commandline_parameters();
 
-	set_input_grab(s.get_bool("inputgrab", false));
 	set_mouse_swap(s.get_bool("swapmouse", false));
 
 	// KLUDGE!
@@ -827,50 +843,12 @@
 	setenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1", 0);
 	#endif
 
-	//try all available video drivers till we find one that matches
-	std::vector<std::string> videomode;
-	int result = -1;
-
-	//add default video mode
-#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
-	videomode.push_back("x11");
-#endif
-#ifdef _WIN32
-	videomode.push_back("windib");
-#endif
-#ifdef __APPLE__
-	videomode.push_back("Quartz");
-#endif
-	//if a video mode is given on the command line, add that one first
-	{
-		const char * videodrv;
-		videodrv = getenv("SDL_VIDEODRIVER");
-		if (videodrv) {
-			log("Also adding video driver %s\n", videodrv);
-			videomode.push_back(videodrv);
-		}
-	}
-	char videodrvused[26];
-	strcpy(videodrvused, "SDL_VIDEODRIVER=\0");
-	wout << videodrvused << "&" << std::endl;
-	for (int i = videomode.size() - 1; result == -1 && i >= 0; --i) {
-		strcpy(videodrvused + 16, videomode[i].c_str());
-		videodrvused[16 + videomode[i].size()] = '\0';
-		putenv(videodrvused);
-		log
-			("Graphics: Trying Video driver: %i %s %s\n",
-			 i, videomode[i].c_str(), videodrvused);
-		result = SDL_Init(sdl_flags);
-	}
-
-	if (result == -1)
+	if (SDL_Init(sdl_flags) == -1)
 		throw wexception
 			("Failed to initialize SDL, no valid video driver: %s",
 			 SDL_GetError());
 
 	SDL_ShowCursor(SDL_DISABLE);
-	SDL_EnableUNICODE(1);
-	SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
 
 	refresh_graphics();
 
@@ -891,8 +869,7 @@
 			<< std::endl;
 
 	init_graphics(0, 0, false, false);
-	SDL_QuitSubSystem
-		(SDL_INIT_TIMER|SDL_INIT_VIDEO|SDL_INIT_CDROM|SDL_INIT_JOYSTICK);
+	SDL_QuitSubSystem(SDL_INIT_TIMER|SDL_INIT_VIDEO|SDL_INIT_JOYSTICK);
 
 #ifndef _WIN32
 	// SOUND can lock up with buggy SDL/drivers. we try to do the right thing

=== modified file 'src/wlapplication.h'
--- src/wlapplication.h	2014-10-16 04:54:10 +0000
+++ src/wlapplication.h	2014-10-28 15:04:08 +0000
@@ -58,7 +58,9 @@
 	 int32_t x, int32_t y);      // The coordinates of the mouse at release time.
 	void (*mouse_move)
 	(const uint8_t state, int32_t x, int32_t y, int32_t xdiff, int32_t ydiff);
-	void (*key)        (bool down, SDL_keysym code);
+	void (*key)        (bool down, SDL_Keysym code);
+	void (*textinput) (const char * text);
+	void (*mouse_wheel) (uint32_t which, int32_t x, int32_t y);
 };
 
 /// You know main functions, of course. This is the main struct.
@@ -143,7 +145,7 @@
 
 	/// Get the state of the current KeyBoard Button
 	/// \warning This function doesn't check for dumbness
-	bool get_key_state(SDLKey const key) const {return SDL_GetKeyState(nullptr)[key];}
+	bool get_key_state(SDL_Scancode const key) const {return SDL_GetKeyboardState(nullptr)[key];}
 
 	//@{
 	void warp_mouse(Point);

=== modified file 'src/wui/CMakeLists.txt'
--- src/wui/CMakeLists.txt	2014-07-16 08:23:42 +0000
+++ src/wui/CMakeLists.txt	2014-10-28 15:04:08 +0000
@@ -127,7 +127,7 @@
     waresqueuedisplay.h
     watchwindow.cc
     watchwindow.h
-  USES_SDL
+  USES_SDL2
   DEPENDS
     base_deprecated
     base_exceptions

=== modified file 'src/wui/actionconfirm.cc'
--- src/wui/actionconfirm.cc	2014-10-27 08:06:06 +0000
+++ src/wui/actionconfirm.cc	2014-10-28 15:04:08 +0000
@@ -265,7 +265,7 @@
 		 (building->get_playercaps() & Widelands::Building::PCap_Bulldoze))
 	{
 		game.send_player_bulldoze
-			(*todestroy, get_key_state(SDLK_LCTRL) << get_key_state(SDLK_RCTRL));
+			(*todestroy, get_key_state(SDL_SCANCODE_LCTRL) << get_key_state(SDL_SCANCODE_RCTRL));
 		iaplayer().need_complete_redraw();
 	}
 

=== modified file 'src/wui/building_statistics_menu.cc'
--- src/wui/building_statistics_menu.cc	2014-10-19 12:15:46 +0000
+++ src/wui/building_statistics_menu.cc	2014-10-28 15:04:08 +0000
@@ -118,6 +118,7 @@
 		(Columns::Size,
 		 boost::bind
 		 	(&BuildingStatisticsMenu::compare_building_size, this, _1, _2));
+	m_table.focus();
 
 	//  toggle when to run button
 	m_progbar.set_total(100);

=== modified file 'src/wui/buildingwindow.cc'
--- src/wui/buildingwindow.cc	2014-10-17 09:18:58 +0000
+++ src/wui/buildingwindow.cc	2014-10-28 15:04:08 +0000
@@ -373,7 +373,7 @@
 */
 void BuildingWindow::act_bulldoze()
 {
-	if (get_key_state(SDLK_LCTRL) || get_key_state(SDLK_RCTRL)) {
+	if (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)) {
 		if (m_building.get_playercaps() & Widelands::Building::PCap_Bulldoze)
 			igbase().game().send_player_bulldoze(m_building);
 	}
@@ -389,7 +389,7 @@
 */
 void BuildingWindow::act_dismantle()
 {
-	if (get_key_state(SDLK_LCTRL) || get_key_state(SDLK_RCTRL)) {
+	if (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)) {
 		if (m_building.get_playercaps() & Widelands::Building::PCap_Dismantle)
 			igbase().game().send_player_dismantle(m_building);
 	}
@@ -432,7 +432,7 @@
 */
 void BuildingWindow::act_enhance(Widelands::BuildingIndex id)
 {
-	if (get_key_state(SDLK_LCTRL) || get_key_state(SDLK_RCTRL)) {
+	if (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)) {
 		if (m_building.get_playercaps() & Widelands::Building::PCap_Enhancable)
 			igbase().game().send_player_enhance_building(m_building, id);
 	}

=== modified file 'src/wui/encyclopedia_window.cc'
--- src/wui/encyclopedia_window.cc	2014-10-27 10:31:04 +0000
+++ src/wui/encyclopedia_window.cc	2014-10-28 15:04:08 +0000
@@ -77,6 +77,7 @@
 			/** TRANSLATORS: Column title in the Tribal Wares Encyclopedia */
 			(wareColumnWidth, ngettext("Consumed Ware Type", "Consumed Ware Types", 0));
 	condTable.add_column (quantityColumnWidth, _("Quantity"));
+	condTable.focus();
 
 	fill_wares();
 

=== modified file 'src/wui/fieldaction.cc'
--- src/wui/fieldaction.cc	2014-09-20 09:37:47 +0000
+++ src/wui/fieldaction.cc	2014-10-28 15:04:08 +0000
@@ -737,9 +737,9 @@
 	if (upcast(Widelands::Flag, flag, m_node.field->get_immovable())) {
 		if (Building * const building = flag->get_building()) {
 			if (building->get_playercaps() & Building::PCap_Bulldoze) {
-				if (get_key_state(SDLK_LCTRL) || get_key_state(SDLK_RCTRL)) {
+				if (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)) {
 					ref_cast<Game, EditorGameBase>(egbase).send_player_bulldoze
-						(*flag, get_key_state(SDLK_LCTRL) || get_key_state(SDLK_RCTRL));
+						(*flag, get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL));
 				}
 				else {
 					show_bulldoze_confirm
@@ -750,7 +750,7 @@
 			}
 		} else {
 			ref_cast<Game, EditorGameBase>(egbase).send_player_bulldoze
-					(*flag, get_key_state(SDLK_LCTRL) || get_key_state(SDLK_RCTRL));
+					(*flag, get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL));
 			ibase().need_complete_redraw();
 		}
 	}
@@ -795,7 +795,7 @@
 	Widelands::EditorGameBase & egbase = ibase().egbase();
 	if (upcast(Widelands::Road, road, egbase.map().get_immovable(m_node)))
 		ref_cast<Game, EditorGameBase>(egbase).send_player_bulldoze
-			(*road, get_key_state(SDLK_LCTRL) || get_key_state(SDLK_RCTRL));
+			(*road, get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL));
 	ibase().need_complete_redraw();
 	okdialog();
 }

=== modified file 'src/wui/game_message_menu.cc'
--- src/wui/game_message_menu.cc	2014-10-11 10:04:45 +0000
+++ src/wui/game_message_menu.cc	2014-10-28 15:04:08 +0000
@@ -57,6 +57,7 @@
 	list->add_column (60, _("Status"), "", UI::Align_HCenter);
 	list->add_column(330, _("Title"));
 	list->add_column(120, _("Time sent"));
+	list->focus();
 
 	UI::Button * clearselectionbtn =
 		new UI::Button
@@ -243,7 +244,7 @@
 /**
  * Handle message menu hotkeys.
  */
-bool GameMessageMenu::handle_key(bool down, SDL_keysym code)
+bool GameMessageMenu::handle_key(bool down, SDL_Keysym code)
 {
 	if (down) {
 		switch (code.sym) {
@@ -252,7 +253,7 @@
 				center_view();
 			return true;
 
-		case SDLK_KP_PERIOD:
+		case SDL_SCANCODE_KP_PERIOD:
 			if (code.mod & KMOD_NUM)
 				break;
 			/* no break */

=== modified file 'src/wui/game_message_menu.h'
--- src/wui/game_message_menu.h	2014-09-10 14:48:40 +0000
+++ src/wui/game_message_menu.h	2014-10-28 15:04:08 +0000
@@ -45,7 +45,7 @@
 
 	enum Mode {Inbox, Archive};
 	void think() override;
-	bool handle_key(bool down, SDL_keysym code) override;
+	bool handle_key(bool down, SDL_Keysym code) override;
 
 private:
 	enum Cols {ColSelect, ColStatus, ColTitle, ColTimeSent};

=== modified file 'src/wui/game_options_menu.cc'
--- src/wui/game_options_menu.cc	2014-10-13 19:32:08 +0000
+++ src/wui/game_options_menu.cc	2014-10-28 15:04:08 +0000
@@ -182,7 +182,7 @@
 }
 
 void GameOptionsMenu::clicked_exit_game() {
-	if (get_key_state(SDLK_LCTRL) || get_key_state(SDLK_RCTRL)) {
+	if (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)) {
 		m_gb.end_modal(0);
 	}
 	else {

=== modified file 'src/wui/game_tips.cc'
--- src/wui/game_tips.cc	2014-07-14 10:45:44 +0000
+++ src/wui/game_tips.cc	2014-10-28 15:04:08 +0000
@@ -121,5 +121,5 @@
 	const Image* rendered_text = UI::g_fh1->render(as_game_tip(m_tips[index].text), tips_area.w);
 	rt.blit(center - Point(rendered_text->width() / 2, rendered_text->height() / 2), rendered_text);
 
-	g_gr->update_rectangle(tips_area);
+	g_gr->update();
 }

=== modified file 'src/wui/interactive_base.cc'
--- src/wui/interactive_base.cc	2014-10-27 10:14:10 +0000
+++ src/wui/interactive_base.cc	2014-10-28 15:04:08 +0000
@@ -366,14 +366,22 @@
 	const uint32_t scrollval = 10;
 
 	if (keyboard_free() && Panel::allow_user_input()) {
-		if (get_key_state(SDLK_UP) || (get_key_state(SDLK_KP8) && (SDL_GetModState() ^ KMOD_NUM)))
+		if (get_key_state(SDL_SCANCODE_UP) ||
+			 (get_key_state(SDL_SCANCODE_KP_8) && (SDL_GetModState() ^ KMOD_NUM))) {
 			set_rel_viewpoint(Point(0, -scrollval), false);
-		if (get_key_state(SDLK_DOWN) || (get_key_state(SDLK_KP2) && (SDL_GetModState() ^ KMOD_NUM)))
+		}
+		if (get_key_state(SDL_SCANCODE_DOWN) ||
+			 (get_key_state(SDL_SCANCODE_KP_2) && (SDL_GetModState() ^ KMOD_NUM))) {
 			set_rel_viewpoint(Point(0,  scrollval), false);
-		if (get_key_state(SDLK_LEFT) || (get_key_state(SDLK_KP4) && (SDL_GetModState() ^ KMOD_NUM)))
+		}
+		if (get_key_state(SDL_SCANCODE_LEFT) ||
+			 (get_key_state(SDL_SCANCODE_KP_4) && (SDL_GetModState() ^ KMOD_NUM))) {
 			set_rel_viewpoint(Point(-scrollval, 0), false);
-		if (get_key_state(SDLK_RIGHT) || (get_key_state(SDLK_KP6) && (SDL_GetModState() ^ KMOD_NUM)))
+		}
+		if (get_key_state(SDL_SCANCODE_RIGHT) ||
+			 (get_key_state(SDL_SCANCODE_KP_6) && (SDL_GetModState() ^ KMOD_NUM))) {
 			set_rel_viewpoint(Point (scrollval, 0), false);
+		}
 	}
 
 	egbase().think(); // Call game logic here. The game advances.
@@ -386,7 +394,7 @@
 
 	//  The entire screen needs to be redrawn (unit movement, tile animation,
 	//  etc...)
-	g_gr->update_fullscreen();
+	g_gr->update();
 
 	update_speedlabel();
 
@@ -656,7 +664,7 @@
 
 		if
 			(allow_user_input() &&
-			 (get_key_state(SDLK_LCTRL) || get_key_state(SDLK_RCTRL)))
+			 (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)))
 		{
 			//  place flags
 			const Map & map = egbase().map();
@@ -667,7 +675,7 @@
 			std::vector<Coords>::const_iterator const last     =
 				c_vector.end  () - 2;
 
-			if (get_key_state(SDLK_LSHIFT) || get_key_state(SDLK_RSHIFT)) {
+			if (get_key_state(SDL_SCANCODE_LSHIFT) || get_key_state(SDL_SCANCODE_RSHIFT)) {
 				for //  start to end
 					(std::vector<Coords>::const_iterator it = first;
 					 it <= last;
@@ -906,13 +914,13 @@
 }
 
 
-bool InteractiveBase::handle_key(bool const down, SDL_keysym const code)
+bool InteractiveBase::handle_key(bool const down, SDL_Keysym const code)
 {
 	if (m->quicknavigation->handle_key(down, code))
 		return true;
 
 	switch (code.sym) {
-	case SDLK_KP9:
+	case SDL_SCANCODE_KP_9:
 		if (code.mod & KMOD_NUM)
 			break;
 		/* no break */
@@ -933,7 +941,7 @@
 					ctrl->toggle_paused();
 		return true;
 
-	case SDLK_KP3:
+	case SDL_SCANCODE_KP_3:
 		if (code.mod & KMOD_NUM)
 			break;
 		/* no break */
@@ -949,7 +957,7 @@
 				}
 		return true;
 #ifndef NDEBUG //  only in debug builds
-		case SDLK_F6:
+		case SDL_SCANCODE_F6:
 			if (get_display_flag(dfDebug)) {
 				GameChatMenu::create_script_console(
 					this, m_debugconsole, *DebugConsole::get_chat_provider());

=== modified file 'src/wui/interactive_base.h'
--- src/wui/interactive_base.h	2014-09-20 09:37:47 +0000
+++ src/wui/interactive_base.h	2014-10-28 15:04:08 +0000
@@ -22,7 +22,7 @@
 
 #include <memory>
 
-#include <SDL_keysym.h>
+#include <SDL_keycode.h>
 
 #include "logic/editor_game_base.h"
 #include "logic/map.h"
@@ -135,7 +135,7 @@
 	void minimap_warp(int32_t x, int32_t y);
 
 	void draw_overlay(RenderTarget &) override;
-	bool handle_key(bool down, SDL_keysym) override;
+	bool handle_key(bool down, SDL_Keysym) override;
 
 	void unset_sel_picture();
 	void set_sel_picture(const char * const);

=== modified file 'src/wui/interactive_player.cc'
--- src/wui/interactive_player.cc	2014-10-27 08:06:06 +0000
+++ src/wui/interactive_player.cc	2014-10-28 15:04:08 +0000
@@ -365,7 +365,7 @@
  * \li Pause: pauses the game
  * \li Return: write chat message
 */
-bool InteractivePlayer::handle_key(bool const down, SDL_keysym const code)
+bool InteractivePlayer::handle_key(bool const down, SDL_Keysym const code)
 {
 	if (down) {
 		switch (code.sym) {
@@ -405,7 +405,7 @@
 			g_gr->toggle_fullscreen();
 			return true;
 
-		case SDLK_KP7:
+		case SDL_SCANCODE_KP_7:
 			if (code.mod & KMOD_NUM)
 				break;
 			/* no break */
@@ -413,7 +413,7 @@
 			move_view_to(game().map().get_starting_pos(m_player_number));
 			return true;
 
-		case SDLK_KP_ENTER:
+		case SDL_SCANCODE_KP_ENTER:
 		case SDLK_RETURN:
 			if (!m_chatProvider | !m_chatenabled || !is_multiplayer())
 				break;

=== modified file 'src/wui/interactive_player.h'
--- src/wui/interactive_player.h	2014-09-10 14:48:40 +0000
+++ src/wui/interactive_player.h	2014-10-28 15:04:08 +0000
@@ -61,7 +61,7 @@
 
 	void node_action() override;
 
-	bool handle_key(bool down, SDL_keysym) override;
+	bool handle_key(bool down, SDL_Keysym) override;
 
 	Widelands::Player & player() const {
 		return game().player(m_player_number);

=== modified file 'src/wui/interactive_spectator.cc'
--- src/wui/interactive_spectator.cc	2014-09-10 16:57:31 +0000
+++ src/wui/interactive_spectator.cc	2014-10-28 15:04:08 +0000
@@ -243,7 +243,7 @@
 /**
  * Global in-game keypresses:
  */
-bool InteractiveSpectator::handle_key(bool const down, SDL_keysym const code)
+bool InteractiveSpectator::handle_key(bool const down, SDL_Keysym const code)
 {
 	if (down)
 		switch (code.sym) {
@@ -268,7 +268,7 @@
 			return true;
 
 		case SDLK_RETURN:
-		case SDLK_KP_ENTER:
+		case SDL_SCANCODE_KP_ENTER:
 			if (!m_chatProvider | !m_chatenabled)
 				break;
 

=== modified file 'src/wui/interactive_spectator.h'
--- src/wui/interactive_spectator.h	2014-09-10 16:57:31 +0000
+++ src/wui/interactive_spectator.h	2014-10-28 15:04:08 +0000
@@ -44,7 +44,7 @@
 
 	Widelands::Player * get_player() const override;
 
-	bool handle_key(bool down, SDL_keysym) override;
+	bool handle_key(bool down, SDL_Keysym) override;
 
 private:
 	void toggle_chat();

=== modified file 'src/wui/mapview.cc'
--- src/wui/mapview.cc	2014-09-10 13:03:40 +0000
+++ src/wui/mapview.cc	2014-10-28 15:04:08 +0000
@@ -192,7 +192,7 @@
 	if (!intbase().get_sel_freeze())
 		track_sel(Point(x, y));
 
-	g_gr->update_fullscreen();
+	g_gr->update();
 	return true;
 }
 

=== modified file 'src/wui/quicknavigation.cc'
--- src/wui/quicknavigation.cc	2014-09-10 08:55:04 +0000
+++ src/wui/quicknavigation.cc	2014-10-28 15:04:08 +0000
@@ -86,7 +86,7 @@
 	m_havefirst = true;
 }
 
-bool QuickNavigation::handle_key(bool down, SDL_keysym key)
+bool QuickNavigation::handle_key(bool down, SDL_Keysym key)
 {
 	if (!m_havefirst)
 		return false;
@@ -98,8 +98,8 @@
 		assert(which < 10);
 
 		bool ctrl =
-			WLApplication::get()->get_key_state(SDLK_LCTRL) ||
-			WLApplication::get()->get_key_state(SDLK_RCTRL);
+			WLApplication::get()->get_key_state(SDL_SCANCODE_LCTRL) ||
+			WLApplication::get()->get_key_state(SDL_SCANCODE_RCTRL);
 		if (ctrl) {
 			m_landmarks[which].point = m_current;
 			m_landmarks[which].set = true;

=== modified file 'src/wui/quicknavigation.h'
--- src/wui/quicknavigation.h	2014-09-14 11:31:58 +0000
+++ src/wui/quicknavigation.h	2014-10-28 15:04:08 +0000
@@ -47,7 +47,7 @@
 
 	void view_changed(Point point, bool jump);
 
-	bool handle_key(bool down, SDL_keysym key);
+	bool handle_key(bool down, SDL_Keysym key);
 
 private:
 	void setview(Point where);

=== modified file 'src/wui/shipwindow.cc'
--- src/wui/shipwindow.cc	2014-09-10 13:03:40 +0000
+++ src/wui/shipwindow.cc	2014-10-28 15:04:08 +0000
@@ -291,7 +291,7 @@
 /// Sink the ship if confirmed
 void ShipWindow::act_sink()
 {
-	if (get_key_state(SDLK_LCTRL) || get_key_state(SDLK_RCTRL)) {
+	if (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)) {
 		m_igbase.game().send_player_sink_ship(m_ship);
 	}
 	else {
@@ -302,7 +302,7 @@
 /// Cancel expedition if confirmed
 void ShipWindow::act_cancel_expedition()
 {
-	if (get_key_state(SDLK_LCTRL) || get_key_state(SDLK_RCTRL)) {
+	if (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)) {
 		m_igbase.game().send_player_cancel_expedition_ship(m_ship);
 	}
 	else {

=== modified file 'utils/macos/build_app.sh'
--- utils/macos/build_app.sh	2014-10-16 04:54:10 +0000
+++ utils/macos/build_app.sh	2014-10-28 15:04:08 +0000
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-set -e 
+set -e
 
 if [ "$#" == "0" ]; then
 	echo "Usage: $0 <bzr_repo_directory>"
@@ -35,7 +35,7 @@
    cp $SOURCE_DIR/COPYING  $DESTINATION/COPYING.txt
 
    echo "Creating DMG ..."
-   hdiutil create -fs HFS+ -volname "Widelands $WLVERSION" -srcfolder "$DESTINATION" "$UP/widelands_64bit_$WLVERSION.dmg" 
+   hdiutil create -fs HFS+ -volname "Widelands $WLVERSION" -srcfolder "$DESTINATION" "$UP/widelands_64bit_$WLVERSION.dmg"
 }
 
 function MakeAppPackage {
@@ -88,8 +88,8 @@
    cp -a src/widelands $DESTINATION/Widelands.app/Contents/MacOS/
 
    echo "Stripping binary ..."
-   strip -u -r $DESTINATION/Widelands.app/Contents/MacOS/widelands 
-	
+   strip -u -r $DESTINATION/Widelands.app/Contents/MacOS/widelands
+
    echo "Copying dynamic libraries ..."
    dylibbundler -od -b -x $DESTINATION/Widelands.app/Contents/MacOS/widelands  -d $DESTINATION/Widelands.app/Contents/libs
 }
@@ -106,26 +106,26 @@
       -DWL_PATHS_ARE_ABSOLUTE:STRING="false" \
       -DCMAKE_PREFIX_PATH:PATH="/usr/local" \
       \
-      -DSDL_LIBRARY:STRING="-L/usr/local/lib /usr/local/lib/libSDLmain.a /usr/local/lib/libSDL.a -Wl,-framework,OpenGL -Wl,-framework,Cocoa -Wl,-framework,ApplicationServices -Wl,-framework,Carbon -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,IOKit" \
-      -DSDL_INCLUDE_DIR:PATH="/usr/local/include/SDL" \
+      -DSDL2_LIBRARY:STRING="-L/usr/local/lib /usr/local/lib/libSDL2main.a /usr/local/lib/libSDL2.a -Wl,-framework,OpenGL -Wl,-framework,Cocoa -Wl,-framework,ApplicationServices -Wl,-framework,Carbon -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,IOKit" \
+      -DSDL2_INCLUDE_DIR:PATH="/usr/local/include/SDL2" \
       \
-      -DSDLIMAGE_LIBRARY:STRING="-Wl,/usr/local/lib/libSDL_image.a -Wl,/usr/local/lib/libjpeg.a" \
-      -DSDLIMAGE_INCLUDE_DIR:PATH="/usr/local/include/SDL" \
+      -DSDL2IMAGE_LIBRARY:STRING="-Wl,/usr/local/lib/libSDL2_image.a -Wl,/usr/local/lib/libjpeg.a" \
+      -DSDL2IMAGE_INCLUDE_DIR:PATH="/usr/local/include/SDL2" \
       \
       -DPNG_LIBRARY:FILEPATH="/usr/local/opt/libpng/lib/libpng.a" \
       -DPNG_INCLUDE_DIR:PATH="/usr/local/opt/libpng/include" \
       \
-      -DSDLTTF_LIBRARY:STRING="-Wl,/usr/local/opt/freetype/lib/libfreetype.a -Wl,/usr/local/lib/libbz2.a -Wl,/usr/local/lib/libSDL_ttf.a" \
-      -DSDLTTF_INCLUDE_DIR:PATH="/usr/local/include/SDL" \
-      \
-      -DSDLGFX_LIBRARY:FILEPATH="/usr/local/lib/libSDL_gfx.a" \
-      -DSDLGFX_INCLUDE_DIR:PATH="/usr/local/include/SDL" \
-      \
-      -DSDLMIXER_LIBRARY:STRING="-Wl,/usr/local/lib/libvorbisfile.a -Wl,/usr/local/lib/libogg.a -Wl,/usr/local/lib/libvorbis.a -Wl,/usr/local/lib/libSDL_mixer.a" \
-      -DSDLMIXER_INCLUDE_DIR:PATH="/usr/local/include/SDL" \
-      \
-      -DSDLNET_LIBRARY:FILEPATH="/usr/local/lib/libSDL_net.a" \
-      -DSDLNET_INCLUDE_DIR:PATH="/usr/local/include/SDL" \
+      -DSDL2TTF_LIBRARY:STRING="-Wl,/usr/local/opt/freetype/lib/libfreetype.a -Wl,/usr/local/lib/libbz2.a -Wl,/usr/local/lib/libSDL2_ttf.a" \
+      -DSDL2TTF_INCLUDE_DIR:PATH="/usr/local/include/SDL2" \
+      \
+      -DSDL2GFX_LIBRARY:FILEPATH="/usr/local/lib/libSDL2_gfx.a" \
+      -DSDL2GFX_INCLUDE_DIR:PATH="/usr/local/include/SDL2" \
+      \
+      -DSDL2MIXER_LIBRARY:STRING="-Wl,/usr/local/lib/libvorbisfile.a -Wl,/usr/local/lib/libogg.a -Wl,/usr/local/lib/libvorbis.a -Wl,/usr/local/lib/libSDL2_mixer.a" \
+      -DSDL2MIXER_INCLUDE_DIR:PATH="/usr/local/include/SDL2" \
+      \
+      -DSDL2NET_LIBRARY:FILEPATH="/usr/local/lib/libSDL2_net.a" \
+      -DSDL2NET_INCLUDE_DIR:PATH="/usr/local/include/SDL2" \
       \
       -DINTL_LIBRARY:STRING="-Wl,/usr/local/opt/libiconv/lib/libiconv.a -Wl,/usr/local/opt/gettext/lib/libintl.a" \
       -DINTL_INCLUDE_DIR:PATH="/usr/local/opt/gettext/include" \


Follow ups