| 1 |
/* GDK - The GIMP Drawing Kit |
| 2 |
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald |
| 3 |
* |
| 4 |
* This library is free software; you can redistribute it and/or |
| 5 |
* modify it under the terms of the GNU Lesser General Public |
| 6 |
* License as published by the Free Software Foundation; either |
| 7 |
* version 2 of the License, or (at your option) any later version. |
| 8 |
* |
| 9 |
* This library is distributed in the hope that it will be useful, |
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 |
* Lesser General Public License for more details. |
| 13 |
* |
| 14 |
* You should have received a copy of the GNU Lesser General Public |
| 15 |
* License along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
*/ |
| 17 |
|
| 18 |
/* |
| 19 |
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS |
| 20 |
* file for a list of people on the GTK+ Team. See the ChangeLog |
| 21 |
* files for a list of changes. These files are distributed with |
| 22 |
* GTK+ at ftp://ftp.gtk.org/pub/gtk/. |
| 23 |
*/ |
| 24 |
|
| 25 |
#include "config.h" |
| 26 |
|
| 27 |
/* needs to be first because any header might include gdk-pixbuf.h otherwise */ |
| 28 |
#define GDK_PIXBUF_ENABLE_BACKEND |
| 29 |
#include <gdk-pixbuf/gdk-pixbuf.h> |
| 30 |
|
| 31 |
#include "gdkcursor.h" |
| 32 |
#include "gdkcursorprivate.h" |
| 33 |
|
| 34 |
#include "gdkprivate-broadway.h" |
| 35 |
#include "gdkdisplay-broadway.h" |
| 36 |
|
| 37 |
#include <string.h> |
| 38 |
#include <errno.h> |
| 39 |
|
| 40 |
struct _GdkBroadwayCursor |
| 41 |
{ |
| 42 |
GdkCursor cursor; |
| 43 |
}; |
| 44 |
|
| 45 |
struct _GdkBroadwayCursorClass |
| 46 |
{ |
| 47 |
GdkCursorClass cursor_class; |
| 48 |
}; |
| 49 |
|
| 50 |
/*** GdkBroadwayCursor ***/ |
| 51 |
|
| 52 |
G_DEFINE_TYPE (GdkBroadwayCursor, gdk_broadway_cursor, GDK_TYPE_CURSOR) |
| 53 |
|
| 54 |
static cairo_surface_t * gdk_broadway_cursor_get_surface (GdkCursor *cursor, |
| 55 |
gdouble *x_hot, |
| 56 |
gdouble *y_hot); |
| 57 |
|
| 58 |
static void |
| 59 |
gdk_broadway_cursor_finalize (GObject *object) |
| 60 |
{ |
| 61 |
G_OBJECT_CLASS (gdk_broadway_cursor_parent_class)->finalize (object); |
| 62 |
} |
| 63 |
|
| 64 |
static void |
| 65 |
gdk_broadway_cursor_class_init (GdkBroadwayCursorClass *xcursor_class) |
| 66 |
{ |
| 67 |
GdkCursorClass *cursor_class = GDK_CURSOR_CLASS (xcursor_class); |
| 68 |
GObjectClass *object_class = G_OBJECT_CLASS (xcursor_class); |
| 69 |
|
| 70 |
object_class->finalize = gdk_broadway_cursor_finalize; |
| 71 |
|
| 72 |
cursor_class->get_surface = gdk_broadway_cursor_get_surface; |
| 73 |
} |
| 74 |
|
| 75 |
static void |
| 76 |
gdk_broadway_cursor_init (GdkBroadwayCursor *cursor) |
| 77 |
{ |
| 78 |
} |
| 79 |
|
| 80 |
/* Called by gdk_display_broadway_finalize to flush any cached cursors |
| 81 |
* for a dead display. |
| 82 |
*/ |
| 83 |
void |
| 84 |
_gdk_broadway_cursor_display_finalize (GdkDisplay *display) |
| 85 |
{ |
| 86 |
} |
| 87 |
|
| 88 |
GdkCursor* |
| 89 |
_gdk_broadway_display_get_cursor_for_type (GdkDisplay *display, |
| 90 |
GdkCursorType cursor_type) |
| 91 |
{ |
| 92 |
GdkBroadwayCursor *private; |
| 93 |
|
| 94 |
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL); |
| 95 |
|
| 96 |
private = g_object_new (GDK_TYPE_BROADWAY_CURSOR, |
| 97 |
"cursor-type", cursor_type, |
| 98 |
"display", display, |
| 99 |
NULL); |
| 100 |
|
| 101 |
return GDK_CURSOR (private); |
| 102 |
} |
| 103 |
|
| 104 |
static cairo_surface_t * |
| 105 |
gdk_broadway_cursor_get_surface (GdkCursor *cursor, |
| 106 |
gdouble *x_hot, |
| 107 |
gdouble *y_hot) |
| 108 |
{ |
| 109 |
g_return_val_if_fail (cursor != NULL, NULL); |
| 110 |
|
| 111 |
return NULL; |
| 112 |
} |
| 113 |
|
| 114 |
void |
| 115 |
_gdk_broadway_cursor_update_theme (GdkCursor *cursor) |
| 116 |
{ |
| 117 |
g_return_if_fail (cursor != NULL); |
| 118 |
} |
| 119 |
|
| 120 |
GdkCursor * |
| 121 |
_gdk_broadway_display_get_cursor_for_surface (GdkDisplay *display, |
| 122 |
cairo_surface_t *surface, |
| 123 |
gdouble x, |
| 124 |
gdouble y) |
| 125 |
{ |
| 126 |
GdkBroadwayCursor *private; |
| 127 |
GdkCursor *cursor; |
| 128 |
|
| 129 |
private = g_object_new (GDK_TYPE_BROADWAY_CURSOR, |
| 130 |
"cursor-type", GDK_CURSOR_IS_PIXMAP, |
| 131 |
"display", display, |
| 132 |
NULL); |
| 133 |
cursor = (GdkCursor *) private; |
| 134 |
|
| 135 |
return cursor; |
| 136 |
} |
| 137 |
|
| 138 |
GdkCursor* |
| 139 |
_gdk_broadway_display_get_cursor_for_name (GdkDisplay *display, |
| 140 |
const gchar *name) |
| 141 |
{ |
| 142 |
GdkBroadwayCursor *private; |
| 143 |
|
| 144 |
private = g_object_new (GDK_TYPE_BROADWAY_CURSOR, |
| 145 |
"cursor-type", GDK_CURSOR_IS_PIXMAP, |
| 146 |
"display", display, |
| 147 |
NULL); |
| 148 |
|
| 149 |
return GDK_CURSOR (private); |
| 150 |
} |
| 151 |
|
| 152 |
gboolean |
| 153 |
_gdk_broadway_display_supports_cursor_alpha (GdkDisplay *display) |
| 154 |
{ |
| 155 |
g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE); |
| 156 |
|
| 157 |
return TRUE; |
| 158 |
} |
| 159 |
|
| 160 |
gboolean |
| 161 |
_gdk_broadway_display_supports_cursor_color (GdkDisplay *display) |
| 162 |
{ |
| 163 |
g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE); |
| 164 |
|
| 165 |
return TRUE; |
| 166 |
} |
| 167 |
|
| 168 |
void |
| 169 |
_gdk_broadway_display_get_default_cursor_size (GdkDisplay *display, |
| 170 |
guint *width, |
| 171 |
guint *height) |
| 172 |
{ |
| 173 |
g_return_if_fail (GDK_IS_DISPLAY (display)); |
| 174 |
|
| 175 |
*width = *height = 20; |
| 176 |
} |
| 177 |
|
| 178 |
void |
| 179 |
_gdk_broadway_display_get_maximal_cursor_size (GdkDisplay *display, |
| 180 |
guint *width, |
| 181 |
guint *height) |
| 182 |
{ |
| 183 |
g_return_if_fail (GDK_IS_DISPLAY (display)); |
| 184 |
|
| 185 |
*width = 128; |
| 186 |
*height = 128; |
| 187 |
} |