]> Pileus Git - ~andy/gtk/blob - gdk/win32/gdkinput.c
win32: Fix modal_hint handling
[~andy/gtk] / gdk / win32 / gdkinput.c
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, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /*
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/. 
25  */
26
27 /* This file should really be one level up, in the backend-independent
28  * GDK, and the x11/gdkinput.c could also be removed.
29  * 
30  * That stuff in x11/gdkinput.c which really *is* X11-dependent should
31  * be in x11/gdkinput-x11.c.
32  */
33
34 #include "config.h"
35
36 #include "gdkdisplay.h"
37 #include "gdkdevice.h"
38 #include "gdkdisplayprivate.h"
39
40 #include "gdkprivate-win32.h"
41 #include "gdkdevicemanager-win32.h"
42
43 gint              _gdk_input_ignore_core;
44
45 GList            *_gdk_input_devices;
46 GList            *_gdk_input_windows;
47
48 GList *
49 gdk_devices_list (void)
50 {
51   return _gdk_win32_display_list_devices (_gdk_display);
52 }
53
54 GList *
55 _gdk_win32_display_list_devices (GdkDisplay *dpy)
56 {
57   g_return_val_if_fail (dpy == _gdk_display, NULL);
58
59   return _gdk_input_devices;
60 }
61
62 /* FIXME: this routine currently needs to be called between creation
63    and the corresponding configure event (because it doesn't get the
64    root_relative_geometry).  This should work with
65    gtk_window_set_extension_events, but will likely fail in other
66    cases */
67
68 void
69 gdk_input_set_extension_events (GdkWindow *window, gint mask,
70                                 GdkExtensionMode mode)
71 {
72   GdkDeviceManager *device_manager;
73   GList *devices, *d;
74
75   g_return_if_fail (GDK_IS_WINDOW (window));
76
77   if (GDK_WINDOW_DESTROYED (window))
78     return;
79
80   if (mode == GDK_EXTENSION_EVENTS_NONE)
81     mask = 0;
82
83   window->extension_events = mask;
84
85   device_manager = gdk_display_get_device_manager (_gdk_display);
86   devices = gdk_device_manager_list_devices (device_manager,
87                                              GDK_DEVICE_TYPE_FLOATING);
88
89   for (d = devices; d; d = d->next)
90     {
91       GdkDevice *dev;
92       gint dev_mask;
93
94       dev = d->data;
95       dev_mask = mask;
96
97       if (gdk_device_get_mode (dev) == GDK_MODE_DISABLED ||
98           (!gdk_device_get_has_cursor (dev) && mode == GDK_EXTENSION_EVENTS_CURSOR))
99         dev_mask = 0;
100
101       gdk_window_set_device_events (window, dev, mask);
102     }
103
104   g_list_free (devices);
105 }
106
107 void
108 _gdk_input_init (GdkDisplay *display)
109 {
110   GdkDeviceManagerWin32 *device_manager;
111
112   _gdk_input_ignore_core = FALSE;
113
114   device_manager = g_object_new (GDK_TYPE_DEVICE_MANAGER_WIN32,
115                                  "display", display,
116                                  NULL);
117   display->device_manager = GDK_DEVICE_MANAGER (device_manager);
118
119   display->core_pointer = device_manager->core_pointer;
120
121   _gdk_input_devices = g_list_append (NULL, display->core_pointer);
122   _gdk_input_devices = g_list_concat (_gdk_input_devices,
123                                       g_list_copy (device_manager->wintab_devices));
124
125   _gdk_input_wintab_init_check (device_manager);
126
127 }