Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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