2
* Minimal implementation of PanoramiX/Xinerama
4
* This is used in rootless mode where the underlying window server
5
* already provides an abstracted view of multiple screens as one
8
* This code is largely based on panoramiX.c, which contains the
9
* following copyright notice:
11
/*****************************************************************
12
Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
13
Permission is hereby granted, free of charge, to any person obtaining a copy
14
of this software and associated documentation files (the "Software"), to deal
15
in the Software without restriction, including without limitation the rights
16
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
copies of the Software.
19
The above copyright notice and this permission notice shall be included in
20
all copies or substantial portions of the Software.
22
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25
DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
26
BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
27
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
28
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30
Except as contained in this notice, the name of Digital Equipment Corporation
31
shall not be used in advertising or otherwise to promote the sale, use or other
32
dealings in this Software without prior written authorization from Digital
33
Equipment Corporation.
34
******************************************************************/
35
/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/pseudoramiX.c,v 1.2 2002/10/16 21:13:33 dawes Exp $ */
37
#include "pseudoramiX.h"
39
#include "extnsionst.h"
40
#include "dixstruct.h"
42
#include "panoramiXproto.h"
45
extern int ProcPanoramiXQueryVersion (ClientPtr client);
47
static void PseudoramiXResetProc(ExtensionEntry *extEntry);
49
static int ProcPseudoramiXQueryVersion(ClientPtr client);
50
static int ProcPseudoramiXGetState(ClientPtr client);
51
static int ProcPseudoramiXGetScreenCount(ClientPtr client);
52
static int ProcPseudoramiXGetScreenSize(ClientPtr client);
53
static int ProcPseudoramiXIsActive(ClientPtr client);
54
static int ProcPseudoramiXQueryScreens(ClientPtr client);
55
static int ProcPseudoramiXDispatch(ClientPtr client);
57
static int SProcPseudoramiXQueryVersion(ClientPtr client);
58
static int SProcPseudoramiXGetState(ClientPtr client);
59
static int SProcPseudoramiXGetScreenCount(ClientPtr client);
60
static int SProcPseudoramiXGetScreenSize(ClientPtr client);
61
static int SProcPseudoramiXIsActive(ClientPtr client);
62
static int SProcPseudoramiXQueryScreens(ClientPtr client);
63
static int SProcPseudoramiXDispatch(ClientPtr client);
71
} PseudoramiXScreenRec;
73
static PseudoramiXScreenRec *pseudoramiXScreens = NULL;
74
static int pseudoramiXScreensAllocated = 0;
75
static int pseudoramiXNumScreens = 0;
76
static unsigned long pseudoramiXGeneration = 0;
79
// Add a PseudoramiX screen.
80
// The rest of the X server will know nothing about this screen.
81
// Can be called before or after extension init.
82
// Screens must be re-added once per generation.
84
PseudoramiXAddScreen(int x, int y, int w, int h)
86
PseudoramiXScreenRec *s;
88
if (noPseudoramiXExtension) return;
90
if (pseudoramiXNumScreens == pseudoramiXScreensAllocated) {
91
pseudoramiXScreensAllocated += pseudoramiXScreensAllocated + 1;
92
pseudoramiXScreens = xrealloc(pseudoramiXScreens,
93
pseudoramiXScreensAllocated *
94
sizeof(PseudoramiXScreenRec));
97
s = &pseudoramiXScreens[pseudoramiXNumScreens++];
105
// Initialize PseudoramiX.
106
// Copied from PanoramiXExtensionInit
107
void PseudoramiXExtensionInit(int argc, char *argv[])
109
Bool success = FALSE;
110
ExtensionEntry *extEntry;
112
if (noPseudoramiXExtension) return;
114
if (pseudoramiXNumScreens == 1 || aquaNumScreens == 1) {
115
// Only one screen - disable Xinerama extension.
116
noPseudoramiXExtension = TRUE;
120
// The server must not run the PanoramiX operations.
121
noPanoramiXExtension = TRUE;
123
if (pseudoramiXGeneration != serverGeneration) {
124
extEntry = AddExtension(PANORAMIX_PROTOCOL_NAME, 0, 0,
125
ProcPseudoramiXDispatch,
126
SProcPseudoramiXDispatch,
127
PseudoramiXResetProc,
128
StandardMinorOpcode);
130
ErrorF("PseudoramiXExtensionInit(): AddExtension failed\n");
132
pseudoramiXGeneration = serverGeneration;
138
ErrorF("%s Extension (PseudoramiX) failed to initialize\n",
139
PANORAMIX_PROTOCOL_NAME);
145
static void PseudoramiXResetProc(ExtensionEntry *extEntry)
147
pseudoramiXNumScreens = 0;
152
static int ProcPseudoramiXQueryVersion(ClientPtr client)
154
return ProcPanoramiXQueryVersion(client);
159
static int ProcPseudoramiXGetState(ClientPtr client)
161
REQUEST(xPanoramiXGetStateReq);
163
xPanoramiXGetStateReply rep;
166
REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
167
pWin = LookupWindow (stuff->window, client);
172
rep.sequenceNumber = client->sequence;
173
rep.state = !noPseudoramiXExtension;
174
if (client->swapped) {
175
swaps (&rep.sequenceNumber, n);
176
swapl (&rep.length, n);
177
swaps (&rep.state, n);
179
WriteToClient (client, sizeof (xPanoramiXGetStateReply), (char *) &rep);
180
return client->noClientException;
185
static int ProcPseudoramiXGetScreenCount(ClientPtr client)
187
REQUEST(xPanoramiXGetScreenCountReq);
189
xPanoramiXGetScreenCountReply rep;
192
REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
193
pWin = LookupWindow (stuff->window, client);
198
rep.sequenceNumber = client->sequence;
199
rep.ScreenCount = pseudoramiXNumScreens;
200
if (client->swapped) {
201
swaps (&rep.sequenceNumber, n);
202
swapl (&rep.length, n);
203
swaps (&rep.ScreenCount, n);
205
WriteToClient (client, sizeof(xPanoramiXGetScreenCountReply), (char *)&rep);
206
return client->noClientException;
211
static int ProcPseudoramiXGetScreenSize(ClientPtr client)
213
REQUEST(xPanoramiXGetScreenSizeReq);
215
xPanoramiXGetScreenSizeReply rep;
218
REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
219
pWin = LookupWindow (stuff->window, client);
224
rep.sequenceNumber = client->sequence;
225
/* screen dimensions */
226
rep.width = pseudoramiXScreens[stuff->screen].w;
227
// was panoramiXdataPtr[stuff->screen].width;
228
rep.height = pseudoramiXScreens[stuff->screen].h;
229
// was panoramiXdataPtr[stuff->screen].height;
230
if (client->swapped) {
231
swaps (&rep.sequenceNumber, n);
232
swapl (&rep.length, n);
233
swaps (&rep.width, n);
234
swaps (&rep.height, n);
236
WriteToClient (client, sizeof(xPanoramiXGetScreenSizeReply), (char *)&rep);
237
return client->noClientException;
242
static int ProcPseudoramiXIsActive(ClientPtr client)
244
/* REQUEST(xXineramaIsActiveReq); */
245
xXineramaIsActiveReply rep;
247
REQUEST_SIZE_MATCH(xXineramaIsActiveReq);
251
rep.sequenceNumber = client->sequence;
252
rep.state = !noPseudoramiXExtension;
253
if (client->swapped) {
255
swaps (&rep.sequenceNumber, n);
256
swapl (&rep.length, n);
257
swapl (&rep.state, n);
259
WriteToClient (client, sizeof (xXineramaIsActiveReply), (char *) &rep);
260
return client->noClientException;
265
static int ProcPseudoramiXQueryScreens(ClientPtr client)
267
/* REQUEST(xXineramaQueryScreensReq); */
268
xXineramaQueryScreensReply rep;
270
REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
273
rep.sequenceNumber = client->sequence;
274
rep.number = noPseudoramiXExtension ? 0 : pseudoramiXNumScreens;
275
rep.length = rep.number * sz_XineramaScreenInfo >> 2;
276
if (client->swapped) {
278
swaps (&rep.sequenceNumber, n);
279
swapl (&rep.length, n);
280
swapl (&rep.number, n);
282
WriteToClient (client, sizeof (xXineramaQueryScreensReply), (char *) &rep);
284
if (!noPseudoramiXExtension) {
285
xXineramaScreenInfo scratch;
288
for(i = 0; i < pseudoramiXNumScreens; i++) {
289
scratch.x_org = pseudoramiXScreens[i].x;
290
scratch.y_org = pseudoramiXScreens[i].y;
291
scratch.width = pseudoramiXScreens[i].w;
292
scratch.height = pseudoramiXScreens[i].h;
294
if(client->swapped) {
296
swaps (&scratch.x_org, n);
297
swaps (&scratch.y_org, n);
298
swaps (&scratch.width, n);
299
swaps (&scratch.height, n);
301
WriteToClient (client, sz_XineramaScreenInfo, (char *) &scratch);
305
return client->noClientException;
310
static int ProcPseudoramiXDispatch (ClientPtr client)
314
case X_PanoramiXQueryVersion:
315
return ProcPseudoramiXQueryVersion(client);
316
case X_PanoramiXGetState:
317
return ProcPseudoramiXGetState(client);
318
case X_PanoramiXGetScreenCount:
319
return ProcPseudoramiXGetScreenCount(client);
320
case X_PanoramiXGetScreenSize:
321
return ProcPseudoramiXGetScreenSize(client);
322
case X_XineramaIsActive:
323
return ProcPseudoramiXIsActive(client);
324
case X_XineramaQueryScreens:
325
return ProcPseudoramiXQueryScreens(client);
333
SProcPseudoramiXQueryVersion (ClientPtr client)
335
REQUEST(xPanoramiXQueryVersionReq);
338
swaps(&stuff->length,n);
339
REQUEST_SIZE_MATCH (xPanoramiXQueryVersionReq);
340
return ProcPseudoramiXQueryVersion(client);
344
SProcPseudoramiXGetState(ClientPtr client)
346
REQUEST(xPanoramiXGetStateReq);
349
swaps (&stuff->length, n);
350
REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
351
return ProcPseudoramiXGetState(client);
355
SProcPseudoramiXGetScreenCount(ClientPtr client)
357
REQUEST(xPanoramiXGetScreenCountReq);
360
swaps (&stuff->length, n);
361
REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
362
return ProcPseudoramiXGetScreenCount(client);
366
SProcPseudoramiXGetScreenSize(ClientPtr client)
368
REQUEST(xPanoramiXGetScreenSizeReq);
371
swaps (&stuff->length, n);
372
REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
373
return ProcPseudoramiXGetScreenSize(client);
378
SProcPseudoramiXIsActive(ClientPtr client)
380
REQUEST(xXineramaIsActiveReq);
383
swaps (&stuff->length, n);
384
REQUEST_SIZE_MATCH(xXineramaIsActiveReq);
385
return ProcPseudoramiXIsActive(client);
390
SProcPseudoramiXQueryScreens(ClientPtr client)
392
REQUEST(xXineramaQueryScreensReq);
395
swaps (&stuff->length, n);
396
REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
397
return ProcPseudoramiXQueryScreens(client);
402
SProcPseudoramiXDispatch (ClientPtr client)
406
case X_PanoramiXQueryVersion:
407
return SProcPseudoramiXQueryVersion(client);
408
case X_PanoramiXGetState:
409
return SProcPseudoramiXGetState(client);
410
case X_PanoramiXGetScreenCount:
411
return SProcPseudoramiXGetScreenCount(client);
412
case X_PanoramiXGetScreenSize:
413
return SProcPseudoramiXGetScreenSize(client);
414
case X_XineramaIsActive:
415
return SProcPseudoramiXIsActive(client);
416
case X_XineramaQueryScreens:
417
return SProcPseudoramiXQueryScreens(client);