1
/* GDK - The GIMP Drawing Kit
2
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
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.
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.
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with this library; if not, write to the
16
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
* Boston, MA 02111-1307, USA.
21
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
22
* file for a list of people on the GTK+ Team. See the ChangeLog
23
* files for a list of changes. These files are distributed with
24
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
30
#include "gdkprivate-quartz.h"
32
#include "gdkprivate.h"
33
#include "gdkinputprivate.h"
35
static GdkDeviceAxis gdk_input_core_axes[] = {
40
GdkDevice *_gdk_core_pointer = NULL;
42
/* Global variables */
44
gchar *_gdk_input_gxid_host;
45
gint _gdk_input_gxid_port;
46
gint _gdk_input_ignore_core;
47
GList *_gdk_input_windows;
48
GList *_gdk_input_devices;
51
_gdk_init_input_core (void)
53
_gdk_core_pointer = g_object_new (GDK_TYPE_DEVICE, NULL);
55
_gdk_core_pointer->name = "Core Pointer";
56
_gdk_core_pointer->source = GDK_SOURCE_MOUSE;
57
_gdk_core_pointer->mode = GDK_MODE_SCREEN;
58
_gdk_core_pointer->has_cursor = TRUE;
59
_gdk_core_pointer->num_axes = 2;
60
_gdk_core_pointer->axes = gdk_input_core_axes;
61
_gdk_core_pointer->num_keys = 0;
62
_gdk_core_pointer->keys = NULL;
64
_gdk_display->core_pointer = _gdk_core_pointer;
68
gdk_device_finalize (GObject *object)
70
g_error ("A GdkDevice object was finalized. This should not happen");
74
gdk_device_class_init (GObjectClass *class)
76
class->finalize = gdk_device_finalize;
80
gdk_device_get_type (void)
82
static GType object_type = 0;
86
static const GTypeInfo object_info =
88
sizeof (GdkDeviceClass),
90
(GBaseFinalizeFunc) NULL,
91
(GClassInitFunc) gdk_device_class_init,
92
NULL, /* class_finalize */
93
NULL, /* class_data */
94
sizeof (GdkDevicePrivate),
96
(GInstanceInitFunc) NULL,
99
object_type = g_type_register_static (G_TYPE_OBJECT,
108
gdk_devices_list (void)
110
return _gdk_input_devices;
114
gdk_display_list_devices (GdkDisplay *dpy)
116
return _gdk_input_devices;
120
gdk_device_set_source (GdkDevice *device,
121
GdkInputSource source)
123
device->source = source;
128
gdk_device_set_key (GdkDevice *device,
131
GdkModifierType modifiers)
133
g_return_if_fail (device != NULL);
134
g_return_if_fail (index < device->num_keys);
136
device->keys[index].keyval = keyval;
137
device->keys[index].modifiers = modifiers;
141
gdk_device_set_axis_use (GdkDevice *device,
145
g_return_if_fail (device != NULL);
146
g_return_if_fail (index < device->num_axes);
148
device->axes[index].use = use;
154
device->axes[index].min = 0.;
155
device->axes[index].max = 0.;
159
device->axes[index].min = -1.;
160
device->axes[index].max = 1;
163
device->axes[index].min = 0.;
164
device->axes[index].max = 1;
170
gdk_device_get_state (GdkDevice *device,
173
GdkModifierType *mask)
177
g_assert (device == _gdk_core_pointer);
179
gdk_window_get_pointer (window, &x_int, &y_int, mask);
189
gdk_device_free_history (GdkTimeCoord **events,
194
for (i = 0; i < n_events; i++)
201
gdk_device_get_history (GdkDevice *device,
205
GdkTimeCoord ***events,
208
g_return_val_if_fail (window != NULL, FALSE);
209
g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
210
g_return_val_if_fail (events != NULL, FALSE);
211
g_return_val_if_fail (n_events != NULL, FALSE);
219
gdk_device_set_mode (GdkDevice *device,
226
_gdk_input_enable_window (GdkWindow *window, GdkDevicePrivate *gdkdev)
232
_gdk_input_disable_window (GdkWindow *window, GdkDevicePrivate *gdkdev)
239
_gdk_input_window_find(GdkWindow *window)
243
for (tmp_list=_gdk_input_windows; tmp_list; tmp_list=tmp_list->next)
244
if (((GdkInputWindow *)(tmp_list->data))->window == window)
245
return (GdkInputWindow *)(tmp_list->data);
247
return NULL; /* Not found */
250
/* FIXME: this routine currently needs to be called between creation
251
and the corresponding configure event (because it doesn't get the
252
root_relative_geometry). This should work with
253
gtk_window_set_extension_events, but will likely fail in other
257
gdk_input_set_extension_events (GdkWindow *window, gint mask,
258
GdkExtensionMode mode)
260
GdkWindowObject *window_private;
264
g_return_if_fail (window != NULL);
265
g_return_if_fail (GDK_IS_WINDOW (window));
267
window_private = (GdkWindowObject*) window;
269
if (mode == GDK_EXTENSION_EVENTS_NONE)
274
iw = g_new(GdkInputWindow,1);
279
iw->obscuring = NULL;
280
iw->num_obscuring = 0;
283
_gdk_input_windows = g_list_append (_gdk_input_windows,iw);
284
window_private->extension_events = mask;
286
/* Add enter window events to the event mask */
287
/* FIXME, this is not needed for XINPUT_NONE */
288
gdk_window_set_events (window,
289
gdk_window_get_events (window) |
290
GDK_ENTER_NOTIFY_MASK);
294
iw = _gdk_input_window_find (window);
297
_gdk_input_windows = g_list_remove (_gdk_input_windows,iw);
301
window_private->extension_events = 0;
304
for (tmp_list = _gdk_input_devices; tmp_list; tmp_list = tmp_list->next)
306
GdkDevicePrivate *gdkdev = (GdkDevicePrivate *)(tmp_list->data);
308
if (gdkdev != (GdkDevicePrivate *)_gdk_core_pointer)
310
if (mask != 0 && gdkdev->info.mode != GDK_MODE_DISABLED
311
&& (gdkdev->info.has_cursor || mode == GDK_EXTENSION_EVENTS_ALL))
312
_gdk_input_enable_window (window,gdkdev);
314
_gdk_input_disable_window (window,gdkdev);
320
_gdk_input_window_destroy (GdkWindow *window)
322
GdkInputWindow *input_window;
324
input_window = _gdk_input_window_find (window);
325
g_return_if_fail (input_window != NULL);
327
_gdk_input_windows = g_list_remove (_gdk_input_windows,input_window);
328
g_free (input_window);
332
_gdk_input_init (void)
334
_gdk_init_input_core ();
335
_gdk_input_devices = g_list_append (NULL, _gdk_core_pointer);
336
_gdk_input_ignore_core = FALSE;
340
_gdk_input_exit (void)
343
GdkDevicePrivate *gdkdev;
345
for (tmp_list = _gdk_input_devices; tmp_list; tmp_list = tmp_list->next)
347
gdkdev = (GdkDevicePrivate *)(tmp_list->data);
348
if (gdkdev != (GdkDevicePrivate *)_gdk_core_pointer)
350
gdk_device_set_mode ((GdkDevice *)gdkdev, GDK_MODE_DISABLED);
352
g_free (gdkdev->info.name);
353
g_free (gdkdev->info.axes);
354
g_free (gdkdev->info.keys);
359
g_list_free (_gdk_input_devices);
361
for (tmp_list = _gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
363
g_free (tmp_list->data);
365
g_list_free (_gdk_input_windows);
369
gdk_device_get_axis (GdkDevice *device, gdouble *axes, GdkAxisUse use, gdouble *value)
373
g_return_val_if_fail (device != NULL, FALSE);
378
for (i = 0; i < device->num_axes; i++)
379
if (device->axes[i].use == use)