Skip to content

Commit ec1cb49

Browse files
committed
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
1 parent 4a8c296 commit ec1cb49

25 files changed

Lines changed: 2044 additions & 138 deletions

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ set_option(RPATH "Use an rpath when linking SDL" ${UNIX_SYS})
218218
set_option(CLOCK_GETTIME "Use clock_gettime() instead of gettimeofday()" OFF)
219219
set_option(INPUT_TSLIB "Use the Touchscreen library for input" ${UNIX_SYS})
220220
set_option(VIDEO_X11 "Use X11 video driver" ${UNIX_SYS})
221+
set_option(VIDEO_WAYLAND "Use Wayland video driver" ${UNIX_SYS})
221222
dep_option(X11_SHARED "Dynamically load X11 support" ON "VIDEO_X11" OFF)
222223
set(SDL_X11_OPTIONS Xcursor Xinerama XInput Xrandr Xscrnsaver XShape Xvm)
223224
foreach(_SUB ${SDL_X11_OPTIONS})
@@ -641,6 +642,7 @@ if(UNIX AND NOT APPLE)
641642
CheckDirectFB()
642643
CheckOpenGLX11()
643644
CheckOpenGLESX11()
645+
CheckWayland()
644646
endif(SDL_VIDEO)
645647

646648
if(LINUX)

WhatsNew.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ This is a list of major changes in SDL's version history.
77
General:
88
* Added an API to load a database of Game Controller mappings from a file:
99
SDL_GameControllerAddMappingsFromFile
10-
10+
* EGL can now create/manage OpenGL and OpenGL ES 1.x/2.x contexts, and share
11+
them using SDL_GL_SHARE_WITH_CURRENT_CONTEXT
12+
* Added testgles2. testgl2 does not need to link with libGL anymore.
13+
1114
Windows:
1215
* Support for OpenGL ES 2.x contexts using either WGL or EGL (natively via
1316
the driver or emulated through ANGLE)
@@ -20,7 +23,7 @@ Android:
2023

2124
Linux:
2225
* Fixed fullscreen and focused behavior when receiving NotifyGrab events
23-
26+
* Wayland support
2427

2528
---------------------------------------------------------------------------
2629
2.0.1:

cmake/sdlchecks.cmake

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,29 @@ macro(CheckX11)
505505
endif(VIDEO_X11)
506506
endmacro(CheckX11)
507507

