[gtk+/wip/otte/gtk4: 28/121] API: Remove GDK_WA_CURSOR



commit 88f4879ecee6fa0387142a8668041d2d284649b4
Author: Benjamin Otte <otte redhat com>
Date:   Fri Sep 30 02:53:31 2016 +0200

    API: Remove GDK_WA_CURSOR
    
    The cursor was set using gdk_window_set_cursor() even in
    gdk_window_new().
    
    So instead of having yet another flag, just make the users of that flag
    call gdk_window_set_cursor() directly after the window was created.

 gdk/gdkwindow.c               |    4 ----
 gdk/gdkwindow.h               |   13 +++++--------
 gdk/quartz/gdkwindow-quartz.c |    4 ----
 gdk/win32/gdkwindow-win32.c   |    7 ++-----
 gtk/gtkentry.c                |   18 +++++++++---------
 gtk/gtklabel.c                |   18 +++++++++---------
 gtk/gtkpaned.c                |   19 +++++++++++--------
 gtk/gtktreeviewcolumn.c       |   10 ++++++----
 gtk/gtkwindow.c               |   12 ++++++++----
 9 files changed, 50 insertions(+), 55 deletions(-)
---
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 901c209..a2fb1aa 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -1489,10 +1489,6 @@ gdk_window_new (GdkWindow     *parent,
 
   recompute_visible_regions (window, FALSE);
 
-  gdk_window_set_cursor (window, ((attributes_mask & GDK_WA_CURSOR) ?
-                                 (attributes->cursor) :
-                                 NULL));
-
   g_signal_connect (gdk_window_get_display (parent), "seat-removed",
                     G_CALLBACK (seat_removed_cb), window);
 
diff --git a/gdk/gdkwindow.h b/gdk/gdkwindow.h
index c3f13b4..319d836 100644
--- a/gdk/gdkwindow.h
+++ b/gdk/gdkwindow.h
@@ -91,14 +91,13 @@ typedef enum
  * @GDK_WA_TITLE: Honor the title field
  * @GDK_WA_X: Honor the X coordinate field
  * @GDK_WA_Y: Honor the Y coordinate field
- * @GDK_WA_CURSOR: Honor the cursor field
  * @GDK_WA_VISUAL: Honor the visual field
  * @GDK_WA_NOREDIR: Honor the override_redirect field
  * @GDK_WA_TYPE_HINT: Honor the type_hint field
  *
  * Used to indicate which fields in the #GdkWindowAttr struct should be honored.
- * For example, if you filled in the “cursor” and “x” fields of #GdkWindowAttr,
- * pass “@GDK_WA_X | @GDK_WA_CURSOR” to gdk_window_new(). Fields in
+ * For example, if you filled in the “title” and “x” fields of #GdkWindowAttr,
+ * pass “@GDK_WA_X | @GDK_WA_TITLE” to gdk_window_new(). Fields in
  * #GdkWindowAttr not covered by a bit in this enum are required; for example,
  * the @width/@height, @wclass, and @window_type fields are required, they have
  * no corresponding flag in #GdkWindowAttributesType.
@@ -108,10 +107,9 @@ typedef enum
   GDK_WA_TITLE    = 1 << 1,
   GDK_WA_X        = 1 << 2,
   GDK_WA_Y        = 1 << 3,
-  GDK_WA_CURSOR           = 1 << 4,
-  GDK_WA_VISUAL           = 1 << 5,
-  GDK_WA_NOREDIR   = 1 << 6,
-  GDK_WA_TYPE_HINT = 1 << 7
+  GDK_WA_VISUAL           = 1 << 4,
+  GDK_WA_NOREDIR   = 1 << 5,
+  GDK_WA_TYPE_HINT = 1 << 6
 } GdkWindowAttributesType;
 
 /* Size restriction enumeration.
@@ -356,7 +354,6 @@ struct _GdkWindowAttr
   GdkWindowWindowClass wclass;
   GdkVisual *visual;
   GdkWindowType window_type;
-  GdkCursor *cursor;
   gboolean override_redirect;
   GdkWindowTypeHint type_hint;
 };
diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c
index f3eceb1..33a701b 100644
--- a/gdk/quartz/gdkwindow-quartz.c
+++ b/gdk/quartz/gdkwindow-quartz.c
@@ -824,10 +824,6 @@ _gdk_quartz_display_create_window_impl (GdkDisplay    *display,
   else
     clear_toplevel_order ();
 
-  gdk_window_set_cursor (window, ((attributes_mask & GDK_WA_CURSOR) ?
-                                 (attributes->cursor) :
-                                 NULL));
-
   impl->view = NULL;
 
   switch (window->window_type)
diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c
index 6d25baa..bfd0140 100644
--- a/gdk/win32/gdkwindow-win32.c
+++ b/gdk/win32/gdkwindow-win32.c
@@ -734,9 +734,9 @@ _gdk_win32_display_create_window_impl (GdkDisplay    *display,
       remaining_mask &= ~GDK_WA_NOREDIR;
     }
 
-  if ((remaining_mask & ~(GDK_WA_VISUAL|GDK_WA_CURSOR|GDK_WA_TITLE|GDK_WA_TYPE_HINT)) != 0)
+  if ((remaining_mask & ~(GDK_WA_VISUAL|GDK_WA_TITLE|GDK_WA_TYPE_HINT)) != 0)
     g_warning ("_gdk_window_impl_new: uexpected attribute 0x%X",
-               remaining_mask & ~(GDK_WA_VISUAL|GDK_WA_CURSOR|GDK_WA_TITLE|GDK_WA_TYPE_HINT));
+               remaining_mask & ~(GDK_WA_VISUAL|GDK_WA_TITLE|GDK_WA_TYPE_HINT));
 
   hparent = GDK_WINDOW_HWND (real_parent);
 
@@ -941,9 +941,6 @@ _gdk_win32_display_create_window_impl (GdkDisplay    *display,
 //  if (!from_set_skip_taskbar_hint && window->window_type == GDK_WINDOW_TEMP)
 //    gdk_window_set_skip_taskbar_hint (window, TRUE);
 
-  if (attributes_mask & GDK_WA_CURSOR)
-    gdk_window_set_cursor (window, attributes->cursor);
-
   _gdk_win32_window_enable_transparency (window);
 }
 
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 312277a..3718eb2 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -3351,20 +3351,20 @@ gtk_entry_realize (GtkWidget *widget)
   attributes.width = priv->text_allocation.width;
   attributes.height = priv->text_allocation.height;
 
-  if (gtk_widget_is_sensitive (widget))
-    {
-      attributes.cursor = gdk_cursor_new_from_name (gtk_widget_get_display (widget), "text");
-      attributes_mask |= GDK_WA_CURSOR;
-    }
-
   priv->text_area = gdk_window_new (gtk_widget_get_window (widget),
                                     &attributes,
                                     attributes_mask);
 
-  gtk_widget_register_window (widget, priv->text_area);
+  if (gtk_widget_is_sensitive (widget))
+    {
+      GdkCursor *cursor;
 
-  if (attributes_mask & GDK_WA_CURSOR)
-    g_clear_object (&attributes.cursor);
+      cursor = gdk_cursor_new_from_name (gtk_widget_get_display (widget), "text");
+      gdk_window_set_cursor (priv->text_area, cursor);
+      g_object_unref (cursor);
+    }
+
+  gtk_widget_register_window (widget, priv->text_area);
 
   gtk_im_context_set_client_window (priv->im_context, priv->text_area);
 
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 3affe96..4937189 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -5430,20 +5430,20 @@ gtk_label_create_window (GtkLabel *label)
     GDK_BUTTON_MOTION_MASK       |
     GDK_POINTER_MOTION_MASK;
   attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_NOREDIR;
+
+  priv->select_info->window = gdk_window_new (gtk_widget_get_window (widget),
+                                               &attributes, attributes_mask);
+
   if (gtk_widget_is_sensitive (widget) && priv->select_info->selectable)
     {
-      attributes.cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget),
-                                                     GDK_XTERM);
-      attributes_mask |= GDK_WA_CURSOR;
-    }
+      GdkCursor *cursor;
 
+      cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), GDK_XTERM);
+      gdk_window_set_cursor (priv->select_info->window, cursor);
+      g_object_unref (cursor);
+    }
 
-  priv->select_info->window = gdk_window_new (gtk_widget_get_window (widget),
-                                               &attributes, attributes_mask);
   gtk_widget_register_window (widget, priv->select_info->window);
-
-  if (attributes_mask & GDK_WA_CURSOR)
-    g_object_unref (attributes.cursor);
 }
 
 static void
diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c
index 8becebd..cbe65e9 100644
--- a/gtk/gtkpaned.c
+++ b/gtk/gtkpaned.c
@@ -1689,20 +1689,23 @@ gtk_paned_realize (GtkWidget *widget)
                            GDK_ENTER_NOTIFY_MASK |
                            GDK_LEAVE_NOTIFY_MASK |
                            GDK_POINTER_MOTION_MASK);
-  attributes.cursor = NULL;
   attributes_mask = GDK_WA_X | GDK_WA_Y;
+
+  priv->handle = gdk_window_new (window,
+                                 &attributes, attributes_mask);
+
   if (gtk_widget_is_sensitive (widget))
     {
-      attributes.cursor = gdk_cursor_new_from_name (gtk_widget_get_display (widget),
-                                                   priv->orientation == GTK_ORIENTATION_HORIZONTAL
-                                                    ? "col-resize" : "row-resize");
-      attributes_mask |= GDK_WA_CURSOR;
+      GdkCursor *cursor;
+
+      cursor = gdk_cursor_new_from_name (gtk_widget_get_display (widget),
+                                         priv->orientation == GTK_ORIENTATION_HORIZONTAL
+                                         ? "col-resize" : "row-resize");
+      gdk_window_set_cursor (priv->handle, cursor);
+      g_object_unref (cursor);
     }
 
-  priv->handle = gdk_window_new (window,
-                                 &attributes, attributes_mask);
   gtk_widget_register_window (widget, priv->handle);
-  g_clear_object (&attributes.cursor);
 
   priv->child1_window = gtk_paned_create_child_window (paned, priv->child1);
   priv->child2_window = gtk_paned_create_child_window (paned, priv->child2);
diff --git a/gtk/gtktreeviewcolumn.c b/gtk/gtktreeviewcolumn.c
index 48b6fcd..fff7ce7 100644
--- a/gtk/gtktreeviewcolumn.c
+++ b/gtk/gtktreeviewcolumn.c
@@ -1315,6 +1315,7 @@ _gtk_tree_view_column_realize_button (GtkTreeViewColumn *column)
   guint attributes_mask;
   gboolean rtl;
   GdkDisplay *display;
+  GdkCursor *cursor;
 
   tree_view = (GtkTreeView *)priv->tree_view;
   rtl       = (gtk_widget_get_direction (priv->tree_view) == GTK_TEXT_DIR_RTL);
@@ -1334,9 +1335,8 @@ _gtk_tree_view_column_realize_button (GtkTreeViewColumn *column)
                     GDK_BUTTON_RELEASE_MASK |
                     GDK_POINTER_MOTION_MASK |
                     GDK_KEY_PRESS_MASK);
-  attributes_mask = GDK_WA_CURSOR | GDK_WA_X | GDK_WA_Y;
+  attributes_mask = GDK_WA_X | GDK_WA_Y;
   display = gdk_window_get_display (_gtk_tree_view_get_header_window (tree_view));
-  attr.cursor = gdk_cursor_new_from_name (display, "col-resize");
   attr.y = 0;
   attr.width = TREE_VIEW_DRAG_WIDTH;
   attr.height = _gtk_tree_view_get_header_height (tree_view);
@@ -1345,11 +1345,13 @@ _gtk_tree_view_column_realize_button (GtkTreeViewColumn *column)
   attr.x       = (allocation.x + (rtl ? 0 : allocation.width)) - TREE_VIEW_DRAG_WIDTH / 2;
   priv->window = gdk_window_new (_gtk_tree_view_get_header_window (tree_view),
                                 &attr, attributes_mask);
+  cursor = gdk_cursor_new_from_name (display, "col-resize");
+  gdk_window_set_cursor (priv->window, cursor);
+  g_object_unref (cursor);
+
   gtk_widget_register_window (GTK_WIDGET (tree_view), priv->window);
 
   gtk_tree_view_column_update_button (column);
-
-  g_clear_object (&attr.cursor);
 }
 
 void
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 205f471..e77060d 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -7147,7 +7147,7 @@ gtk_window_realize (GtkWidget *widget)
 
   if (priv->client_decorated && priv->type == GTK_WINDOW_TOPLEVEL)
     {
-      const gchar *cursor[8] = {
+      const gchar *cursor_names[8] = {
         "nw-resize", "n-resize", "ne-resize",
         "w-resize",               "e-resize",
         "sw-resize", "s-resize", "se-resize"
@@ -7157,13 +7157,17 @@ gtk_window_realize (GtkWidget *widget)
       attributes.width = 1;
       attributes.height = 1;
       attributes.event_mask = GDK_BUTTON_PRESS_MASK;
-      attributes_mask = GDK_WA_CURSOR;
+      attributes_mask = 0;
 
       for (i = 0; i < 8; i++)
         {
-          attributes.cursor = gdk_cursor_new_from_name (gtk_widget_get_display (widget), cursor[i]);
+          GdkCursor *cursor;
+
           priv->border_window[i] = gdk_window_new (gdk_window, &attributes, attributes_mask);
-          g_clear_object (&attributes.cursor);
+
+          cursor = gdk_cursor_new_from_name (gtk_widget_get_display (widget), cursor_names[i]);
+          gdk_window_set_cursor (priv->border_window[i], cursor);
+          g_object_unref (cursor);
 
           gdk_window_show (priv->border_window[i]);
           gtk_widget_register_window (widget, priv->border_window[i]);


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