[gimp] app: add utility functions proximity_in() and proximity_out()



commit 75add92218195581127908f5b9ccf8b7d9b14de8
Author: Michael Natterer <mitch gimp org>
Date:   Sun Feb 27 12:08:09 2011 +0100

    app: add utility functions proximity_in() and proximity_out()
    
    and use them instead of manually setting proximity. Also add comments
    about why we call the proximity functions where we call them (instead
    of calling them where it seems more logical).

 app/display/gimpdisplayshell-tool-events.c |   39 ++++++++++++++++++++++-----
 1 files changed, 31 insertions(+), 8 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-tool-events.c b/app/display/gimpdisplayshell-tool-events.c
index 46e52bb..18ee2a8 100644
--- a/app/display/gimpdisplayshell-tool-events.c
+++ b/app/display/gimpdisplayshell-tool-events.c
@@ -66,6 +66,9 @@
 static GdkModifierType
                   gimp_display_shell_key_to_state             (gint              key);
 
+static void       gimp_display_shell_proximity_in             (GimpDisplayShell *shell);
+static void       gimp_display_shell_proximity_out            (GimpDisplayShell *shell);
+
 static void       gimp_display_shell_check_device_cursor      (GimpDisplayShell *shell);
 
 static void       gimp_display_shell_start_scrolling          (GimpDisplayShell *shell,
@@ -348,6 +351,8 @@ gimp_display_shell_canvas_tool_events (GtkWidget        *canvas,
 
         update_sw_cursor = TRUE;
 
+        /*  proximity_in() is called in MOTION_NOTIFY  */
+
         tool_manager_oper_update_active (gimp,
                                          &image_coords, state,
                                          shell->proximity,
@@ -362,8 +367,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget        *canvas,
         if (cevent->mode != GDK_CROSSING_NORMAL)
           return TRUE;
 
-        shell->proximity = FALSE;
-        gimp_display_shell_clear_software_cursor (shell);
+        gimp_display_shell_proximity_out (shell);
 
         tool_manager_oper_update_active (gimp,
                                          &image_coords, state,
@@ -373,6 +377,8 @@ gimp_display_shell_canvas_tool_events (GtkWidget        *canvas,
       break;
 
     case GDK_PROXIMITY_IN:
+      /*  proximity_in() is called in MOTION_NOTIFY  */
+
       tool_manager_oper_update_active (gimp,
                                        &image_coords, state,
                                        shell->proximity,
@@ -380,8 +386,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget        *canvas,
       break;
 
     case GDK_PROXIMITY_OUT:
-      shell->proximity = FALSE;
-      gimp_display_shell_clear_software_cursor (shell);
+      gimp_display_shell_proximity_out (shell);
 
       tool_manager_oper_update_active (gimp,
                                        &image_coords, state,
@@ -854,11 +859,13 @@ gimp_display_shell_canvas_tool_events (GtkWidget        *canvas,
 
         update_sw_cursor = TRUE;
 
+        /*  call proximity_in() here because the pointer might already
+         *  be in proximity when the canvas starts to receive events,
+         *  like when a new image has been created into an empty
+         *  display
+         */
         if (! shell->proximity)
-          {
-            shell->proximity = TRUE;
-            gimp_display_shell_check_device_cursor (shell);
-          }
+          gimp_display_shell_proximity_in (shell);
 
         if (shell->scrolling)
           {
@@ -1365,6 +1372,22 @@ gimp_display_shell_key_to_state (gint key)
 }
 
 static void
+gimp_display_shell_proximity_in (GimpDisplayShell *shell)
+{
+  shell->proximity = TRUE;
+
+  gimp_display_shell_check_device_cursor (shell);
+}
+
+static void
+gimp_display_shell_proximity_out (GimpDisplayShell *shell)
+{
+  shell->proximity = FALSE;
+
+  gimp_display_shell_clear_software_cursor (shell);
+}
+
+static void
 gimp_display_shell_check_device_cursor (GimpDisplayShell *shell)
 {
   GimpDeviceInfo *current_device;



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