508+
# Requires:
509+
# - EGL
510+
macro(CheckWayland)
511+
if(VIDEO_WAYLAND)
512+
pkg_check_modules(WAYLAND wayland-client wayland-cursor wayland-egl egl xkbcommon)
513+
if(WAYLAND_FOUND)
514+
link_directories(
515+
${WAYLAND_LIBRARY_DIRS}
516+
)
517+
include_directories(
518+
${WAYLAND_INCLUDE_DIRS}
519+
)
520+
set(EXTRA_LIBS ${WAYLAND_LIBRARIES} ${EXTRA_LIBS})
521+
set(HAVE_VIDEO_WAYLAND TRUE)
522+
set(HAVE_SDL_VIDEO TRUE)
523+
524+
file(GLOB WAYLAND_SOURCES ${SDL2_SOURCE_DIR}/src/video/wayland/*.c)
525+
set(SOURCE_FILES ${SOURCE_FILES} ${WAYLAND_SOURCES})
526+
set(SDL_VIDEO_DRIVER_WAYLAND 1)
527+
endif(WAYLAND_FOUND)
528+
endif(VIDEO_WAYLAND)
529+
endmacro(CheckWayland)
530+
508531
# Requires:
509532
# - n/a
510533
#

configure

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,7 @@ enable_sndio
817817
enable_sndio_shared
818818
enable_diskaudio
819819
enable_dummyaudio
820+
enable_video_wayland
820821
enable_video_x11
821822
with_x
822823
enable_x11_shared
@@ -1532,6 +1533,7 @@ Optional Features:
15321533
--enable-sndio-shared dynamically load sndio audio support [[default=yes]]
15331534
--enable-diskaudio support the disk writer audio driver [[default=yes]]
15341535
--enable-dummyaudio support the dummy audio driver [[default=yes]]
1536+
--enable-video-wayland use Wayland video driver [[default=yes]]
15351537
--enable-video-x11 use X11 video driver [[default=yes]]
15361538
--enable-x11-shared dynamically load X11 support [[default=maybe]]
15371539
--enable-video-x11-xcursor
@@ -18633,6 +18635,82 @@ $as_echo "$need_gcc_Wno_multichar" >&6; }
1863318635
fi
1863418636
}
1863518637

18638+
CheckWayland()
18639+
{
18640+
# Check whether --enable-video-wayland was given.
18641+
if test "${enable_video_wayland+set}" = set; then :
18642+
enableval=$enable_video_wayland;
18643+
else
18644+
enable_video_wayland=yes
18645+
fi
18646+
18647+
18648+
if test x$enable_video = xyes -a x$enable_video_wayland = xyes; then
18649+
# Extract the first word of "pkg-config", so it can be a program name with args.
18650+
set dummy pkg-config; ac_word=$2
18651+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
18652+
$as_echo_n "checking for $ac_word... " >&6; }
18653+
if ${ac_cv_path_PKG_CONFIG+:} false; then :
18654+
$as_echo_n "(cached) " >&6
18655+
else
18656+
case $PKG_CONFIG in
18657+
[\\/]* | ?:[\\/]*)
18658+
ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
18659+
;;
18660+
*)
18661+
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
18662+
for as_dir in $PATH
18663+
do
18664+
IFS=$as_save_IFS
18665+
test -z "$as_dir" && as_dir=.
18666+
for ac_exec_ext in '' $ac_executable_extensions; do
18667+
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
18668+
ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
18669+
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
18670+
break 2
18671+
fi
18672+
done
18673+
done
18674+
IFS=$as_save_IFS
18675+
18676+
test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no"
18677+
;;
18678+
esac
18679+
fi
18680+
PKG_CONFIG=$ac_cv_path_PKG_CONFIG
18681+
if test -n "$PKG_CONFIG"; then
18682+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
18683+
$as_echo "$PKG_CONFIG" >&6; }
18684+
else
18685+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
18686+
$as_echo "no" >&6; }
18687+
fi
18688+
18689+
18690+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Wayland support" >&5
18691+
$as_echo_n "checking for Wayland support... " >&6; }
18692+
video_wayland=no
18693+
if test x$PKG_CONFIG != xno; then
18694+
if $PKG_CONFIG --exists wayland-client wayland-egl wayland-cursor egl xkbcommon ; then
18695+
WAYLAND_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl wayland-cursor egl xkbcommon`
18696+
WAYLAND_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl wayland-cursor egl xkbcommon`
18697+
video_wayland=yes
18698+
fi
18699+
fi
18700+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_wayland" >&5
18701+
$as_echo "$video_wayland" >&6; }
18702+
18703+
if test x$video_wayland = xyes; then
18704+
18705+
$as_echo "#define SDL_VIDEO_DRIVER_WAYLAND 1" >>confdefs.h
18706+
18707+
SOURCES="$SOURCES $srcdir/src/video/wayland/*.c"
18708+
EXTRA_CFLAGS="$EXTRA_CFLAGS $WAYLAND_CFLAGS"
18709+
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $WAYLAND_LIBS"
18710+
have_video=yes
18711+
fi
18712+
fi
18713+
}
1863618714

1863718715
CheckX11()
1863818716
{
@@ -22220,6 +22298,7 @@ case "$host" in
2222022298
CheckNAS
2222122299
CheckSNDIO
2222222300
CheckX11
22301+
CheckWayland
2222322302
CheckDirectFB
2222422303
CheckFusionSound
2222522304
CheckOpenGLX11

configure.in

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,36 @@ CheckWarnAll()
11151115
fi
11161116
}
11171117

1118+
dnl Check for Wayland
1119+
CheckWayland()
1120+
{
1121+
AC_ARG_ENABLE(video-wayland,
1122+
AC_HELP_STRING([--enable-video-wayland], [use Wayland video driver [[default=yes]]]),
1123+
,enable_video_wayland=yes)
1124+
1125+
if test x$enable_video = xyes -a x$enable_video_wayland = xyes; then
1126+
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
1127+
AC_MSG_CHECKING(for Wayland support)
1128+
video_wayland=no
1129+
if test x$PKG_CONFIG != xno; then
1130+
if $PKG_CONFIG --exists wayland-client wayland-egl wayland-cursor egl xkbcommon ; then
1131+
WAYLAND_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl wayland-cursor egl xkbcommon`
1132+
WAYLAND_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl wayland-cursor egl xkbcommon`
1133+
video_wayland=yes
1134+
fi
1135+
fi
1136+
AC_MSG_RESULT($video_wayland)
1137+
1138+
if test x$video_wayland = xyes; then
1139+
AC_DEFINE(SDL_VIDEO_DRIVER_WAYLAND, 1, [ ])
1140+
SOURCES="$SOURCES $srcdir/src/video/wayland/*.c"
1141+
EXTRA_CFLAGS="$EXTRA_CFLAGS $WAYLAND_CFLAGS"
1142+
dnl FIXME do dynamic loading code here.
1143+
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $WAYLAND_LIBS"
1144+
have_video=yes
1145+
fi
1146+
fi
1147+
}
11181148

11191149
dnl Find the X11 include and library directories
11201150
CheckX11()
@@ -2449,6 +2479,7 @@ case "$host" in
24492479
CheckNAS
24502480
CheckSNDIO
24512481
CheckX11
2482+
CheckWayland
24522483
CheckDirectFB
24532484
CheckFusionSound
24542485
CheckOpenGLX11

include/SDL_config.h.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@
259259
#cmakedefine SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC @SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC@
260260
#cmakedefine SDL_VIDEO_DRIVER_DUMMY @SDL_VIDEO_DRIVER_DUMMY@
261261
#cmakedefine SDL_VIDEO_DRIVER_WINDOWS @SDL_VIDEO_DRIVER_WINDOWS@
262+
#cmakedefine SDL_VIDEO_DRIVER_WAYLAND @SDL_VIDEO_DRIVER_WAYLAND@
262263
#cmakedefine SDL_VIDEO_DRIVER_X11 @SDL_VIDEO_DRIVER_X11@
263264
#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC @SDL_VIDEO_DRIVER_X11_DYNAMIC@
264265
#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT @SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT@

include/SDL_config.h.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@
260260
#undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC
261261
#undef SDL_VIDEO_DRIVER_DUMMY
262262
#undef SDL_VIDEO_DRIVER_WINDOWS
263+
#undef SDL_VIDEO_DRIVER_WAYLAND
263264
#undef SDL_VIDEO_DRIVER_X11
264265
#undef SDL_VIDEO_DRIVER_RPI
265266
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC

include/SDL_syswm.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ typedef enum
101101
SDL_SYSWM_UNKNOWN,
102102
SDL_SYSWM_WINDOWS,
103103
SDL_SYSWM_X11,
104+
SDL_SYSWM_WAYLAND,
104105
SDL_SYSWM_DIRECTFB,
105106
SDL_SYSWM_COCOA,
106107
SDL_SYSWM_UIKIT,
@@ -175,6 +176,14 @@ struct SDL_SysWMinfo
175176
Window window; /**< The X11 window */
176177
} x11;
177178
#endif
179+
#if defined(SDL_VIDEO_DRIVER_WAYLAND)
180+
struct
181+
{
182+
struct wl_display *display; /**< Wayland display */
183+
struct wl_surface *surface; /**< Wayland surface */
184+
struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */
185+
} wl;
186+
#endif
178187
#if defined(SDL_VIDEO_DRIVER_DIRECTFB)
179188
struct
180189
{

src/render/opengl/SDL_glfuncs.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ SDL_PROC_UNUSED(void, glColor3bv, (const GLbyte *))
3030
SDL_PROC_UNUSED(void, glColor3d, (GLdouble, GLdouble, GLdouble))
3131
SDL_PROC_UNUSED(void, glColor3dv, (const GLdouble *))
3232
SDL_PROC_UNUSED(void, glColor3f, (GLfloat, GLfloat, GLfloat))
33-
SDL_PROC_UNUSED(void, glColor3fv, (const GLfloat *))
33+
SDL_PROC(void, glColor3fv, (const GLfloat *))
3434
SDL_PROC_UNUSED(void, glColor3i, (GLint, GLint, GLint))
3535
SDL_PROC_UNUSED(void, glColor3iv, (const GLint *))
3636
SDL_PROC_UNUSED(void, glColor3s, (GLshort, GLshort, GLshort))
@@ -85,7 +85,7 @@ SDL_PROC_UNUSED(void, glCopyTexSubImage2D,
8585
SDL_PROC_UNUSED(void, glCullFace, (GLenum mode))
8686
SDL_PROC_UNUSED(void, glDeleteLists, (GLuint list, GLsizei range))
8787
SDL_PROC(void, glDeleteTextures, (GLsizei n, const GLuint * textures))
88-
SDL_PROC_UNUSED(void, glDepthFunc, (GLenum func))
88+
SDL_PROC(void, glDepthFunc, (GLenum func))
8989
SDL_PROC_UNUSED(void, glDepthMask, (GLboolean flag))
9090
SDL_PROC_UNUSED(void, glDepthRange, (GLclampd zNear, GLclampd zFar))
9191
SDL_PROC(void, glDisable, (GLenum cap))
@@ -334,13 +334,13 @@ SDL_PROC_UNUSED(void, glRectsv, (const GLshort * v1, const GLshort * v2))
334334
SDL_PROC_UNUSED(GLint, glRenderMode, (GLenum mode))
335335
SDL_PROC(void, glRotated,
336336
(GLdouble angle, GLdouble x, GLdouble y, GLdouble z))
337-
SDL_PROC_UNUSED(void, glRotatef,
337+
SDL_PROC(void, glRotatef,
338338
(GLfloat angle, GLfloat x, GLfloat y, GLfloat z))
339339
SDL_PROC_UNUSED(void, glScaled, (GLdouble x, GLdouble y, GLdouble z))
340340
SDL_PROC_UNUSED(void, glScalef, (GLfloat x, GLfloat y, GLfloat z))
341341
SDL_PROC(void, glScissor, (GLint x, GLint y, GLsizei width, GLsizei height))
342342
SDL_PROC_UNUSED(void, glSelectBuffer, (GLsizei size, GLuint * buffer))
343-
SDL_PROC_UNUSED(void, glShadeModel, (GLenum mode))
343+
SDL_PROC(void, glShadeModel, (GLenum mode))
344344
SDL_PROC_UNUSED(void, glStencilFunc, (GLenum func, GLint ref, GLuint mask))
345345
SDL_PROC_UNUSED(void, glStencilMask, (GLuint mask))
346346
SDL_PROC_UNUSED(void, glStencilOp, (GLenum fail, GLenum zfail, GLenum zpass))
@@ -432,7 +432,7 @@ SDL_PROC_UNUSED(void, glVertex2sv, (const GLshort * v))
432432
SDL_PROC_UNUSED(void, glVertex3d, (GLdouble x, GLdouble y, GLdouble z))
433433
SDL_PROC_UNUSED(void, glVertex3dv, (const GLdouble * v))
434434
SDL_PROC_UNUSED(void, glVertex3f, (GLfloat x, GLfloat y, GLfloat z))
435-
SDL_PROC_UNUSED(void, glVertex3fv, (const GLfloat * v))
435+
SDL_PROC(void, glVertex3fv, (const GLfloat * v))
436436
SDL_PROC_UNUSED(void, glVertex3i, (GLint x, GLint y, GLint z))
437437
SDL_PROC_UNUSED(void, glVertex3iv, (const GLint * v))
438438
SDL_PROC_UNUSED(void, glVertex3s, (GLshort x, GLshort y, GLshort z))

0 commit comments

Comments
 (0)