Skip to content

Commit c012839

Browse files
committed
Implement a wayland backend for clutter.
Allows standalone processes to use Clutter as a wayland client directly.
1 parent 2135c36 commit c012839

24 files changed

Lines changed: 2826 additions & 4 deletions

clutter/clutter/clutter-backend.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@
6464
#ifdef CLUTTER_WINDOWING_EGL
6565
#include "egl/clutter-backend-eglnative.h"
6666
#endif
67+
#ifdef CLUTTER_WINDOWING_WAYLAND_CLIENT
68+
#include "wayland-client/clutter-backend-wayland-client.h"
69+
#endif
6770

6871
#ifdef CLUTTER_HAS_WAYLAND_COMPOSITOR_SUPPORT
6972
#include <cogl/cogl-wayland-server.h>
@@ -452,6 +455,9 @@ static const struct {
452455
#endif
453456
#ifdef CLUTTER_WINDOWING_EGL
454457
{ CLUTTER_WINDOWING_EGL, clutter_backend_egl_native_new },
458+
#endif
459+
#ifdef CLUTTER_WINDOWING_WAYLAND_CLIENT
460+
{ CLUTTER_WINDOWING_WAYLAND_CLIENT, clutter_backend_wayland_client_new },
455461
#endif
456462
{ NULL, NULL },
457463
};

clutter/clutter/clutter-build-config.h.meson

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
/* Have evdev support for input handling */
88
#mesondefine HAVE_EVDEV
99

10+
/* Have Wayland client backend support */
11+
#mesondefine HAVE_WAYLAND_CLIENT
12+
1013
/* Building with libwacom for advanced tablet management */
1114
#mesondefine HAVE_LIBWACOM
1215

clutter/clutter/meson.build

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,62 @@ if have_wayland
296296
clutter_backend_private_headers += clutter_wayland_private_headers
297297
endif
298298

299+
if have_wayland_client
300+
# Generate Wayland client protocols
301+
wayland_scanner = find_program('wayland-scanner')
302+
wayland_protocols_dir = wayland_protocols_dep.get_variable(pkgconfig: 'pkgdatadir')
303+
304+
# xdg-shell protocol (required by layer-shell)
305+
xdg_shell_xml = join_paths(wayland_protocols_dir, 'stable', 'xdg-shell', 'xdg-shell.xml')
306+
307+
xdg_shell_client_header = custom_target('xdg-shell-client-protocol.h',
308+
input: xdg_shell_xml,
309+
output: 'xdg-shell-client-protocol.h',
310+
command: [wayland_scanner, 'client-header', '@INPUT@', '@OUTPUT@'],
311+
)
312+
313+
xdg_shell_protocol_code = custom_target('xdg-shell-protocol.c',
314+
input: xdg_shell_xml,
315+
output: 'xdg-shell-protocol.c',
316+
command: [wayland_scanner, 'private-code', '@INPUT@', '@OUTPUT@'],
317+
)
318+
319+
# layer-shell protocol
320+
layer_shell_xml = files('wayland-client/wlr-layer-shell-unstable-v1.xml')
321+
322+
layer_shell_client_header = custom_target('wlr-layer-shell-client-protocol.h',
323+
input: layer_shell_xml,
324+
output: 'wlr-layer-shell-unstable-v1-client-protocol.h',
325+
command: [wayland_scanner, 'client-header', '@INPUT@', '@OUTPUT@'],
326+
)
327+
328+
layer_shell_protocol_code = custom_target('wlr-layer-shell-protocol.c',
329+
input: layer_shell_xml,
330+
output: 'wlr-layer-shell-unstable-v1-protocol.c',
331+
command: [wayland_scanner, 'private-code', '@INPUT@', '@OUTPUT@'],
332+
)
333+
334+
clutter_wayland_client_sources = [
335+
'wayland-client/clutter-backend-wayland-client.c',
336+
'wayland-client/clutter-stage-wayland-client.c',
337+
'wayland-client/clutter-seat-wayland-client.c',
338+
'wayland-client/clutter-keymap-wayland-client.c',
339+
xdg_shell_protocol_code,
340+
layer_shell_protocol_code,
341+
]
342+
clutter_backend_sources += clutter_wayland_client_sources
343+
344+
clutter_wayland_client_private_headers = [
345+
'wayland-client/clutter-backend-wayland-client.h',
346+
'wayland-client/clutter-stage-wayland-client.h',
347+
'wayland-client/clutter-seat-wayland-client.h',
348+
'wayland-client/clutter-keymap-wayland-client.h',
349+
xdg_shell_client_header,
350+
layer_shell_client_header,
351+
]
352+
clutter_backend_private_headers += clutter_wayland_client_private_headers
353+
endif
354+
299355
cally_headers = [
300356
'cally/cally-actor.h',
301357
'cally/cally-clone.h',
@@ -334,6 +390,7 @@ cdata = configuration_data()
334390
cdata.set_quoted('MUFFIN_VERSION', meson.project_version())
335391
cdata.set('CLUTTER_DRIVERS', '"*"')
336392
cdata.set('HAVE_EVDEV', have_native_backend)
393+
cdata.set('HAVE_WAYLAND_CLIENT', have_wayland_client)
337394
cdata.set('HAVE_LIBWACOM', have_libwacom)
338395
cdata.set('HAVE_PANGO_FT2', have_pango_ft2)
339396

@@ -364,6 +421,11 @@ if have_native_backend
364421
'#define CLUTTER_INPUT_EVDEV "evdev"',
365422
]
366423
endif
424+
if have_wayland_client
425+
clutter_config_defines += [
426+
'#define CLUTTER_WINDOWING_WAYLAND_CLIENT "wayland-client"',
427+
]
428+
endif
367429
clutter_config_defines += [
368430
'#define CLUTTER_INPUT_NULL "null"',
369431
]

0 commit comments

Comments
 (0)