]> Pileus Git - ~andy/gtk/blob - gdk/x11/gdkdevicemanager-x11.c
Inclusion cleanups in sources
[~andy/gtk] / gdk / x11 / gdkdevicemanager-x11.c
1 /* GDK - The GIMP Drawing Kit
2  * Copyright (C) 2009 Carlos Garnacho <carlosg@gnome.org>
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 #include "config.h"
21
22 #include "gdkdevicemanager-core.h"
23 #ifdef XINPUT_XFREE
24 #include "gdkdevicemanager-xi.h"
25 #ifdef XINPUT_2
26 #include "gdkdevicemanager-xi2.h"
27 #endif
28 #endif
29 #include "gdkx.h"
30
31 GdkDeviceManager *
32 _gdk_device_manager_new (GdkDisplay *display)
33 {
34   if (!g_getenv ("GDK_CORE_DEVICE_EVENTS"))
35     {
36 #if defined (XINPUT_2) || defined (XINPUT_XFREE)
37       int opcode, firstevent, firsterror;
38       Display *xdisplay;
39
40       xdisplay = GDK_DISPLAY_XDISPLAY (display);
41
42       if (XQueryExtension (xdisplay, "XInputExtension",
43                            &opcode, &firstevent, &firsterror))
44         {
45 #ifdef XINPUT_2
46           int major, minor;
47
48           major = 2;
49           minor = 0;
50
51           if (_gdk_enable_multidevice &&
52               XIQueryVersion (xdisplay, &major, &minor) != BadRequest)
53             {
54               GdkDeviceManagerXI2 *device_manager_xi2;
55
56               GDK_NOTE (INPUT, g_print ("Creating XI2 device manager\n"));
57
58               device_manager_xi2 = g_object_new (GDK_TYPE_DEVICE_MANAGER_XI2,
59                                                  "display", display,
60                                                  NULL);
61               device_manager_xi2->opcode = opcode;
62
63               return GDK_DEVICE_MANAGER (device_manager_xi2);
64             }
65           else
66 #endif /* XINPUT_2 */
67             {
68               GDK_NOTE (INPUT, g_print ("Creating XI device manager\n"));
69
70               return g_object_new (GDK_TYPE_DEVICE_MANAGER_XI,
71                                    "display", display,
72                                    "event-base", firstevent,
73                                    NULL);
74             }
75         }
76 #endif /* XINPUT_2 || XINPUT_XFREE */
77     }
78
79   GDK_NOTE (INPUT, g_print ("Creating core device manager\n"));
80
81   return g_object_new (GDK_TYPE_DEVICE_MANAGER_CORE,
82                        "display", display,
83                        NULL);
84 }