2
* Copyright 2006 by VMware, 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 shall be included in
12
* all copies or substantial portions of the Software.
14
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20
* OTHER DEALINGS IN THE SOFTWARE.
22
* Except as contained in this notice, the name of the copyright holder(s)
23
* and author(s) shall not be used in advertising or otherwise to promote
24
* the sale, use or other dealings in this Software without prior written
25
* authorization from the copyright holder(s) and author(s).
31
* The VMWARE_CTRL client library.
37
#include <X11/Xlibint.h>
38
#include "libvmwarectrl.h"
39
#include "vmwarectrlproto.h"
40
#include <X11/extensions/Xext.h>
41
#include <X11/extensions/extutil.h>
45
* Static data and functions.
48
static XExtensionInfo _vmwarectrl_info_data;
49
static XExtensionInfo *vmwarectrl_info = &_vmwarectrl_info_data;
50
static char *vmwarectrl_extension_name = VMWARE_CTRL_PROTOCOL_NAME;
52
#define VMwareCtrlCheckExtension(dpy, i, val) \
53
XextCheckExtension(dpy, i, vmwarectrl_extension_name, val)
55
static int close_display(Display *dpy, XExtCodes *codes);
57
static /* const */ XExtensionHooks vmwarectrl_extension_hooks = {
62
NULL, /* create_font */
64
close_display, /* close_display */
65
NULL, /* wire_to_event */
66
NULL, /* event_to_wire */
68
NULL, /* error_string */
71
static XEXT_GENERATE_CLOSE_DISPLAY (close_display, vmwarectrl_info)
73
static XEXT_GENERATE_FIND_DISPLAY (find_display, vmwarectrl_info,
74
vmwarectrl_extension_name,
75
&vmwarectrl_extension_hooks,
79
*----------------------------------------------------------------------------
81
* VMwareCtrl_QueryExtension --
83
* Standard QueryExtension implementation. Not very interesting for
84
* VMWARE_CTRL as it doesn't define any events or errors.
87
* True if information is successfully retrieved. False otherwise.
92
*----------------------------------------------------------------------------
96
VMwareCtrl_QueryExtension(Display *dpy, // IN:
97
int *event_basep, // OUT:
98
int *error_basep) // OUT:
100
XExtDisplayInfo *info = find_display(dpy);
102
if (XextHasExtension(info)) {
103
*event_basep = info->codes->first_event;
104
*error_basep = info->codes->first_error;
113
*----------------------------------------------------------------------------
115
* VMwareCtrl_QueryVersion --
117
* Send the QueryVersion command to the driver and return the results.
120
* True if information is successfully retrieved. False otherwise.
125
*----------------------------------------------------------------------------
129
VMwareCtrl_QueryVersion(Display *dpy, // IN:
130
int *majorVersion, // OUT:
131
int *minorVersion) // OUT:
133
xVMwareCtrlQueryVersionReply rep;
134
xVMwareCtrlQueryVersionReq *req;
135
XExtDisplayInfo *info = find_display(dpy);
138
VMwareCtrlCheckExtension(dpy, info, False);
141
GetReq(VMwareCtrlQueryVersion, req);
142
req->reqType = info->codes->major_opcode;
143
req->VMwareCtrlReqType = X_VMwareCtrlQueryVersion;
145
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
148
*majorVersion = rep.majorVersion;
149
*minorVersion = rep.minorVersion;
162
*----------------------------------------------------------------------------
164
* VMwareCtrl_SetRes --
166
* Send the SetRes command to the driver.
169
* True if the resolution was set. False otherwise.
174
*----------------------------------------------------------------------------
178
VMwareCtrl_SetRes(Display *dpy, // IN:
183
xVMwareCtrlSetResReply rep;
184
xVMwareCtrlSetResReq *req;
185
XExtDisplayInfo *info = find_display(dpy);
188
VMwareCtrlCheckExtension(dpy, info, False);
191
GetReq(VMwareCtrlSetRes, req);
192
req->reqType = info->codes->major_opcode;
193
req->VMwareCtrlReqType = X_VMwareCtrlSetRes;
194
req->screen = screen;
198
if (!_XReply(dpy, (xReply *)&rep,
199
(SIZEOF(xVMwareCtrlSetResReply) - SIZEOF(xReply)) >> 2,
215
*----------------------------------------------------------------------------
217
* VMwareCtrl_SetTopology --
219
* Send the SetTopology command to the driver.
221
* Solaris 10 uses a different Xinerama standard than expected here. As a
222
* result, topology set is not supported and this function is excluded from
226
* True if the resolution and xinerama topology were set. False otherwise.
231
*----------------------------------------------------------------------------
236
VMwareCtrl_SetTopology(Display *dpy, // IN:
238
xXineramaScreenInfo extents[], // IN:
241
xVMwareCtrlSetTopologyReply rep;
242
xVMwareCtrlSetTopologyReq *req;
243
XExtDisplayInfo *info = find_display(dpy);
247
VMwareCtrlCheckExtension(dpy, info, False);
250
GetReq(VMwareCtrlSetTopology, req);
251
req->reqType = info->codes->major_opcode;
252
req->VMwareCtrlReqType = X_VMwareCtrlSetTopology;
253
req->screen = screen;
254
req->number = number;
256
len = ((long) number) << 1;
257
SetReqLen(req, len, len);
259
_XSend(dpy, (char *)extents, len);
261
if (!_XReply(dpy, (xReply *)&rep,
262
(SIZEOF(xVMwareCtrlSetTopologyReply) - SIZEOF(xReply)) >> 2,