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/.
31 #include "gdkscreen-x11.h"
32 #include "gdkdisplay-x11.h"
33 #include "gdkwindow.h"
36 /* Addition used for extension_events mask */
37 #define GDK_ALL_DEVICES_MASK (1<<30)
39 struct _GdkInputWindow
41 GList *windows; /* GdkWindow:s with extension_events set */
44 GdkWindow *impl_window; /* an impl window */
51 * Returns the list of available input devices for the default display.
52 * The list is statically allocated and should not be freed.
54 * Return value: a list of #GdkDevice
56 * Deprecated: 3.0: Use gdk_device_manager_list_devices() instead.
59 gdk_devices_list (void)
61 return gdk_display_list_devices (gdk_display_get_default ());
65 _gdk_input_select_device_events (GdkWindow *impl_window,
77 iw = ((GdkWindowObject *)impl_window)->input_window;
82 "has-cursor", &has_cursor,
86 mode == GDK_MODE_DISABLED ||
87 type == GDK_DEVICE_TYPE_MASTER)
90 for (l = iw->windows; l != NULL; l = l->next)
94 if (has_cursor || (w->extension_events & GDK_ALL_DEVICES_MASK))
96 event_mask = w->extension_events;
99 event_mask |= GDK_PROXIMITY_OUT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK;
101 gdk_window_set_device_events ((GdkWindow *) w, device, event_mask);
107 unset_extension_events (GdkWindow *window)
109 GdkWindowObject *window_private;
110 GdkWindowObject *impl_window;
111 GdkDisplayX11 *display_x11;
114 window_private = (GdkWindowObject*) window;
115 impl_window = (GdkWindowObject *)_gdk_window_get_impl_window (window);
116 iw = impl_window->input_window;
118 display_x11 = GDK_DISPLAY_X11 (GDK_WINDOW_DISPLAY (window));
120 if (window_private->extension_events != 0)
122 g_assert (iw != NULL);
123 g_assert (g_list_find (iw->windows, window) != NULL);
125 iw->windows = g_list_remove (iw->windows, window);
126 if (iw->windows == NULL)
128 impl_window->input_window = NULL;
129 display_x11->input_windows = g_list_remove (display_x11->input_windows, iw);
134 window_private->extension_events = 0;
138 * gdk_input_set_extension_events:
139 * @window: a #GdkWindow.
140 * @mask: the event mask
141 * @mode: the type of extension events that are desired.
143 * Turns extension events on or off for a particular window,
144 * and specifies the event mask for extension events.
146 * Deprecated: 3.0: Use gdk_window_set_device_events() instead.
149 gdk_input_set_extension_events (GdkWindow *window,
151 GdkExtensionMode mode)
153 GdkWindowObject *window_private;
154 GdkWindowObject *impl_window;
156 GdkDisplayX11 *display_x11;
161 g_return_if_fail (window != NULL);
162 g_return_if_fail (GDK_WINDOW_IS_X11 (window));
164 window_private = (GdkWindowObject*) window;
165 display_x11 = GDK_DISPLAY_X11 (GDK_WINDOW_DISPLAY (window));
166 if (GDK_WINDOW_DESTROYED (window))
169 impl_window = (GdkWindowObject *)_gdk_window_get_impl_window (window);
171 if (mode == GDK_EXTENSION_EVENTS_ALL && mask != 0)
172 mask |= GDK_ALL_DEVICES_MASK;
174 if (mode == GDK_EXTENSION_EVENTS_NONE)
177 iw = impl_window->input_window;
183 iw = g_new0 (GdkInputWindow,1);
185 iw->impl_window = (GdkWindow *)impl_window;
189 display_x11->input_windows = g_list_append (display_x11->input_windows, iw);
190 impl_window->input_window = iw;
193 if (window_private->extension_events == 0)
194 iw->windows = g_list_append (iw->windows, window);
195 window_private->extension_events = mask;
199 unset_extension_events (window);
203 for (tmp_list = display_x11->input_devices; tmp_list; tmp_list = tmp_list->next)
205 GdkDevice *dev = tmp_list->data;
206 _gdk_input_select_device_events (GDK_WINDOW (impl_window), dev);
208 #endif /* !XINPUT_NONE */
212 _gdk_input_window_destroy (GdkWindow *window)
214 unset_extension_events (window);
218 _gdk_input_check_extension_events (GdkDevice *device)
220 GdkDisplayX11 *display_impl;
221 GdkInputWindow *input_window;
224 display_impl = GDK_DISPLAY_X11 (gdk_device_get_display (device));
226 for (tmp_list = display_impl->input_windows; tmp_list; tmp_list = tmp_list->next)
228 input_window = tmp_list->data;
229 _gdk_input_select_device_events (input_window->impl_window, device);
233 #define __GDK_INPUT_C__
234 #include "gdkaliasdef.c"