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.
This commit is contained in:
Benjamin Otte 2016-09-30 02:53:31 +02:00
parent 2fd5048943
commit fcbd480c76
9 changed files with 52 additions and 57 deletions

View File

@ -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);

View File

@ -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;
};

View File

@ -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)

View File

@ -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);
}

View File

@ -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);

View File

@ -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;
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;
}
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);
if (gtk_widget_is_sensitive (widget) && priv->select_info->selectable)
{
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);
}
gtk_widget_register_window (widget, priv->select_info->window);
}
static void

View File

@ -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;
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;
}
priv->handle = gdk_window_new (window,
&attributes, attributes_mask);
if (gtk_widget_is_sensitive (widget))
{
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);
}
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);

View File

@ -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

View File

@ -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]);