summaryrefslogtreecommitdiff
path: root/gdk
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2017-11-03 23:19:22 +0100
committerBenjamin Otte <otte@redhat.com>2017-11-04 00:07:13 +0100
commit9323d098a6b80b396272ef9a1649218fbdced13b (patch)
tree2e6ee72e50d59e4d8e0faad7ecb7cd967a90a857 /gdk
parente2996732b9ede9a0fb9e43e1ef2d468efd0021ae (diff)
downloadgtk+-9323d098a6b80b396272ef9a1649218fbdced13b.tar.gz
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.
Diffstat (limited to 'gdk')
-rw-r--r--gdk/gdkcursor.c72
-rw-r--r--gdk/gdkcursor.h19
-rw-r--r--gdk/gdkdnd.c4
-rw-r--r--gdk/gdkwindow.c1
-rw-r--r--gdk/wayland/gdkdevice-wayland.c2
5 files changed, 32 insertions, 66 deletions
diff --git a/gdk/gdkcursor.c b/gdk/gdkcursor.c
index 3d1c2d4e84..63faa0e24c 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 df88e023dc..21210a0c3c 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 0d22e26ee1..15f0cab30a 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 8c1e13e81f..c7c2f40d5b 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 0fc6c58c66..4c7789b3e2 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);