mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-20 16:10:06 +01:00
meson.build: check gtk targets before building
We have two different dependencies on Wayland: GTK support and the wayland-protocols we use directly. If we have GTK support but wayland-protocols is not installed at meson configure time, our build fails. To avoid having multiple ifdefs in the code, let's define two new ones: HAVE_GTK_WAYLAND and HAVE_GTK_X11, both set if GTK supports that particular target (from pkgconfig) and we have the other support libraries we need. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
3542023996
commit
6a1bd5b0c9
2 changed files with 37 additions and 29 deletions
12
meson.build
12
meson.build
|
|
@ -561,14 +561,20 @@ if get_option('debug-gui')
|
||||||
config_h.set10('HAVE_GTK3', dep_gtk.found())
|
config_h.set10('HAVE_GTK3', dep_gtk.found())
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
gtk_targets = dep_gtk.get_pkgconfig_variable('targets')
|
||||||
|
have_gtk_wayland = gtk_targets.contains('wayland')
|
||||||
|
have_gtk_x11 = gtk_targets.contains('x11')
|
||||||
|
|
||||||
dep_cairo = dependency('cairo')
|
dep_cairo = dependency('cairo')
|
||||||
dep_glib = dependency('glib-2.0')
|
dep_glib = dependency('glib-2.0')
|
||||||
dep_wayland_client = dependency('wayland-client', required : false)
|
|
||||||
dep_wayland_protocols = dependency('wayland-protocols', required : false)
|
|
||||||
dep_x11 = dependency('x11', required : false)
|
dep_x11 = dependency('x11', required : false)
|
||||||
|
config_h.set10('HAVE_GTK_X11', have_gtk_x11 and dep_x11.found())
|
||||||
|
|
||||||
debug_gui_sources = [ 'tools/libinput-debug-gui.c' ]
|
debug_gui_sources = [ 'tools/libinput-debug-gui.c' ]
|
||||||
|
|
||||||
|
if have_gtk_wayland
|
||||||
|
dep_wayland_client = dependency('wayland-client', required : false)
|
||||||
|
dep_wayland_protocols = dependency('wayland-protocols', required : false)
|
||||||
if dep_wayland_client.found() and dep_wayland_protocols.found()
|
if dep_wayland_client.found() and dep_wayland_protocols.found()
|
||||||
wayland_scanner = find_program('wayland-scanner')
|
wayland_scanner = find_program('wayland-scanner')
|
||||||
wlproto_dir = dep_wayland_protocols.get_pkgconfig_variable('pkgdatadir')
|
wlproto_dir = dep_wayland_protocols.get_pkgconfig_variable('pkgdatadir')
|
||||||
|
|
@ -589,6 +595,8 @@ if get_option('debug-gui')
|
||||||
)
|
)
|
||||||
|
|
||||||
debug_gui_sources += [ wayland_headers, wayland_sources ]
|
debug_gui_sources += [ wayland_headers, wayland_sources ]
|
||||||
|
config_h.set10('HAVE_GTK_WAYLAND', true)
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
deps_debug_gui = [
|
deps_debug_gui = [
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@
|
||||||
|
|
||||||
#include "shared.h"
|
#include "shared.h"
|
||||||
|
|
||||||
#ifdef GDK_WINDOWING_WAYLAND
|
#if HAVE_GTK_WAYLAND
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
#include "pointer-constraints-unstable-v1-client-protocol.h"
|
#include "pointer-constraints-unstable-v1-client-protocol.h"
|
||||||
#if HAVE_GTK4
|
#if HAVE_GTK4
|
||||||
|
|
@ -58,7 +58,7 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef GDK_WINDOWING_X11
|
#if HAVE_GTK_X11
|
||||||
#include <X11/X.h>
|
#include <X11/X.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#if HAVE_GTK4
|
#if HAVE_GTK4
|
||||||
|
|
@ -120,7 +120,7 @@ struct window {
|
||||||
struct {
|
struct {
|
||||||
bool locked;
|
bool locked;
|
||||||
|
|
||||||
#ifdef GDK_WINDOWING_WAYLAND
|
#if HAVE_GTK_WAYLAND
|
||||||
struct zwp_pointer_constraints_v1 *wayland_pointer_constraints;
|
struct zwp_pointer_constraints_v1 *wayland_pointer_constraints;
|
||||||
struct zwp_locked_pointer_v1 *wayland_locked_pointer;
|
struct zwp_locked_pointer_v1 *wayland_locked_pointer;
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -207,7 +207,7 @@ struct window {
|
||||||
struct libinput_device *devices[50];
|
struct libinput_device *devices[50];
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef GDK_WINDOWING_WAYLAND
|
#if HAVE_GTK_WAYLAND
|
||||||
static void
|
static void
|
||||||
wayland_registry_global(void *data,
|
wayland_registry_global(void *data,
|
||||||
struct wl_registry *registry,
|
struct wl_registry *registry,
|
||||||
|
|
@ -297,9 +297,9 @@ backend_is_wayland(void)
|
||||||
{
|
{
|
||||||
return GDK_IS_WAYLAND_DISPLAY(gdk_display_get_default());
|
return GDK_IS_WAYLAND_DISPLAY(gdk_display_get_default());
|
||||||
}
|
}
|
||||||
#endif /* GDK_WINDOWING_WAYLAND */
|
#endif /* HAVE_GTK_WAYLAND */
|
||||||
|
|
||||||
#ifdef GDK_WINDOWING_X11
|
#if HAVE_GTK_X11
|
||||||
static bool
|
static bool
|
||||||
x_lock_pointer(struct window *w)
|
x_lock_pointer(struct window *w)
|
||||||
{
|
{
|
||||||
|
|
@ -342,19 +342,19 @@ backend_is_x11(void)
|
||||||
{
|
{
|
||||||
return GDK_IS_X11_DISPLAY(gdk_display_get_default());
|
return GDK_IS_X11_DISPLAY(gdk_display_get_default());
|
||||||
}
|
}
|
||||||
#endif /* GDK_WINDOWING_X11 */
|
#endif /* HAVE_GTK_X11 */
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
window_lock_pointer(struct window *w)
|
window_lock_pointer(struct window *w)
|
||||||
{
|
{
|
||||||
w->lock_pointer.locked = false;
|
w->lock_pointer.locked = false;
|
||||||
|
|
||||||
#ifdef GDK_WINDOWING_WAYLAND
|
#if HAVE_GTK_WAYLAND
|
||||||
if (backend_is_wayland())
|
if (backend_is_wayland())
|
||||||
w->lock_pointer.locked = wayland_lock_pointer(w);
|
w->lock_pointer.locked = wayland_lock_pointer(w);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef GDK_WINDOWING_X11
|
#if HAVE_GTK_X11
|
||||||
if (backend_is_x11())
|
if (backend_is_x11())
|
||||||
w->lock_pointer.locked = x_lock_pointer(w);
|
w->lock_pointer.locked = x_lock_pointer(w);
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -370,12 +370,12 @@ window_unlock_pointer(struct window *w)
|
||||||
|
|
||||||
w->lock_pointer.locked = false;
|
w->lock_pointer.locked = false;
|
||||||
|
|
||||||
#ifdef GDK_WINDOWING_WAYLAND
|
#if HAVE_GTK_WAYLAND
|
||||||
if (backend_is_wayland())
|
if (backend_is_wayland())
|
||||||
wayland_unlock_pointer(w);
|
wayland_unlock_pointer(w);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef GDK_WINDOWING_X11
|
#if HAVE_GTK_X11
|
||||||
if (backend_is_x11())
|
if (backend_is_x11())
|
||||||
x_unlock_pointer(w);
|
x_unlock_pointer(w);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue