[mutter/wayland] idle-monitor: Move the alarms field to the XSync backend
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wayland] idle-monitor: Move the alarms field to the XSync backend
- Date: Mon, 31 Mar 2014 03:11:50 +0000 (UTC)
commit 3961f291e44026fc75abfdd6cc01e0e9d0f8c571
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Sun Mar 30 22:33:49 2014 -0400
idle-monitor: Move the alarms field to the XSync backend
For whatever reason, this hash table was in the generic
implementation section instead of the XSync implementation,
even though it's only used by the XSync implementation.
Use it as a first pass of things to move over.
src/core/meta-idle-monitor-private.h | 1 -
src/core/meta-idle-monitor-xsync.c | 17 +++++++++++++----
src/core/meta-idle-monitor.c | 2 --
3 files changed, 13 insertions(+), 7 deletions(-)
---
diff --git a/src/core/meta-idle-monitor-private.h b/src/core/meta-idle-monitor-private.h
index f3fc4c7..f2cc716 100644
--- a/src/core/meta-idle-monitor-private.h
+++ b/src/core/meta-idle-monitor-private.h
@@ -45,7 +45,6 @@ struct _MetaIdleMonitor
GObject parent_instance;
GHashTable *watches;
- GHashTable *alarms;
int device_id;
/* X11 implementation */
diff --git a/src/core/meta-idle-monitor-xsync.c b/src/core/meta-idle-monitor-xsync.c
index 8d3fcc7..df04a12 100644
--- a/src/core/meta-idle-monitor-xsync.c
+++ b/src/core/meta-idle-monitor-xsync.c
@@ -33,6 +33,8 @@
struct _MetaIdleMonitorXSync
{
MetaIdleMonitor parent;
+
+ GHashTable *alarms;
};
struct _MetaIdleMonitorXSyncClass
@@ -168,7 +170,8 @@ init_xsync (MetaIdleMonitor *monitor)
static void
meta_idle_monitor_xsync_dispose (GObject *object)
{
- MetaIdleMonitor *monitor = META_IDLE_MONITOR (object);
+ MetaIdleMonitorXSync *monitor_xsync = META_IDLE_MONITOR_XSYNC (object);
+ MetaIdleMonitor *monitor = META_IDLE_MONITOR (monitor_xsync);
if (monitor->user_active_alarm != None)
{
@@ -176,6 +179,8 @@ meta_idle_monitor_xsync_dispose (GObject *object)
monitor->user_active_alarm = None;
}
+ g_clear_pointer (&monitor_xsync->alarms, g_hash_table_destroy);
+
G_OBJECT_CLASS (meta_idle_monitor_xsync_parent_class)->dispose (object);
}
@@ -228,6 +233,7 @@ free_watch (gpointer data)
MetaIdleMonitorWatchXSync *watch_xsync = data;
MetaIdleMonitorWatch *watch = (MetaIdleMonitorWatch *) watch_xsync;
MetaIdleMonitor *monitor = watch->monitor;
+ MetaIdleMonitorXSync *monitor_xsync = META_IDLE_MONITOR_XSYNC (monitor);
g_object_ref (monitor);
@@ -244,7 +250,7 @@ free_watch (gpointer data)
watch_xsync->xalarm != None)
{
XSyncDestroyAlarm (monitor->display, watch_xsync->xalarm);
- g_hash_table_remove (monitor->alarms, (gpointer) watch_xsync->xalarm);
+ g_hash_table_remove (monitor_xsync->alarms, (gpointer) watch_xsync->xalarm);
}
g_object_unref (monitor);
@@ -258,6 +264,7 @@ meta_idle_monitor_xsync_make_watch (MetaIdleMonitor *monitor,
gpointer user_data,
GDestroyNotify notify)
{
+ MetaIdleMonitorXSync *monitor_xsync = META_IDLE_MONITOR_XSYNC (monitor);
MetaIdleMonitorWatchXSync *watch_xsync;
MetaIdleMonitorWatch *watch;
@@ -277,7 +284,7 @@ meta_idle_monitor_xsync_make_watch (MetaIdleMonitor *monitor,
{
watch_xsync->xalarm = _xsync_alarm_set (monitor, XSyncPositiveTransition, timeout_msec, TRUE);
- g_hash_table_add (monitor->alarms, (gpointer) watch_xsync->xalarm);
+ g_hash_table_add (monitor_xsync->alarms, (gpointer) watch_xsync->xalarm);
if (meta_idle_monitor_get_idletime (monitor) > (gint64)timeout_msec)
watch->idle_source_id = g_idle_add (fire_watch_idle, watch);
@@ -312,12 +319,14 @@ meta_idle_monitor_xsync_init (MetaIdleMonitorXSync *monitor_xsync)
MetaIdleMonitor *monitor = META_IDLE_MONITOR (monitor_xsync);
monitor->watches = g_hash_table_new_full (NULL, NULL, NULL, free_watch);
+ monitor_xsync->alarms = g_hash_table_new (NULL, NULL);
}
void
meta_idle_monitor_xsync_handle_xevent (MetaIdleMonitor *monitor,
XSyncAlarmNotifyEvent *alarm_event)
{
+ MetaIdleMonitorXSync *monitor_xsync = META_IDLE_MONITOR_XSYNC (monitor);
XSyncAlarm alarm;
GList *watches;
gboolean has_alarm;
@@ -336,7 +345,7 @@ meta_idle_monitor_xsync_handle_xevent (MetaIdleMonitor *monitor,
FALSE);
has_alarm = TRUE;
}
- else if (g_hash_table_contains (monitor->alarms, (gpointer) alarm))
+ else if (g_hash_table_contains (monitor_xsync->alarms, (gpointer) alarm))
{
ensure_alarm_rescheduled (monitor->display,
alarm);
diff --git a/src/core/meta-idle-monitor.c b/src/core/meta-idle-monitor.c
index 4230679..faa89b3 100644
--- a/src/core/meta-idle-monitor.c
+++ b/src/core/meta-idle-monitor.c
@@ -91,7 +91,6 @@ meta_idle_monitor_dispose (GObject *object)
MetaIdleMonitor *monitor = META_IDLE_MONITOR (object);
g_clear_pointer (&monitor->watches, g_hash_table_destroy);
- g_clear_pointer (&monitor->alarms, g_hash_table_destroy);
G_OBJECT_CLASS (meta_idle_monitor_parent_class)->dispose (object);
}
@@ -159,7 +158,6 @@ meta_idle_monitor_class_init (MetaIdleMonitorClass *klass)
static void
meta_idle_monitor_init (MetaIdleMonitor *monitor)
{
- monitor->alarms = g_hash_table_new (NULL, NULL);
}
static GType
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]