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.
This commit is contained in:
Benjamin Otte 2017-11-03 23:19:22 +01:00
parent e2996732b9
commit 9323d098a6
26 changed files with 69 additions and 148 deletions

View File

@ -123,7 +123,7 @@ query_for_toplevel (GdkDisplay *display,
gtk_container_add (GTK_CONTAINER (frame), label); gtk_container_add (GTK_CONTAINER (frame), label);
gtk_widget_show (popup); 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 (); device = gtk_get_current_event_device ();
if (gdk_seat_grab (gdk_device_get_seat (device), if (gdk_seat_grab (gdk_device_get_seat (device),

View File

@ -43,11 +43,9 @@ add_button (GtkWidget *section,
const gchar *css_name) const gchar *css_name)
{ {
GtkWidget *image, *button; GtkWidget *image, *button;
GdkDisplay *display;
GdkCursor *cursor; GdkCursor *cursor;
display = gtk_widget_get_display (section); cursor = gdk_cursor_new_from_name (css_name, NULL);
cursor = gdk_cursor_new_from_name (display, css_name);
if (cursor == NULL) if (cursor == NULL)
image = gtk_image_new_from_icon_name ("image-missing", GTK_ICON_SIZE_MENU); image = gtk_image_new_from_icon_name ("image-missing", GTK_ICON_SIZE_MENU);
else else

View File

@ -254,11 +254,9 @@ do_hypertext (GtkWidget *do_widget)
GtkWidget *view; GtkWidget *view;
GtkWidget *sw; GtkWidget *sw;
GtkTextBuffer *buffer; GtkTextBuffer *buffer;
GdkDisplay *display;
display = gtk_widget_get_display (do_widget); hand_cursor = gdk_cursor_new_from_name ("pointer", NULL);
hand_cursor = gdk_cursor_new_from_name (display, "pointer"); regular_cursor = gdk_cursor_new_from_name ("text", NULL);
regular_cursor = gdk_cursor_new_from_name (display, "text");
window = gtk_window_new (GTK_WINDOW_TOPLEVEL); window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Hypertext"); gtk_window_set_title (GTK_WINDOW (window), "Hypertext");

View File

@ -80,7 +80,7 @@ get_busy (GSimpleAction *action,
GtkApplication *app = gtk_window_get_application (GTK_WINDOW (window)); GtkApplication *app = gtk_window_get_application (GTK_WINDOW (window));
g_application_mark_busy (G_APPLICATION (app)); 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); gdk_window_set_cursor (gtk_widget_get_window (window), cursor);
g_object_unref (cursor); g_object_unref (cursor);
g_timeout_add (5000, get_idle, window); g_timeout_add (5000, get_idle, window);

View File

@ -29,7 +29,6 @@
#include "gdkcursor.h" #include "gdkcursor.h"
#include "gdkcursorprivate.h" #include "gdkcursorprivate.h"
#include "gdkdisplayprivate.h"
#include "gdkintl.h" #include "gdkintl.h"
#include "gdkinternals.h" #include "gdkinternals.h"
@ -85,7 +84,6 @@
enum { enum {
PROP_0, PROP_0,
PROP_DISPLAY,
PROP_FALLBACK, PROP_FALLBACK,
PROP_HOTSPOT_X, PROP_HOTSPOT_X,
PROP_HOTSPOT_Y, PROP_HOTSPOT_Y,
@ -105,9 +103,6 @@ gdk_cursor_get_property (GObject *object,
switch (prop_id) switch (prop_id)
{ {
case PROP_DISPLAY:
g_value_set_object (value, cursor->display);
break;
case PROP_FALLBACK: case PROP_FALLBACK:
g_value_set_object (value, cursor->fallback); g_value_set_object (value, cursor->fallback);
break; break;
@ -139,11 +134,6 @@ gdk_cursor_set_property (GObject *object,
switch (prop_id) 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: case PROP_FALLBACK:
cursor->fallback = g_value_dup_object (value); cursor->fallback = g_value_dup_object (value);
break; break;
@ -186,13 +176,6 @@ gdk_cursor_class_init (GdkCursorClass *cursor_class)
object_class->set_property = gdk_cursor_set_property; object_class->set_property = gdk_cursor_set_property;
object_class->finalize = gdk_cursor_finalize; 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, g_object_class_install_property (object_class,
PROP_FALLBACK, PROP_FALLBACK,
g_param_spec_object ("fallback", g_param_spec_object ("fallback",
@ -283,7 +266,8 @@ gdk_cursor_equal (gconstpointer a,
/** /**
* gdk_cursor_new_from_name: * 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 * @name: the name of the cursor
* *
* Creates a new cursor by looking up @name in the current 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 * Since: 2.8
*/ */
GdkCursor* GdkCursor*
gdk_cursor_new_from_name (GdkDisplay *display, gdk_cursor_new_from_name (const gchar *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 (name != NULL, NULL);
g_return_val_if_fail (fallback == NULL || GDK_IS_CURSOR (fallback), NULL);
return g_object_new (GDK_TYPE_CURSOR, return g_object_new (GDK_TYPE_CURSOR,
"display", display,
"name", name, "name", name,
"fallback", fallback,
NULL); NULL);
} }
/** /**
* gdk_cursor_new_from_pixbuf: * gdk_cursor_new_from_pixbuf:
* @display: the #GdkDisplay for which the cursor will be created
* @pixbuf: the #GdkPixbuf containing the cursor image * @pixbuf: the #GdkPixbuf containing the cursor image
* @x: the horizontal offset of the hotspot of the cursor. * @x: the horizontal offset of the hotspot of the cursor.
* @y: the vertical 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. * Creates a new cursor from a pixbuf.
* *
@ -377,10 +362,10 @@ gdk_cursor_new_from_name (GdkDisplay *display,
* Since: 2.4 * Since: 2.4
*/ */
GdkCursor * GdkCursor *
gdk_cursor_new_from_pixbuf (GdkDisplay *display, gdk_cursor_new_from_pixbuf (GdkPixbuf *pixbuf,
GdkPixbuf *pixbuf,
gint x, gint x,
gint y) gint y,
GdkCursor *fallback)
{ {
GdkTexture *texture; GdkTexture *texture;
const char *option; const char *option;
@ -388,8 +373,8 @@ gdk_cursor_new_from_pixbuf (GdkDisplay *display,
gint64 value; gint64 value;
GdkCursor *cursor; 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 (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"))) 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); 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); g_object_unref (texture);
@ -424,10 +409,11 @@ gdk_cursor_new_from_pixbuf (GdkDisplay *display,
/** /**
* gdk_cursor_new_from_texture: * gdk_cursor_new_from_texture:
* @display: the #GdkDisplay for which the cursor will be created
* @texture: the texture providing the pixel data * @texture: the texture providing the pixel data
* @hotspot_x: the horizontal offset of the hotspot of the cursor * @hotspot_x: the horizontal offset of the hotspot of the cursor
* @hotspot_y: the vertical 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. * Creates a new cursor from a #GdkTexture.
* *
@ -448,42 +434,24 @@ gdk_cursor_new_from_pixbuf (GdkDisplay *display,
* Since: 3.94 * Since: 3.94
*/ */
GdkCursor * GdkCursor *
gdk_cursor_new_from_texture (GdkDisplay *display, gdk_cursor_new_from_texture (GdkTexture *texture,
GdkTexture *texture,
int hotspot_x, 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 (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_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 (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, return g_object_new (GDK_TYPE_CURSOR,
"display", display,
"texture", texture, "texture", texture,
"hotspot-x", hotspot_x, "hotspot-x", hotspot_x,
"hotspot-y", hotspot_y, "hotspot-y", hotspot_y,
"fallback", fallback,
NULL); 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: * gdk_cursor_get_fallback:
* @cursor: a #GdkCursor. * @cursor: a #GdkCursor.

View File

@ -46,20 +46,19 @@ GDK_AVAILABLE_IN_ALL
GType gdk_cursor_get_type (void) G_GNUC_CONST; GType gdk_cursor_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GdkCursor* gdk_cursor_new_from_pixbuf (GdkDisplay *display, GdkCursor* gdk_cursor_new_from_pixbuf (GdkPixbuf *pixbuf,
GdkPixbuf *pixbuf,
gint x, gint x,
gint y); gint y,
GdkCursor *fallback);
GDK_AVAILABLE_IN_3_94 GDK_AVAILABLE_IN_3_94
GdkCursor* gdk_cursor_new_from_texture (GdkDisplay *display, GdkCursor* gdk_cursor_new_from_texture (GdkTexture *texture,
GdkTexture *texture,
int hotspot_x, int hotspot_x,
int hotspot_y); int hotspot_y,
GdkCursor *fallback);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GdkCursor* gdk_cursor_new_from_name (GdkDisplay *display, GdkCursor* gdk_cursor_new_from_name (const gchar *name,
const gchar *name); GdkCursor *fallback);
GDK_AVAILABLE_IN_ALL
GdkDisplay* gdk_cursor_get_display (GdkCursor *cursor);
GDK_AVAILABLE_IN_3_94 GDK_AVAILABLE_IN_3_94
GdkCursor * gdk_cursor_get_fallback (GdkCursor *cursor); GdkCursor * gdk_cursor_get_fallback (GdkCursor *cursor);
GDK_AVAILABLE_IN_3_94 GDK_AVAILABLE_IN_3_94

View File

@ -762,8 +762,8 @@ gdk_drag_get_cursor (GdkDragContext *context,
break; break;
if (drag_cursors[i].cursor == NULL) if (drag_cursors[i].cursor == NULL)
drag_cursors[i].cursor = gdk_cursor_new_from_name (context->display, drag_cursors[i].cursor = gdk_cursor_new_from_name (drag_cursors[i].name, NULL);
drag_cursors[i].name);
return drag_cursors[i].cursor; return drag_cursors[i].cursor;
} }

View File

@ -4248,7 +4248,6 @@ gdk_window_set_cursor_internal (GdkWindow *window,
return; return;
g_assert (gdk_window_get_display (window) == gdk_device_get_display (device)); 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 || if (window->window_type == GDK_WINDOW_ROOT ||
window->window_type == GDK_WINDOW_FOREIGN) window->window_type == GDK_WINDOW_FOREIGN)

View File

@ -509,7 +509,7 @@ gdk_wayland_device_set_window_cursor (GdkDevice *device,
g_object_unref (pointer->cursor); g_object_unref (pointer->cursor);
if (cursor == NULL) if (cursor == NULL)
pointer->cursor = gdk_cursor_new_from_name (seat->display, "default"); pointer->cursor = gdk_cursor_new_from_name ("default", NULL);
else else
pointer->cursor = g_object_ref (cursor); pointer->cursor = g_object_ref (cursor);

View File

@ -852,13 +852,11 @@ gtk_about_dialog_realize (GtkWidget *widget)
{ {
GtkAboutDialog *about = GTK_ABOUT_DIALOG (widget); GtkAboutDialog *about = GTK_ABOUT_DIALOG (widget);
GtkAboutDialogPrivate *priv = about->priv; GtkAboutDialogPrivate *priv = about->priv;
GdkDisplay *display;
GTK_WIDGET_CLASS (gtk_about_dialog_parent_class)->realize (widget); GTK_WIDGET_CLASS (gtk_about_dialog_parent_class)->realize (widget);
display = gtk_widget_get_display (widget); priv->hand_cursor = gdk_cursor_new_from_name ("pointer", NULL);
priv->hand_cursor = gdk_cursor_new_from_name (display, "pointer"); priv->regular_cursor = gdk_cursor_new_from_name ("text", NULL);
priv->regular_cursor = gdk_cursor_new_from_name (display, "text");
} }
static void static void

View File

@ -223,7 +223,7 @@ set_cross_cursor (GtkWidget *widget,
return; return;
if (enabled) 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); gdk_window_set_device_cursor (window, device, cursor);

View File

@ -147,7 +147,6 @@ static void gtk_drag_get_event_actions (const GdkEvent *event,
GdkDragAction *suggested_action, GdkDragAction *suggested_action,
GdkDragAction *possible_actions); GdkDragAction *possible_actions);
static GdkCursor * gtk_drag_get_cursor (GtkWidget *widget, static GdkCursor * gtk_drag_get_cursor (GtkWidget *widget,
GdkDisplay *display,
GdkDragAction action, GdkDragAction action,
GtkDragSourceInfo *info); GtkDragSourceInfo *info);
static void gtk_drag_update_cursor (GtkDragSourceInfo *info); static void gtk_drag_update_cursor (GtkDragSourceInfo *info);
@ -465,7 +464,6 @@ ensure_drag_cursor_pixbuf (int i)
static GdkCursor * static GdkCursor *
gtk_drag_get_cursor (GtkWidget *widget, gtk_drag_get_cursor (GtkWidget *widget,
GdkDisplay *display,
GdkDragAction action, GdkDragAction action,
GtkDragSourceInfo *info) GtkDragSourceInfo *info)
{ {
@ -484,19 +482,13 @@ gtk_drag_get_cursor (GtkWidget *widget,
if (drag_cursors[i].action == action) if (drag_cursors[i].action == action)
break; 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) 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) if (drag_cursors[i].cursor == NULL)
{ {
ensure_drag_cursor_pixbuf (i); 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; return drag_cursors[i].cursor;
@ -519,7 +511,6 @@ gtk_drag_update_cursor (GtkDragSourceInfo *info)
return; return;
cursor = gtk_drag_get_cursor (info->widget, cursor = gtk_drag_get_cursor (info->widget,
gdk_cursor_get_display (info->cursor),
drag_cursors[i].action, info); drag_cursors[i].action, info);
if (cursor != info->cursor) if (cursor != info->cursor)
@ -1220,7 +1211,6 @@ gtk_drag_begin_internal (GtkWidget *widget,
&suggested_action, &possible_actions); &suggested_action, &possible_actions);
cursor = gtk_drag_get_cursor (widget, cursor = gtk_drag_get_cursor (widget,
gtk_widget_get_display (widget),
suggested_action, suggested_action,
NULL); NULL);
@ -1762,7 +1752,6 @@ _gtk_drag_source_handle_event (GtkWidget *widget,
if (info->have_grab) if (info->have_grab)
{ {
cursor = gtk_drag_get_cursor (widget, cursor = gtk_drag_get_cursor (widget,
gtk_widget_get_display (widget),
gdk_drag_context_get_selected_action (context), gdk_drag_context_get_selected_action (context),
info); info);
if (info->cursor != cursor) if (info->cursor != cursor)

View File

@ -2806,7 +2806,7 @@ set_text_cursor (GtkWidget *widget)
{ {
GdkCursor *cursor; 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); gtk_widget_set_cursor (widget, cursor);
g_clear_object (&cursor); g_clear_object (&cursor);
} }
@ -2817,12 +2817,9 @@ update_cursors (GtkWidget *widget)
GtkEntry *entry = GTK_ENTRY (widget); GtkEntry *entry = GTK_ENTRY (widget);
GtkEntryPrivate *priv = entry->priv; GtkEntryPrivate *priv = entry->priv;
EntryIconInfo *icon_info = NULL; EntryIconInfo *icon_info = NULL;
GdkDisplay *display;
GdkCursor *cursor; GdkCursor *cursor;
gint i; gint i;
display = gtk_widget_get_display (widget);
for (i = 0; i < MAX_ICONS; i++) for (i = 0; i < MAX_ICONS; i++)
{ {
if ((icon_info = priv->icons[i]) != NULL) if ((icon_info = priv->icons[i]) != NULL)
@ -2832,7 +2829,7 @@ update_cursors (GtkWidget *widget)
(gtk_widget_get_sensitive (icon_info->widget) || (gtk_widget_get_sensitive (icon_info->widget) ||
(icon_info->nonactivatable && icon_info->target_list == NULL))) (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); gtk_widget_set_cursor (icon_info->widget, cursor);
g_clear_object (&cursor); g_clear_object (&cursor);
} }
@ -4031,7 +4028,7 @@ set_invisible_cursor (GtkWidget *widget)
{ {
GdkCursor *cursor; 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); gtk_widget_set_cursor (widget, cursor);
g_object_unref (cursor); g_object_unref (cursor);
} }

View File

@ -4325,7 +4325,7 @@ set_busy_cursor (GtkFileChooserWidget *impl,
display = gtk_widget_get_display (widget); display = gtk_widget_get_display (widget);
if (busy) if (busy)
cursor = gdk_cursor_new_from_name (display, "progress"); cursor = gdk_cursor_new_from_name ("progress", NULL);
else else
cursor = NULL; cursor = NULL;

View File

@ -3756,17 +3756,14 @@ gtk_label_update_cursor (GtkLabel *label)
if (gtk_widget_get_realized (widget)) if (gtk_widget_get_realized (widget))
{ {
GdkDisplay *display;
GdkCursor *cursor; GdkCursor *cursor;
if (gtk_widget_is_sensitive (widget)) if (gtk_widget_is_sensitive (widget))
{ {
display = gtk_widget_get_display (widget);
if (priv->select_info->active_link) 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) else if (priv->select_info->selectable)
cursor = gdk_cursor_new_from_name (display, "text"); cursor = gdk_cursor_new_from_name ("text", NULL);
else else
cursor = NULL; cursor = NULL;
} }
@ -4960,7 +4957,7 @@ gtk_label_set_selectable_hint (GtkLabel *label)
{ {
GdkCursor *cursor; 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); gtk_widget_set_cursor (widget, cursor);
g_object_unref (cursor); g_object_unref (cursor);
} }

View File

@ -309,14 +309,12 @@ static void
set_hand_cursor (GtkWidget *widget, set_hand_cursor (GtkWidget *widget,
gboolean show_hand) gboolean show_hand)
{ {
GdkDisplay *display;
GdkCursor *cursor; GdkCursor *cursor;
display = gtk_widget_get_display (widget);
cursor = NULL;
if (show_hand) 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); gtk_widget_set_cursor (widget, cursor);

View File

@ -311,11 +311,9 @@ gtk_paned_motion_notify (GtkWidget *widget,
GtkPaned *paned = GTK_PANED (widget); GtkPaned *paned = GTK_PANED (widget);
GtkPanedPrivate *priv = gtk_paned_get_instance_private (paned); GtkPanedPrivate *priv = gtk_paned_get_instance_private (paned);
GdkRectangle handle_area; GdkRectangle handle_area;
GdkDisplay *display;
gdouble x, y; gdouble x, y;
get_handle_area (paned, &handle_area); get_handle_area (paned, &handle_area);
display = gtk_widget_get_display (widget);
if (gdk_event_get_coords ((GdkEvent *) event, &x, &y) && if (gdk_event_get_coords ((GdkEvent *) event, &x, &y) &&
(gdk_rectangle_contains_point (&handle_area, x, y) || (gdk_rectangle_contains_point (&handle_area, x, y) ||
@ -324,9 +322,9 @@ gtk_paned_motion_notify (GtkWidget *widget,
GdkCursor *cursor; GdkCursor *cursor;
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) 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 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); gtk_widget_set_cursor (widget, cursor);
g_object_unref (cursor); g_object_unref (cursor);

View File

@ -324,7 +324,6 @@ set_busy_cursor (GtkPlacesView *view,
{ {
GtkWidget *widget; GtkWidget *widget;
GtkWindow *toplevel; GtkWindow *toplevel;
GdkDisplay *display;
GdkCursor *cursor; GdkCursor *cursor;
toplevel = get_toplevel (GTK_WIDGET (view)); toplevel = get_toplevel (GTK_WIDGET (view));
@ -332,15 +331,12 @@ set_busy_cursor (GtkPlacesView *view,
if (!toplevel || !gtk_widget_get_realized (widget)) if (!toplevel || !gtk_widget_get_realized (widget))
return; return;
display = gtk_widget_get_display (widget);
if (busy) if (busy)
cursor = gdk_cursor_new_from_name (display, "progress"); cursor = gdk_cursor_new_from_name ("progress", NULL);
else else
cursor = NULL; cursor = NULL;
gdk_window_set_cursor (gtk_widget_get_window (widget), cursor); gdk_window_set_cursor (gtk_widget_get_window (widget), cursor);
gdk_display_flush (display);
if (cursor) if (cursor)
g_object_unref (cursor); g_object_unref (cursor);

View File

@ -581,7 +581,6 @@ set_busy_cursor (GtkPrintUnixDialog *dialog,
{ {
GtkWidget *widget; GtkWidget *widget;
GtkWindow *toplevel; GtkWindow *toplevel;
GdkDisplay *display;
GdkCursor *cursor; GdkCursor *cursor;
toplevel = get_toplevel (GTK_WIDGET (dialog)); toplevel = get_toplevel (GTK_WIDGET (dialog));
@ -590,15 +589,12 @@ set_busy_cursor (GtkPrintUnixDialog *dialog,
if (!toplevel || !gtk_widget_get_realized (widget)) if (!toplevel || !gtk_widget_get_realized (widget))
return; return;
display = gtk_widget_get_display (widget);
if (busy) if (busy)
cursor = gdk_cursor_new_from_name (display, "progress"); cursor = gdk_cursor_new_from_name ("progress", NULL);
else else
cursor = NULL; cursor = NULL;
gdk_window_set_cursor (gtk_widget_get_window (widget), cursor); gdk_window_set_cursor (gtk_widget_get_window (widget), cursor);
gdk_display_flush (display);
if (cursor) if (cursor)
g_object_unref (cursor); g_object_unref (cursor);

View File

@ -636,7 +636,7 @@ set_busy_cursor (GtkRecentChooserDefault *impl,
display = gtk_widget_get_display (GTK_WIDGET (toplevel)); display = gtk_widget_get_display (GTK_WIDGET (toplevel));
if (busy) if (busy)
cursor = gdk_cursor_new_from_name (display, "progress"); cursor = gdk_cursor_new_from_name ("progress", NULL);
else else
cursor = NULL; cursor = NULL;

View File

@ -3194,11 +3194,9 @@ gtk_scrolled_window_allocate_scrollbar (GtkScrolledWindow *scrolled_window,
static void static void
install_scroll_cursor (GtkScrolledWindow *scrolled_window) install_scroll_cursor (GtkScrolledWindow *scrolled_window)
{ {
GdkDisplay *display;
GdkCursor *cursor; GdkCursor *cursor;
display = gtk_widget_get_display (GTK_WIDGET (scrolled_window)); cursor = gdk_cursor_new_from_name ("all-scroll", NULL);
cursor = gdk_cursor_new_from_name (display, "all-scroll");
gtk_widget_set_cursor (GTK_WIDGET (scrolled_window), cursor); gtk_widget_set_cursor (GTK_WIDGET (scrolled_window), cursor);
g_clear_object (&cursor); g_clear_object (&cursor);
} }

View File

@ -4710,7 +4710,7 @@ gtk_text_view_map (GtkWidget *widget)
if (priv->bottom_window) if (priv->bottom_window)
text_window_map (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); gtk_widget_set_cursor (widget, cursor);
g_object_unref (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_get_realized (widget))
{ {
if (gtk_widget_is_sensitive (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 else
cursor = NULL; cursor = NULL;
@ -4882,11 +4882,9 @@ gtk_text_view_state_flags_changed (GtkWidget *widget,
static void static void
set_invisible_cursor (GdkWindow *window) set_invisible_cursor (GdkWindow *window)
{ {
GdkDisplay *display;
GdkCursor *cursor; GdkCursor *cursor;
display = gdk_window_get_display (window); cursor = gdk_cursor_new_from_name ("none", NULL);
cursor = gdk_cursor_new_from_name (display, "none");
gdk_window_set_cursor (window, cursor); 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) if (text_view->priv->mouse_cursor_obscured)
{ {
GdkDisplay *display;
GdkCursor *cursor; GdkCursor *cursor;
display = gtk_widget_get_display (GTK_WIDGET (text_view)); cursor = gdk_cursor_new_from_name ("text", NULL);
cursor = gdk_cursor_new_from_name (display, "text");
gdk_window_set_cursor (text_view->priv->text_window->bin_window, cursor); gdk_window_set_cursor (text_view->priv->text_window->bin_window, cursor);
g_object_unref (cursor); g_object_unref (cursor);
text_view->priv->mouse_cursor_obscured = FALSE; text_view->priv->mouse_cursor_obscured = FALSE;
@ -9739,7 +9735,6 @@ text_window_realize (GtkTextWindow *win,
GtkWidget *widget) GtkWidget *widget)
{ {
GdkWindow *window; GdkWindow *window;
GdkDisplay *display;
GdkCursor *cursor; GdkCursor *cursor;
window = gtk_widget_get_window (widget); window = gtk_widget_get_window (widget);
@ -9764,8 +9759,7 @@ text_window_realize (GtkTextWindow *win,
if (win->type == GTK_TEXT_WINDOW_TEXT && if (win->type == GTK_TEXT_WINDOW_TEXT &&
gtk_widget_is_sensitive (widget)) gtk_widget_is_sensitive (widget))
{ {
display = gdk_window_get_display (window); cursor = gdk_cursor_new_from_name ("text", NULL);
cursor = gdk_cursor_new_from_name (display, "text");
gdk_window_set_cursor (win->bin_window, cursor); gdk_window_set_cursor (win->bin_window, cursor);
g_clear_object (&cursor); g_clear_object (&cursor);

View File

@ -4507,8 +4507,7 @@ gtk_tree_view_motion (GtkWidget *widget,
if (_gtk_tree_view_column_coords_in_resize_rect (column, x, y)) 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 ("col-resize", NULL);
GdkCursor *cursor = gdk_cursor_new_from_name (display, "col-resize");
gtk_widget_set_cursor (widget, cursor); gtk_widget_set_cursor (widget, cursor);
g_object_unref (cursor); g_object_unref (cursor);

View File

@ -1843,8 +1843,7 @@ captured_event_cb (GtkWidget *widget,
{ {
if (edge_under_coordinates (GTK_WINDOW (widget), x, y, i)) if (edge_under_coordinates (GTK_WINDOW (widget), x, y, i))
{ {
cursor = gdk_cursor_new_from_name (gtk_widget_get_display (widget), cursor = gdk_cursor_new_from_name (cursor_names[i], NULL);
cursor_names[i]);
break; break;
} }
} }

View File

@ -283,7 +283,7 @@ gtk_inspector_on_inspect (GtkWidget *button,
} }
display = gdk_display_get_default (); 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), status = gdk_seat_grab (gdk_display_get_default_seat (display),
gtk_widget_get_window (iw->invisible), gtk_widget_get_window (iw->invisible),
GDK_SEAT_CAPABILITY_ALL_POINTING, TRUE, GDK_SEAT_CAPABILITY_ALL_POINTING, TRUE,

View File

@ -3852,12 +3852,12 @@ set_cursor_from_name (GtkWidget *entry,
GdkCursor *cursor; GdkCursor *cursor;
name = gtk_entry_get_text (GTK_ENTRY (entry)); 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) if (cursor == NULL)
{ {
name = 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); 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; data->is_toplevel = widget == data->toplevel_button;
if (!data->cursor) 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), gdk_seat_grab (gdk_device_get_seat (device),
gtk_widget_get_window (widget), gtk_widget_get_window (widget),