2 * Copyright © 2009 Red Hat, Inc.
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:
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
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.
24 #ifdef HAVE_DIX_CONFIG_H
25 #include <dix-config.h>
28 #include <X11/Xatom.h>
31 #include "scrnintstr.h"
35 #include "xserver-properties.h"
41 /* from Xext/xtest.c */
42 extern DeviceIntPtr xtestpointer
, xtestkeyboard
;
44 /* Needed for the screen setup, otherwise we crash during sprite initialization */
46 device_cursor_init(DeviceIntPtr dev
, ScreenPtr screen
)
52 device_cursor_cleanup(DeviceIntPtr dev
, ScreenPtr screen
)
57 xtest_init_devices(void)
60 ClientRec server_client
;
62 /* random stuff that needs initialization */
63 memset(&screen
, 0, sizeof(screen
));
64 screenInfo
.numScreens
= 1;
65 screenInfo
.screens
[0] = &screen
;
70 screen
.DeviceCursorInitialize
= device_cursor_init
;
71 screen
.DeviceCursorCleanup
= device_cursor_cleanup
;
73 serverClient
= &server_client
;
74 InitClient(serverClient
, 0, (pointer
) NULL
);
75 if (!InitClientResources(serverClient
)) /* for root resources */
76 FatalError("couldn't init server resources");
80 /* this also inits the xtest devices */
84 assert(xtestkeyboard
);
85 assert(IsXTestDevice(xtestpointer
, NULL
));
86 assert(IsXTestDevice(xtestkeyboard
, NULL
));
87 assert(IsXTestDevice(xtestpointer
, inputInfo
.pointer
));
89 assert(IsXTestDevice(xtestkeyboard
, inputInfo
.keyboard
));
90 assert(GetXTestDevice(inputInfo
.pointer
) == xtestpointer
);
92 assert(GetXTestDevice(inputInfo
.keyboard
) == xtestkeyboard
);
96 * Each xtest devices has a property attached marking it. This property
100 xtest_properties(void)
104 XIPropertyValuePtr prop
;
105 Atom xtest_prop
= XIGetKnownProperty(XI_PROP_XTEST_DEVICE
);
107 rc
= XIGetDeviceProperty(xtestpointer
, xtest_prop
, &prop
);
108 assert(rc
== Success
);
111 rc
= XIGetDeviceProperty(xtestkeyboard
, xtest_prop
, &prop
);
112 assert(rc
== Success
);
113 assert(prop
!= NULL
);
115 rc
= XIChangeDeviceProperty(xtestpointer
, xtest_prop
,
116 XA_INTEGER
, 8, PropModeReplace
, 1, &value
,
118 assert(rc
== BadAccess
);
119 rc
= XIChangeDeviceProperty(xtestkeyboard
, xtest_prop
,
120 XA_INTEGER
, 8, PropModeReplace
, 1, &value
,
122 assert(rc
== BadAccess
);
126 main(int argc
, char **argv
)
128 xtest_init_devices();