Magellan Linux

Contents of /trunk/tigervnc/patches/tigervnc-1.0.1-xserver19.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1251 - (show annotations) (download)
Fri Jan 21 19:42:53 2011 UTC (13 years, 3 months ago) by niro
File size: 44295 byte(s)
added more upstream fixes as well: r4088, r4089, r4090, r4091, r4092, r4112
1 diff -Naur tigervnc-1.0.1/unix/xserver/hw/vnc/Input.cc tigervnc-1.0.1-magellan/unix/xserver/hw/vnc/Input.cc
2 --- tigervnc-1.0.1/unix/xserver/hw/vnc/Input.cc 2011-01-21 20:43:03.000000000 +0100
3 +++ tigervnc-1.0.1-magellan/unix/xserver/hw/vnc/Input.cc 2011-01-21 20:52:21.000000000 +0100
4 @@ -679,6 +679,8 @@
5 action = down ? KeyPress : KeyRelease;
6 n = GetKeyboardEvents(eventq, keyboardDev, action, kc);
7 enqueueEvents(keyboardDev, n);
8 +
9 + FREE_MAPS;
10
11 /*
12 * When faking a modifier we are putting a keycode (which can
13 diff -Naur tigervnc-1.0.1/unix/xserver/hw/vnc/vncHooks.cc tigervnc-1.0.1-magellan/unix/xserver/hw/vnc/vncHooks.cc
14 --- tigervnc-1.0.1/unix/xserver/hw/vnc/vncHooks.cc 2011-01-21 20:42:01.000000000 +0100
15 +++ tigervnc-1.0.1-magellan/unix/xserver/hw/vnc/vncHooks.cc 2011-01-21 20:46:08.000000000 +0100
16 @@ -93,11 +93,16 @@
17 #if XORG == 15
18 static DevPrivateKey vncHooksScreenPrivateKey = &vncHooksScreenPrivateKey;
19 static DevPrivateKey vncHooksGCPrivateKey = &vncHooksGCPrivateKey;
20 -#else
21 +#elif XORG < 19
22 static int vncHooksScreenPrivateKeyIndex;
23 static int vncHooksGCPrivateKeyIndex;
24 static DevPrivateKey vncHooksScreenPrivateKey = &vncHooksScreenPrivateKeyIndex;
25 static DevPrivateKey vncHooksGCPrivateKey = &vncHooksGCPrivateKeyIndex;
26 +#else
27 +static DevPrivateKeyRec vncHooksScreenKeyRec;
28 +static DevPrivateKeyRec vncHooksGCKeyRec;
29 +#define vncHooksScreenPrivateKey (&vncHooksScreenKeyRec)
30 +#define vncHooksGCPrivateKey (&vncHooksGCKeyRec)
31 #endif
32
33 #define vncHooksScreenPrivate(pScreen) \
34 @@ -223,6 +228,7 @@
35 {
36 vncHooksScreenPtr vncHooksScreen;
37
38 +#if XORG < 19
39 if (!dixRequestPrivate(vncHooksScreenPrivateKey, sizeof(vncHooksScreenRec))) {
40 ErrorF("vncHooksInit: Allocation of vncHooksScreen failed\n");
41 return FALSE;
42 @@ -232,6 +238,20 @@
43 return FALSE;
44 }
45
46 +#else
47 + if (!dixRegisterPrivateKey(&vncHooksScreenKeyRec, PRIVATE_SCREEN,
48 + sizeof(vncHooksScreenRec))) {
49 + ErrorF("vncHooksInit: Allocation of vncHooksScreen failed\n");
50 + return FALSE;
51 + }
52 + if (!dixRegisterPrivateKey(&vncHooksGCKeyRec, PRIVATE_GC,
53 + sizeof(vncHooksGCRec))) {
54 + ErrorF("vncHooksInit: Allocation of vncHooksGCRec failed\n");
55 + return FALSE;
56 + }
57 +
58 +#endif
59 +
60 vncHooksScreen = vncHooksScreenPrivate(pScreen);
61
62 vncHooksScreen->desktop = desktop;
63 @@ -344,7 +364,7 @@
64 static Bool vncHooksCreateGC(GCPtr pGC)
65 {
66 SCREEN_UNWRAP(pGC->pScreen, CreateGC);
67 -
68 +
69 vncHooksGCPtr vncHooksGC = vncHooksGCPrivate(pGC);
70
71 Bool ret = (*pScreen->CreateGC) (pGC);
72 diff -Naur tigervnc-1.0.1/unix/xserver/hw/vnc/xorg-version.h tigervnc-1.0.1-magellan/unix/xserver/hw/vnc/xorg-version.h
73 --- tigervnc-1.0.1/unix/xserver/hw/vnc/xorg-version.h 2011-01-21 20:42:27.000000000 +0100
74 +++ tigervnc-1.0.1-magellan/unix/xserver/hw/vnc/xorg-version.h 2011-01-21 20:44:22.000000000 +0100
75 @@ -30,8 +30,12 @@
76 #define XORG 16
77 #elif XORG_VERSION_CURRENT < ((1 * 10000000) + (7 * 100000) + (99 * 1000))
78 #define XORG 17
79 +#elif XORG_VERSION_CURRENT < ((1 * 10000000) + (8 * 100000) + (99 * 1000))
80 +#define XORG 18
81 +#elif XORG_VERSION_CURRENT < ((1 * 10000000) + (9 * 100000) + (99 * 1000))
82 +#define XORG 19
83 #else
84 -#error "X.Org newer than 1.7 is not supported"
85 +#error "X.Org newer than 1.9 is not supported"
86 #endif
87
88 #endif
89 diff -Naur tigervnc-1.0.1/unix/xserver/hw/vnc/XserverDesktop.cc tigervnc-1.0.1-magellan/unix/xserver/hw/vnc/XserverDesktop.cc
90 --- tigervnc-1.0.1/unix/xserver/hw/vnc/XserverDesktop.cc 2011-01-21 20:43:00.000000000 +0100
91 +++ tigervnc-1.0.1-magellan/unix/xserver/hw/vnc/XserverDesktop.cc 2011-01-21 20:47:41.000000000 +0100
92 @@ -768,8 +768,14 @@
93 region.get_rects(&rects);
94 for (i = rects.begin(); i != rects.end(); i++) {
95 for (int y = i->tl.y; y < i->br.y; y++) {
96 - (*pScreen->GetImage) ((DrawablePtr)WindowTable[pScreen->myNum],
97 - i->tl.x, y, i->width(), 1,
98 + DrawablePtr pDrawable;
99 +#if XORG < 19
100 + pDrawable = (DrawablePtr) WindowTable[pScreen->myNum];
101 +#else
102 + pDrawable = (DrawablePtr) pScreen->root;
103 +#endif
104 +
105 + (*pScreen->GetImage) (pDrawable, i->tl.x, y, i->width(), 1,
106 ZPixmap, (unsigned long)~0L,
107 ((char*)data
108 + y * bytesPerRow + i->tl.x * bytesPerPixel));
109 diff -Naur tigervnc-1.0.1/unix/xserver/hw/vnc/XserverDesktop.cc.orig tigervnc-1.0.1-magellan/unix/xserver/hw/vnc/XserverDesktop.cc.orig
110 --- tigervnc-1.0.1/unix/xserver/hw/vnc/XserverDesktop.cc.orig 2011-01-21 20:42:27.000000000 +0100
111 +++ tigervnc-1.0.1-magellan/unix/xserver/hw/vnc/XserverDesktop.cc.orig 2011-01-21 20:40:33.000000000 +0100
112 @@ -167,8 +167,7 @@
113 if (httpListener)
114 httpServer = new FileHTTPServer(this);
115
116 - pointerDevice = new PointerDevice(server);
117 - keyboardDevice = new KeyboardDevice();
118 + inputDevice = new InputDevice(server);
119 }
120
121 XserverDesktop::~XserverDesktop()
122 @@ -177,8 +176,7 @@
123 delete [] data;
124 TimerFree(deferredUpdateTimer);
125 TimerFree(dummyTimer);
126 - delete pointerDevice;
127 - delete keyboardDevice;
128 + delete inputDevice;
129 delete httpServer;
130 delete server;
131 }
132 @@ -589,7 +587,7 @@
133 }
134 }
135
136 - pointerDevice->Sync();
137 + inputDevice->PointerSync();
138 }
139
140 int timeout = server->checkTimeouts();
141 @@ -648,8 +646,8 @@
142
143 void XserverDesktop::pointerEvent(const Point& pos, int buttonMask)
144 {
145 - pointerDevice->Move(pos);
146 - pointerDevice->ButtonAction(buttonMask);
147 + inputDevice->PointerMove(pos);
148 + inputDevice->PointerButtonAction(buttonMask);
149 }
150
151 void XserverDesktop::clientCutText(const char* str, int len)
152 @@ -810,7 +808,7 @@
153 void XserverDesktop::keyEvent(rdr::U32 keysym, bool down)
154 {
155 if (down)
156 - keyboardDevice->Press(keysym);
157 + inputDevice->KeyboardPress(keysym);
158 else
159 - keyboardDevice->Release(keysym);
160 + inputDevice->KeyboardRelease(keysym);
161 }
162 diff -Naur tigervnc-1.0.1/unix/xserver/hw/vnc/xvnc.cc tigervnc-1.0.1-magellan/unix/xserver/hw/vnc/xvnc.cc
163 --- tigervnc-1.0.1/unix/xserver/hw/vnc/xvnc.cc 2011-01-21 20:42:27.000000000 +0100
164 +++ tigervnc-1.0.1-magellan/unix/xserver/hw/vnc/xvnc.cc 2011-01-21 20:49:23.000000000 +0100
165 @@ -609,7 +609,11 @@
166
167 for (i = 0; i < entries; i++) ppix[i] = i;
168 /* XXX truecolor */
169 +#if XORG < 19
170 QueryColors(pmap, entries, ppix, prgb);
171 +#else
172 + QueryColors(pmap, entries, ppix, prgb, serverClient);
173 +#endif
174
175 for (i = 0; i < entries; i++) { /* convert xrgbs to xColorItems */
176 defs[i].pixel = ppix[i] & 0xff; /* change pixel to index */
177 @@ -857,7 +861,11 @@
178 static void
179 xf86SetRootClip (ScreenPtr pScreen, Bool enable)
180 {
181 +#if XORG < 19
182 WindowPtr pWin = WindowTable[pScreen->myNum];
183 +#else
184 + WindowPtr pWin = pScreen->root;
185 +#endif
186 WindowPtr pChild;
187 Bool WasViewable = (Bool)(pWin->viewable);
188 Bool anyMarked = FALSE;
189 diff -Naur tigervnc-1.0.1/unix/xserver/hw/vnc/xvnc.cc.orig tigervnc-1.0.1-magellan/unix/xserver/hw/vnc/xvnc.cc.orig
190 --- tigervnc-1.0.1/unix/xserver/hw/vnc/xvnc.cc.orig 1970-01-01 01:00:00.000000000 +0100
191 +++ tigervnc-1.0.1-magellan/unix/xserver/hw/vnc/xvnc.cc.orig 2011-01-21 20:48:36.000000000 +0100
192 @@ -0,0 +1,1328 @@
193 +/* Copyright (c) 1993 X Consortium
194 + Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
195 + Copyright (C) 2009 Pierre Ossman for Cendio AB
196 +
197 +Permission is hereby granted, free of charge, to any person obtaining
198 +a copy of this software and associated documentation files (the
199 +"Software"), to deal in the Software without restriction, including
200 +without limitation the rights to use, copy, modify, merge, publish,
201 +distribute, sublicense, and/or sell copies of the Software, and to
202 +permit persons to whom the Software is furnished to do so, subject to
203 +the following conditions:
204 +
205 +The above copyright notice and this permission notice shall be included
206 +in all copies or substantial portions of the Software.
207 +
208 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
209 +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
210 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
211 +IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
212 +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
213 +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
214 +OTHER DEALINGS IN THE SOFTWARE.
215 +
216 +Except as contained in this notice, the name of the X Consortium shall
217 +not be used in advertising or otherwise to promote the sale, use or
218 +other dealings in this Software without prior written authorization
219 +from the X Consortium.
220 +
221 +*/
222 +
223 +#ifdef HAVE_DIX_CONFIG_H
224 +#include <dix-config.h>
225 +#endif
226 +
227 +#include <rfb/Configuration.h>
228 +#include <rfb/Logger_stdio.h>
229 +#include <rfb/LogWriter.h>
230 +#include <network/TcpSocket.h>
231 +#include "vncExtInit.h"
232 +#include "xorg-version.h"
233 +
234 +extern "C" {
235 +#define class c_class
236 +#define public c_public
237 +#ifdef WIN32
238 +#include <X11/Xwinsock.h>
239 +#endif
240 +#include <stdio.h>
241 +#include <X11/X.h>
242 +#define NEED_EVENTS
243 +#include <X11/Xproto.h>
244 +#include <X11/Xos.h>
245 +#include "scrnintstr.h"
246 +#include "servermd.h"
247 +#include "fb.h"
248 +#include "mi.h"
249 +#include "mibstore.h"
250 +#include "colormapst.h"
251 +#include "gcstruct.h"
252 +#include "input.h"
253 +#include "mipointer.h"
254 +#define new New
255 +#include "micmap.h"
256 +#undef new
257 +#include <sys/types.h>
258 +#include <sys/stat.h>
259 +#include <errno.h>
260 +#ifndef WIN32
261 +#include <sys/param.h>
262 +#endif
263 +#include <X11/XWDFile.h>
264 +#ifdef HAS_SHM
265 +#include <sys/ipc.h>
266 +#include <sys/shm.h>
267 +#endif /* HAS_SHM */
268 +#include "dix.h"
269 +#include "miline.h"
270 +#include "inputstr.h"
271 +#ifdef RANDR
272 +#include "randrstr.h"
273 +#endif /* RANDR */
274 +#include <X11/keysym.h>
275 + extern char buildtime[];
276 +#if XORG >= 17
277 +#undef VENDOR_RELEASE
278 +#undef VENDOR_STRING
279 +#include "version-config.h"
280 +#include "site.h"
281 +#endif
282 +#undef class
283 +#undef public
284 +}
285 +
286 +#define XVNCVERSION "TigerVNC 1.0.1"
287 +#define XVNCCOPYRIGHT ("Copyright (C) 2002-2005 RealVNC Ltd.\n" \
288 + "Copyright (C) 2000-2006 Constantin Kaplinsky\n" \
289 + "Copyright (C) 2004-2009 Peter Astrand for Cendio AB\n" \
290 + "See http://www.tigervnc.org for information on TigerVNC.\n")
291 +
292 +
293 +extern char *display;
294 +extern int monitorResolution;
295 +
296 +#define VFB_DEFAULT_WIDTH 1024
297 +#define VFB_DEFAULT_HEIGHT 768
298 +#define VFB_DEFAULT_DEPTH 24
299 +#define VFB_DEFAULT_WHITEPIXEL 0xffffffff
300 +#define VFB_DEFAULT_BLACKPIXEL 0
301 +#define VFB_DEFAULT_LINEBIAS 0
302 +#define XWD_WINDOW_NAME_LEN 60
303 +
304 +typedef struct
305 +{
306 + int width;
307 + int height;
308 +
309 + int depth;
310 +
311 + /* Computed when allocated */
312 +
313 + int paddedBytesWidth;
314 + int paddedWidth;
315 +
316 + int bitsPerPixel;
317 +
318 + /* Private */
319 +
320 + int sizeInBytes;
321 +
322 + void *pfbMemory;
323 +
324 +#ifdef HAS_SHM
325 + int shmid;
326 +#endif
327 +} vfbFramebufferInfo, *vfbFramebufferInfoPtr;
328 +
329 +typedef struct
330 +{
331 + int scrnum;
332 +
333 + Pixel blackPixel;
334 + Pixel whitePixel;
335 +
336 + unsigned int lineBias;
337 +
338 + CloseScreenProcPtr closeScreen;
339 +
340 + vfbFramebufferInfo fb;
341 +
342 + Bool pixelFormatDefined;
343 + Bool rgbNotBgr;
344 + int redBits, greenBits, blueBits;
345 +} vfbScreenInfo, *vfbScreenInfoPtr;
346 +
347 +static int vfbNumScreens;
348 +static vfbScreenInfo vfbScreens[MAXSCREENS];
349 +static Bool vfbPixmapDepths[33];
350 +typedef enum { NORMAL_MEMORY_FB, SHARED_MEMORY_FB } fbMemType;
351 +static fbMemType fbmemtype = NORMAL_MEMORY_FB;
352 +static int lastScreen = -1;
353 +static Bool Render = TRUE;
354 +
355 +static bool displaySpecified = false;
356 +static bool wellKnownSocketsCreated = false;
357 +static char displayNumStr[16];
358 +
359 +
360 +static void
361 +vfbInitializePixmapDepths(void)
362 +{
363 + int i;
364 + vfbPixmapDepths[1] = TRUE; /* always need bitmaps */
365 + for (i = 2; i <= 32; i++)
366 + vfbPixmapDepths[i] = FALSE;
367 +}
368 +
369 +static void
370 +vfbInitializeDefaultScreens(void)
371 +{
372 + int i;
373 +
374 + for (i = 0; i < MAXSCREENS; i++)
375 + {
376 + vfbScreens[i].scrnum = i;
377 + vfbScreens[i].blackPixel = VFB_DEFAULT_BLACKPIXEL;
378 + vfbScreens[i].whitePixel = VFB_DEFAULT_WHITEPIXEL;
379 + vfbScreens[i].lineBias = VFB_DEFAULT_LINEBIAS;
380 + vfbScreens[i].fb.width = VFB_DEFAULT_WIDTH;
381 + vfbScreens[i].fb.height = VFB_DEFAULT_HEIGHT;
382 + vfbScreens[i].fb.pfbMemory = NULL;
383 + vfbScreens[i].fb.depth = VFB_DEFAULT_DEPTH;
384 + vfbScreens[i].pixelFormatDefined = FALSE;
385 + }
386 + vfbNumScreens = 1;
387 +}
388 +
389 +static int
390 +vfbBitsPerPixel(int depth)
391 +{
392 + if (depth == 1) return 1;
393 + else if (depth <= 8) return 8;
394 + else if (depth <= 16) return 16;
395 + else return 32;
396 +}
397 +
398 +static void vfbFreeFramebufferMemory(vfbFramebufferInfoPtr pfb);
399 +
400 +extern "C" {
401 +
402 +void ddxGiveUp()
403 +{
404 + int i;
405 +
406 + /* clean up the framebuffers */
407 + for (i = 0; i < vfbNumScreens; i++)
408 + vfbFreeFramebufferMemory(&vfbScreens[i].fb);
409 +}
410 +
411 +void
412 +AbortDDX()
413 +{
414 + ddxGiveUp();
415 +}
416 +
417 +#ifdef __DARWIN__
418 +void
419 +DarwinHandleGUI(int argc, char *argv[])
420 +{
421 +}
422 +
423 +void GlxExtensionInit();
424 +void GlxWrapInitVisuals(void *procPtr);
425 +
426 +void
427 +DarwinGlxExtensionInit()
428 +{
429 + GlxExtensionInit();
430 +}
431 +
432 +void
433 +DarwinGlxWrapInitVisuals(
434 + void *procPtr)
435 +{
436 + GlxWrapInitVisuals(procPtr);
437 +}
438 +#endif
439 +
440 +void
441 +OsVendorInit()
442 +{
443 +}
444 +
445 +void
446 +OsVendorFatalError()
447 +{
448 +}
449 +
450 +void ddxBeforeReset(void)
451 +{
452 + return;
453 +}
454 +
455 +void
456 +ddxUseMsg()
457 +{
458 + ErrorF("\nXvnc %s - built %s\n%s", XVNCVERSION, buildtime, XVNCCOPYRIGHT);
459 + ErrorF("Underlying X server release %d, %s\n\n", VENDOR_RELEASE,
460 + VENDOR_STRING);
461 + ErrorF("-screen scrn WxHxD set screen's width, height, depth\n");
462 + ErrorF("-pixdepths list-of-int support given pixmap depths\n");
463 +#ifdef RENDER
464 + ErrorF("+/-render turn on/off RENDER extension support"
465 + "(default on)\n");
466 +#endif
467 + ErrorF("-linebias n adjust thin line pixelization\n");
468 + ErrorF("-blackpixel n pixel value for black\n");
469 + ErrorF("-whitepixel n pixel value for white\n");
470 +
471 +#ifdef HAS_SHM
472 + ErrorF("-shmem put framebuffers in shared memory\n");
473 +#endif
474 +
475 + ErrorF("-geometry WxH set screen 0's width, height\n");
476 + ErrorF("-depth D set screen 0's depth\n");
477 + ErrorF("-pixelformat fmt set pixel format (rgbNNN or bgrNNN)\n");
478 + ErrorF("-inetd has been launched from inetd\n");
479 + ErrorF("\nVNC parameters:\n");
480 +
481 + fprintf(stderr,"\n"
482 + "Parameters can be turned on with -<param> or off with -<param>=0\n"
483 + "Parameters which take a value can be specified as "
484 + "-<param> <value>\n"
485 + "Other valid forms are <param>=<value> -<param>=<value> "
486 + "--<param>=<value>\n"
487 + "Parameter names are case-insensitive. The parameters are:\n\n");
488 + rfb::Configuration::listParams(79, 14);
489 + }
490 +}
491 +
492 +/* ddxInitGlobals - called by |InitGlobals| from os/util.c */
493 +void ddxInitGlobals(void)
494 +{
495 +}
496 +
497 +static
498 +bool displayNumFree(int num)
499 +{
500 + try {
501 + network::TcpListener l(6000+num);
502 + } catch (rdr::Exception& e) {
503 + return false;
504 + }
505 + char file[256];
506 + sprintf(file, "/tmp/.X%d-lock", num);
507 + if (access(file, F_OK) == 0) return false;
508 + sprintf(file, "/tmp/.X11-unix/X%d", num);
509 + if (access(file, F_OK) == 0) return false;
510 + sprintf(file, "/usr/spool/sockets/X11/%d", num);
511 + if (access(file, F_OK) == 0) return false;
512 + return true;
513 +}
514 +
515 +int
516 +ddxProcessArgument(int argc, char *argv[], int i)
517 +{
518 + static Bool firstTime = TRUE;
519 +
520 + if (firstTime)
521 + {
522 + vfbInitializeDefaultScreens();
523 + vfbInitializePixmapDepths();
524 + firstTime = FALSE;
525 + rfb::initStdIOLoggers();
526 + rfb::LogWriter::setLogParams("*:stderr:30");
527 + }
528 +
529 + if (argv[i][0] == ':')
530 + displaySpecified = true;
531 +
532 + if (strcmp (argv[i], "-screen") == 0) /* -screen n WxHxD */
533 + {
534 + int screenNum;
535 + if (i + 2 >= argc) UseMsg();
536 + screenNum = atoi(argv[i+1]);
537 + if (screenNum < 0 || screenNum >= MAXSCREENS)
538 + {
539 + ErrorF("Invalid screen number %d\n", screenNum);
540 + UseMsg();
541 + }
542 + if (3 != sscanf(argv[i+2], "%dx%dx%d",
543 + &vfbScreens[screenNum].fb.width,
544 + &vfbScreens[screenNum].fb.height,
545 + &vfbScreens[screenNum].fb.depth))
546 + {
547 + ErrorF("Invalid screen configuration %s\n", argv[i+2]);
548 + UseMsg();
549 + }
550 +
551 + if (screenNum >= vfbNumScreens)
552 + vfbNumScreens = screenNum + 1;
553 + lastScreen = screenNum;
554 + return 3;
555 + }
556 +
557 + if (strcmp (argv[i], "-pixdepths") == 0) /* -pixdepths list-of-depth */
558 + {
559 + int depth, ret = 1;
560 +
561 + if (++i >= argc) UseMsg();
562 + while ((i < argc) && (depth = atoi(argv[i++])) != 0)
563 + {
564 + if (depth < 0 || depth > 32)
565 + {
566 + ErrorF("Invalid pixmap depth %d\n", depth);
567 + UseMsg();
568 + }
569 + vfbPixmapDepths[depth] = TRUE;
570 + ret++;
571 + }
572 + return ret;
573 + }
574 +
575 + if (strcmp (argv[i], "+render") == 0) /* +render */
576 + {
577 + Render = TRUE;
578 + return 1;
579 + }
580 +
581 + if (strcmp (argv[i], "-render") == 0) /* -render */
582 + {
583 + Render = FALSE;
584 + return 1;
585 + }
586 +
587 + if (strcmp (argv[i], "-blackpixel") == 0) /* -blackpixel n */
588 + {
589 + Pixel pix;
590 + if (++i >= argc) UseMsg();
591 + pix = atoi(argv[i]);
592 + if (-1 == lastScreen)
593 + {
594 + int i;
595 + for (i = 0; i < MAXSCREENS; i++)
596 + {
597 + vfbScreens[i].blackPixel = pix;
598 + }
599 + }
600 + else
601 + {
602 + vfbScreens[lastScreen].blackPixel = pix;
603 + }
604 + return 2;
605 + }
606 +
607 + if (strcmp (argv[i], "-whitepixel") == 0) /* -whitepixel n */
608 + {
609 + Pixel pix;
610 + if (++i >= argc) UseMsg();
611 + pix = atoi(argv[i]);
612 + if (-1 == lastScreen)
613 + {
614 + int i;
615 + for (i = 0; i < MAXSCREENS; i++)
616 + {
617 + vfbScreens[i].whitePixel = pix;
618 + }
619 + }
620 + else
621 + {
622 + vfbScreens[lastScreen].whitePixel = pix;
623 + }
624 + return 2;
625 + }
626 +
627 + if (strcmp (argv[i], "-linebias") == 0) /* -linebias n */
628 + {
629 + unsigned int linebias;
630 + if (++i >= argc) UseMsg();
631 + linebias = atoi(argv[i]);
632 + if (-1 == lastScreen)
633 + {
634 + int i;
635 + for (i = 0; i < MAXSCREENS; i++)
636 + {
637 + vfbScreens[i].lineBias = linebias;
638 + }
639 + }
640 + else
641 + {
642 + vfbScreens[lastScreen].lineBias = linebias;
643 + }
644 + return 2;
645 + }
646 +
647 +#ifdef HAS_SHM
648 + if (strcmp (argv[i], "-shmem") == 0) /* -shmem */
649 + {
650 + fbmemtype = SHARED_MEMORY_FB;
651 + return 1;
652 + }
653 +#endif
654 +
655 + if (strcmp(argv[i], "-geometry") == 0)
656 + {
657 + if (++i >= argc) UseMsg();
658 + if (sscanf(argv[i],"%dx%d",&vfbScreens[0].fb.width,
659 + &vfbScreens[0].fb.height) != 2) {
660 + ErrorF("Invalid geometry %s\n", argv[i]);
661 + UseMsg();
662 + }
663 + return 2;
664 + }
665 +
666 + if (strcmp(argv[i], "-depth") == 0)
667 + {
668 + if (++i >= argc) UseMsg();
669 + vfbScreens[0].fb.depth = atoi(argv[i]);
670 + return 2;
671 + }
672 +
673 + if (strcmp(argv[i], "-pixelformat") == 0)
674 + {
675 + char rgbbgr[4];
676 + int bits1, bits2, bits3;
677 + if (++i >= argc) UseMsg();
678 + if (sscanf(argv[i], "%3s%1d%1d%1d", rgbbgr,&bits1,&bits2,&bits3) < 4) {
679 + ErrorF("Invalid pixel format %s\n", argv[i]);
680 + UseMsg();
681 + }
682 +
683 +#define SET_PIXEL_FORMAT(vfbScreen) \
684 + (vfbScreen).pixelFormatDefined = TRUE; \
685 + (vfbScreen).fb.depth = bits1 + bits2 + bits3; \
686 + (vfbScreen).greenBits = bits2; \
687 + if (strcasecmp(rgbbgr, "bgr") == 0) { \
688 + (vfbScreen).rgbNotBgr = FALSE; \
689 + (vfbScreen).redBits = bits3; \
690 + (vfbScreen).blueBits = bits1; \
691 + } else if (strcasecmp(rgbbgr, "rgb") == 0) { \
692 + (vfbScreen).rgbNotBgr = TRUE; \
693 + (vfbScreen).redBits = bits1; \
694 + (vfbScreen).blueBits = bits3; \
695 + } else { \
696 + ErrorF("Invalid pixel format %s\n", argv[i]); \
697 + UseMsg(); \
698 + }
699 +
700 + if (-1 == lastScreen)
701 + {
702 + int i;
703 + for (i = 0; i < MAXSCREENS; i++)
704 + {
705 + SET_PIXEL_FORMAT(vfbScreens[i]);
706 + }
707 + }
708 + else
709 + {
710 + SET_PIXEL_FORMAT(vfbScreens[lastScreen]);
711 + }
712 +
713 + return 2;
714 + }
715 +
716 + if (strcmp(argv[i], "-inetd") == 0)
717 + {
718 + dup2(0,3);
719 + vncInetdSock = 3;
720 + close(2);
721 +
722 + if (!displaySpecified) {
723 + int port = network::TcpSocket::getSockPort(vncInetdSock);
724 + int displayNum = port - 5900;
725 + if (displayNum < 0 || displayNum > 99 || !displayNumFree(displayNum)) {
726 + for (displayNum = 1; displayNum < 100; displayNum++)
727 + if (displayNumFree(displayNum)) break;
728 +
729 + if (displayNum == 100)
730 + FatalError("Xvnc error: no free display number for -inetd");
731 + }
732 +
733 + display = displayNumStr;
734 + sprintf(displayNumStr, "%d", displayNum);
735 + }
736 +
737 + return 1;
738 + }
739 +
740 + if (rfb::Configuration::setParam(argv[i]))
741 + return 1;
742 +
743 + if (argv[i][0] == '-' && i+1 < argc) {
744 + if (rfb::Configuration::setParam(&argv[i][1], argv[i+1]))
745 + return 2;
746 + }
747 +
748 + return 0;
749 +}
750 +
751 +#ifdef DDXTIME /* from ServerOSDefines */
752 +CARD32
753 +GetTimeInMillis()
754 +{
755 + struct timeval tp;
756 +
757 + X_GETTIMEOFDAY(&tp);
758 + return(tp.tv_sec * 1000) + (tp.tv_usec / 1000);
759 +}
760 +#endif
761 +
762 +static ColormapPtr InstalledMaps[MAXSCREENS];
763 +
764 +static int
765 +vfbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps)
766 +{
767 + /* By the time we are processing requests, we can guarantee that there
768 + * is always a colormap installed */
769 + *pmaps = InstalledMaps[pScreen->myNum]->mid;
770 + return (1);
771 +}
772 +
773 +
774 +static void
775 +vfbInstallColormap(ColormapPtr pmap)
776 +{
777 + int index = pmap->pScreen->myNum;
778 + ColormapPtr oldpmap = InstalledMaps[index];
779 +
780 + if (pmap != oldpmap)
781 + {
782 + int entries;
783 + VisualPtr pVisual;
784 + Pixel * ppix;
785 + xrgb * prgb;
786 + xColorItem *defs;
787 + int i;
788 +
789 + if(oldpmap != (ColormapPtr)None)
790 + WalkTree(pmap->pScreen, TellLostMap, (char *)&oldpmap->mid);
791 + /* Install pmap */
792 + InstalledMaps[index] = pmap;
793 + WalkTree(pmap->pScreen, TellGainedMap, (char *)&pmap->mid);
794 +
795 + entries = pmap->pVisual->ColormapEntries;
796 + pVisual = pmap->pVisual;
797 +
798 + ppix = (Pixel *)xalloc(entries * sizeof(Pixel));
799 + prgb = (xrgb *)xalloc(entries * sizeof(xrgb));
800 + defs = (xColorItem *)xalloc(entries * sizeof(xColorItem));
801 +
802 + for (i = 0; i < entries; i++) ppix[i] = i;
803 + /* XXX truecolor */
804 + QueryColors(pmap, entries, ppix, prgb);
805 +
806 + for (i = 0; i < entries; i++) { /* convert xrgbs to xColorItems */
807 + defs[i].pixel = ppix[i] & 0xff; /* change pixel to index */
808 + defs[i].red = prgb[i].red;
809 + defs[i].green = prgb[i].green;
810 + defs[i].blue = prgb[i].blue;
811 + defs[i].flags = DoRed|DoGreen|DoBlue;
812 + }
813 + (*pmap->pScreen->StoreColors)(pmap, entries, defs);
814 +
815 + xfree(ppix);
816 + xfree(prgb);
817 + xfree(defs);
818 + }
819 +}
820 +
821 +static void
822 +vfbUninstallColormap(ColormapPtr pmap)
823 +{
824 + ColormapPtr curpmap = InstalledMaps[pmap->pScreen->myNum];
825 +
826 + if(pmap == curpmap)
827 + {
828 + if (pmap->mid != pmap->pScreen->defColormap)
829 + {
830 + curpmap = (ColormapPtr) LookupIDByType(pmap->pScreen->defColormap,
831 + RT_COLORMAP);
832 + (*pmap->pScreen->InstallColormap)(curpmap);
833 + }
834 + }
835 +}
836 +
837 +static Bool
838 +vfbSaveScreen(ScreenPtr pScreen, int on)
839 +{
840 + return TRUE;
841 +}
842 +
843 +#ifdef HAS_SHM
844 +static void
845 +vfbAllocateSharedMemoryFramebuffer(vfbFramebufferInfoPtr pfb)
846 +{
847 + /* create the shared memory segment */
848 +
849 + pfb->shmid = shmget(IPC_PRIVATE, pfb->sizeInBytes, IPC_CREAT|0777);
850 + if (pfb->shmid < 0) {
851 + perror("shmget");
852 + ErrorF("shmget %d bytes failed, errno %d", pfb->sizeInBytes, errno);
853 + return;
854 + }
855 +
856 + /* try to attach it */
857 +
858 + pfb->pfbMemory = shmat(pfb->shmid, 0, 0);
859 + if (-1 == (long)pfb->pfbMemory) {
860 + perror("shmat");
861 + ErrorF("shmat failed, errno %d", errno);
862 + pfb->pfbMemory = NULL;
863 + return;
864 + }
865 +}
866 +#endif /* HAS_SHM */
867 +
868 +
869 +static void *
870 +vfbAllocateFramebufferMemory(vfbFramebufferInfoPtr pfb)
871 +{
872 + if (pfb->pfbMemory != NULL)
873 + return pfb->pfbMemory; /* already done */
874 +
875 + /* Compute memory layout */
876 + pfb->paddedBytesWidth = PixmapBytePad(pfb->width, pfb->depth);
877 + pfb->bitsPerPixel = vfbBitsPerPixel(pfb->depth);
878 + pfb->paddedWidth = pfb->paddedBytesWidth * 8 / pfb->bitsPerPixel;
879 + pfb->sizeInBytes = pfb->paddedBytesWidth * pfb->height;
880 +
881 + /* And allocate buffer */
882 + switch (fbmemtype) {
883 +#ifdef HAS_SHM
884 + case SHARED_MEMORY_FB:
885 + vfbAllocateSharedMemoryFramebuffer(pfb);
886 + break;
887 +#else
888 + case SHARED_MEMORY_FB:
889 + break;
890 +#endif
891 + case NORMAL_MEMORY_FB:
892 + pfb->pfbMemory = Xalloc(pfb->sizeInBytes);
893 + break;
894 + }
895 +
896 + /* This will be NULL if any of the above failed */
897 + return pfb->pfbMemory;
898 +}
899 +
900 +static void
901 +vfbFreeFramebufferMemory(vfbFramebufferInfoPtr pfb)
902 +{
903 + if ((pfb == NULL) || (pfb->pfbMemory == NULL))
904 + return;
905 +
906 + switch (fbmemtype) {
907 +#ifdef HAS_SHM
908 + case SHARED_MEMORY_FB:
909 + if (-1 == shmdt(pfb->pfbMemory)) {
910 + perror("shmdt");
911 + ErrorF("shmdt failed, errno %d", errno);
912 + }
913 + break;
914 +#else /* HAS_SHM */
915 + case SHARED_MEMORY_FB:
916 + break;
917 +#endif /* HAS_SHM */
918 + case NORMAL_MEMORY_FB:
919 + Xfree(pfb->pfbMemory);
920 + break;
921 + }
922 +
923 + pfb->pfbMemory = NULL;
924 +}
925 +
926 +static Bool
927 +vfbCursorOffScreen (ScreenPtr *ppScreen, int *x, int *y)
928 +{
929 + return FALSE;
930 +}
931 +
932 +static void
933 +vfbCrossScreen (ScreenPtr pScreen, Bool entering)
934 +{
935 +}
936 +
937 +static Bool vfbRealizeCursor(
938 +#if XORG >= 16
939 + DeviceIntPtr pDev,
940 +#endif
941 + ScreenPtr pScreen, CursorPtr pCursor) {
942 + return TRUE;
943 +}
944 +
945 +static Bool vfbUnrealizeCursor(
946 +#if XORG >= 16
947 + DeviceIntPtr pDev,
948 +#endif
949 + ScreenPtr pScreen, CursorPtr pCursor) {
950 + return TRUE;
951 +}
952 +
953 +static void vfbSetCursor(
954 +#if XORG >= 16
955 + DeviceIntPtr pDev,
956 +#endif
957 + ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
958 +{
959 +}
960 +
961 +static void vfbMoveCursor(
962 +#if XORG >= 16
963 + DeviceIntPtr pDev,
964 +#endif
965 + ScreenPtr pScreen, int x, int y)
966 +{
967 +}
968 +
969 +#if XORG >= 16
970 +static Bool
971 +vfbDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
972 +{
973 + return TRUE;
974 +}
975 +
976 +static void
977 +vfbDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen)
978 +{
979 +}
980 +#endif
981 +
982 +static miPointerSpriteFuncRec vfbPointerSpriteFuncs = {
983 + vfbRealizeCursor,
984 + vfbUnrealizeCursor,
985 + vfbSetCursor,
986 + vfbMoveCursor
987 +#if XORG >= 16
988 + , vfbDeviceCursorInitialize,
989 + vfbDeviceCursorCleanup
990 +#endif
991 +};
992 +
993 +static miPointerScreenFuncRec vfbPointerCursorFuncs = {
994 + vfbCursorOffScreen,
995 + vfbCrossScreen,
996 + miPointerWarpCursor
997 +};
998 +
999 +#ifdef RANDR
1000 +
1001 +static Bool vncRandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
1002 +{
1003 + vfbScreenInfoPtr pvfb = &vfbScreens[pScreen->myNum];
1004 + Bool ret, gotCurrent = FALSE;
1005 + int i;
1006 +
1007 + const int widths[] = { 1920, 1920, 1600, 1680, 1400, 1360, 1280, 1280, 1280, 1280, 1024, 800, 640 };
1008 + const int heights[] = { 1200, 1080, 1200, 1050, 1050, 768, 1024, 960, 800, 720, 768, 600, 480 };
1009 +
1010 + for (i = 0;i < sizeof(widths)/sizeof(*widths);i++) {
1011 + RRScreenSizePtr pSize;
1012 +
1013 + pSize = RRRegisterSize(pScreen, widths[i], heights[i],
1014 + pScreen->mmWidth, pScreen->mmHeight);
1015 + if (!pSize)
1016 + return FALSE;
1017 +
1018 + ret = RRRegisterRate(pScreen, pSize, 60);
1019 + if (!ret)
1020 + return FALSE;
1021 +
1022 + if ((widths[i] == pScreen->width) && (heights[i] == pScreen->height)) {
1023 + RRSetCurrentConfig(pScreen, RR_Rotate_0, 60, pSize);
1024 + gotCurrent = TRUE;
1025 + }
1026 + }
1027 +
1028 + if (!gotCurrent) {
1029 + RRScreenSizePtr pSize;
1030 +
1031 + pSize = RRRegisterSize(pScreen, pScreen->width, pScreen->height,
1032 + pScreen->mmWidth, pScreen->mmHeight);
1033 + if (!pSize)
1034 + return FALSE;
1035 +
1036 + RRRegisterRate(pScreen, pSize, 60);
1037 +
1038 + RRSetCurrentConfig(pScreen, RR_Rotate_0, 60, pSize);
1039 + }
1040 +
1041 + *rotations = RR_Rotate_0;
1042 +
1043 + return TRUE;
1044 +}
1045 +
1046 +/* from hw/xfree86/common/xf86Helper.c */
1047 +
1048 +#include "mivalidate.h"
1049 +static void
1050 +xf86SetRootClip (ScreenPtr pScreen, Bool enable)
1051 +{
1052 +#if XORG < 19
1053 + WindowPtr pWin = WindowTable[pScreen->myNum];
1054 +#else
1055 + WindowPtr pWin = pScreen->root;
1056 +#endif
1057 + WindowPtr pChild;
1058 + Bool WasViewable = (Bool)(pWin->viewable);
1059 + Bool anyMarked = FALSE;
1060 + RegionPtr pOldClip = NULL, bsExposed;
1061 +#ifdef DO_SAVE_UNDERS
1062 + Bool dosave = FALSE;
1063 +#endif
1064 + WindowPtr pLayerWin;
1065 + BoxRec box;
1066 +
1067 + if (WasViewable)
1068 + {
1069 + for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib)
1070 + {
1071 + (void) (*pScreen->MarkOverlappedWindows)(pChild,
1072 + pChild,
1073 + &pLayerWin);
1074 + }
1075 + (*pScreen->MarkWindow) (pWin);
1076 + anyMarked = TRUE;
1077 + if (pWin->valdata)
1078 + {
1079 + if (HasBorder (pWin))
1080 + {
1081 + RegionPtr borderVisible;
1082 +
1083 + borderVisible = REGION_CREATE(pScreen, NullBox, 1);
1084 + REGION_SUBTRACT(pScreen, borderVisible,
1085 + &pWin->borderClip, &pWin->winSize);
1086 + pWin->valdata->before.borderVisible = borderVisible;
1087 + }
1088 + pWin->valdata->before.resized = TRUE;
1089 + }
1090 + }
1091 +
1092 + /*
1093 + * Use REGION_BREAK to avoid optimizations in ValidateTree
1094 + * that assume the root borderClip can't change well, normally
1095 + * it doesn't...)
1096 + */
1097 + if (enable)
1098 + {
1099 + box.x1 = 0;
1100 + box.y1 = 0;
1101 + box.x2 = pScreen->width;
1102 + box.y2 = pScreen->height;
1103 + REGION_INIT (pScreen, &pWin->winSize, &box, 1);
1104 + REGION_INIT (pScreen, &pWin->borderSize, &box, 1);
1105 + if (WasViewable)
1106 + REGION_RESET(pScreen, &pWin->borderClip, &box);
1107 + pWin->drawable.width = pScreen->width;
1108 + pWin->drawable.height = pScreen->height;
1109 + REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
1110 + }
1111 + else
1112 + {
1113 + REGION_EMPTY(pScreen, &pWin->borderClip);
1114 + REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
1115 + }
1116 +
1117 + ResizeChildrenWinSize (pWin, 0, 0, 0, 0);
1118 +
1119 + if (WasViewable)
1120 + {
1121 + if (pWin->backStorage)
1122 + {
1123 + pOldClip = REGION_CREATE(pScreen, NullBox, 1);
1124 + REGION_COPY(pScreen, pOldClip, &pWin->clipList);
1125 + }
1126 +
1127 + if (pWin->firstChild)
1128 + {
1129 + anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin->firstChild,
1130 + pWin->firstChild,
1131 + (WindowPtr *)NULL);
1132 + }
1133 + else
1134 + {
1135 + (*pScreen->MarkWindow) (pWin);
1136 + anyMarked = TRUE;
1137 + }
1138 +
1139 +#ifdef DO_SAVE_UNDERS
1140 + if (DO_SAVE_UNDERS(pWin))
1141 + {
1142 + dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pLayerWin);
1143 + }
1144 +#endif /* DO_SAVE_UNDERS */
1145 +
1146 + if (anyMarked)
1147 + (*pScreen->ValidateTree)(pWin, NullWindow, VTOther);
1148 + }
1149 +
1150 + if (pWin->backStorage &&
1151 + ((pWin->backingStore == Always) || WasViewable))
1152 + {
1153 + if (!WasViewable)
1154 + pOldClip = &pWin->clipList; /* a convenient empty region */
1155 + bsExposed = (*pScreen->TranslateBackingStore)
1156 + (pWin, 0, 0, pOldClip,
1157 + pWin->drawable.x, pWin->drawable.y);
1158 + if (WasViewable)
1159 + REGION_DESTROY(pScreen, pOldClip);
1160 + if (bsExposed)
1161 + {
1162 + RegionPtr valExposed = NullRegion;
1163 +
1164 + if (pWin->valdata)
1165 + valExposed = &pWin->valdata->after.exposed;
1166 + (*pScreen->WindowExposures) (pWin, valExposed, bsExposed);
1167 + if (valExposed)
1168 + REGION_EMPTY(pScreen, valExposed);
1169 + REGION_DESTROY(pScreen, bsExposed);
1170 + }
1171 + }
1172 + if (WasViewable)
1173 + {
1174 + if (anyMarked)
1175 + (*pScreen->HandleExposures)(pWin);
1176 +#ifdef DO_SAVE_UNDERS
1177 + if (dosave)
1178 + (*pScreen->PostChangeSaveUnder)(pLayerWin, pLayerWin);
1179 +#endif /* DO_SAVE_UNDERS */
1180 + if (anyMarked && pScreen->PostValidateTree)
1181 + (*pScreen->PostValidateTree)(pWin, NullWindow, VTOther);
1182 + }
1183 + if (pWin->realized)
1184 + WindowsRestructured ();
1185 + FlushAllOutput ();
1186 +}
1187 +
1188 +static Bool vncRandRSetConfig (ScreenPtr pScreen, Rotation rotation,
1189 + int rate, RRScreenSizePtr pSize)
1190 +{
1191 + vfbScreenInfoPtr pvfb = &vfbScreens[pScreen->myNum];
1192 + vfbFramebufferInfo fb;
1193 + PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen);
1194 + void *pbits;
1195 + Bool ret;
1196 + int oldwidth, oldheight, oldmmWidth, oldmmHeight;
1197 + int dpix, dpiy;
1198 +
1199 + /* Prevent updates while we fiddle */
1200 + xf86SetRootClip(pScreen, FALSE);
1201 +
1202 + /* Store current state in case we fail */
1203 + oldwidth = pScreen->width;
1204 + oldheight = pScreen->height;
1205 + oldmmWidth = pScreen->mmWidth;
1206 + oldmmHeight = pScreen->mmHeight;
1207 +
1208 + /* Compute the current DPI (for use later) */
1209 + dpix = (pScreen->width * 254 + pScreen->mmWidth * 5) / (pScreen->mmWidth * 10);
1210 + dpiy = (pScreen->height * 254 + pScreen->mmHeight * 5) / (pScreen->mmHeight * 10);
1211 +
1212 + /* Then set the new dimensions */
1213 + pScreen->width = pSize->width;
1214 + pScreen->height = pSize->height;
1215 +
1216 + /* Try to keep the same DPI as we do not have a physical screen */
1217 + pScreen->mmWidth = (pScreen->width * 254 + dpix * 5) / (dpix * 10);
1218 + pScreen->mmHeight = (pScreen->height * 254 + dpiy * 5) / (dpiy * 10);
1219 +
1220 + /* Allocate a new framebuffer */
1221 + memset(&fb, 0, sizeof(vfbFramebufferInfo));
1222 +
1223 + fb.width = pScreen->width;
1224 + fb.height = pScreen->height;
1225 + fb.depth = pvfb->fb.depth;
1226 +
1227 + pbits = vfbAllocateFramebufferMemory(&fb);
1228 + if (!pbits) {
1229 + /* Allocation failed. Restore old state */
1230 + pScreen->width = oldwidth;
1231 + pScreen->height = oldheight;
1232 + pScreen->mmWidth = oldmmWidth;
1233 + pScreen->mmHeight = oldmmHeight;
1234 +
1235 + xf86SetRootClip(pScreen, TRUE);
1236 +
1237 + return FALSE;
1238 + }
1239 +
1240 + /* Update root pixmap with the new dimensions and buffer */
1241 + ret = pScreen->ModifyPixmapHeader(rootPixmap, fb.width, fb.height,
1242 + -1, -1, fb.paddedBytesWidth, pbits);
1243 + if (!ret) {
1244 + /* Update failed. Free the new framebuffer and restore old state */
1245 + vfbFreeFramebufferMemory(&fb);
1246 +
1247 + pScreen->width = oldwidth;
1248 + pScreen->height = oldheight;
1249 + pScreen->mmWidth = oldmmWidth;
1250 + pScreen->mmHeight = oldmmHeight;
1251 +
1252 + xf86SetRootClip(pScreen, TRUE);
1253 +
1254 + return FALSE;
1255 + }
1256 +
1257 + /* Free the old framebuffer and keep the info about the new one */
1258 + vfbFreeFramebufferMemory(&pvfb->fb);
1259 + memcpy(&pvfb->fb, &fb, sizeof(vfbFramebufferInfo));
1260 +
1261 + /* Let VNC get the new framebuffer (actual update is in vncHooks.cc) */
1262 + vncFbptr[pScreen->myNum] = pbits;
1263 + vncFbstride[pScreen->myNum] = fb.paddedWidth;
1264 +
1265 + /* Restore ability to update screen, now with new dimensions */
1266 + xf86SetRootClip(pScreen, TRUE);
1267 +
1268 + return TRUE;
1269 +}
1270 +
1271 +#endif
1272 +
1273 +static Bool
1274 +vfbCloseScreen(int index, ScreenPtr pScreen)
1275 +{
1276 + vfbScreenInfoPtr pvfb = &vfbScreens[index];
1277 + int i;
1278 +
1279 + pScreen->CloseScreen = pvfb->closeScreen;
1280 +
1281 + /*
1282 + * XXX probably lots of stuff to clean. For now,
1283 + * clear InstalledMaps[] so that server reset works correctly.
1284 + */
1285 + for (i = 0; i < MAXSCREENS; i++)
1286 + InstalledMaps[i] = NULL;
1287 +
1288 + return pScreen->CloseScreen(index, pScreen);
1289 +}
1290 +
1291 +static Bool
1292 +vfbScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
1293 +{
1294 + vfbScreenInfoPtr pvfb = &vfbScreens[index];
1295 + int dpi = 100;
1296 + int ret;
1297 + void *pbits;
1298 +
1299 + if (monitorResolution) dpi = monitorResolution;
1300 +
1301 + pbits = vfbAllocateFramebufferMemory(&pvfb->fb);
1302 + if (!pbits) return FALSE;
1303 + vncFbptr[index] = pbits;
1304 + vncFbstride[index] = pvfb->fb.paddedWidth;
1305 +
1306 + miSetPixmapDepths();
1307 +
1308 + switch (pvfb->fb.depth) {
1309 + case 8:
1310 + miSetVisualTypesAndMasks (8,
1311 + ((1 << StaticGray) |
1312 + (1 << GrayScale) |
1313 + (1 << StaticColor) |
1314 + (1 << PseudoColor) |
1315 + (1 << TrueColor) |
1316 + (1 << DirectColor)),
1317 + 8, PseudoColor, 0, 0, 0);
1318 + break;
1319 + case 16:
1320 + miSetVisualTypesAndMasks (16,
1321 + ((1 << TrueColor) |
1322 + (1 << DirectColor)),
1323 + 8, TrueColor, 0xf800, 0x07e0, 0x001f);
1324 + break;
1325 + case 24:
1326 + miSetVisualTypesAndMasks (24,
1327 + ((1 << TrueColor) |
1328 + (1 << DirectColor)),
1329 + 8, TrueColor, 0xff0000, 0x00ff00, 0x0000ff);
1330 + break;
1331 + case 32:
1332 + miSetVisualTypesAndMasks (32,
1333 + ((1 << TrueColor) |
1334 + (1 << DirectColor)),
1335 + 8, TrueColor, 0xff000000, 0x00ff0000, 0x0000ff00);
1336 + break;
1337 + default:
1338 + return FALSE;
1339 + }
1340 +
1341 + ret = fbScreenInit(pScreen, pbits, pvfb->fb.width, pvfb->fb.height,
1342 + dpi, dpi, pvfb->fb.paddedWidth, pvfb->fb.bitsPerPixel);
1343 +
1344 +#ifdef RENDER
1345 + if (ret && Render)
1346 + ret = fbPictureInit (pScreen, 0, 0);
1347 +#endif
1348 +
1349 + if (!ret) return FALSE;
1350 +
1351 + miInitializeBackingStore(pScreen);
1352 +
1353 + /*
1354 + * Circumvent the backing store that was just initialised. This amounts
1355 + * to a truely bizarre way of initialising SaveDoomedAreas and friends.
1356 + */
1357 +
1358 + pScreen->InstallColormap = vfbInstallColormap;
1359 + pScreen->UninstallColormap = vfbUninstallColormap;
1360 + pScreen->ListInstalledColormaps = vfbListInstalledColormaps;
1361 +
1362 + pScreen->SaveScreen = vfbSaveScreen;
1363 +
1364 + miPointerInitialize(pScreen, &vfbPointerSpriteFuncs, &vfbPointerCursorFuncs,
1365 + FALSE);
1366 +
1367 + pScreen->blackPixel = pvfb->blackPixel;
1368 + pScreen->whitePixel = pvfb->whitePixel;
1369 +
1370 + if (!pvfb->pixelFormatDefined && pvfb->fb.depth == 16) {
1371 + pvfb->pixelFormatDefined = TRUE;
1372 + pvfb->rgbNotBgr = TRUE;
1373 + pvfb->blueBits = pvfb->redBits = 5;
1374 + pvfb->greenBits = 6;
1375 + }
1376 +
1377 + if (pvfb->pixelFormatDefined) {
1378 + VisualPtr vis = pScreen->visuals;
1379 + for (int i = 0; i < pScreen->numVisuals; i++) {
1380 + if (pvfb->rgbNotBgr) {
1381 + vis->offsetBlue = 0;
1382 + vis->blueMask = (1 << pvfb->blueBits) - 1;
1383 + vis->offsetGreen = pvfb->blueBits;
1384 + vis->greenMask = ((1 << pvfb->greenBits) - 1) << vis->offsetGreen;
1385 + vis->offsetRed = vis->offsetGreen + pvfb->greenBits;
1386 + vis->redMask = ((1 << pvfb->redBits) - 1) << vis->offsetRed;
1387 + } else {
1388 + vis->offsetRed = 0;
1389 + vis->redMask = (1 << pvfb->redBits) - 1;
1390 + vis->offsetGreen = pvfb->redBits;
1391 + vis->greenMask = ((1 << pvfb->greenBits) - 1) << vis->offsetGreen;
1392 + vis->offsetBlue = vis->offsetGreen + pvfb->greenBits;
1393 + vis->blueMask = ((1 << pvfb->blueBits) - 1) << vis->offsetBlue;
1394 + }
1395 + vis++;
1396 + }
1397 + }
1398 +
1399 + ret = fbCreateDefColormap(pScreen);
1400 + if (!ret) return FALSE;
1401 +
1402 + miSetZeroLineBias(pScreen, pvfb->lineBias);
1403 +
1404 + pvfb->closeScreen = pScreen->CloseScreen;
1405 + pScreen->CloseScreen = vfbCloseScreen;
1406 +
1407 +#ifdef RANDR
1408 + rrScrPrivPtr rp;
1409 +
1410 + ret = RRScreenInit(pScreen);
1411 + if (!ret) return FALSE;
1412 +
1413 + rp = rrGetScrPriv(pScreen);
1414 + rp->rrGetInfo = vncRandRGetInfo;
1415 + rp->rrSetConfig = vncRandRSetConfig;
1416 +#endif
1417 +
1418 +
1419 + return TRUE;
1420 +
1421 +} /* end vfbScreenInit */
1422 +
1423 +
1424 +static void vfbClientStateChange(CallbackListPtr*, pointer, pointer) {
1425 + dispatchException &= ~DE_RESET;
1426 +}
1427 +
1428 +void
1429 +InitOutput(ScreenInfo *screenInfo, int argc, char **argv)
1430 +{
1431 + ErrorF("\nXvnc %s - built %s\n%s", XVNCVERSION, buildtime, XVNCCOPYRIGHT);
1432 + ErrorF("Underlying X server release %d, %s\n\n", VENDOR_RELEASE,
1433 + VENDOR_STRING);
1434 + int i;
1435 + int NumFormats = 0;
1436 +
1437 + /* initialize pixmap formats */
1438 +
1439 + /* must have a pixmap depth to match every screen depth */
1440 + for (i = 0; i < vfbNumScreens; i++)
1441 + {
1442 + vfbPixmapDepths[vfbScreens[i].fb.depth] = TRUE;
1443 + }
1444 +
1445 + /* RENDER needs a good set of pixmaps. */
1446 + if (Render) {
1447 + vfbPixmapDepths[1] = TRUE;
1448 + vfbPixmapDepths[4] = TRUE;
1449 + vfbPixmapDepths[8] = TRUE;
1450 +/* vfbPixmapDepths[15] = TRUE; */
1451 + vfbPixmapDepths[16] = TRUE;
1452 + vfbPixmapDepths[24] = TRUE;
1453 + vfbPixmapDepths[32] = TRUE;
1454 + }
1455 +
1456 + for (i = 1; i <= 32; i++)
1457 + {
1458 + if (vfbPixmapDepths[i])
1459 + {
1460 + if (NumFormats >= MAXFORMATS)
1461 + FatalError ("MAXFORMATS is too small for this server\n");
1462 + screenInfo->formats[NumFormats].depth = i;
1463 + screenInfo->formats[NumFormats].bitsPerPixel = vfbBitsPerPixel(i);
1464 + screenInfo->formats[NumFormats].scanlinePad = BITMAP_SCANLINE_PAD;
1465 + NumFormats++;
1466 + }
1467 + }
1468 +
1469 + screenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
1470 + screenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
1471 + screenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
1472 + screenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
1473 + screenInfo->numPixmapFormats = NumFormats;
1474 +
1475 + /* initialize screens */
1476 +
1477 + for (i = 0; i < vfbNumScreens; i++)
1478 + {
1479 + if (-1 == AddScreen(vfbScreenInit, argc, argv))
1480 + {
1481 + FatalError("Couldn't add screen %d", i);
1482 + }
1483 + }
1484 +
1485 + if (!AddCallback(&ClientStateCallback, vfbClientStateChange, 0)) {
1486 + FatalError("AddCallback failed\n");
1487 + }
1488 +} /* end InitOutput */
1489 +
1490 +/* this is just to get the server to link on AIX */
1491 +#ifdef AIXV3
1492 +int SelectWaitTime = 10000; /* usec */
1493 +#endif
1494 +
1495 +void DDXRingBell(int percent, int pitch, int duration)
1496 +{
1497 + if (percent > 0)
1498 + vncBell();
1499 +}
1500 +
1501 +Bool LegalModifier(unsigned int key, DeviceIntPtr pDev)
1502 +{
1503 + return TRUE;
1504 +}
1505 +
1506 +void ProcessInputEvents()
1507 +{
1508 + mieqProcessInputEvents();
1509 +#if XORG == 15
1510 + miPointerUpdate();
1511 +#endif
1512 +}
1513 +
1514 +// InitInput is called after InitExtensions, so we're guaranteed that
1515 +// vncExtensionInit() has already been called.
1516 +
1517 +void InitInput(int argc, char *argv[])
1518 +{
1519 + mieqInit ();
1520 +}
1521 diff -Naur tigervnc-1.0.1/unix/xserver19.patch tigervnc-1.0.1-magellan/unix/xserver19.patch
1522 --- tigervnc-1.0.1/unix/xserver19.patch 1970-01-01 01:00:00.000000000 +0100
1523 +++ tigervnc-1.0.1-magellan/unix/xserver19.patch 2011-01-21 20:41:21.000000000 +0100
1524 @@ -0,0 +1,86 @@
1525 +diff -up xserver/configure.ac.vnc xserver/configure.ac
1526 +--- xserver/configure.ac.vnc 2010-07-20 11:34:55.086181932 +0200
1527 ++++ xserver/configure.ac 2010-07-20 11:35:02.196706133 +0200
1528 +@@ -30,7 +30,6 @@ AC_INIT([xorg-server], 1.8.99.905, [http
1529 + RELEASE_DATE="2010-07-14"
1530 + AC_CONFIG_SRCDIR([Makefile.am])
1531 + AM_INIT_AUTOMAKE([foreign dist-bzip2])
1532 +-AM_MAINTAINER_MODE
1533 +
1534 + # Require xorg-macros: XORG_DEFAULT_OPTIONS
1535 + m4_ifndef([XORG_MACROS_VERSION],
1536 +@@ -64,6 +63,7 @@ dnl forcing an entire recompile.x
1537 + AC_CONFIG_HEADERS(include/version-config.h)
1538 +
1539 + AC_PROG_CC
1540 ++AC_PROG_CXX
1541 + AM_PROG_AS
1542 + AC_PROG_INSTALL
1543 + AC_PROG_LN_S
1544 +@@ -1512,6 +1512,9 @@ if test "x$XVFB" = xyes; then
1545 + AC_SUBST([XVFB_SYS_LIBS])
1546 + fi
1547 +
1548 ++dnl Xvnc DDX
1549 ++AC_SUBST([XVNC_CPPFLAGS], ["-DHAVE_DIX_CONFIG_H $XEXT_INC $FB_INC $MI_INC $RENDER_INC $RANDR_INC"])
1550 ++AC_SUBST([XVNC_LIBS], ["$FB_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $RECORD_LIB $GLX_LIBS $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $MAIN_LIB"])
1551 +
1552 + dnl Xnest DDX
1553 +
1554 +@@ -1550,6 +1553,8 @@ xorg_bus_linuxpci=no
1555 + xorg_bus_bsdpci=no
1556 + xorg_bus_sparc=no
1557 +
1558 ++AC_DEFINE_UNQUOTED(XORG_VERSION_CURRENT, [$VENDOR_RELEASE], [Current Xorg version])
1559 ++
1560 + if test "x$XORG" = xyes; then
1561 + XORG_DDXINCS='-I$(top_srcdir)/hw/xfree86 -I$(top_srcdir)/hw/xfree86/include -I$(top_srcdir)/hw/xfree86/common'
1562 + XORG_OSINCS='-I$(top_srcdir)/hw/xfree86/os-support -I$(top_srcdir)/hw/xfree86/os-support/bus -I$(top_srcdir)/os'
1563 +@@ -1796,7 +1801,6 @@ if test "x$XORG" = xyes; then
1564 + AC_DEFINE(XORGSERVER, 1, [Building Xorg server])
1565 + AC_DEFINE(XFree86Server, 1, [Building XFree86 server])
1566 + AC_DEFINE(XFree86LOADER, 1, [Building loadable XFree86 server])
1567 +- AC_DEFINE_UNQUOTED(XORG_VERSION_CURRENT, [$VENDOR_RELEASE], [Current Xorg version])
1568 + AC_DEFINE(NEED_XF86_TYPES, 1, [Need XFree86 typedefs])
1569 + AC_DEFINE(NEED_XF86_PROTOTYPES, 1, [Need XFree86 helper functions])
1570 + AC_DEFINE(__XSERVERNAME__, "Xorg", [Name of X server])
1571 +@@ -2246,6 +2250,7 @@ hw/dmx/input/Makefile
1572 + hw/dmx/glxProxy/Makefile
1573 + hw/dmx/Makefile
1574 + hw/vfb/Makefile
1575 ++hw/vnc/Makefile
1576 + hw/xnest/Makefile
1577 + hw/xwin/Makefile
1578 + hw/xwin/glx/Makefile
1579 +diff -up xserver/hw/Makefile.am.vnc xserver/hw/Makefile.am
1580 +--- xserver/hw/Makefile.am.vnc 2010-07-20 11:34:55.276195912 +0200
1581 ++++ xserver/hw/Makefile.am 2010-07-20 11:35:02.196706133 +0200
1582 +@@ -33,7 +33,8 @@ SUBDIRS = \
1583 + $(XNEST_SUBDIRS) \
1584 + $(DMX_SUBDIRS) \
1585 + $(KDRIVE_SUBDIRS) \
1586 +- $(XQUARTZ_SUBDIRS)
1587 ++ $(XQUARTZ_SUBDIRS) \
1588 ++ vnc
1589 +
1590 + DIST_SUBDIRS = dmx xfree86 vfb xnest xwin xquartz kdrive
1591 +
1592 +diff -up xserver/mi/miinitext.c.vnc xserver/mi/miinitext.c
1593 +--- xserver/mi/miinitext.c.vnc 2010-07-20 11:34:55.286196649 +0200
1594 ++++ xserver/mi/miinitext.c 2010-07-20 11:35:02.196706133 +0200
1595 +@@ -263,6 +263,7 @@ extern void DamageExtensionInit(INITARGS
1596 + extern void CompositeExtensionInit(INITARGS);
1597 + #endif
1598 + extern void GEExtensionInit(INITARGS);
1599 ++extern void vncExtensionInit(INITARGS);
1600 +
1601 + /* The following is only a small first step towards run-time
1602 + * configurable extensions.
1603 +@@ -435,6 +436,7 @@ InitExtensions(int argc, char *argv[])
1604 + #ifdef XF86BIGFONT
1605 + if (!noXFree86BigfontExtension) XFree86BigfontExtensionInit();
1606 + #endif
1607 ++ vncExtensionInit();
1608 + #if !defined(NO_HW_ONLY_EXTS)
1609 + #if defined(XF86VIDMODE)
1610 + if (!noXFree86VidModeExtension) XFree86VidModeExtensionInit();