[gnome-flashback/wip/muktupavels/remove-per-device-idle-monitors: 2/2] idle-monitor: remove per-device idle monitors
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback/wip/muktupavels/remove-per-device-idle-monitors: 2/2] idle-monitor: remove per-device idle monitors
- Date: Mon, 23 May 2022 19:59:31 +0000 (UTC)
commit d416d9d865673efc61bd76a45b3ff643473fee6d
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Mon May 23 19:13:14 2022 +0300
idle-monitor: remove per-device idle monitors
Related gnome_idle_monitor_new_for_device API has been removed
from gnome-desktop:
https://gitlab.gnome.org/GNOME/gnome-desktop/-/commit/9d01763ba2a3
And more importantly per-device idle monitors has been removed
also from mutter:
https://gitlab.gnome.org/GNOME/mutter/-/commit/586723eb4480237be4b
daemons/idle-monitor/Makefile.am | 2 -
daemons/idle-monitor/flashback-idle-monitor.c | 111 ++----------------
daemons/idle-monitor/meta-backend.c | 155 -------------------------
daemons/idle-monitor/meta-backend.h | 53 ---------
daemons/idle-monitor/meta-idle-monitor-xsync.c | 15 +--
daemons/idle-monitor/meta-idle-monitor.c | 91 ---------------
daemons/idle-monitor/meta-idle-monitor.h | 4 -
7 files changed, 10 insertions(+), 421 deletions(-)
---
diff --git a/daemons/idle-monitor/Makefile.am b/daemons/idle-monitor/Makefile.am
index ee8830d..3330a94 100644
--- a/daemons/idle-monitor/Makefile.am
+++ b/daemons/idle-monitor/Makefile.am
@@ -23,8 +23,6 @@ gnome_flashback_idle_monitor_SOURCES = \
gf-idle-monitor-main.c \
meta-dbus-idle-monitor.c \
meta-dbus-idle-monitor.h \
- meta-backend.c \
- meta-backend.h \
meta-idle-monitor.c \
meta-idle-monitor.h \
meta-idle-monitor-xsync.c \
diff --git a/daemons/idle-monitor/flashback-idle-monitor.c b/daemons/idle-monitor/flashback-idle-monitor.c
index 5633b99..f9f0165 100644
--- a/daemons/idle-monitor/flashback-idle-monitor.c
+++ b/daemons/idle-monitor/flashback-idle-monitor.c
@@ -26,7 +26,6 @@
#include <X11/extensions/sync.h>
#include "flashback-idle-monitor.h"
-#include "meta-backend.h"
#include "meta-idle-monitor.h"
#include "meta-idle-monitor-xsync.h"
#include "meta-dbus-idle-monitor.h"
@@ -35,6 +34,8 @@ struct _FlashbackIdleMonitor
{
GObject parent;
+ MetaIdleMonitor *monitor;
+
gint dbus_name_id;
gint xsync_event_base;
@@ -218,44 +219,6 @@ create_monitor_skeleton (GDBusObjectManagerServer *server,
g_object_unref (object);
}
-static void
-on_device_added (GdkSeat *seat,
- GdkDevice *device,
- gpointer user_data)
-{
- FlashbackIdleMonitor *idle_monitor;
- MetaIdleMonitor *monitor;
- gint device_id;
- gchar *path;
-
- idle_monitor = FLASHBACK_IDLE_MONITOR (user_data);
-
- device_id = gdk_x11_device_get_id (device);
- monitor = meta_idle_monitor_get_for_device (device_id);
- path = g_strdup_printf ("/org/gnome/Mutter/IdleMonitor/Device%d", device_id);
-
- create_monitor_skeleton (idle_monitor->server, monitor, path);
- g_free (path);
-}
-
-static void
-on_device_removed (GdkSeat *seat,
- GdkDevice *device,
- gpointer user_data)
-{
- FlashbackIdleMonitor *monitor;
- gint device_id;
- gchar *path;
-
- monitor = FLASHBACK_IDLE_MONITOR (user_data);
-
- device_id = gdk_x11_device_get_id (device);
- path = g_strdup_printf ("/org/gnome/Mutter/IdleMonitor/Device%d", device_id);
-
- g_dbus_object_manager_server_unexport (monitor->server, path);
- g_free (path);
-}
-
static void
on_bus_acquired (GDBusConnection *connection,
const char *name,
@@ -263,45 +226,15 @@ on_bus_acquired (GDBusConnection *connection,
{
FlashbackIdleMonitor *idle_monitor;
const gchar *server_path;
- MetaIdleMonitor *monitor;
const gchar *core_path;
- GdkDisplay *display;
- GdkSeat *seat;
- GList *devices;
- GList *iter;
idle_monitor = FLASHBACK_IDLE_MONITOR (user_data);
server_path = "/org/gnome/Mutter/IdleMonitor";
idle_monitor->server = g_dbus_object_manager_server_new (server_path);
- monitor = meta_idle_monitor_get_core ();
core_path = "/org/gnome/Mutter/IdleMonitor/Core";
- create_monitor_skeleton (idle_monitor->server, monitor, core_path);
-
- display = gdk_display_get_default ();
- seat = gdk_display_get_default_seat (display);
- devices = NULL;
-
- devices = g_list_append (devices, gdk_seat_get_pointer (seat));
- devices = g_list_append (devices, gdk_seat_get_keyboard (seat));
- devices = g_list_concat (devices, gdk_seat_get_slaves (seat, GDK_SEAT_CAPABILITY_ALL));
-
- for (iter = devices; iter; iter = iter->next)
- {
- GdkDevice *device;
-
- device = (GdkDevice *) iter->data;
-
- on_device_added (seat, device, idle_monitor);
- }
-
- g_list_free (devices);
-
- g_signal_connect_object (seat, "device-added",
- G_CALLBACK (on_device_added), idle_monitor, 0);
- g_signal_connect_object (seat, "device-removed",
- G_CALLBACK (on_device_removed), idle_monitor, 0);
+ create_monitor_skeleton (idle_monitor->server, idle_monitor->monitor, core_path);
g_dbus_object_manager_server_set_connection (idle_monitor->server, connection);
}
@@ -326,22 +259,15 @@ filter_func (GdkXEvent *xevent,
gpointer user_data)
{
FlashbackIdleMonitor *monitor;
- MetaBackend *backend;
XEvent *xev;
- gint i;
monitor = FLASHBACK_IDLE_MONITOR (user_data);
- backend = meta_get_backend ();
xev = (XEvent *) xevent;
if (xev->type == (monitor->xsync_event_base + XSyncAlarmNotify))
{
- for (i = 0; i <= backend->device_id_max; i++)
- {
- if (backend->device_monitors[i])
- meta_idle_monitor_xsync_handle_xevent (backend->device_monitors[i],
- (XSyncAlarmNotifyEvent*) xev);
- }
+ meta_idle_monitor_xsync_handle_xevent (monitor->monitor,
+ (XSyncAlarmNotifyEvent*) xev);
}
return GDK_FILTER_CONTINUE;
@@ -351,10 +277,6 @@ static void
flashback_idle_monitor_dispose (GObject *object)
{
FlashbackIdleMonitor *monitor;
- GdkDisplay *display;
- GdkSeat *seat;
- GList *devices;
- GList *iter;
const gchar *core_path;
monitor = FLASHBACK_IDLE_MONITOR (object);
@@ -365,25 +287,6 @@ flashback_idle_monitor_dispose (GObject *object)
monitor->dbus_name_id = 0;
}
- display = gdk_display_get_default ();
- seat = gdk_display_get_default_seat (display);
- devices = NULL;
-
- devices = g_list_append (devices, gdk_seat_get_pointer (seat));
- devices = g_list_append (devices, gdk_seat_get_keyboard (seat));
- devices = g_list_concat (devices, gdk_seat_get_slaves (seat, GDK_SEAT_CAPABILITY_ALL));
-
- for (iter = devices; iter; iter = iter->next)
- {
- GdkDevice *device;
-
- device = (GdkDevice *) iter->data;
-
- on_device_removed (seat, device, monitor);
- }
-
- g_list_free (devices);
-
core_path = "/org/gnome/Mutter/IdleMonitor/Core";
g_dbus_object_manager_server_unexport (monitor->server, core_path);
@@ -401,6 +304,8 @@ flashback_idle_monitor_finalize (GObject *object)
gdk_window_remove_filter (NULL, (GdkFilterFunc) filter_func, monitor);
+ g_object_unref (monitor->monitor);
+
G_OBJECT_CLASS (flashback_idle_monitor_parent_class)->finalize (object);
}
@@ -414,6 +319,8 @@ flashback_idle_monitor_init (FlashbackIdleMonitor *monitor)
gint major;
gint minor;
+ monitor->monitor = g_object_new (META_TYPE_IDLE_MONITOR_XSYNC, NULL);
+
monitor->dbus_name_id = g_bus_own_name (G_BUS_TYPE_SESSION,
"org.gnome.Mutter.IdleMonitor",
G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
diff --git a/daemons/idle-monitor/meta-idle-monitor-xsync.c b/daemons/idle-monitor/meta-idle-monitor-xsync.c
index 14ef2d9..2f5bd85 100644
--- a/daemons/idle-monitor/meta-idle-monitor-xsync.c
+++ b/daemons/idle-monitor/meta-idle-monitor-xsync.c
@@ -103,37 +103,24 @@ set_alarm_enabled (Display *dpy,
XSyncChangeAlarm (dpy, alarm, XSyncCAEvents, &attr);
}
-static char *
-counter_name_for_device (int device_id)
-{
- if (device_id > 0)
- return g_strdup_printf ("DEVICEIDLETIME %d", device_id);
-
- return g_strdup ("IDLETIME");
-}
-
static XSyncCounter
find_idletime_counter (MetaIdleMonitorXSync *monitor_xsync)
{
- MetaIdleMonitor *monitor = META_IDLE_MONITOR (monitor_xsync);
int i;
int ncounters;
XSyncSystemCounter *counters;
XSyncCounter counter = None;
- char *counter_name;
- counter_name = counter_name_for_device (monitor->device_id);
counters = XSyncListSystemCounters (monitor_xsync->display, &ncounters);
for (i = 0; i < ncounters; i++)
{
- if (counters[i].name != NULL && strcmp (counters[i].name, counter_name) == 0)
+ if (counters[i].name != NULL && strcmp (counters[i].name, "IDLETIME") == 0)
{
counter = counters[i].counter;
break;
}
}
XSyncFreeSystemCounterList (counters);
- g_free (counter_name);
return counter;
}
diff --git a/daemons/idle-monitor/meta-idle-monitor.c b/daemons/idle-monitor/meta-idle-monitor.c
index 203940f..5479e91 100644
--- a/daemons/idle-monitor/meta-idle-monitor.c
+++ b/daemons/idle-monitor/meta-idle-monitor.c
@@ -30,19 +30,9 @@
#include "meta-idle-monitor.h"
#include "meta-idle-monitor-xsync.h"
-#include "meta-backend.h"
G_STATIC_ASSERT(sizeof(unsigned long) == sizeof(gpointer));
-enum
-{
- PROP_0,
- PROP_DEVICE_ID,
- PROP_LAST,
-};
-
-static GParamSpec *obj_props[PROP_LAST];
-
G_DEFINE_TYPE (MetaIdleMonitor, meta_idle_monitor, G_TYPE_OBJECT)
void
@@ -83,64 +73,12 @@ meta_idle_monitor_dispose (GObject *object)
G_OBJECT_CLASS (meta_idle_monitor_parent_class)->dispose (object);
}
-static void
-meta_idle_monitor_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- MetaIdleMonitor *monitor = META_IDLE_MONITOR (object);
-
- switch (prop_id)
- {
- case PROP_DEVICE_ID:
- g_value_set_int (value, monitor->device_id);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-meta_idle_monitor_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- MetaIdleMonitor *monitor = META_IDLE_MONITOR (object);
- switch (prop_id)
- {
- case PROP_DEVICE_ID:
- monitor->device_id = g_value_get_int (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
static void
meta_idle_monitor_class_init (MetaIdleMonitorClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->dispose = meta_idle_monitor_dispose;
- object_class->get_property = meta_idle_monitor_get_property;
- object_class->set_property = meta_idle_monitor_set_property;
-
- /**
- * MetaIdleMonitor:device_id:
- *
- * The device to listen to idletime on.
- */
- obj_props[PROP_DEVICE_ID] =
- g_param_spec_int ("device-id",
- "Device ID",
- "The device to listen to idletime on",
- 0, 255, 0,
- G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
- g_object_class_install_property (object_class, PROP_DEVICE_ID, obj_props[PROP_DEVICE_ID]);
}
static void
@@ -148,35 +86,6 @@ meta_idle_monitor_init (MetaIdleMonitor *monitor)
{
}
-/**
- * meta_idle_monitor_get_core:
- *
- * Returns: (transfer none): the #MetaIdleMonitor that tracks the server-global
- * idletime for all devices. To track device-specific idletime,
- * use meta_idle_monitor_get_for_device().
- */
-MetaIdleMonitor *
-meta_idle_monitor_get_core (void)
-{
- MetaBackend *backend = meta_get_backend ();
- return meta_backend_get_idle_monitor (backend, 0);
-}
-
-/**
- * meta_idle_monitor_get_for_device:
- * @device_id: the device to get the idle time for.
- *
- * Returns: (transfer none): a new #MetaIdleMonitor that tracks the
- * device-specific idletime for @device. To track server-global idletime
- * for all devices, use meta_idle_monitor_get_core().
- */
-MetaIdleMonitor *
-meta_idle_monitor_get_for_device (gint device_id)
-{
- MetaBackend *backend = meta_get_backend ();
- return meta_backend_get_idle_monitor (backend, device_id);
-}
-
static MetaIdleMonitorWatch *
make_watch (MetaIdleMonitor *monitor,
guint64 timeout_msec,
diff --git a/daemons/idle-monitor/meta-idle-monitor.h b/daemons/idle-monitor/meta-idle-monitor.h
index 327851a..7c9dbbe 100644
--- a/daemons/idle-monitor/meta-idle-monitor.h
+++ b/daemons/idle-monitor/meta-idle-monitor.h
@@ -52,7 +52,6 @@ struct _MetaIdleMonitor
GObject parent_instance;
GHashTable *watches;
- int device_id;
};
struct _MetaIdleMonitorClass
@@ -69,9 +68,6 @@ struct _MetaIdleMonitorClass
GType meta_idle_monitor_get_type (void);
-MetaIdleMonitor *meta_idle_monitor_get_core (void);
-MetaIdleMonitor *meta_idle_monitor_get_for_device (int device_id);
-
guint meta_idle_monitor_add_idle_watch (MetaIdleMonitor *monitor,
guint64 interval_msec,
MetaIdleMonitorWatchFunc callback,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]