1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
#include <stdlib.h>
#include "gdkscreen-x11.h"
#include "gdkdisplay-x11.h"
#include "gdkwindow.h"
#include "gdkalias.h"
/* Addition used for extension_events mask */
#define GDK_ALL_DEVICES_MASK (1<<30)
struct _GdkInputWindow
{
GList *windows; /* GdkWindow:s with extension_events set */
/* gdk window */
GdkWindow *impl_window; /* an impl window */
};
/**
* gdk_devices_list:
*
* Returns the list of available input devices for the default display.
* The list is statically allocated and should not be freed.
*
* Return value: a list of #GdkDevice
*
* Deprecated: 3.0: Use gdk_device_manager_list_devices() instead.
**/
GList *
gdk_devices_list (void)
{
return gdk_display_list_devices (gdk_display_get_default ());
}
static void
_gdk_input_select_device_events (GdkWindow *impl_window,
GdkDevice *device)
{
guint event_mask;
GdkWindowObject *w;
GdkInputWindow *iw;
GdkInputMode mode;
gboolean has_cursor;
GdkDeviceType type;
GList *l;
event_mask = 0;
iw = ((GdkWindowObject *)impl_window)->input_window;
g_object_get (device,
"type", &type,
"input-mode", &mode,
"has-cursor", &has_cursor,
NULL);
if (iw == NULL ||
mode == GDK_MODE_DISABLED ||
type == GDK_DEVICE_TYPE_MASTER)
return;
for (l = iw->windows; l != NULL; l = l->next)
{
w = l->data;
if (has_cursor || (w->extension_events & GDK_ALL_DEVICES_MASK))
{
event_mask = w->extension_events;
if (event_mask)
event_mask |= GDK_PROXIMITY_OUT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK;
gdk_window_set_device_events ((GdkWindow *) w, device, event_mask);
}
}
}
static void
unset_extension_events (GdkWindow *window)
{
GdkWindowObject *window_private;
GdkWindowObject *impl_window;
GdkDisplayX11 *display_x11;
GdkInputWindow *iw;
window_private = (GdkWindowObject*) window;
impl_window = (GdkWindowObject *)_gdk_window_get_impl_window (window);
iw = impl_window->input_window;
display_x11 = GDK_DISPLAY_X11 (GDK_WINDOW_DISPLAY (window));
if (window_private->extension_events != 0)
{
g_assert (iw != NULL);
g_assert (g_list_find (iw->windows, window) != NULL);
iw->windows = g_list_remove (iw->windows, window);
if (iw->windows == NULL)
{
impl_window->input_window = NULL;
display_x11->input_windows = g_list_remove (display_x11->input_windows, iw);
g_free (iw);
}
}
window_private->extension_events = 0;
}
/**
* gdk_input_set_extension_events:
* @window: a #GdkWindow.
* @mask: the event mask
* @mode: the type of extension events that are desired.
*
* Turns extension events on or off for a particular window,
* and specifies the event mask for extension events.
*
* Deprecated: 3.0: Use gdk_window_set_device_events() instead.
**/
void
gdk_input_set_extension_events (GdkWindow *window,
gint mask,
GdkExtensionMode mode)
{
GdkWindowObject *window_private;
GdkWindowObject *impl_window;
GdkInputWindow *iw;
GdkDisplayX11 *display_x11;
#ifndef XINPUT_NONE
GList *tmp_list;
#endif
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_WINDOW_IS_X11 (window));
window_private = (GdkWindowObject*) window;
display_x11 = GDK_DISPLAY_X11 (GDK_WINDOW_DISPLAY (window));
if (GDK_WINDOW_DESTROYED (window))
return;
impl_window = (GdkWindowObject *)_gdk_window_get_impl_window (window);
if (mode == GDK_EXTENSION_EVENTS_ALL && mask != 0)
mask |= GDK_ALL_DEVICES_MASK;
if (mode == GDK_EXTENSION_EVENTS_NONE)
mask = 0;
iw = impl_window->input_window;
if (mask != 0)
{
if (!iw)
{
iw = g_new0 (GdkInputWindow,1);
iw->impl_window = (GdkWindow *)impl_window;
iw->windows = NULL;
display_x11->input_windows = g_list_append (display_x11->input_windows, iw);
impl_window->input_window = iw;
}
if (window_private->extension_events == 0)
iw->windows = g_list_append (iw->windows, window);
window_private->extension_events = mask;
}
else
{
unset_extension_events (window);
}
#ifndef XINPUT_NONE
for (tmp_list = display_x11->input_devices; tmp_list; tmp_list = tmp_list->next)
{
GdkDevice *dev = tmp_list->data;
_gdk_input_select_device_events (GDK_WINDOW (impl_window), dev);
}
#endif /* !XINPUT_NONE */
}
void
_gdk_input_window_destroy (GdkWindow *window)
{
unset_extension_events (window);
}
void
_gdk_input_check_extension_events (GdkDevice *device)
{
GdkDisplayX11 *display_impl;
GdkInputWindow *input_window;
GList *tmp_list;
display_impl = GDK_DISPLAY_X11 (gdk_device_get_display (device));
for (tmp_list = display_impl->input_windows; tmp_list; tmp_list = tmp_list->next)
{
input_window = tmp_list->data;
_gdk_input_select_device_events (input_window->impl_window, device);
}
}
#define __GDK_INPUT_C__
#include "gdkaliasdef.c"
|