[gnome-settings-daemon/wip/benzea/sysfs-backlight-switch] power: Bind building sysfs backlight helper to meson option
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon/wip/benzea/sysfs-backlight-switch] power: Bind building sysfs backlight helper to meson option
- Date: Tue, 2 Oct 2018 14:44:35 +0000 (UTC)
commit 27b62f53891d91fbe0f2e57be7cb8e26896607a5
Author: Benjamin Berg <bberg redhat com>
Date: Mon Oct 1 10:52:53 2018 +0200
power: Bind building sysfs backlight helper to meson option
This is require so that BSDs can explicitly disable building the
backlight helper. BSDs also have udev/GUdev support to some extend,
which is why we need the explicit option.
See issue #94
meson.build | 8 ++++++++
meson_options.txt | 2 ++
plugins/power/gsd-backlight.c | 28 ++++++++++++++--------------
plugins/power/meson.build | 4 ++--
4 files changed, 26 insertions(+), 16 deletions(-)
---
diff --git a/meson.build b/meson.build
index 47cf3722..6a2b8ab4 100644
--- a/meson.build
+++ b/meson.build
@@ -126,6 +126,14 @@ if enable_gudev
endif
config_h.set10('HAVE_GUDEV', enable_gudev)
+# Linux sysfs backlight support (default enabled)
+enable_sysfs_backlight = get_option('sysfs_backlight')
+if enable_sysfs_backlight and not enable_gudev
+ assert(enable_gudev, 'GUDev support is required for sysfs backlight support.')
+endif
+config_h.set10('HAVE_SYSFS_BACKLIGHT', enable_sysfs_backlight)
+
+# Timer FD checking
has_timerfd_create = cc.has_function('timerfd_create')
config_h.set10('HAVE_TIMERFD', has_timerfd_create)
diff --git a/meson_options.txt b/meson_options.txt
index 50bd1749..241f4e81 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -8,3 +8,5 @@ option('network_manager', type: 'boolean', value: true, description: 'build with
option('rfkill', type: 'boolean', value: true, description: 'build with rfkill support (not optional on
Linux platforms)')
option('smartcard', type: 'boolean', value: true, description: 'build with smartcard support')
option('wayland', type: 'boolean', value: true, description: 'build with Wayland support')
+
+option('sysfs_backlight', type: 'boolean', value: true, description: 'build with brightness control code via
sysfs for Linux platforms')
diff --git a/plugins/power/gsd-backlight.c b/plugins/power/gsd-backlight.c
index 2159f429..1d7170d1 100644
--- a/plugins/power/gsd-backlight.c
+++ b/plugins/power/gsd-backlight.c
@@ -25,9 +25,9 @@
#include "gsd-power-constants.h"
#include "gsd-power-manager.h"
-#ifdef HAVE_GUDEV
+#if HAVE_SYSFS_BACKLIGHT
#include <gudev/gudev.h>
-#endif /* HAVE_GUDEV */
+#endif /* HAVE_SYSFS_BACKLIGHT */
struct _GsdBacklight
{
@@ -39,7 +39,7 @@ struct _GsdBacklight
gint brightness_target;
gint brightness_step;
-#ifdef HAVE_GUDEV
+#if HAVE_SYSFS_BACKLIGHT
GUdevClient *udev;
GUdevDevice *udev_device;
@@ -47,7 +47,7 @@ struct _GsdBacklight
GQueue tasks;
gint idle_update;
-#endif
+#endif /* HAVE_SYSFS_BACKLIGHT */
GnomeRRScreen *rr_screen;
};
@@ -70,7 +70,7 @@ G_DEFINE_TYPE_EXTENDED (GsdBacklight, gsd_backlight, G_TYPE_OBJECT, 0,
G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE,
gsd_backlight_initable_iface_init);)
-#ifdef HAVE_GUDEV
+#if HAVE_SYSFS_BACKLIGHT
static GUdevDevice*
gsd_backlight_udev_get_type (GList *devices, const gchar *type)
{
@@ -395,7 +395,7 @@ gsd_backlight_process_taskqueue (GsdBacklight *backlight)
/* And run it! */
gsd_backlight_run_set_helper (backlight, to_run);
}
-#endif /* HAVE_GUDEV */
+#endif /* HAVE_SYSFS_BACKLIGHT */
static GnomeRROutput*
gsd_backlight_rr_find_output (GsdBacklight *backlight, gboolean controllable)
@@ -464,7 +464,7 @@ gsd_backlight_set_brightness_val_async (GsdBacklight *backlight,
task = g_task_new (backlight, cancellable, callback, user_data);
-#ifdef HAVE_GUDEV
+#if HAVE_SYSFS_BACKLIGHT
if (backlight->udev_device != NULL) {
BacklightHelperData *task_data;
@@ -478,7 +478,7 @@ gsd_backlight_set_brightness_val_async (GsdBacklight *backlight,
return;
}
-#endif /* HAVE_GUDEV */
+#endif /* HAVE_SYSFS_BACKLIGHT */
/* Fallback to setting via GNOME RR/X11 */
output = gsd_backlight_rr_find_output (backlight, TRUE);
@@ -716,11 +716,11 @@ gsd_backlight_initable_init (GInitable *initable,
return FALSE;
}
-#ifdef HAVE_GUDEV
+#if HAVE_SYSFS_BACKLIGHT
/* Try finding a udev device. */
if (gsd_backlight_udev_init (backlight))
goto found;
-#endif /* HAVE_GUDEV */
+#endif /* HAVE_SYSFS_BACKLIGHT */
/* Try GNOME RR as a fallback. */
output = gsd_backlight_rr_find_output (backlight, TRUE);
@@ -755,7 +755,7 @@ gsd_backlight_finalize (GObject *object)
{
GsdBacklight *backlight = GSD_BACKLIGHT (object);
-#ifdef HAVE_GUDEV
+#if HAVE_SYSFS_BACKLIGHT
g_assert (backlight->active_task == NULL);
g_assert (g_queue_is_empty (&backlight->tasks));
g_clear_object (&backlight->udev);
@@ -764,7 +764,7 @@ gsd_backlight_finalize (GObject *object)
g_source_remove (backlight->idle_update);
backlight->idle_update = 0;
}
-#endif /* HAVE_GUDEV */
+#endif /* HAVE_SYSFS_BACKLIGHT */
g_clear_object (&backlight->rr_screen);
}
@@ -807,10 +807,10 @@ gsd_backlight_init (GsdBacklight *backlight)
backlight->brightness_val = -1;
backlight->brightness_step = 1;
-#ifdef HAVE_GUDEV
+#if HAVE_SYSFS_BACKLIGHT
backlight->active_task = NULL;
g_queue_init (&backlight->tasks);
-#endif /* HAVE_GUDEV */
+#endif /* HAVE_SYSFS_BACKLIGHT */
}
GsdBacklight *
diff --git a/plugins/power/meson.build b/plugins/power/meson.build
index 0158a466..30e95ee3 100644
--- a/plugins/power/meson.build
+++ b/plugins/power/meson.build
@@ -18,7 +18,7 @@ deps = plugins_deps + [
dependency('xext')
]
-if enable_gudev
+if enable_sysfs_backlight
deps += gudev_dep
endif
@@ -59,7 +59,7 @@ gsd_power_enums_update = executable(
c_args: cflags
)
-if enable_gudev
+if enable_sysfs_backlight
policy = 'org.gnome.settings-daemon.plugins.power.policy'
policy_in = configure_file(
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]