[libdazzle] panel: allow pausing the transient grab monitoring
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libdazzle] panel: allow pausing the transient grab monitoring
- Date: Mon, 24 Jul 2017 22:51:14 +0000 (UTC)
commit 78274c841bbfa546c37a358e58a522b089948def
Author: Christian Hergert <chergert redhat com>
Date: Mon Jul 24 15:50:47 2017 -0700
panel: allow pausing the transient grab monitoring
src/panel/dzl-dock-manager.c | 57 ++++++++++++++++++++++++++++++++++++++++-
src/panel/dzl-dock-manager.h | 2 +
2 files changed, 57 insertions(+), 2 deletions(-)
---
diff --git a/src/panel/dzl-dock-manager.c b/src/panel/dzl-dock-manager.c
index ece818e..7c8d041 100644
--- a/src/panel/dzl-dock-manager.c
+++ b/src/panel/dzl-dock-manager.c
@@ -28,6 +28,7 @@ typedef struct
DzlDockTransientGrab *grab;
GHashTable *queued_focus_by_toplevel;
guint queued_handler;
+ gint pause_count;
} DzlDockManagerPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (DzlDockManager, dzl_dock_manager, G_TYPE_OBJECT)
@@ -46,13 +47,16 @@ dzl_dock_manager_do_set_focus (DzlDockManager *self,
GtkWidget *toplevel)
{
DzlDockManagerPrivate *priv = dzl_dock_manager_get_instance_private (self);
- DzlDockTransientGrab *grab = NULL;
+ g_autoptr(DzlDockTransientGrab) grab = NULL;
GtkWidget *parent;
g_assert (DZL_IS_DOCK_MANAGER (self));
g_assert (GTK_IS_WIDGET (focus));
g_assert (GTK_IS_WIDGET (toplevel));
+ if (priv->pause_count > 0)
+ return;
+
if (priv->grab != NULL)
{
/*
@@ -105,7 +109,7 @@ dzl_dock_manager_do_set_focus (DzlDockManager *self,
/* Start the grab process */
if (grab != NULL)
{
- priv->grab = grab;
+ priv->grab = g_steal_pointer (&grab);
dzl_dock_transient_grab_acquire (priv->grab);
}
}
@@ -343,3 +347,52 @@ dzl_dock_manager_unregister_dock (DzlDockManager *self,
g_signal_emit (self, signals [UNREGISTER_DOCK], 0, dock);
}
+
+/**
+ * dzl_dock_manager_pause_grabs:
+ * @self: a #DzlDockManager
+ *
+ * Requests that the transient grab monitoring stop until
+ * dzl_dock_manager_unpause_grabs() is called.
+ *
+ * This might be useful while setting up UI so that you don't focus
+ * something unexpectedly.
+ *
+ * This function may be called multiple times and after an equivalent
+ * number of calls to dzl_dock_manager_unpause_grabs(), transient
+ * grab monitoring will continue.
+ *
+ * Since: 3.26
+ */
+void
+dzl_dock_manager_pause_grabs (DzlDockManager *self)
+{
+ DzlDockManagerPrivate *priv = dzl_dock_manager_get_instance_private (self);
+
+ g_return_if_fail (DZL_IS_DOCK_MANAGER (self));
+ g_return_if_fail (priv->pause_count >= 0);
+
+ priv->pause_count++;
+}
+
+/**
+ * dzl_dock_manager_unpause_grabs:
+ * @self: a #DzlDockManager
+ *
+ * Unpauses a previous call to dzl_dock_manager_pause_grabs().
+ *
+ * Once the pause count returns to zero, transient grab monitoring
+ * will be restored.
+ *
+ * Since: 3.26
+ */
+void
+dzl_dock_manager_unpause_grabs (DzlDockManager *self)
+{
+ DzlDockManagerPrivate *priv = dzl_dock_manager_get_instance_private (self);
+
+ g_return_if_fail (DZL_IS_DOCK_MANAGER (self));
+ g_return_if_fail (priv->pause_count > 0);
+
+ priv->pause_count--;
+}
diff --git a/src/panel/dzl-dock-manager.h b/src/panel/dzl-dock-manager.h
index b63cb15..8952c19 100644
--- a/src/panel/dzl-dock-manager.h
+++ b/src/panel/dzl-dock-manager.h
@@ -51,6 +51,8 @@ void dzl_dock_manager_register_dock (DzlDockManager *self,
DzlDock *dock);
void dzl_dock_manager_unregister_dock (DzlDockManager *self,
DzlDock *dock);
+void dzl_dock_manager_pause_grabs (DzlDockManager *self);
+void dzl_dock_manager_unpause_grabs (DzlDockManager *self);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]