Blob Blame History Raw
From 922aa08fe726ccb187cf44426cb7f89a521bb3bb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Mon, 23 Sep 2019 04:21:13 -0700
Subject: [PATCH 1/2] Use old gamma control protocol if available

This is based on version number but should we decide to keep
support for this protocol in our embedded wlroot for longer
we can add that as well.

(cherry picked from commit aec0a1abdf57a1e3db77e89cb32593f54f150c7f)
---
 config.h.in   | 1 +
 meson.build   | 9 +++++++++
 src/desktop.c | 6 +++++-
 src/desktop.h | 4 ++++
 4 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/config.h.in b/config.h.in
index 31650e1..9314dde 100644
--- a/config.h.in
+++ b/config.h.in
@@ -7,3 +7,4 @@
 
 #mesondefine PHOC_VERSION
 #mesondefine PHOC_XWAYLAND
+#mesondefine PHOC_USE_GAMMA_CONTROL
diff --git a/meson.build b/meson.build
index a650f13..6774bf5 100644
--- a/meson.build
+++ b/meson.build
@@ -62,9 +62,17 @@ if get_option('xwayland').enabled() and not wlroots_has_xwayland
 endif
 have_xwayland = get_option('xwayland').enabled()
 
+wlroots_major_version = wlroots.version().split('.')[0]
+wlroots_minor_version = wlroots.version().split('.')[1]
+use_gamma_control = false
+if wlroots_major_version.to_int() == 0 and wlroots_minor_version.to_int() == 6
+  use_gamma_control = true
+endif
+
 config_h = configuration_data()
 config_h.set_quoted('PHOC_VERSION', meson.project_version())
 config_h.set('PHOC_XWAYLAND', have_xwayland)
+config_h.set('PHOC_USE_GAMMA_CONTROL', use_gamma_control)
 
 configure_file(
   input: 'config.h.in',
@@ -134,6 +142,7 @@ summary = [
         '',
         '           xwayland: @0@'.format(have_xwayland),
         ' wlroots subproject: @0@'.format(wlroots_proj.found()),
+        '  use gamma control: @0@'.format(use_gamma_control),
         '--------------------------',
         ''
 ]
diff --git a/src/desktop.c b/src/desktop.c
index 9968a36..a5455e0 100644
--- a/src/desktop.c
+++ b/src/desktop.c
@@ -12,7 +12,9 @@
 #include <wlr/types/wlr_data_control_v1.h>
 #include <wlr/types/wlr_export_dmabuf_v1.h>
 #include <wlr/types/wlr_gamma_control_v1.h>
-#include <wlr/types/wlr_gamma_control.h>
+#ifdef PHOC_USE_GAMMA_CONTROL
+#  include <wlr/types/wlr_gamma_control.h>
+#endif
 #include <wlr/types/wlr_gtk_primary_selection.h>
 #include <wlr/types/wlr_idle_inhibit_v1.h>
 #include <wlr/types/wlr_idle.h>
@@ -468,7 +470,9 @@ phoc_desktop_constructed (GObject *object)
   }
 #endif
 
+#ifdef PHOC_USE_GAMMA_CONTROL
   self->gamma_control_manager = wlr_gamma_control_manager_create(server->wl_display);
+#endif
   self->gamma_control_manager_v1 = wlr_gamma_control_manager_v1_create(server->wl_display);
   self->screenshooter = wlr_screenshooter_create(server->wl_display);
   self->export_dmabuf_manager_v1 =
diff --git a/src/desktop.h b/src/desktop.h
index 4d6af3d..291b003 100644
--- a/src/desktop.h
+++ b/src/desktop.h
@@ -6,7 +6,9 @@
 #include <wlr/types/wlr_compositor.h>
 #include <wlr/types/wlr_foreign_toplevel_management_v1.h>
 #include <wlr/types/wlr_gamma_control_v1.h>
+#ifdef PHOC_USE_GAMMA_CONTROL
 #include <wlr/types/wlr_gamma_control.h>
+#endif
 #include <wlr/types/wlr_gtk_primary_selection.h>
 #include <wlr/types/wlr_idle_inhibit_v1.h>
 #include <wlr/types/wlr_idle.h>
@@ -62,7 +64,9 @@ struct _PhocDesktop {
 	struct wlr_compositor *compositor;
 	struct wlr_xdg_shell_v6 *xdg_shell_v6;
 	struct wlr_xdg_shell *xdg_shell;
+#ifdef PHOC_USE_GAMMA_CONTROL
 	struct wlr_gamma_control_manager *gamma_control_manager;
+#endif
 	struct wlr_gamma_control_manager_v1 *gamma_control_manager_v1;
 	struct wlr_screenshooter *screenshooter;
 	struct wlr_export_dmabuf_manager_v1 *export_dmabuf_manager_v1;
-- 
2.23.0