[gimp] app: fix selecting fonts with arrow keys in Fonts dockable.



commit 55b3e3a336b3dc8c792d8a5f8d6f20b211589773
Author: Jehan <jehan girinstud io>
Date:   Tue Feb 1 23:15:54 2022 +0100

    app: fix selecting fonts with arrow keys in Fonts dockable.
    
    My commit ca28934dfc02 was very wrong. We absolutely need to set context
    in list view editors too. In particular, we could not loop through fonts
    in the Fonts dockable very quickly with up/down arrow keys anymore
    (since the GimpFontFactoryView is a GimpContainerEditor).
    
    When doing this though, we could have some weird crash in the
    GimpContainerPopup watching for context change through button
    press/release. Indeed when doing this, simply opening the popup (for
    instance clicking on the Fonts icon in text tool options) would trigger
    a context change as a button click consequence.
    The solution is obviously to check which widget the button event belongs
    to and ignore it if it happened on any other widget than the popup.

 app/widgets/gimpcontainereditor.c |  3 +--
 app/widgets/gimpcontainerpopup.c  | 20 ++++++++++++++------
 2 files changed, 15 insertions(+), 8 deletions(-)
---
diff --git a/app/widgets/gimpcontainereditor.c b/app/widgets/gimpcontainereditor.c
index 1a7b5bb580..c2c2f4c26c 100644
--- a/app/widgets/gimpcontainereditor.c
+++ b/app/widgets/gimpcontainereditor.c
@@ -448,8 +448,7 @@ gimp_container_editor_select_items (GimpContainerView   *view,
   if (klass->select_item)
     klass->select_item (editor, viewable);
 
-  if (editor->priv->container &&
-      editor->priv->view_type == GIMP_VIEW_TYPE_GRID)
+  if (editor->priv->container)
     {
       const gchar *signal_name;
       GType        children_type;
diff --git a/app/widgets/gimpcontainerpopup.c b/app/widgets/gimpcontainerpopup.c
index 76a0ba0355..82ff7c2f9b 100644
--- a/app/widgets/gimpcontainerpopup.c
+++ b/app/widgets/gimpcontainerpopup.c
@@ -126,15 +126,23 @@ gimp_container_popup_context_changed (GimpContext        *context,
                                       GimpViewable       *viewable,
                                       GimpContainerPopup *popup)
 {
-  GdkEvent *current_event;
-  gboolean  confirm = FALSE;
+  GdkEvent  *current_event;
+  GtkWidget *current_widget = GTK_WIDGET (popup);
+  gboolean   confirm        = FALSE;
 
   current_event = gtk_get_current_event ();
 
-  if (current_event)
+  if (current_event && gtk_widget_get_window (current_widget))
     {
-      if (((GdkEventAny *) current_event)->type == GDK_BUTTON_PRESS ||
-          ((GdkEventAny *) current_event)->type == GDK_BUTTON_RELEASE)
+      GdkWindow *event_window = gdk_window_get_effective_toplevel (((GdkEventAny *) current_event)->window);
+      GdkWindow *popup_window = gdk_window_get_effective_toplevel (gtk_widget_get_window (current_widget));
+
+      /* We need to differentiate a context change as a consequence of
+       * an event on another widget.
+       */
+      if ((((GdkEventAny *) current_event)->type == GDK_BUTTON_PRESS ||
+           ((GdkEventAny *) current_event)->type == GDK_BUTTON_RELEASE) &&
+          event_window == popup_window)
         confirm = TRUE;
 
       gdk_event_free (current_event);
@@ -367,7 +375,7 @@ gimp_container_popup_create_view (GimpContainerPopup *popup)
       GimpObject *object;
       GList      *items = NULL;
 
-      object = gimp_context_get_by_type (popup->context, children_type);
+      object = gimp_context_get_by_type (popup->orig_context, children_type);
       if (object)
         items = g_list_prepend (NULL, object);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]