From 01a0fa9437b9d4ca74e39b6e8e256fc5f05187d2 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Wed, 21 Mar 2018 14:11:39 +0100 Subject: [PATCH] idle-monitor: Add ResetIdletime API, for testing purposes The ResetIdletime API can be used instead of an "XTest" binary to programmatically reset the idle time, as if the user pressed a button on a keyboard. This is necessary since we stopped using the XSync extension to monitor idletimes, as it didn't consider inhibitors as busy, and mutter's clutter code ignores "Core Events" as generated by XTest. This patch will require minimal changes to gnome-settings-daemon's power test suite so that "key press" idletime resets are triggered through this D-Bus interface rather than through XTest and a roundtrip through the X server. https://bugzilla.gnome.org/show_bug.cgi?id=705942 --- src/backends/meta-idle-monitor-dbus.c | 23 +++++++++++++++++++++++ src/org.gnome.Mutter.IdleMonitor.xml | 2 ++ 2 files changed, 25 insertions(+) diff --git a/src/backends/meta-idle-monitor-dbus.c b/src/backends/meta-idle-monitor-dbus.c index a0e8ec1cb..e01d6dda6 100644 --- a/src/backends/meta-idle-monitor-dbus.c +++ b/src/backends/meta-idle-monitor-dbus.c @@ -24,6 +24,7 @@ #include "meta-idle-monitor-dbus.h" #include +#include #include "meta-dbus-idle-monitor.h" #include @@ -43,6 +44,26 @@ handle_get_idletime (MetaDBusIdleMonitor *skeleton, return TRUE; } +static gboolean +handle_reset_idletime (MetaDBusIdleMonitor *skeleton, + GDBusMethodInvocation *invocation, + MetaIdleMonitor *monitor) +{ + if (!g_getenv ("MUTTER_DEBUG_RESET_IDLETIME")) + { + g_dbus_method_invocation_return_error_literal (invocation, + G_DBUS_ERROR, + G_DBUS_ERROR_UNKNOWN_METHOD, + "No such method"); + return FALSE; + } + + meta_idle_monitor_reset_idletime (meta_idle_monitor_get_core ()); + meta_dbus_idle_monitor_complete_reset_idletime (skeleton, invocation); + + return TRUE; +} + typedef struct { MetaDBusIdleMonitor *dbus_monitor; MetaIdleMonitor *monitor; @@ -173,6 +194,8 @@ create_monitor_skeleton (GDBusObjectManagerServer *manager, G_CALLBACK (handle_add_user_active_watch), monitor, 0); g_signal_connect_object (skeleton, "handle-remove-watch", G_CALLBACK (handle_remove_watch), monitor, 0); + g_signal_connect_object (skeleton, "handle-reset-idletime", + G_CALLBACK (handle_reset_idletime), monitor, 0); g_signal_connect_object (skeleton, "handle-get-idletime", G_CALLBACK (handle_get_idletime), monitor, 0); diff --git a/src/org.gnome.Mutter.IdleMonitor.xml b/src/org.gnome.Mutter.IdleMonitor.xml index 34a26dd93..374af4dc4 100644 --- a/src/org.gnome.Mutter.IdleMonitor.xml +++ b/src/org.gnome.Mutter.IdleMonitor.xml @@ -28,6 +28,8 @@ + +