1 /**
2 * Copyright © 2009 Red Hat, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
24 #ifdef HAVE_DIX_CONFIG_H
25 #include <dix-config.h>
26 #endif
27 #include <stdint.h>
28 #include <X11/Xatom.h>
29 #include "input.h"
30 #include "inputstr.h"
31 #include "scrnintstr.h"
32 #include "exevents.h"
33 #include "xkbsrv.h"
34 #include "xserver-properties.h"
36 /**
37 */
39 /* from Xext/xtest.c */
40 extern DeviceIntPtr xtestpointer, xtestkeyboard;
42 /* Needed for the screen setup, otherwise we crash during sprite initialization */
43 static Bool device_cursor_init(DeviceIntPtr dev, ScreenPtr screen) { return TRUE; }
45 static void xtest_init_devices(void)
46 {
47 ScreenRec screen;
49 /* random stuff that needs initialization */
50 memset(&screen, 0, sizeof(screen));
51 screenInfo.numScreens = 1;
52 screenInfo.screens[0] = &screen;
53 screen.myNum = 0;
54 screen.id = 100;
55 screen.width = 640;
56 screen.height = 480;
57 screen.DeviceCursorInitialize = device_cursor_init;
58 dixResetPrivates();
59 InitAtoms();
61 XkbInitPrivates();
63 /* this also inits the xtest devices */
64 InitCoreDevices();
66 assert(xtestpointer);
67 assert(xtestkeyboard);
68 assert(IsXTestDevice(xtestpointer, NULL));
69 assert(IsXTestDevice(xtestkeyboard, NULL));
70 assert(IsXTestDevice(xtestpointer, inputInfo.pointer));
71 assert(IsXTestDevice(xtestkeyboard, inputInfo.keyboard));
72 assert(GetXTestDevice(inputInfo.pointer) == xtestpointer);
73 assert(GetXTestDevice(inputInfo.keyboard) == xtestkeyboard);
74 }
76 /**
77 * Each xtest devices has a property attached marking it. This property
78 * cannot be changed.
79 */
80 static void xtest_properties(void)
81 {
82 int rc;
83 char value = 1;
84 XIPropertyValuePtr prop;
85 Atom xtest_prop = XIGetKnownProperty(XI_PROP_XTEST_DEVICE);
87 rc = XIGetDeviceProperty(xtestpointer, xtest_prop, &prop);
88 assert(rc == Success);
89 assert(prop);
91 rc = XIGetDeviceProperty(xtestkeyboard, xtest_prop, &prop);
92 assert(rc == Success);
93 assert(prop != NULL);
95 rc = XIChangeDeviceProperty(xtestpointer, xtest_prop,
96 XA_INTEGER, 8, PropModeReplace, 1, &value, FALSE);
97 assert(rc == BadAccess);
98 rc = XIChangeDeviceProperty(xtestkeyboard, xtest_prop,
99 XA_INTEGER, 8, PropModeReplace, 1, &value, FALSE);
100 assert(rc == BadAccess);
101 }
105 int main(int argc, char** argv)
106 {
107 xtest_init_devices();
108 xtest_properties();
110 return 0;
111 }