Wayland support



Based on the original port to Wayland by: Joel Teichroeb, Benjamin Franzke, Scott Moreau, et al.



Additional changes in this commit, done by me:



* Wayland uses the common EGL framework

* EGL can now create a desktop OpenGL context

* testgl2 loads GL functions dynamically, no need to link to libGL anymore

* Assorted fixes to the Wayland backend



Tested on the Weston Compositor (v1.0.5) that ships with Ubuntu 13.10,

running Weston under X. Tests ran: testrendercopyex (all backends), testgl2, testgles2,testintersections

2.1 --- a/WhatsNew.txt Fri Dec 13 09:48:12 2013 -0300 2.2 +++ b/WhatsNew.txt Sat Dec 14 20:18:43 2013 -0300 2.3 @@ -7,7 +7,10 @@ 2.4 General: 2.5 * Added an API to load a database of Game Controller mappings from a file: 2.6 SDL_GameControllerAddMappingsFromFile 2.7 - 2.8 +* EGL can now create/manage OpenGL and OpenGL ES 1.x/2.x contexts, and share 2.9 + them using SDL_GL_SHARE_WITH_CURRENT_CONTEXT 2.10 +* Added testgles2. testgl2 does not need to link with libGL anymore. 2.11 + 2.12 Windows: 2.13 * Support for OpenGL ES 2.x contexts using either WGL or EGL (natively via 2.14 the driver or emulated through ANGLE) 2.15 @@ -20,7 +23,7 @@ 2.16 2.17 Linux: 2.18 * Fixed fullscreen and focused behavior when receiving NotifyGrab events 2.19 - 2.20 +* Wayland support 2.21 2.22 --------------------------------------------------------------------------- 2.23 2.0.1:

15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 15.2 +++ b/src/video/wayland/SDL_waylandevents_c.h Sat Dec 14 20:18:43 2013 -0300 15.3 @@ -0,0 +1,37 @@ 15.4 +/* 15.5 + Simple DirectMedia Layer 15.6 + Copyright (C) 1997-2013 Sam Lantinga 15.7 + 15.8 + This software is provided 'as-is', without any express or implied 15.9 + warranty. In no event will the authors be held liable for any damages 15.10 + arising from the use of this software. 15.11 + 15.12 + Permission is granted to anyone to use this software for any purpose, 15.13 + including commercial applications, and to alter it and redistribute it 15.14 + freely, subject to the following restrictions: 15.15 + 15.16 + 1. The origin of this software must not be misrepresented; you must not 15.17 + claim that you wrote the original software. If you use this software 15.18 + in a product, an acknowledgment in the product documentation would be 15.19 + appreciated but is not required. 15.20 + 2. Altered source versions must be plainly marked as such, and must not be 15.21 + misrepresented as being the original software. 15.22 + 3. This notice may not be removed or altered from any source distribution. 15.23 +*/ 15.24 + 15.25 +#include "SDL_config.h" 15.26 + 15.27 +#ifndef _SDL_waylandevents_h 15.28 +#define _SDL_waylandevents_h 15.29 + 15.30 +#include "SDL_waylandvideo.h" 15.31 +#include "SDL_waylandwindow.h" 15.32 + 15.33 +extern void Wayland_PumpEvents(_THIS); 15.34 + 15.35 +extern void Wayland_display_add_input(SDL_VideoData *d, uint32_t id); 15.36 +extern void Wayland_display_destroy_input(SDL_VideoData *d); 15.37 + 15.38 +#endif /* _SDL_waylandevents_h */ 15.39 + 15.40 +/* vi: set ts=4 sw=4 expandtab: */

17.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 17.2 +++ b/src/video/wayland/SDL_waylandmouse.h Sat Dec 14 20:18:43 2013 -0300 17.3 @@ -0,0 +1,31 @@ 17.4 +/* 17.5 + Simple DirectMedia Layer 17.6 + Copyright (C) 1997-2013 Sam Lantinga 17.7 + 17.8 + This software is provided 'as-is', without any express or implied 17.9 + warranty. In no event will the authors be held liable for any damages 17.10 + arising from the use of this software. 17.11 + 17.12 + Permission is granted to anyone to use this software for any purpose, 17.13 + including commercial applications, and to alter it and redistribute it 17.14 + freely, subject to the following restrictions: 17.15 + 17.16 + 1. The origin of this software must not be misrepresented; you must not 17.17 + claim that you wrote the original software. If you use this software 17.18 + in a product, an acknowledgment in the product documentation would be 17.19 + appreciated but is not required. 17.20 + 2. Altered source versions must be plainly marked as such, and must not be 17.21 + misrepresented as being the original software. 17.22 + 3. This notice may not be removed or altered from any source distribution. 17.23 +*/ 17.24 + 17.25 +#include "SDL_config.h" 17.26 +#include "SDL_mouse.h" 17.27 +#include "SDL_waylandvideo.h" 17.28 + 17.29 +#if SDL_VIDEO_DRIVER_WAYLAND 17.30 + 17.31 +extern void Wayland_InitMouse(void); 17.32 +extern void Wayland_FiniMouse(void); 17.33 + 17.34 +#endif

