[gnome-desktop] idle-monitor: Per-device idle monitors aren't supported in Wayland



commit d4842ab4a5f461654acf634c27076ed4d24ac6de
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Feb 23 00:21:20 2018 +0100

    idle-monitor: Per-device idle monitors aren't supported in Wayland
    
    So return an error.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=793737

 libgnome-desktop/gnome-idle-monitor.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/libgnome-desktop/gnome-idle-monitor.c b/libgnome-desktop/gnome-idle-monitor.c
index 05dbed4..b85c096 100644
--- a/libgnome-desktop/gnome-idle-monitor.c
+++ b/libgnome-desktop/gnome-idle-monitor.c
@@ -24,8 +24,12 @@
 #include <string.h>
 
 #include <glib.h>
+#include <glib/gi18n-lib.h>
 #include <gdk/gdkx.h>
 #include <gdk/gdk.h>
+#if defined(GDK_WINDOWING_WAYLAND)
+#include <gdk/gdkwayland.h>
+#endif
 
 #define GNOME_DESKTOP_USE_UNSTABLE_API
 #include "gnome-idle-monitor.h"
@@ -429,12 +433,21 @@ gnome_idle_monitor_new (void)
  * Returns: a new #GnomeIdleMonitor that tracks the device-specific
  * idletime for @device. If device-specific idletime is not available,
  * %NULL is returned, and @error is set. To track server-global
- * idletime for all devices, use gnome_idle_monitor_new().
+ * idletime for all devices, use gnome_idle_monitor_new(). This function
+ * only works under X11, not under Wayland and will return an error.
  */
 GnomeIdleMonitor *
 gnome_idle_monitor_new_for_device (GdkDevice  *device,
                                   GError    **error)
 {
+#if defined(GDK_WINDOWING_WAYLAND)
+       if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ())) {
+               g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+                                    "Per-device idle monitors not supported under Wayland");
+               return NULL;
+       }
+#endif
+
        return GNOME_IDLE_MONITOR (g_initable_new (GNOME_TYPE_IDLE_MONITOR, NULL, error,
                                                   "device", device, NULL));
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]