]> Pileus Git - ~andy/gtk/blob - gdk/x11/gdkdevicemanager-x11.c
Rename GdkDevice[Manager]Core to GdkX11Device[Manager]Core
[~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 "gdkx11devicemanager-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 "gdkinternals.h"
30 #include "gdkprivate-x11.h"
31
32 GdkDeviceManager *
33 _gdk_x11_device_manager_new (GdkDisplay *display)
34 {
35   if (!g_getenv ("GDK_CORE_DEVICE_EVENTS"))
36     {
37 #if defined (XINPUT_2) || defined (XINPUT_XFREE)
38       int opcode, firstevent, firsterror;
39       Display *xdisplay;
40
41       xdisplay = GDK_DISPLAY_XDISPLAY (display);
42
43       if (XQueryExtension (xdisplay, "XInputExtension",
44                            &opcode, &firstevent, &firsterror))
45         {
46 #ifdef XINPUT_2
47           int major, minor;
48
49           major = 2;
50           minor = 0;
51
52           if (!_gdk_disable_multidevice &&
53               XIQueryVersion (xdisplay, &major, &minor) != BadRequest)
54             {
55               GdkDeviceManagerXI2 *device_manager_xi2;
56
57               GDK_NOTE (INPUT, g_print ("Creating XI2 device manager\n"));
58
59               device_manager_xi2 = g_object_new (GDK_TYPE_DEVICE_MANAGER_XI2,
60                                                  "display", display,
61                                                  NULL);
62               device_manager_xi2->opcode = opcode;
63
64               return GDK_DEVICE_MANAGER (device_manager_xi2);
65             }
66           else
67 #endif /* XINPUT_2 */
68             {
69               GDK_NOTE (INPUT, g_print ("Creating XI device manager\n"));
70
71               return g_object_new (GDK_TYPE_DEVICE_MANAGER_XI,
72                                    "display", display,
73                                    "event-base", firstevent,
74                                    NULL);
75             }
76         }
77 #endif /* XINPUT_2 || XINPUT_XFREE */
78     }
79
80   GDK_NOTE (INPUT, g_print ("Creating core device manager\n"));
81
82   return g_object_new (GDK_TYPE_X11_DEVICE_MANAGER_CORE,
83                        "display", display,
84                        NULL);
85 }