19.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 19.2 +++ b/src/video/wayland/SDL_waylandopengles.h Sat Dec 14 20:18:43 2013 -0300 19.3 @@ -0,0 +1,46 @@ 19.4 +/* 19.5 + Simple DirectMedia Layer 19.6 + Copyright (C) 1997-2013 Sam Lantinga 19.7 + 19.8 + This software is provided 'as-is', without any express or implied 19.9 + warranty. In no event will the authors be held liable for any damages 19.10 + arising from the use of this software. 19.11 + 19.12 + Permission is granted to anyone to use this software for any purpose, 19.13 + including commercial applications, and to alter it and redistribute it 19.14 + freely, subject to the following restrictions: 19.15 + 19.16 + 1. The origin of this software must not be misrepresented; you must not 19.17 + claim that you wrote the original software. If you use this software 19.18 + in a product, an acknowledgment in the product documentation would be 19.19 + appreciated but is not required. 19.20 + 2. Altered source versions must be plainly marked as such, and must not be 19.21 + misrepresented as being the original software. 19.22 + 3. This notice may not be removed or altered from any source distribution. 19.23 +*/ 19.24 +#include "SDL_config.h" 19.25 + 19.26 +#ifndef _SDL_waylandopengles_h 19.27 +#define _SDL_waylandopengles_h 19.28 + 19.29 +#include "../SDL_sysvideo.h" 19.30 +#include "../SDL_egl_c.h" 19.31 + 19.32 +typedef struct SDL_PrivateGLESData 19.33 +{ 19.34 +} SDL_PrivateGLESData; 19.35 + 19.36 +/* OpenGLES functions */ 19.37 +#define Wayland_GLES_GetAttribute SDL_EGL_GetAttribute 19.38 +#define Wayland_GLES_GetProcAddress SDL_EGL_GetProcAddress 19.39 +#define Wayland_GLES_UnloadLibrary SDL_EGL_UnloadLibrary 19.40 +#define Wayland_GLES_SetSwapInterval SDL_EGL_SetSwapInterval 19.41 +#define Wayland_GLES_GetSwapInterval SDL_EGL_GetSwapInterval 19.42 + 19.43 +extern int Wayland_GLES_LoadLibrary(_THIS, const char *path); 19.44 +extern SDL_GLContext Wayland_GLES_CreateContext(_THIS, SDL_Window * window); 19.45 +extern void Wayland_GLES_SwapWindow(_THIS, SDL_Window * window); 19.46 +extern int Wayland_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); 19.47 +extern void Wayland_GLES_DeleteContext(_THIS, SDL_GLContext context); 19.48 + 19.49 +#endif /* _SDL_waylandopengles_h */

21.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 21.2 +++ b/src/video/wayland/SDL_waylandvideo.h Sat Dec 14 20:18:43 2013 -0300 21.3 @@ -0,0 +1,71 @@ 21.4 +/* 21.5 + Simple DirectMedia Layer 21.6 + Copyright (C) 1997-2013 Sam Lantinga 21.7 + 21.8 + This software is provided 'as-is', without any express or implied 21.9 + warranty. In no event will the authors be held liable for any damages 21.10 + arising from the use of this software. 21.11 + 21.12 + Permission is granted to anyone to use this software for any purpose, 21.13 + including commercial applications, and to alter it and redistribute it 21.14 + freely, subject to the following restrictions: 21.15 + 21.16 + 1. The origin of this software must not be misrepresented; you must not 21.17 + claim that you wrote the original software. If you use this software 21.18 + in a product, an acknowledgment in the product documentation would be 21.19 + appreciated but is not required. 21.20 + 2. Altered source versions must be plainly marked as such, and must not be 21.21 + misrepresented as being the original software. 21.22 + 3. This notice may not be removed or altered from any source distribution. 21.23 +*/ 21.24 + 21.25 +#include "SDL_config.h" 21.26 + 21.27 +#ifndef _SDL_waylandvideo_h 21.28 +#define _SDL_waylandvideo_h 21.29 + 21.30 +#include 21.31 +#include 21.32 +#include 21.33 + 21.34 +#include 21.35 + 21.36 +struct xkb_context; 21.37 +struct SDL_WaylandInput; 21.38 + 21.39 +typedef struct { 21.40 + struct wl_display *display; 21.41 + struct wl_registry *registry; 21.42 + struct wl_compositor *compositor; 21.43 + struct wl_output *output; 21.44 + struct wl_shm *shm; 21.45 + struct wl_cursor_theme *cursor_theme; 21.46 + struct wl_cursor *default_cursor; 21.47 + struct wl_pointer *pointer; 21.48 + struct wl_shell *shell; 21.49 + 21.50 + struct { 21.51 + int32_t x, y, width, height; 21.52 + } screen_allocation; 21.53 + 21.54 + struct wl_list modes_list; 21.55 + 21.56 + EGLDisplay edpy; 21.57 + EGLContext context; 21.58 + EGLConfig econf; 21.59 + 21.60 + struct xkb_context *xkb_context; 21.61 + struct SDL_WaylandInput *input; 21.62 + 21.63 + uint32_t shm_formats; 21.64 +} SDL_VideoData; 21.65 + 21.66 +static inline void 21.67 +wayland_schedule_write(SDL_VideoData *data) 21.68 +{ 21.69 + wl_display_flush(data->display); 21.70 +} 21.71 + 21.72 +#endif /* _SDL_nullvideo_h */ 21.73 + 21.74 +/* vi: set ts=4 sw=4 expandtab: */