[gimp] app: properly release shell scrolling on button release.



commit 203652651d46096f6424267a0217f584a5236d3a
Author: Jehan <jehan girinstud io>
Date:   Sun Aug 21 17:38:04 2022 +0200

    app: properly release shell scrolling on button release.
    
    If we released first the modifiers, then the pointer button during
    scrolling, we could end up blocked on scrolling. This makes sure the
    button release is the finale scroll unlock, allowing modifiers to be
    only used for starting the scroll.
    
    It also fixes activating custom actions, by storing the action
    description from the initial modifiers at press time, not release time.

 app/display/gimpdisplayshell-tool-events.c | 19 ++++++++-----------
 app/display/gimpdisplayshell.h             |  1 +
 2 files changed, 9 insertions(+), 11 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-tool-events.c b/app/display/gimpdisplayshell-tool-events.c
index ed62d2cf55..f0269ac30c 100644
--- a/app/display/gimpdisplayshell-tool-events.c
+++ b/app/display/gimpdisplayshell-tool-events.c
@@ -598,6 +598,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget        *canvas,
                                                     bevent->x, bevent->y);
                 break;
               case GIMP_MODIFIER_ACTION_ACTION:
+                shell->mod_action_desc = g_strdup (action_desc);
                 break;
               case GIMP_MODIFIER_ACTION_NONE:
                 gimp_display_triggers_context_menu (event, shell, gimp, &image_coords, FALSE);
@@ -724,20 +725,13 @@ gimp_display_shell_canvas_tool_events (GtkWidget        *canvas,
           }
         else
           {
-            const gchar        *action_desc = NULL;
-            GimpImageWindow    *window;
-            GimpUIManager      *manager;
-            GdkDevice          *device;
-            GimpModifierAction  action;
+            GimpImageWindow *window;
+            GimpUIManager   *manager;
 
             window  = gimp_display_shell_get_window (shell);
             manager = gimp_image_window_get_ui_manager (window);
-            device  = gdk_event_get_source_device (event);
-            action  = gimp_modifiers_manager_get_action (mod_manager, device,
-                                                         bevent->button, bevent->state,
-                                                         &action_desc);
 
-            switch (action)
+            switch (shell->mod_action)
               {
               case GIMP_MODIFIER_ACTION_MENU:
                 break;
@@ -758,11 +752,14 @@ gimp_display_shell_canvas_tool_events (GtkWidget        *canvas,
                 gimp_display_shell_stop_scrolling (shell, event);
                 break;
               case GIMP_MODIFIER_ACTION_ACTION:
-                gimp_display_shell_activate_action (manager, action_desc, NULL);
+                gimp_display_shell_activate_action (manager, shell->mod_action_desc, NULL);
+                g_clear_pointer (&shell->mod_action_desc, g_free);
                 break;
               case GIMP_MODIFIER_ACTION_NONE:
                 break;
               }
+
+            shell->mod_action = GIMP_MODIFIER_ACTION_NONE;
           }
 
         return_val = TRUE;
diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h
index 93dc8bacc7..ebeac6415b 100644
--- a/app/display/gimpdisplayshell.h
+++ b/app/display/gimpdisplayshell.h
@@ -217,6 +217,7 @@ struct _GimpDisplayShell
 
   /* Modifier action currently ON. */
   GimpModifierAction mod_action;
+  gchar             *mod_action_desc;
 
   gint               scroll_start_x;
   gint               scroll_start_y;


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