~ubuntu-branches/ubuntu/quantal/open-vm-tools/quantal-201210021442

« back to all changes in this revision

Viewing changes to lib/resolution/libvmwarectrl.c

  • Committer: Bazaar Package Importer
  • Author(s): Serge Hallyn
  • Date: 2011-03-31 14:20:05 UTC
  • mfrom: (1.4.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110331142005-3n9red91p7ogkweo
Tags: 2011.03.28-387002-0ubuntu1
* Merge latest upstream git tag.  This has the unlocked_ioctl change
  needed to fix dkms build failures (LP: #727342)
* Changes in debian/rules:
  - work around a bug in toolbox/Makefile, where install-exec-hook is
    not happening.  This needs to get fixed the right way.
  - don't install 'vmware-user' which seems to no longer exist
  - move /etc/xdg into open-vm-toolbox (which should be done using .install)
* debian/open-vm-tools.init: add 'modprobe [-r] vmblock'. (LP: #332323)
* debian/rules and debian/open-vm-toolbox.lintian-overrides:
  - Make vmware-user-suid-wrapper suid-root (LP: #332323)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright 2006 by VMware, 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 shall be included in
12
 
 * all copies or substantial portions of the Software.
13
 
 *
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.
21
 
 *
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).
26
 
 */
27
 
 
28
 
/*
29
 
 * libvmwarectrl.c --
30
 
 *
31
 
 *      The VMWARE_CTRL client library.
32
 
 */
33
 
 
34
 
 
35
 
#define NEED_EVENTS
36
 
#define NEED_REPLIES
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>
42
 
 
43
 
 
44
 
/*
45
 
 * Static data and functions.
46
 
 */
47
 
 
48
 
static XExtensionInfo _vmwarectrl_info_data;
49
 
static XExtensionInfo *vmwarectrl_info = &_vmwarectrl_info_data;
50
 
static char *vmwarectrl_extension_name = VMWARE_CTRL_PROTOCOL_NAME;
51
 
 
52
 
#define VMwareCtrlCheckExtension(dpy, i, val) \
53
 
  XextCheckExtension(dpy, i, vmwarectrl_extension_name, val)
54
 
 
55
 
static int close_display(Display *dpy, XExtCodes *codes);
56
 
 
57
 
static /* const */ XExtensionHooks vmwarectrl_extension_hooks = {
58
 
    NULL,          /* create_gc */
59
 
    NULL,          /* copy_gc */
60
 
    NULL,          /* flush_gc */
61
 
    NULL,          /* free_gc */
62
 
    NULL,          /* create_font */
63
 
    NULL,          /* free_font */
64
 
    close_display, /* close_display */
65
 
    NULL,          /* wire_to_event */
66
 
    NULL,          /* event_to_wire */
67
 
    NULL,          /* error */
68
 
    NULL,          /* error_string */
69
 
};
70
 
 
71
 
static XEXT_GENERATE_CLOSE_DISPLAY (close_display, vmwarectrl_info)
72
 
 
73
 
static XEXT_GENERATE_FIND_DISPLAY (find_display, vmwarectrl_info,
74
 
                                   vmwarectrl_extension_name,
75
 
                                   &vmwarectrl_extension_hooks,
76
 
                                   0, NULL)
77
 
 
78
 
/*
79
 
 *----------------------------------------------------------------------------
80
 
 *
81
 
 * VMwareCtrl_QueryExtension --
82
 
 *
83
 
 *      Standard QueryExtension implementation. Not very interesting for
84
 
 *      VMWARE_CTRL as it doesn't define any events or errors.
85
 
 *
86
 
 * Results:
87
 
 *      True if information is successfully retrieved. False otherwise.
88
 
 *
89
 
 * Side effects:
90
 
 *      None.
91
 
 *
92
 
 *----------------------------------------------------------------------------
93
 
 */
94
 
 
95
 
Bool
96
 
VMwareCtrl_QueryExtension(Display *dpy,     // IN:
97
 
                          int *event_basep, // OUT:
98
 
                          int *error_basep) // OUT:
99
 
{
100
 
   XExtDisplayInfo *info = find_display(dpy);
101
 
 
102
 
   if (XextHasExtension(info)) {
103
 
      *event_basep = info->codes->first_event;
104
 
      *error_basep = info->codes->first_error;
105
 
      return True;
106
 
   } else {
107
 
      return False;
108
 
   }
109
 
}
110
 
 
111
 
 
112
 
/*
113
 
 *----------------------------------------------------------------------------
114
 
 *
115
 
 * VMwareCtrl_QueryVersion --
116
 
 *
117
 
 *      Send the QueryVersion command to the driver and return the results.
118
 
 *
119
 
 * Results:
120
 
 *      True if information is successfully retrieved. False otherwise.
121
 
 *
122
 
 * Side effects:
123
 
 *      None.
124
 
 *
125
 
 *----------------------------------------------------------------------------
126
 
 */
127
 
 
128
 
Bool
129
 
VMwareCtrl_QueryVersion(Display *dpy,      // IN:
130
 
                        int *majorVersion, // OUT:
131
 
                        int *minorVersion) // OUT:
132
 
{
133
 
   xVMwareCtrlQueryVersionReply rep;
134
 
   xVMwareCtrlQueryVersionReq *req;
135
 
   XExtDisplayInfo *info = find_display(dpy);
136
 
   Bool ret = False;
137
 
 
138
 
   VMwareCtrlCheckExtension(dpy, info, False);
139
 
   LockDisplay(dpy);
140
 
 
141
 
   GetReq(VMwareCtrlQueryVersion, req);
142
 
   req->reqType = info->codes->major_opcode;
143
 
   req->VMwareCtrlReqType = X_VMwareCtrlQueryVersion;
144
 
 
145
 
   if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
146
 
      goto exit;
147
 
   }
148
 
   *majorVersion = rep.majorVersion;
149
 
   *minorVersion = rep.minorVersion;
150
 
 
151
 
   ret = True;
152
 
 
153
 
exit:
154
 
   UnlockDisplay(dpy);
155
 
   SyncHandle();
156
 
 
157
 
   return ret;
158
 
}
159
 
 
160
 
 
161
 
/*
162
 
 *----------------------------------------------------------------------------
163
 
 *
164
 
 * VMwareCtrl_SetRes --
165
 
 *
166
 
 *      Send the SetRes command to the driver.
167
 
 *
168
 
 * Results:
169
 
 *      True if the resolution was set. False otherwise.
170
 
 *
171
 
 * Side effects:
172
 
 *      None.
173
 
 *
174
 
 *----------------------------------------------------------------------------
175
 
 */
176
 
 
177
 
Bool
178
 
VMwareCtrl_SetRes(Display *dpy, // IN:
179
 
                  int screen,   // IN:
180
 
                  int x,        // IN:
181
 
                  int y)        // IN:
182
 
{
183
 
   xVMwareCtrlSetResReply rep;
184
 
   xVMwareCtrlSetResReq *req;
185
 
   XExtDisplayInfo *info = find_display(dpy);
186
 
   Bool ret = False;
187
 
 
188
 
   VMwareCtrlCheckExtension(dpy, info, False);
189
 
   LockDisplay(dpy);
190
 
 
191
 
   GetReq(VMwareCtrlSetRes, req);
192
 
   req->reqType = info->codes->major_opcode;
193
 
   req->VMwareCtrlReqType = X_VMwareCtrlSetRes;
194
 
   req->screen = screen;
195
 
   req->x = x;
196
 
   req->y = y;
197
 
 
198
 
   if (!_XReply(dpy, (xReply *)&rep,
199
 
                (SIZEOF(xVMwareCtrlSetResReply) - SIZEOF(xReply)) >> 2,
200
 
                xFalse)) {
201
 
      goto exit;
202
 
   }
203
 
 
204
 
   ret = True;
205
 
 
206
 
exit:
207
 
   UnlockDisplay(dpy);
208
 
   SyncHandle();
209
 
 
210
 
   return ret;
211
 
}
212
 
 
213
 
 
214
 
/*
215
 
 *----------------------------------------------------------------------------
216
 
 *
217
 
 * VMwareCtrl_SetTopology --
218
 
 *
219
 
 *      Send the SetTopology command to the driver.
220
 
 *
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
223
 
 *      Solaris builds.
224
 
 *
225
 
 * Results:
226
 
 *      True if the resolution and xinerama topology were set. False otherwise.
227
 
 *
228
 
 * Side effects:
229
 
 *      None.
230
 
 *
231
 
 *----------------------------------------------------------------------------
232
 
 */
233
 
 
234
 
#ifndef NO_MULTIMON
235
 
Bool
236
 
VMwareCtrl_SetTopology(Display *dpy,          // IN:
237
 
                       int screen,            // IN:
238
 
                       xXineramaScreenInfo extents[], // IN:
239
 
                       int number)            // IN:
240
 
{
241
 
   xVMwareCtrlSetTopologyReply rep;
242
 
   xVMwareCtrlSetTopologyReq *req;
243
 
   XExtDisplayInfo *info = find_display(dpy);
244
 
   Bool ret = False;
245
 
   long len;
246
 
 
247
 
   VMwareCtrlCheckExtension(dpy, info, False);
248
 
   LockDisplay(dpy);
249
 
 
250
 
   GetReq(VMwareCtrlSetTopology, req);
251
 
   req->reqType = info->codes->major_opcode;
252
 
   req->VMwareCtrlReqType = X_VMwareCtrlSetTopology;
253
 
   req->screen = screen;
254
 
   req->number = number;
255
 
 
256
 
   len = ((long) number) << 1;
257
 
   SetReqLen(req, len, len);
258
 
   len <<= 2;
259
 
   _XSend(dpy, (char *)extents, len);
260
 
 
261
 
   if (!_XReply(dpy, (xReply *)&rep,
262
 
                (SIZEOF(xVMwareCtrlSetTopologyReply) - SIZEOF(xReply)) >> 2,
263
 
                xFalse)) {
264
 
      goto exit;
265
 
   }
266
 
 
267
 
   ret = True;
268
 
 
269
 
exit:
270
 
   UnlockDisplay(dpy);
271
 
   SyncHandle();
272
 
 
273
 
   return ret;
274
 
}
275
 
#endif