[gimp] app: more responsive lock and link popovers.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: more responsive lock and link popovers.
- Date: Thu, 23 Dec 2021 13:03:27 +0000 (UTC)
commit 8508eda45fff04a3d0b6e1a77dfd19c4abaac96b
Author: Jehan <jehan girinstud io>
Date: Wed Feb 10 19:03:28 2021 +0100
app: more responsive lock and link popovers.
First of all, let's use gtk_widget_show|hide() instead of
gtk_popover_popup|down() because these GtkPopover API sometimes "block"
when clicking very fast on the item list, sometimes up to 2 or 3 seconds
(at least it feels like seconds, I haven't actually timed it!). I'm sure
the ones who developed it thought it was nice to have slow popping
dialogs, but when working fast, this can only be frustrating).
The second responsiveness change is that when clicking out of useful
lock popover area, it should not only close, but the event should be
passed onto the item tree view when relevant. This allows for instance
to directly click on an eye cell to change a layer visibility without
having to click twice.
app/widgets/gimpitemtreeview.c | 49 ++++++++++++++++++++++++++++++++++++++++-
app/widgets/gimplayertreeview.c | 2 +-
2 files changed, 49 insertions(+), 2 deletions(-)
---
diff --git a/app/widgets/gimpitemtreeview.c b/app/widgets/gimpitemtreeview.c
index 3f86b77288..ab23893855 100644
--- a/app/widgets/gimpitemtreeview.c
+++ b/app/widgets/gimpitemtreeview.c
@@ -211,6 +211,9 @@ static void gimp_item_tree_view_lock_toggled (GtkWidget *widget,
GimpItemTreeView *view);
static void gimp_item_tree_view_update_lock_box (GimpItemTreeView *view,
GimpItem *item);
+static gboolean gimp_item_tree_view_popover_button_press (GtkWidget *widget,
+ GdkEvent *event,
+ GimpItemTreeView *view);
static gboolean gimp_item_tree_view_item_pre_clicked(GimpCellRendererViewable *cell,
const gchar *path_str,
@@ -555,6 +558,10 @@ gimp_item_tree_view_constructed (GObject *object)
/* Lock popover. */
item_view->priv->lock_popover = gtk_popover_new (GTK_WIDGET (tree_view->view));
gtk_popover_set_modal (GTK_POPOVER (item_view->priv->lock_popover), TRUE);
+ g_signal_connect (item_view->priv->lock_popover,
+ "button-press-event",
+ G_CALLBACK (gimp_item_tree_view_popover_button_press),
+ item_view);
gtk_container_add (GTK_CONTAINER (item_view->priv->lock_popover), item_view->priv->lock_box);
gtk_widget_show (item_view->priv->lock_box);
}
@@ -1736,7 +1743,7 @@ gimp_item_tree_view_lock_clicked (GtkCellRendererToggle *toggle,
gtk_popover_set_pointing_to (GTK_POPOVER (view->priv->lock_popover), &rect);
gtk_tree_path_free (path);
- gtk_popover_popup (GTK_POPOVER (view->priv->lock_popover));
+ gtk_widget_show (view->priv->lock_popover);
}
}
@@ -1948,6 +1955,46 @@ gimp_item_tree_view_update_lock_box (GimpItemTreeView *view,
view->priv->lock_box_item = item;
}
+static gboolean
+gimp_item_tree_view_popover_button_press (GtkWidget *widget,
+ GdkEvent *event,
+ GimpItemTreeView *view)
+{
+ GimpContainerTreeView *tree_view = GIMP_CONTAINER_TREE_VIEW (view);
+ GdkEventButton *bevent = (GdkEventButton *) event;
+ GdkEvent *new_event;
+
+ /* If we get to the popover signal handling, it means we didn't click
+ * inside popover's buttons, which would have stopped the signal
+ * first. So we were going to hide the popover anyway.
+ * Nevertheless I do with with gtk_widget_hide() instead of
+ * gtk_popover_popdown() because the animation stuff is very buggy
+ * (sometimes the popup stays displayed even though it doesn't react,
+ * blocking the GUI for a second or so).
+ * Moreover I directly retransfer the event as though it was sent to
+ * the item tree view. This allows much faster GUI interaction, not
+ * having to click twice, once to close the popup, then a second for
+ * the actual action (like eye switching or lock on another item or
+ * item selection).
+ */
+ gtk_widget_hide (widget);
+
+ if (gtk_tree_view_get_path_at_pos (tree_view->view,
+ bevent->x, bevent->y,
+ NULL, NULL, NULL, NULL))
+ {
+ new_event = gdk_event_copy (event);
+ g_object_unref (new_event->any.window);
+ new_event->any.window = g_object_ref (gtk_widget_get_window (GTK_WIDGET (tree_view->view)));
+ new_event->any.send_event = TRUE;
+
+ gtk_main_do_event (new_event);
+ gdk_event_free (new_event);
+ }
+
+ return GDK_EVENT_STOP;
+}
+
/* GtkTreeView callbacks */
diff --git a/app/widgets/gimplayertreeview.c b/app/widgets/gimplayertreeview.c
index ba7fbbf852..5af94fb09e 100644
--- a/app/widgets/gimplayertreeview.c
+++ b/app/widgets/gimplayertreeview.c
@@ -1314,7 +1314,7 @@ static void
gimp_layer_tree_view_new_link_exit (GimpLayerTreeView *view)
{
if (gimp_layer_tree_view_new_link_clicked (view))
- gtk_popover_popdown (GTK_POPOVER (view->priv->link_popover));
+ gtk_widget_hide (GTK_POPOVER (view->priv->link_popover));
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]