[gtk+] gdk: Cursors no longer have a display



commit 9323d098a6b80b396272ef9a1649218fbdced13b
Author: Benjamin Otte <otte redhat com>
Date:   Fri Nov 3 23:19:22 2017 +0100

    gdk: Cursors no longer have a display
    
    Change constructors to reflect that.
    
    While doing so, also add a fallback argument to the cursor constructors,
    so it is now possible to create cursors with fallback.

 demos/gtk-demo/changedisplay.c        |    2 +-
 demos/gtk-demo/cursors.c              |    4 +-
 demos/gtk-demo/hypertext.c            |    6 +--
 demos/widget-factory/widget-factory.c |    2 +-
 gdk/gdkcursor.c                       |   72 +++++++++-----------------------
 gdk/gdkcursor.h                       |   19 ++++-----
 gdk/gdkdnd.c                          |    4 +-
 gdk/gdkwindow.c                       |    1 -
 gdk/wayland/gdkdevice-wayland.c       |    2 +-
 gtk/gtkaboutdialog.c                  |    6 +--
 gtk/gtkcolorplane.c                   |    2 +-
 gtk/gtkdnd.c                          |   15 +------
 gtk/gtkentry.c                        |    9 +---
 gtk/gtkfilechooserwidget.c            |    2 +-
 gtk/gtklabel.c                        |    9 +---
 gtk/gtklinkbutton.c                   |    8 +--
 gtk/gtkpaned.c                        |    6 +--
 gtk/gtkplacesview.c                   |    6 +--
 gtk/gtkprintunixdialog.c              |    6 +--
 gtk/gtkrecentchooserdefault.c         |    2 +-
 gtk/gtkscrolledwindow.c               |    4 +-
 gtk/gtktextview.c                     |   16 ++-----
 gtk/gtktreeview.c                     |    3 +-
 gtk/gtkwindow.c                       |    3 +-
 gtk/inspector/inspect-button.c        |    2 +-
 tests/testgtk.c                       |    6 +-
 26 files changed, 69 insertions(+), 148 deletions(-)
