[notification-daemon] Don't add an event filter unless it is needed
- From: William Jon McCann <mccann src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [notification-daemon] Don't add an event filter unless it is needed
- Date: Sat, 9 Jan 2010 02:40:20 +0000 (UTC)
commit eec8a1db3ef83dc99d912085cfdd3c8626200d24
Author: William Jon McCann <jmccann redhat com>
Date: Fri Jan 8 20:24:18 2010 -0500
Don't add an event filter unless it is needed
When stack only themes are used there is no need to monitor the
event queue. So only add the filter when it is needed.
src/daemon/daemon.c | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c
index ff774f0..1fe6248 100644
--- a/src/daemon/daemon.c
+++ b/src/daemon/daemon.c
@@ -211,7 +211,6 @@ notify_daemon_init(NotifyDaemon *daemon)
daemon->priv->idle_reposition_notify_ids = g_hash_table_new(NULL, NULL);
daemon->priv->monitored_window_hash = g_hash_table_new(NULL, NULL);
- gdk_window_add_filter(NULL, _notify_x11_filter, daemon);
daemon->priv->notification_hash =
g_hash_table_new_full(g_int_hash, g_int_equal, g_free,
(GDestroyNotify)_notify_timeout_destroy);
@@ -223,6 +222,9 @@ notify_daemon_finalize(GObject *object)
NotifyDaemon *daemon = NOTIFY_DAEMON(object);
GObjectClass *parent_class = G_OBJECT_CLASS(notify_daemon_parent_class);
+ if (g_hash_table_size(daemon->priv->monitored_window_hash) > 0)
+ gdk_window_remove_filter(NULL, _notify_x11_filter, daemon);
+
g_hash_table_destroy(daemon->priv->monitored_window_hash);
g_hash_table_destroy(daemon->priv->idle_reposition_notify_ids);
g_hash_table_destroy(daemon->priv->notification_hash);
@@ -410,6 +412,8 @@ _notify_x11_filter(GdkXEvent *xevent,
{
g_hash_table_remove(daemon->priv->monitored_window_hash,
GUINT_TO_POINTER(xev->xany.window));
+ if (g_hash_table_size(daemon->priv->monitored_window_hash) == 0)
+ gdk_window_remove_filter(NULL, _notify_x11_filter, daemon);
return GDK_FILTER_CONTINUE;
}
@@ -1000,6 +1004,11 @@ monitor_notification_source_windows(NotifyDaemon *daemon,
Window root = None;
Window parent;
+ /* Start monitoring events if necessary. We don't want to
+ filter events unless we absolutely have to. */
+ if (g_hash_table_size(daemon->priv->monitored_window_hash) == 0)
+ gdk_window_add_filter(NULL, _notify_x11_filter, daemon);
+
/* Store the window in the timeout */
g_assert(nt != NULL);
nt->src_window_xid = source;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]