[libdazzle] dock: drop transient grab when focusing with dzl_dock_item_present()
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libdazzle] dock: drop transient grab when focusing with dzl_dock_item_present()
- Date: Tue, 26 Jun 2018 06:00:41 +0000 (UTC)
commit 8df18c59e49ce2183479ddcdc612a7ce05b97f81
Author: Christian Hergert <chergert redhat com>
Date: Mon Jun 25 22:59:23 2018 -0700
dock: drop transient grab when focusing with dzl_dock_item_present()
This helps us when we don't want to keep the transient grab around.
Otherwise, we can just use gtk_widget_grab_focus().
src/panel/dzl-dock-item.c | 10 ++++++++++
src/panel/dzl-dock-manager.c | 22 +++++++++++++++++-----
src/panel/dzl-dock-manager.h | 2 ++
src/panel/dzl-dock-transient-grab.c | 11 +++++++++++
src/panel/dzl-dock-transient-grab.h | 2 ++
5 files changed, 42 insertions(+), 5 deletions(-)
---
diff --git a/src/panel/dzl-dock-item.c b/src/panel/dzl-dock-item.c
index 4ee16be..f05899d 100644
--- a/src/panel/dzl-dock-item.c
+++ b/src/panel/dzl-dock-item.c
@@ -372,8 +372,18 @@ dzl_dock_item_present (DzlDockItem *self)
{
if (DZL_IS_DOCK_ITEM (parent))
{
+ DzlDockManager *manager;
+
dzl_dock_item_present_child (DZL_DOCK_ITEM (parent), self);
dzl_dock_item_present (DZL_DOCK_ITEM (parent));
+
+ /* gtk_widget_grab_focus() results in a transient grab,
+ * we want a real grab (that doesn't release the parent)
+ * when we are focused during this code path.
+ */
+ if ((manager = dzl_dock_item_get_manager (self)))
+ dzl_dock_manager_release_transient_grab (manager);
+
return;
}
}
diff --git a/src/panel/dzl-dock-manager.c b/src/panel/dzl-dock-manager.c
index 9761b5c..d0c9e61 100644
--- a/src/panel/dzl-dock-manager.c
+++ b/src/panel/dzl-dock-manager.c
@@ -270,11 +270,7 @@ dzl_dock_manager_finalize (GObject *object)
dzl_clear_pointer (&priv->queued_focus_by_toplevel, g_hash_table_unref);
- if (priv->queued_handler)
- {
- g_source_remove (priv->queued_handler);
- priv->queued_handler = 0;
- }
+ dzl_clear_source (&priv->queued_handler);
while (priv->docks->len > 0)
{
@@ -398,3 +394,19 @@ dzl_dock_manager_unpause_grabs (DzlDockManager *self)
priv->pause_count--;
}
+
+void
+dzl_dock_manager_release_transient_grab (DzlDockManager *self)
+{
+ DzlDockManagerPrivate *priv = dzl_dock_manager_get_instance_private (self);
+
+ g_return_if_fail (DZL_IS_DOCK_MANAGER (self));
+
+ if (priv->grab != NULL)
+ {
+ g_autoptr(DzlDockTransientGrab) grab = g_steal_pointer (&priv->grab);
+ dzl_dock_transient_grab_cancel (grab);
+ }
+
+ dzl_clear_source (&priv->queued_handler);
+}
diff --git a/src/panel/dzl-dock-manager.h b/src/panel/dzl-dock-manager.h
index 6204bc4..abad793 100644
--- a/src/panel/dzl-dock-manager.h
+++ b/src/panel/dzl-dock-manager.h
@@ -60,6 +60,8 @@ DZL_AVAILABLE_IN_ALL
void dzl_dock_manager_pause_grabs (DzlDockManager *self);
DZL_AVAILABLE_IN_ALL
void dzl_dock_manager_unpause_grabs (DzlDockManager *self);
+DZL_AVAILABLE_IN_3_30
+void dzl_dock_manager_release_transient_grab (DzlDockManager *self);
G_END_DECLS
diff --git a/src/panel/dzl-dock-transient-grab.c b/src/panel/dzl-dock-transient-grab.c
index ee29356..9d37181 100644
--- a/src/panel/dzl-dock-transient-grab.c
+++ b/src/panel/dzl-dock-transient-grab.c
@@ -325,3 +325,14 @@ dzl_dock_transient_grab_steal_common_ancestors (DzlDockTransientGrab *self,
}
}
}
+
+void
+dzl_dock_transient_grab_cancel (DzlDockTransientGrab *self)
+{
+ g_return_if_fail (DZL_IS_DOCK_TRANSIENT_GRAB (self));
+
+ dzl_clear_source (&self->timeout);
+ while (self->items->len)
+ dzl_dock_transient_grab_remove_index (self, self->items->len - 1);
+ g_hash_table_remove_all (self->hidden);
+}
diff --git a/src/panel/dzl-dock-transient-grab.h b/src/panel/dzl-dock-transient-grab.h
index fdf1b4f..8b5b6ac 100644
--- a/src/panel/dzl-dock-transient-grab.h
+++ b/src/panel/dzl-dock-transient-grab.h
@@ -60,6 +60,8 @@ gboolean dzl_dock_transient_grab_is_descendant (DzlDockTra
DZL_AVAILABLE_IN_ALL
void dzl_dock_transient_grab_steal_common_ancestors (DzlDockTransientGrab *self,
DzlDockTransientGrab *other);
+DZL_AVAILABLE_IN_3_30
+void dzl_dock_transient_grab_cancel (DzlDockTransientGrab *self);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]