---
diff --git a/demos/gtk-demo/changedisplay.c b/demos/gtk-demo/changedisplay.c
index d04b3e5..fc79ac8 100644
--- a/demos/gtk-demo/changedisplay.c
+++ b/demos/gtk-demo/changedisplay.c
@@ -123,7 +123,7 @@ query_for_toplevel (GdkDisplay *display,
   gtk_container_add (GTK_CONTAINER (frame), label);
 
   gtk_widget_show (popup);
-  cursor = gdk_cursor_new_from_name (display, "crosshair");
+  cursor = gdk_cursor_new_from_name ("crosshair", NULL);
   device = gtk_get_current_event_device ();
 
   if (gdk_seat_grab (gdk_device_get_seat (device),
diff --git a/demos/gtk-demo/cursors.c b/demos/gtk-demo/cursors.c
index 1a6e180..d684819 100644
--- a/demos/gtk-demo/cursors.c
+++ b/demos/gtk-demo/cursors.c
@@ -43,11 +43,9 @@ add_button (GtkWidget   *section,
             const gchar *css_name)
 {
   GtkWidget *image, *button;
-  GdkDisplay *display;
   GdkCursor *cursor;
 
-  display = gtk_widget_get_display (section);
-  cursor = gdk_cursor_new_from_name (display, css_name);
+  cursor = gdk_cursor_new_from_name (css_name, NULL);
   if (cursor == NULL)
     image = gtk_image_new_from_icon_name ("image-missing", GTK_ICON_SIZE_MENU);
   else
diff --git a/demos/gtk-demo/hypertext.c b/demos/gtk-demo/hypertext.c
index e2ca980..ecb9fd3 100644
--- a/demos/gtk-demo/hypertext.c
+++ b/demos/gtk-demo/hypertext.c
@@ -254,11 +254,9 @@ do_hypertext (GtkWidget *do_widget)
       GtkWidget *view;
       GtkWidget *sw;
       GtkTextBuffer *buffer;
-      GdkDisplay *display;
 
-      display = gtk_widget_get_display (do_widget);
-      hand_cursor = gdk_cursor_new_from_name (display, "pointer");
-      regular_cursor = gdk_cursor_new_from_name (display, "text");
+      hand_cursor = gdk_cursor_new_from_name ("pointer", NULL);
+      regular_cursor = gdk_cursor_new_from_name ("text", NULL);
 
       window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
       gtk_window_set_title (GTK_WINDOW (window), "Hypertext");
diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c
index 6482344..9ad481d 100644
--- a/demos/widget-factory/widget-factory.c
+++ b/demos/widget-factory/widget-factory.c
@@ -80,7 +80,7 @@ get_busy (GSimpleAction *action,
   GtkApplication *app = gtk_window_get_application (GTK_WINDOW (window));
 
   g_application_mark_busy (G_APPLICATION (app));
-  cursor = gdk_cursor_new_from_name (gtk_widget_get_display (window), "wait");
+  cursor = gdk_cursor_new_from_name ("wait", NULL);
   gdk_window_set_cursor (gtk_widget_get_window (window), cursor);
   g_object_unref (cursor);
   g_timeout_add (5000, get_idle, window);
diff --git a/gdk/gdkcursor.c b/gdk/gdkcursor.c
index 3d1c2d4..63faa0e 100644
--- a/gdk/gdkcursor.c
+++ b/gdk/gdkcursor.c
@@ -29,7 +29,6 @@
 
 #include "gdkcursor.h"
 #include "gdkcursorprivate.h"
-#include "gdkdisplayprivate.h"
 #include "gdkintl.h"
 #include "gdkinternals.h"
 
@@ -85,7 +84,6 @@
 
 enum {
   PROP_0,
-  PROP_DISPLAY,
   PROP_FALLBACK,
   PROP_HOTSPOT_X,
   PROP_HOTSPOT_Y,
@@ -105,9 +103,6 @@ gdk_cursor_get_property (GObject    *object,
 
   switch (prop_id)
     {
-    case PROP_DISPLAY:
-      g_value_set_object (value, cursor->display);
-      break;
     case PROP_FALLBACK:
       g_value_set_object (value, cursor->fallback);
       break;
@@ -139,11 +134,6 @@ gdk_cursor_set_property (GObject      *object,
 
   switch (prop_id)
     {
-    case PROP_DISPLAY:
-      cursor->display = g_value_get_object (value);
-      /* check that implementations actually provide the display when constructing */
-      g_assert (cursor->display != NULL);
-      break;
     case PROP_FALLBACK:
       cursor->fallback = g_value_dup_object (value);
       break;
@@ -187,13 +177,6 @@ gdk_cursor_class_init (GdkCursorClass *cursor_class)
   object_class->finalize = gdk_cursor_finalize;
 
   g_object_class_install_property (object_class,
-                                  PROP_DISPLAY,
-                                  g_param_spec_object ("display",
-                                                        P_("Display"),
-                                                        P_("Display of this cursor"),
-                                                        GDK_TYPE_DISPLAY,
-                                                        G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-  g_object_class_install_property (object_class,
                                   PROP_FALLBACK,
                                   g_param_spec_object ("fallback",
                                                         P_("Fallback"),
@@ -283,7 +266,8 @@ gdk_cursor_equal (gconstpointer a,
 
 /**
  * gdk_cursor_new_from_name:
- * @display: the #GdkDisplay for which the cursor will be created
+ * @fallback: (allow-none): %NULL or the #GdkCursor to fall back to when
+ *     this one cannot be supported
  * @name: the name of the cursor
  *
  * Creates a new cursor by looking up @name in the current cursor
@@ -334,24 +318,25 @@ gdk_cursor_equal (gconstpointer a,
  * Since: 2.8
  */
 GdkCursor*
-gdk_cursor_new_from_name (GdkDisplay  *display,
-                          const gchar *name)
+gdk_cursor_new_from_name (const gchar *name,
+                          GdkCursor   *fallback)
 {
-  g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
   g_return_val_if_fail (name != NULL, NULL);
+  g_return_val_if_fail (fallback == NULL || GDK_IS_CURSOR (fallback), NULL);
 
   return g_object_new (GDK_TYPE_CURSOR,
-                       "display", display,
                        "name", name,
+                       "fallback", fallback,
                        NULL);
 }
 
 /**
  * gdk_cursor_new_from_pixbuf:
- * @display: the #GdkDisplay for which the cursor will be created
  * @pixbuf: the #GdkPixbuf containing the cursor image
  * @x: the horizontal offset of the “hotspot” of the cursor.
  * @y: the vertical offset of the “hotspot” of the cursor.
+ * @fallback: (allow-none): %NULL or the #GdkCursor to fall back to when
+ *     this one cannot be supported
  *
  * Creates a new cursor from a pixbuf.
  *
@@ -377,10 +362,10 @@ gdk_cursor_new_from_name (GdkDisplay  *display,
  * Since: 2.4
  */
 GdkCursor *
-gdk_cursor_new_from_pixbuf (GdkDisplay *display,
-                            GdkPixbuf  *pixbuf,
+gdk_cursor_new_from_pixbuf (GdkPixbuf  *pixbuf,
                             gint        x,
-                            gint        y)
+                            gint        y,
+                            GdkCursor  *fallback)
 {
   GdkTexture *texture;
   const char *option;
@@ -388,8 +373,8 @@ gdk_cursor_new_from_pixbuf (GdkDisplay *display,
   gint64 value;
   GdkCursor *cursor;
  
-  g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
   g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
+  g_return_val_if_fail (fallback == NULL || GDK_IS_CURSOR (fallback), NULL);
 
   if (x == -1 && (option = gdk_pixbuf_get_option (pixbuf, "x_hot")))
     {
@@ -415,7 +400,7 @@ gdk_cursor_new_from_pixbuf (GdkDisplay *display,
 
   texture = gdk_texture_new_for_pixbuf (pixbuf);
   
-  cursor = gdk_cursor_new_from_texture (display, texture, x, y);
+  cursor = gdk_cursor_new_from_texture (texture, x, y, fallback);
 
   g_object_unref (texture);
 
@@ -424,10 +409,11 @@ gdk_cursor_new_from_pixbuf (GdkDisplay *display,
 
 /**
  * gdk_cursor_new_from_texture:
- * @display: the #GdkDisplay for which the cursor will be created
  * @texture: the texture providing the pixel data
  * @hotspot_x: the horizontal offset of the “hotspot” of the cursor
  * @hotspot_y: the vertical offset of the “hotspot” of the cursor
+ * @fallback: (allow-none): %NULL or the #GdkCursor to fall back to when
+ *     this one cannot be supported
  *
  * Creates a new cursor from a #GdkTexture.
  *
@@ -448,43 +434,25 @@ gdk_cursor_new_from_pixbuf (GdkDisplay *display,
  * Since: 3.94
  */
 GdkCursor *
-gdk_cursor_new_from_texture (GdkDisplay *display,
-                            GdkTexture *texture,
+gdk_cursor_new_from_texture (GdkTexture *texture,
                             int         hotspot_x,
-                            int         hotspot_y)
+                            int         hotspot_y,
+                             GdkCursor  *fallback)
 {
-  g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
   g_return_val_if_fail (GDK_IS_TEXTURE (texture), NULL);
   g_return_val_if_fail (0 <= hotspot_x && hotspot_x < gdk_texture_get_width (texture), NULL);
   g_return_val_if_fail (0 <= hotspot_y && hotspot_y < gdk_texture_get_height (texture), NULL);
+  g_return_val_if_fail (fallback == NULL || GDK_IS_CURSOR (fallback), NULL);
 
   return g_object_new (GDK_TYPE_CURSOR, 
-                       "display", display,
                        "texture", texture,
                        "hotspot-x", hotspot_x,
                        "hotspot-y", hotspot_y,
+                       "fallback", fallback,
                        NULL);
 }
 
 /**
- * gdk_cursor_get_display:
- * @cursor: a #GdkCursor.
- *
- * Returns the display on which the #GdkCursor is defined.
- *
- * Returns: (transfer none): the #GdkDisplay associated to @cursor
- *
- * Since: 2.2
- */
-GdkDisplay *
-gdk_cursor_get_display (GdkCursor *cursor)
-{
-  g_return_val_if_fail (GDK_IS_CURSOR (cursor), NULL);
-
-  return cursor->display;
-}
-
-/**
  * gdk_cursor_get_fallback:
  * @cursor: a #GdkCursor.
  *
diff --git a/gdk/gdkcursor.h b/gdk/gdkcursor.h
index df88e02..21210a0 100644
--- a/gdk/gdkcursor.h
+++ b/gdk/gdkcursor.h
@@ -46,20 +46,19 @@ GDK_AVAILABLE_IN_ALL
 GType      gdk_cursor_get_type           (void) G_GNUC_CONST;
 
 GDK_AVAILABLE_IN_ALL
-GdkCursor* gdk_cursor_new_from_pixbuf   (GdkDisplay      *display,
-                                         GdkPixbuf       *pixbuf,
+GdkCursor* gdk_cursor_new_from_pixbuf   (GdkPixbuf       *pixbuf,
                                          gint             x,
-                                         gint             y);
+                                         gint             y,
+                                          GdkCursor       *fallback);
 GDK_AVAILABLE_IN_3_94
-GdkCursor* gdk_cursor_new_from_texture   (GdkDisplay      *display,
-                                         GdkTexture      *texture,
+GdkCursor* gdk_cursor_new_from_texture   (GdkTexture      *texture,
                                          int              hotspot_x,
-                                         int              hotspot_y);
+                                         int              hotspot_y,
+                                          GdkCursor       *fallback);
 GDK_AVAILABLE_IN_ALL
-GdkCursor*  gdk_cursor_new_from_name    (GdkDisplay      *display,
-                                         const gchar     *name);
-GDK_AVAILABLE_IN_ALL
-GdkDisplay* gdk_cursor_get_display      (GdkCursor       *cursor);
+GdkCursor*  gdk_cursor_new_from_name    (const gchar     *name,
+                                          GdkCursor       *fallback);
+                                         
 GDK_AVAILABLE_IN_3_94
 GdkCursor * gdk_cursor_get_fallback      (GdkCursor      *cursor);
 GDK_AVAILABLE_IN_3_94
diff --git a/gdk/gdkdnd.c b/gdk/gdkdnd.c
index 0d22e26..15f0cab 100644
--- a/gdk/gdkdnd.c
+++ b/gdk/gdkdnd.c
@@ -762,8 +762,8 @@ gdk_drag_get_cursor (GdkDragContext *context,
       break;
 
   if (drag_cursors[i].cursor == NULL)
-    drag_cursors[i].cursor = gdk_cursor_new_from_name (context->display,
-                                                       drag_cursors[i].name);
+    drag_cursors[i].cursor = gdk_cursor_new_from_name (drag_cursors[i].name, NULL);
+                                                       
   return drag_cursors[i].cursor;
 }
 
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 8c1e13e..c7c2f40 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -4248,7 +4248,6 @@ gdk_window_set_cursor_internal (GdkWindow *window,
     return;
 
   g_assert (gdk_window_get_display (window) == gdk_device_get_display (device));
-  g_assert (!cursor || gdk_window_get_display (window) == gdk_cursor_get_display (cursor));
 
   if (window->window_type == GDK_WINDOW_ROOT ||
       window->window_type == GDK_WINDOW_FOREIGN)
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index 0fc6c58..4c7789b 100644
--- a/gdk/wayland/gdkdevice-wayland.c
+++ b/gdk/wayland/gdkdevice-wayland.c
@@ -509,7 +509,7 @@ gdk_wayland_device_set_window_cursor (GdkDevice *device,
     g_object_unref (pointer->cursor);
 
   if (cursor == NULL)
-    pointer->cursor = gdk_cursor_new_from_name (seat->display, "default");
+    pointer->cursor = gdk_cursor_new_from_name ("default", NULL);
   else
     pointer->cursor = g_object_ref (cursor);
 
diff --git a/gtk/gtkaboutdialog.c b/gtk/gtkaboutdialog.c
index 820f01c..d80ee1f 100644
--- a/gtk/gtkaboutdialog.c
+++ b/gtk/gtkaboutdialog.c
@@ -852,13 +852,11 @@ gtk_about_dialog_realize (GtkWidget *widget)
 {
   GtkAboutDialog *about = GTK_ABOUT_DIALOG (widget);
   GtkAboutDialogPrivate *priv = about->priv;
-  GdkDisplay *display;
 
   GTK_WIDGET_CLASS (gtk_about_dialog_parent_class)->realize (widget);
 
-  display = gtk_widget_get_display (widget);
-  priv->hand_cursor = gdk_cursor_new_from_name (display, "pointer");
-  priv->regular_cursor = gdk_cursor_new_from_name (display, "text");
+  priv->hand_cursor = gdk_cursor_new_from_name ("pointer", NULL);
+  priv->regular_cursor = gdk_cursor_new_from_name ("text", NULL);
 }
 
 static void
diff --git a/gtk/gtkcolorplane.c b/gtk/gtkcolorplane.c
index 7b1e8b1..1c83374 100644
--- a/gtk/gtkcolorplane.c
+++ b/gtk/gtkcolorplane.c
@@ -223,7 +223,7 @@ set_cross_cursor (GtkWidget *widget,
     return;
 
   if (enabled)
-    cursor = gdk_cursor_new_from_name (gtk_widget_get_display (GTK_WIDGET (widget)), "crosshair");
+    cursor = gdk_cursor_new_from_name ("crosshair", NULL);
 
   gdk_window_set_device_cursor (window, device, cursor);
 
diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c
index 606926e..40c14ee 100644
--- a/gtk/gtkdnd.c
+++ b/gtk/gtkdnd.c
@@ -147,7 +147,6 @@ static void          gtk_drag_get_event_actions (const GdkEvent  *event,
                                                  GdkDragAction   *suggested_action,
                                                  GdkDragAction   *possible_actions);
 static GdkCursor *   gtk_drag_get_cursor         (GtkWidget      *widget,
-                                                  GdkDisplay     *display,
                                                   GdkDragAction   action,
                                                   GtkDragSourceInfo *info);
 static void          gtk_drag_update_cursor      (GtkDragSourceInfo *info);
@@ -465,7 +464,6 @@ ensure_drag_cursor_pixbuf (int i)
 
 static GdkCursor *
 gtk_drag_get_cursor (GtkWidget         *widget,
-                     GdkDisplay        *display,
                      GdkDragAction      action,
                      GtkDragSourceInfo *info)
 {
@@ -484,19 +482,13 @@ gtk_drag_get_cursor (GtkWidget         *widget,
     if (drag_cursors[i].action == action)
       break;
 
-  if (drag_cursors[i].cursor != NULL)
-    {
-      if (display != gdk_cursor_get_display (drag_cursors[i].cursor))
-        g_clear_object (&drag_cursors[i].cursor);
-    }
-
   if (drag_cursors[i].cursor == NULL)
-    drag_cursors[i].cursor = gdk_cursor_new_from_name (display, drag_cursors[i].name);
+    drag_cursors[i].cursor = gdk_cursor_new_from_name (drag_cursors[i].name, NULL);
 
   if (drag_cursors[i].cursor == NULL)
     {
       ensure_drag_cursor_pixbuf (i);
-      drag_cursors[i].cursor = gdk_cursor_new_from_pixbuf (display, drag_cursors[i].pixbuf, 0, 0);
+      drag_cursors[i].cursor = gdk_cursor_new_from_pixbuf (drag_cursors[i].pixbuf, 0, 0, NULL);
     }
 
   return drag_cursors[i].cursor;
@@ -519,7 +511,6 @@ gtk_drag_update_cursor (GtkDragSourceInfo *info)
     return;
 
   cursor = gtk_drag_get_cursor (info->widget,
-                                gdk_cursor_get_display (info->cursor),
                                 drag_cursors[i].action, info);
 
   if (cursor != info->cursor)
@@ -1220,7 +1211,6 @@ gtk_drag_begin_internal (GtkWidget          *widget,
                               &suggested_action, &possible_actions);
   
   cursor = gtk_drag_get_cursor (widget,
-                                gtk_widget_get_display (widget), 
                                 suggested_action,
                                 NULL);
   
@@ -1762,7 +1752,6 @@ _gtk_drag_source_handle_event (GtkWidget *widget,
         if (info->have_grab)
           {
             cursor = gtk_drag_get_cursor (widget, 
-                                          gtk_widget_get_display (widget),
                                           gdk_drag_context_get_selected_action (context),
                                           info);
             if (info->cursor != cursor)
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 634eb40..e318c35 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -2806,7 +2806,7 @@ set_text_cursor (GtkWidget *widget)
 {
   GdkCursor *cursor;
 
-  cursor = gdk_cursor_new_from_name (gtk_widget_get_display (widget), "text");
+  cursor = gdk_cursor_new_from_name ("text", NULL);
   gtk_widget_set_cursor (widget, cursor);
   g_clear_object (&cursor);
 }
@@ -2817,12 +2817,9 @@ update_cursors (GtkWidget *widget)
   GtkEntry *entry = GTK_ENTRY (widget);
   GtkEntryPrivate *priv = entry->priv;
   EntryIconInfo *icon_info = NULL;
-  GdkDisplay *display;
   GdkCursor *cursor;
   gint i;
 
-  display = gtk_widget_get_display (widget);
-
   for (i = 0; i < MAX_ICONS; i++)
     {
       if ((icon_info = priv->icons[i]) != NULL)
@@ -2832,7 +2829,7 @@ update_cursors (GtkWidget *widget)
               (gtk_widget_get_sensitive (icon_info->widget) ||
                (icon_info->nonactivatable && icon_info->target_list == NULL)))
             {
-              cursor = gdk_cursor_new_from_name (display, "default");
+              cursor = gdk_cursor_new_from_name ("default", NULL);
               gtk_widget_set_cursor (icon_info->widget, cursor);
               g_clear_object (&cursor);
             }
@@ -4031,7 +4028,7 @@ set_invisible_cursor (GtkWidget *widget)
 {
   GdkCursor *cursor;
 
-  cursor = gdk_cursor_new_from_name (gtk_widget_get_display (widget), "none");
+  cursor = gdk_cursor_new_from_name ("none", NULL);
   gtk_widget_set_cursor (widget, cursor);
   g_object_unref (cursor);
 }
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index e826c4a..dcbd32e 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -4325,7 +4325,7 @@ set_busy_cursor (GtkFileChooserWidget *impl,
   display = gtk_widget_get_display (widget);
 
   if (busy)
-    cursor = gdk_cursor_new_from_name (display, "progress");
+    cursor = gdk_cursor_new_from_name ("progress", NULL);
   else
     cursor = NULL;
 
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index a29db71..1a82368 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -3756,17 +3756,14 @@ gtk_label_update_cursor (GtkLabel *label)
 
   if (gtk_widget_get_realized (widget))
     {
-      GdkDisplay *display;
       GdkCursor *cursor;
 
       if (gtk_widget_is_sensitive (widget))
         {
-          display = gtk_widget_get_display (widget);
-
           if (priv->select_info->active_link)
-            cursor = gdk_cursor_new_from_name (display, "pointer");
+            cursor = gdk_cursor_new_from_name ("pointer", NULL);
           else if (priv->select_info->selectable)
-            cursor = gdk_cursor_new_from_name (display, "text");
+            cursor = gdk_cursor_new_from_name ("text", NULL);
           else
             cursor = NULL;
         }
@@ -4960,7 +4957,7 @@ gtk_label_set_selectable_hint (GtkLabel *label)
     {
       GdkCursor *cursor;
 
-      cursor = gdk_cursor_new_from_name (gtk_widget_get_display (widget), "text");
+      cursor = gdk_cursor_new_from_name ("text", NULL);
       gtk_widget_set_cursor (widget, cursor);
       g_object_unref (cursor);
     }
diff --git a/gtk/gtklinkbutton.c b/gtk/gtklinkbutton.c
index 37aaf10..430d427 100644
--- a/gtk/gtklinkbutton.c
+++ b/gtk/gtklinkbutton.c
@@ -309,14 +309,12 @@ static void
 set_hand_cursor (GtkWidget *widget,
                 gboolean   show_hand)
 {
-  GdkDisplay *display;
   GdkCursor *cursor;
 
-  display = gtk_widget_get_display (widget);
-
-  cursor = NULL;
   if (show_hand)
-    cursor = gdk_cursor_new_from_name (display, "pointer");
+    cursor = gdk_cursor_new_from_name ("pointer", NULL);
+  else
+    cursor = NULL;
 
   gtk_widget_set_cursor (widget, cursor);
 
diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c
index 7af1076..66d3485 100644
--- a/gtk/gtkpaned.c
+++ b/gtk/gtkpaned.c
@@ -311,11 +311,9 @@ gtk_paned_motion_notify (GtkWidget      *widget,
   GtkPaned *paned = GTK_PANED (widget);
   GtkPanedPrivate *priv = gtk_paned_get_instance_private (paned);
   GdkRectangle handle_area;
-  GdkDisplay *display;
   gdouble x, y;
 
   get_handle_area (paned, &handle_area);
-  display = gtk_widget_get_display (widget);
 
   if (gdk_event_get_coords ((GdkEvent *) event, &x, &y) &&
       (gdk_rectangle_contains_point (&handle_area, x, y) ||
@@ -324,9 +322,9 @@ gtk_paned_motion_notify (GtkWidget      *widget,
       GdkCursor *cursor;
 
       if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
-        cursor = gdk_cursor_new_from_name (display, "col-resize");
+        cursor = gdk_cursor_new_from_name ("col-resize", NULL);
       else
-        cursor = gdk_cursor_new_from_name (display, "row-resize");
+        cursor = gdk_cursor_new_from_name ("row-resize", NULL);
 
       gtk_widget_set_cursor (widget, cursor);
       g_object_unref (cursor);
diff --git a/gtk/gtkplacesview.c b/gtk/gtkplacesview.c
index f9dfc76..bda8b18 100644
--- a/gtk/gtkplacesview.c
+++ b/gtk/gtkplacesview.c
@@ -324,7 +324,6 @@ set_busy_cursor (GtkPlacesView *view,
 {
   GtkWidget *widget;
   GtkWindow *toplevel;
-  GdkDisplay *display;
   GdkCursor *cursor;
 
   toplevel = get_toplevel (GTK_WIDGET (view));
@@ -332,15 +331,12 @@ set_busy_cursor (GtkPlacesView *view,
   if (!toplevel || !gtk_widget_get_realized (widget))
     return;
 
-  display = gtk_widget_get_display (widget);
-
   if (busy)
-    cursor = gdk_cursor_new_from_name (display, "progress");
+    cursor = gdk_cursor_new_from_name ("progress", NULL);
   else
     cursor = NULL;
 
   gdk_window_set_cursor (gtk_widget_get_window (widget), cursor);
-  gdk_display_flush (display);
 
   if (cursor)
     g_object_unref (cursor);
diff --git a/gtk/gtkprintunixdialog.c b/gtk/gtkprintunixdialog.c
index ebe6ecf..9f668b3 100644
--- a/gtk/gtkprintunixdialog.c
+++ b/gtk/gtkprintunixdialog.c
@@ -581,7 +581,6 @@ set_busy_cursor (GtkPrintUnixDialog *dialog,
 {
   GtkWidget *widget;
   GtkWindow *toplevel;
-  GdkDisplay *display;
   GdkCursor *cursor;
 
   toplevel = get_toplevel (GTK_WIDGET (dialog));
@@ -590,15 +589,12 @@ set_busy_cursor (GtkPrintUnixDialog *dialog,
   if (!toplevel || !gtk_widget_get_realized (widget))
     return;
 
-  display = gtk_widget_get_display (widget);
-
   if (busy)
-    cursor = gdk_cursor_new_from_name (display, "progress");
+    cursor = gdk_cursor_new_from_name ("progress", NULL);
   else
     cursor = NULL;
 
   gdk_window_set_cursor (gtk_widget_get_window (widget), cursor);
-  gdk_display_flush (display);
 
   if (cursor)
     g_object_unref (cursor);
diff --git a/gtk/gtkrecentchooserdefault.c b/gtk/gtkrecentchooserdefault.c
index bc563f1..41d06e4 100644
--- a/gtk/gtkrecentchooserdefault.c
+++ b/gtk/gtkrecentchooserdefault.c
@@ -636,7 +636,7 @@ set_busy_cursor (GtkRecentChooserDefault *impl,
   display = gtk_widget_get_display (GTK_WIDGET (toplevel));
 
   if (busy)
-    cursor = gdk_cursor_new_from_name (display, "progress");
+    cursor = gdk_cursor_new_from_name ("progress", NULL);
   else
     cursor = NULL;
 
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index a9a2061..9db5cf1 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -3194,11 +3194,9 @@ gtk_scrolled_window_allocate_scrollbar (GtkScrolledWindow *scrolled_window,
 static void
 install_scroll_cursor (GtkScrolledWindow *scrolled_window)
 {
-  GdkDisplay *display;
   GdkCursor *cursor;
 
-  display = gtk_widget_get_display (GTK_WIDGET (scrolled_window));
-  cursor = gdk_cursor_new_from_name (display, "all-scroll");
+  cursor = gdk_cursor_new_from_name ("all-scroll", NULL);
   gtk_widget_set_cursor (GTK_WIDGET (scrolled_window), cursor);
   g_clear_object (&cursor);
 }
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index e2a9b7d..247f553 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -4710,7 +4710,7 @@ gtk_text_view_map (GtkWidget *widget)
   if (priv->bottom_window)
     text_window_map (priv->bottom_window);
 
-  cursor = gdk_cursor_new_from_name (gtk_widget_get_display (widget), "text");
+  cursor = gdk_cursor_new_from_name ("text", NULL);
   gtk_widget_set_cursor (widget, cursor);
   g_object_unref (cursor);
 
@@ -4843,7 +4843,7 @@ gtk_text_view_state_flags_changed (GtkWidget     *widget,
   if (gtk_widget_get_realized (widget))
     {
       if (gtk_widget_is_sensitive (widget))
-        cursor = gdk_cursor_new_from_name (gtk_widget_get_display (widget), "text");
+        cursor = gdk_cursor_new_from_name ("text", NULL);
       else
         cursor = NULL;
 
@@ -4882,11 +4882,9 @@ gtk_text_view_state_flags_changed (GtkWidget     *widget,
 static void
 set_invisible_cursor (GdkWindow *window)
 {
-  GdkDisplay *display;
   GdkCursor *cursor;
 
-  display = gdk_window_get_display (window);
-  cursor = gdk_cursor_new_from_name (display, "none");
+  cursor = gdk_cursor_new_from_name ("none", NULL);
  
   gdk_window_set_cursor (window, cursor);
   
@@ -4909,11 +4907,9 @@ gtk_text_view_unobscure_mouse_cursor (GtkTextView *text_view)
 {
   if (text_view->priv->mouse_cursor_obscured)
     {
-      GdkDisplay *display;
       GdkCursor *cursor;
 
-      display = gtk_widget_get_display (GTK_WIDGET (text_view));
-      cursor = gdk_cursor_new_from_name (display, "text");
+      cursor = gdk_cursor_new_from_name ("text", NULL);
       gdk_window_set_cursor (text_view->priv->text_window->bin_window, cursor);
       g_object_unref (cursor);
       text_view->priv->mouse_cursor_obscured = FALSE;
@@ -9739,7 +9735,6 @@ text_window_realize (GtkTextWindow *win,
                      GtkWidget     *widget)
 {
   GdkWindow *window;
-  GdkDisplay *display;
   GdkCursor *cursor;
 
   window = gtk_widget_get_window (widget);
@@ -9764,8 +9759,7 @@ text_window_realize (GtkTextWindow *win,
   if (win->type == GTK_TEXT_WINDOW_TEXT &&
       gtk_widget_is_sensitive (widget))
     {
-      display = gdk_window_get_display (window);
-      cursor = gdk_cursor_new_from_name (display, "text");
+      cursor = gdk_cursor_new_from_name ("text", NULL);
       gdk_window_set_cursor (win->bin_window, cursor);
       g_clear_object (&cursor);
 
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index c33654b..680db99 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -4507,8 +4507,7 @@ gtk_tree_view_motion (GtkWidget      *widget,
 
       if (_gtk_tree_view_column_coords_in_resize_rect (column, x, y))
         {
-          GdkDisplay *display = gtk_widget_get_display (widget);
-          GdkCursor *cursor = gdk_cursor_new_from_name (display, "col-resize");
+          GdkCursor *cursor = gdk_cursor_new_from_name ("col-resize", NULL);
 
           gtk_widget_set_cursor (widget, cursor);
           g_object_unref (cursor);
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index d322cbb..775b6c4 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -1843,8 +1843,7 @@ captured_event_cb (GtkWidget *widget,
     {
       if (edge_under_coordinates (GTK_WINDOW (widget), x, y, i))
         {
-          cursor = gdk_cursor_new_from_name (gtk_widget_get_display (widget),
-                                             cursor_names[i]);
+          cursor = gdk_cursor_new_from_name (cursor_names[i], NULL);
           break;
         }
     }
diff --git a/gtk/inspector/inspect-button.c b/gtk/inspector/inspect-button.c
index 8e8a1ec..8c5ecdc 100644
--- a/gtk/inspector/inspect-button.c
+++ b/gtk/inspector/inspect-button.c
@@ -283,7 +283,7 @@ gtk_inspector_on_inspect (GtkWidget          *button,
     }
 
   display = gdk_display_get_default ();
-  cursor = gdk_cursor_new_from_name (display, "crosshair");
+  cursor = gdk_cursor_new_from_name ("crosshair", NULL);
   status = gdk_seat_grab (gdk_display_get_default_seat (display),
                           gtk_widget_get_window (iw->invisible),
                           GDK_SEAT_CAPABILITY_ALL_POINTING, TRUE,
diff --git a/tests/testgtk.c b/tests/testgtk.c
index 9786a52..3b70e33 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -3852,12 +3852,12 @@ set_cursor_from_name (GtkWidget *entry,
   GdkCursor *cursor;
 
   name = gtk_entry_get_text (GTK_ENTRY (entry));
-  cursor = gdk_cursor_new_from_name (gtk_widget_get_display (widget), name);
+  cursor = gdk_cursor_new_from_name (name, NULL);
 
   if (cursor == NULL)
     {
       name = NULL;
-      cursor = gdk_cursor_new_from_name (gtk_widget_get_display (widget), "none");
+      cursor = gdk_cursor_new_from_name ("none", NULL);
     }
 
   gdk_window_set_cursor (gtk_widget_get_window (widget), cursor);
@@ -7020,7 +7020,7 @@ snapshot_widget (GtkButton *button,
   data->is_toplevel = widget == data->toplevel_button;
 
   if (!data->cursor)
-    data->cursor = gdk_cursor_new_from_name (gtk_widget_get_display (widget), "crosshair");
+    data->cursor = gdk_cursor_new_from_name ("crosshair", NULL);
 
   gdk_seat_grab (gdk_device_get_seat (device),
                  gtk_widget_get_window (widget),


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