[gimp/gimp-2-10] app: pass a GdkWindow not GdkDisplay to gimp_cursor_new()



commit 1706950400fc003750c99ac0e34803232965a288
Author: Michael Natterer <mitch gimp org>
Date:   Mon Dec 31 14:04:04 2018 +0100

    app: pass a GdkWindow not GdkDisplay to gimp_cursor_new()
    
    Preparation for adding HiDPI cursors.
    
    (cherry picked from commit 47ff7e1467fb69fbf39fc3b3ef3752ac869599fd)

 app/widgets/gimpcursor.c        | 16 +++++++++++-----
 app/widgets/gimpcursor.h        |  2 +-
 app/widgets/gimpdialogfactory.c | 37 +++++++++++++++----------------------
 3 files changed, 27 insertions(+), 28 deletions(-)
---
diff --git a/app/widgets/gimpcursor.c b/app/widgets/gimpcursor.c
index fa5c63997a..ce00bc0eb4 100644
--- a/app/widgets/gimpcursor.c
+++ b/app/widgets/gimpcursor.c
@@ -245,21 +245,24 @@ get_cursor_pixbuf (GimpCursor *cursor)
 }
 
 GdkCursor *
-gimp_cursor_new (GdkDisplay         *display,
+gimp_cursor_new (GdkWindow          *window,
                  GimpHandedness      cursor_handedness,
                  GimpCursorType      cursor_type,
                  GimpToolCursorType  tool_cursor,
                  GimpCursorModifier  modifier)
 {
+  GdkDisplay *display;
   GimpCursor *bmcursor   = NULL;
   GimpCursor *bmmodifier = NULL;
   GimpCursor *bmtool     = NULL;
   GdkCursor  *cursor;
   GdkPixbuf  *pixbuf;
 
-  g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
+  g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
   g_return_val_if_fail (cursor_type < GIMP_CURSOR_LAST, NULL);
 
+  display = gdk_window_get_display (window);
+
   if (cursor_type <= (GimpCursorType) GDK_LAST_CURSOR)
     return gdk_cursor_new_for_display (display, (GdkCursorType) cursor_type);
 
@@ -413,20 +416,23 @@ gimp_cursor_set (GtkWidget          *widget,
                  GimpToolCursorType  tool_cursor,
                  GimpCursorModifier  modifier)
 {
+  GdkWindow *window;
   GdkCursor *cursor;
 
   g_return_if_fail (GTK_IS_WIDGET (widget));
   g_return_if_fail (gtk_widget_get_realized (widget));
 
-  cursor = gimp_cursor_new (gtk_widget_get_display (widget),
+  window = gtk_widget_get_window (widget);
+
+  cursor = gimp_cursor_new (window,
                             cursor_handedness,
                             cursor_type,
                             tool_cursor,
                             modifier);
-  gdk_window_set_cursor (gtk_widget_get_window (widget), cursor);
+  gdk_window_set_cursor (window, cursor);
   gdk_cursor_unref (cursor);
 
-  gdk_display_flush (gtk_widget_get_display (widget));
+  gdk_display_flush (gdk_window_get_display (window));
 }
 
 GimpCursorType
diff --git a/app/widgets/gimpcursor.h b/app/widgets/gimpcursor.h
index b0dc6398f5..f6b9ad05c0 100644
--- a/app/widgets/gimpcursor.h
+++ b/app/widgets/gimpcursor.h
@@ -19,7 +19,7 @@
 #define __GIMP_CURSOR_H__
 
 
-GdkCursor      * gimp_cursor_new    (GdkDisplay         *display,
+GdkCursor      * gimp_cursor_new    (GdkWindow          *window,
                                      GimpHandedness      cursor_handedness,
                                      GimpCursorType      cursor_type,
                                      GimpToolCursorType  tool_cursor,
diff --git a/app/widgets/gimpdialogfactory.c b/app/widgets/gimpdialogfactory.c
index c3ba7b0b95..35811d0ee2 100644
--- a/app/widgets/gimpdialogfactory.c
+++ b/app/widgets/gimpdialogfactory.c
@@ -1544,9 +1544,7 @@ gimp_dialog_factory_show (GimpDialogFactory *factory)
 void
 gimp_dialog_factory_set_busy (GimpDialogFactory *factory)
 {
-  GdkDisplay *display = NULL;
-  GdkCursor  *cursor  = NULL;
-  GList      *list;
+  GList *list;
 
   if (! factory)
     return;
@@ -1557,27 +1555,20 @@ gimp_dialog_factory_set_busy (GimpDialogFactory *factory)
 
       if (GTK_IS_WIDGET (widget) && gtk_widget_is_toplevel (widget))
         {
-          if (!display || display != gtk_widget_get_display (widget))
-            {
-              display = gtk_widget_get_display (widget);
+          GdkWindow *window = gtk_widget_get_window (widget);
 
-              if (cursor)
-                gdk_cursor_unref (cursor);
-
-              cursor = gimp_cursor_new (display,
-                                        GIMP_HANDEDNESS_RIGHT,
-                                        (GimpCursorType) GDK_WATCH,
-                                        GIMP_TOOL_CURSOR_NONE,
-                                        GIMP_CURSOR_MODIFIER_NONE);
+          if (window)
+            {
+              GdkCursor *cursor = gimp_cursor_new (window,
+                                                   GIMP_HANDEDNESS_RIGHT,
+                                                   (GimpCursorType) GDK_WATCH,
+                                                   GIMP_TOOL_CURSOR_NONE,
+                                                   GIMP_CURSOR_MODIFIER_NONE);
+              gdk_window_set_cursor (window, cursor);
+              gdk_cursor_unref (cursor);
             }
-
-          if (gtk_widget_get_window (widget))
-            gdk_window_set_cursor (gtk_widget_get_window (widget), cursor);
         }
     }
-
-  if (cursor)
-    gdk_cursor_unref (cursor);
 }
 
 void
@@ -1594,8 +1585,10 @@ gimp_dialog_factory_unset_busy (GimpDialogFactory *factory)
 
       if (GTK_IS_WIDGET (widget) && gtk_widget_is_toplevel (widget))
         {
-          if (gtk_widget_get_window (widget))
-            gdk_window_set_cursor (gtk_widget_get_window (widget), NULL);
+          GdkWindow *window = gtk_widget_get_window (widget);
+
+          if (window)
+            gdk_window_set_cursor (window, NULL);
         }
     }
 }


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