[libdazzle] util: use dzl_clear_source() to remove GSource by uint id
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libdazzle] util: use dzl_clear_source() to remove GSource by uint id
- Date: Mon, 24 Jul 2017 22:51:04 +0000 (UTC)
commit 5efe27b7216820ea9b388d661e5113a109857e8e
Author: Christian Hergert <chergert redhat com>
Date: Mon Jul 24 15:49:11 2017 -0700
util: use dzl_clear_source() to remove GSource by uint id
src/panel/dzl-dock-manager.c | 6 +++---
src/util/dzl-util-private.h | 9 +++++++++
2 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/src/panel/dzl-dock-manager.c b/src/panel/dzl-dock-manager.c
index 53cc93c..a81afd8 100644
--- a/src/panel/dzl-dock-manager.c
+++ b/src/panel/dzl-dock-manager.c
@@ -20,6 +20,7 @@
#include "panel/dzl-dock-manager.h"
#include "panel/dzl-dock-transient-grab.h"
+#include "util/dzl-util-private.h"
typedef struct
{
@@ -152,9 +153,8 @@ dzl_dock_manager_set_focus (DzlDockManager *self,
* to the hierarchy, as they may implicitly grab focus.
*/
g_hash_table_insert (priv->queued_focus_by_toplevel, toplevel, focus);
- if (priv->queued_handler != 0)
- g_source_remove (priv->queued_handler);
- priv->queued_handler = g_timeout_add (0, do_delayed_focus_update, self);
+ dzl_clear_source (&priv->queued_handler);
+ priv->queued_handler = gdk_threads_add_idle (do_delayed_focus_update, self);
}
static void
diff --git a/src/util/dzl-util-private.h b/src/util/dzl-util-private.h
index 89fc4ae..09f3879 100644
--- a/src/util/dzl-util-private.h
+++ b/src/util/dzl-util-private.h
@@ -42,6 +42,15 @@ dzl_str_equal0 (const gchar *str1,
return g_strcmp0 (str1, str2) == 0;
}
+static inline void
+dzl_clear_source (guint *source_ptr)
+{
+ guint source = *source_ptr;
+ *source_ptr = 0;
+ if (source != 0)
+ g_source_remove (source);
+}
+
void dzl_gtk_widget_class_add_css_resource (GtkWidgetClass *widget_class,
const gchar *resource);
void dzl_gtk_widget_add_class (GtkWidget *widget,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]