diff options
Diffstat (limited to 'nx-X11/programs/Xserver/hw/vfb')
-rw-r--r-- | nx-X11/programs/Xserver/hw/vfb/Imakefile | 71 | ||||
-rw-r--r-- | nx-X11/programs/Xserver/hw/vfb/InitInput.c | 344 | ||||
-rw-r--r-- | nx-X11/programs/Xserver/hw/vfb/InitOutput.c | 1046 | ||||
-rw-r--r-- | nx-X11/programs/Xserver/hw/vfb/Xvfb.man | 132 | ||||
-rw-r--r-- | nx-X11/programs/Xserver/hw/vfb/lk201kbd.h | 159 |
5 files changed, 1752 insertions, 0 deletions
diff --git a/nx-X11/programs/Xserver/hw/vfb/Imakefile b/nx-X11/programs/Xserver/hw/vfb/Imakefile new file mode 100644 index 000000000..b58ff8fab --- /dev/null +++ b/nx-X11/programs/Xserver/hw/vfb/Imakefile @@ -0,0 +1,71 @@ +XCOMM $Xorg: Imakefile,v 1.5 2000/08/17 19:48:38 cpqbld Exp $ + + + + +XCOMM $XFree86: xc/programs/Xserver/hw/vfb/Imakefile,v 3.30 2001/05/31 16:11:10 dawes Exp $ + +#include <Server.tmpl> + +#if HasShm +SHMDEF = -DHAS_SHM +#endif + +XCOMM add more architectures here as we discover them +#if defined(HPArchitecture) || \ + (defined(SparcArchitecture) && !defined(LynxOSArchitecture)) || \ + SystemV4 || \ + defined(OSF1Architecture) || \ + defined(i386BsdArchitecture) || \ + (defined(KFreeBSDArchitecture) && defined(i386Architecture)) || \ + defined(LinuxArchitecture) || \ + defined(DarwinArchitecture) +MMAPDEF = -DHAS_MMAP +#endif + +#ifdef OS2Architecture +SRCS1 = os2_stubs.c +OBJS1 = os2_stubs.o +#endif + +SRCSA = InitInput.c InitOutput.c stubs.c $(SRCS1) miinitext.c $(SRCS2) + +OBJSA = InitInput.o InitOutput.o stubs.o $(OBJS1) miinitext.o $(OBJS2) + +INCLUDES = -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \ + -I$(SERVERSRC)/fb -I$(SERVERSRC)/mi -I$(SERVERSRC)/include -I../../os \ + -I$(SERVERSRC)/Xext -I$(EXTINCSRC) -I$(XINCLUDESRC) \ + -I$(SERVERSRC)/render + +DEFINES = $(OS_DEFINES) $(SHMDEF) $(MMAPDEF) -UXFree86LOADER + + +#if BuildDPMS +SRCSC = dpmsstubs.c +OBJSC = dpmsstubs.o +#endif + +SRCS = $(SRCSA) $(SRCSB) $(SRCSC) +OBJS = $(OBJSA) $(OBJSB) $(OBJSC) + +NormalLibraryObjectRule() +NormalLibraryTarget(vfb,$(OBJS)) + +#ifdef OS2Architecture +LinkSourceFile(os2_stubs.c,../xfree86/os-support/os2) +SpecialCObjectRule(os2_stubs,$(ICONFIGFILES),-DOS2NULLSELECT) +#endif + +LinkSourceFile(stubs.c,../../Xi) +SpecialCObjectRule(InitInput,$(ICONFIGFILES),$(EXT_DEFINES)) + +LinkSourceFile(miinitext.c,$(SERVERSRC)/mi) +SpecialCObjectRule(miinitext,$(ICONFIGFILES),$(EXT_DEFINES) $(PAN_DEFINES) -DNO_HW_ONLY_EXTS -DNO_MODULE_EXTS $(EXT_MODULE_DEFINES) -UXFree86LOADER) + +#if BuildDPMS +LinkSourceFile(dpmsstubs.c,$(SERVERSRC)/Xext) +SpecialCObjectRule(dpmsstubs,$(ICONFIGFILES),$(EXT_DEFINES)) +#endif + +InstallManPage(Xvfb,$(MANDIR)) +DependTarget() diff --git a/nx-X11/programs/Xserver/hw/vfb/InitInput.c b/nx-X11/programs/Xserver/hw/vfb/InitInput.c new file mode 100644 index 000000000..57f466444 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/vfb/InitInput.c @@ -0,0 +1,344 @@ +/* $Xorg: InitInput.c,v 1.4 2001/02/09 02:04:44 xorgcvs Exp $ */ +/* + +Copyright 1993, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from The Open Group. + +*/ +/* $XFree86: xc/programs/Xserver/hw/vfb/InitInput.c,v 3.9 2001/12/14 19:59:45 dawes Exp $ */ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include <X11/X.h> +#define NEED_EVENTS +#include "mi.h" +#include <X11/Xproto.h> +#include "scrnintstr.h" +#include "inputstr.h" +#include <X11/Xos.h> +#include "mibstore.h" +#include "mipointer.h" +#include "lk201kbd.h" +#include <X11/keysym.h> + +Bool +LegalModifier(unsigned int key, DevicePtr pDev) +{ + return TRUE; +} + +void +ProcessInputEvents() +{ + mieqProcessInputEvents(); + miPointerUpdate(); +} + +#define VFB_MIN_KEY 8 +#define VFB_MAX_KEY 255 +KeySym map[MAP_LENGTH * LK201_GLYPHS_PER_KEY]; + +/* The only reason for using the LK201 mappings here was that they were + * easy to lift. + */ +static Bool +GetLK201Mappings(KeySymsPtr pKeySyms, CARD8 *pModMap) +{ +#define INDEX(in) ((in - VFB_MIN_KEY) * LK201_GLYPHS_PER_KEY) + int i; + + for (i = 0; i < MAP_LENGTH; i++) + pModMap[i] = NoSymbol; /* make sure it is restored */ + pModMap[ KEY_LOCK ] = LockMask; + pModMap[ KEY_SHIFT ] = ShiftMask; + pModMap[ KEY_CTRL ] = ControlMask; + pModMap[ KEY_COMPOSE ] = Mod1Mask; + + pKeySyms->minKeyCode = VFB_MIN_KEY; + pKeySyms->maxKeyCode = VFB_MAX_KEY; + pKeySyms->mapWidth = LK201_GLYPHS_PER_KEY; + pKeySyms->map = map; + + for (i = 0; i < (MAP_LENGTH * LK201_GLYPHS_PER_KEY); i++) + map[i] = NoSymbol; /* make sure it is restored */ + + map[INDEX(KEY_F1)] = XK_F1; + map[INDEX(KEY_F2)] = XK_F2; + map[INDEX(KEY_F3)] = XK_F3; + map[INDEX(KEY_F4)] = XK_F4; + map[INDEX(KEY_F5)] = XK_F5; + map[INDEX(KEY_F6)] = XK_F6; + map[INDEX(KEY_F7)] = XK_F7; + map[INDEX(KEY_F8)] = XK_F8; + map[INDEX(KEY_F9)] = XK_F9; + map[INDEX(KEY_F10)] = XK_F10; + map[INDEX(KEY_F11)] = XK_F11; + map[INDEX(KEY_F12)] = XK_F12; + map[INDEX(KEY_F13)] = XK_F13; + map[INDEX(KEY_F14)] = XK_F14; + + map[INDEX(KEY_HELP)] = XK_Help; + map[INDEX(KEY_MENU)] = XK_Menu; + + map[INDEX(KEY_F17)] = XK_F17; + map[INDEX(KEY_F18)] = XK_F18; + map[INDEX(KEY_F19)] = XK_F19; + map[INDEX(KEY_F20)] = XK_F20; + + map[INDEX(KEY_FIND)] = XK_Find; + map[INDEX(KEY_INSERT_HERE)] = XK_Insert; + map[INDEX(KEY_REMOVE)] = XK_Delete; + map[INDEX(KEY_SELECT)] = XK_Select; + map[INDEX(KEY_PREV_SCREEN)] = XK_Prior; + map[INDEX(KEY_NEXT_SCREEN)] = XK_Next; + + map[INDEX(KEY_KP_0)] = XK_KP_0; + map[INDEX(KEY_KP_PERIOD)] = XK_KP_Decimal; + map[INDEX(KEY_KP_ENTER)] = XK_KP_Enter; + map[INDEX(KEY_KP_1)] = XK_KP_1; + map[INDEX(KEY_KP_2)] = XK_KP_2; + map[INDEX(KEY_KP_3)] = XK_KP_3; + map[INDEX(KEY_KP_4)] = XK_KP_4; + map[INDEX(KEY_KP_5)] = XK_KP_5; + map[INDEX(KEY_KP_6)] = XK_KP_6; + map[INDEX(KEY_KP_COMMA)] = XK_KP_Separator; + map[INDEX(KEY_KP_7)] = XK_KP_7; + map[INDEX(KEY_KP_8)] = XK_KP_8; + map[INDEX(KEY_KP_9)] = XK_KP_9; + map[INDEX(KEY_KP_HYPHEN)] = XK_KP_Subtract; + map[INDEX(KEY_KP_PF1)] = XK_KP_F1; + map[INDEX(KEY_KP_PF2)] = XK_KP_F2; + map[INDEX(KEY_KP_PF3)] = XK_KP_F3; + map[INDEX(KEY_KP_PF4)] = XK_KP_F4; + + map[INDEX(KEY_LEFT)] = XK_Left; + map[INDEX(KEY_RIGHT)] = XK_Right; + map[INDEX(KEY_DOWN)] = XK_Down; + map[INDEX(KEY_UP)] = XK_Up; + + map[INDEX(KEY_SHIFT)] = XK_Shift_L; + map[INDEX(KEY_CTRL)] = XK_Control_L; + map[INDEX(KEY_LOCK)] = XK_Caps_Lock; + map[INDEX(KEY_COMPOSE)] = XK_Multi_key; + map[INDEX(KEY_COMPOSE)+1] = XK_Meta_L; + map[INDEX(KEY_DELETE)] = XK_Delete; + map[INDEX(KEY_RETURN)] = XK_Return; + map[INDEX(KEY_TAB)] = XK_Tab; + + map[INDEX(KEY_TILDE)] = XK_quoteleft; + map[INDEX(KEY_TILDE)+1] = XK_asciitilde; + + map[INDEX(KEY_TR_1)] = XK_1; + map[INDEX(KEY_TR_1)+1] = XK_exclam; + map[INDEX(KEY_Q)] = XK_Q; + map[INDEX(KEY_A)] = XK_A; + map[INDEX(KEY_Z)] = XK_Z; + + map[INDEX(KEY_TR_2)] = XK_2; + map[INDEX(KEY_TR_2)+1] = XK_at; + + map[INDEX(KEY_W)] = XK_W; + map[INDEX(KEY_S)] = XK_S; + map[INDEX(KEY_X)] = XK_X; + + map[INDEX(KEY_LANGLE_RANGLE)] = XK_less; + map[INDEX(KEY_LANGLE_RANGLE)+1] = XK_greater; + + map[INDEX(KEY_TR_3)] = XK_3; + map[INDEX(KEY_TR_3)+1] = XK_numbersign; + + map[INDEX(KEY_E)] = XK_E; + map[INDEX(KEY_D)] = XK_D; + map[INDEX(KEY_C)] = XK_C; + + map[INDEX(KEY_TR_4)] = XK_4; + map[INDEX(KEY_TR_4)+1] = XK_dollar; + + map[INDEX(KEY_R)] = XK_R; + map[INDEX(KEY_F)] = XK_F; + map[INDEX(KEY_V)] = XK_V; + map[INDEX(KEY_SPACE)] = XK_space; + + map[INDEX(KEY_TR_5)] = XK_5; + map[INDEX(KEY_TR_5)+1] = XK_percent; + + map[INDEX(KEY_T)] = XK_T; + map[INDEX(KEY_G)] = XK_G; + map[INDEX(KEY_B)] = XK_B; + + map[INDEX(KEY_TR_6)] = XK_6; + map[INDEX(KEY_TR_6)+1] = XK_asciicircum; + + map[INDEX(KEY_Y)] = XK_Y; + map[INDEX(KEY_H)] = XK_H; + map[INDEX(KEY_N)] = XK_N; + + map[INDEX(KEY_TR_7)] = XK_7; + map[INDEX(KEY_TR_7)+1] = XK_ampersand; + + map[INDEX(KEY_U)] = XK_U; + map[INDEX(KEY_J)] = XK_J; + map[INDEX(KEY_M)] = XK_M; + + map[INDEX(KEY_TR_8)] = XK_8; + map[INDEX(KEY_TR_8)+1] = XK_asterisk; + + map[INDEX(KEY_I)] = XK_I; + map[INDEX(KEY_K)] = XK_K; + + map[INDEX(KEY_COMMA)] = XK_comma; + map[INDEX(KEY_COMMA)+1] = XK_less; + + map[INDEX(KEY_TR_9)] = XK_9; + map[INDEX(KEY_TR_9)+1] = XK_parenleft; + + map[INDEX(KEY_O)] = XK_O; + map[INDEX(KEY_L)] = XK_L; + + map[INDEX(KEY_PERIOD)] = XK_period; + map[INDEX(KEY_PERIOD)+1] = XK_greater; + + map[INDEX(KEY_TR_0)] = XK_0; + map[INDEX(KEY_TR_0)+1] = XK_parenright; + + map[INDEX(KEY_P)] = XK_P; + + map[INDEX(KEY_SEMICOLON)] = XK_semicolon; + map[INDEX(KEY_SEMICOLON)+1] = XK_colon; + + map[INDEX(KEY_QMARK)] = XK_slash; + map[INDEX(KEY_QMARK)+1] = XK_question; + + map[INDEX(KEY_PLUS)] = XK_equal; + map[INDEX(KEY_PLUS)+1] = XK_plus; + + map[INDEX(KEY_RBRACE)] = XK_bracketright; + map[INDEX(KEY_RBRACE)+1] = XK_braceright; + + map[INDEX(KEY_VBAR)] = XK_backslash; + map[INDEX(KEY_VBAR)+1] = XK_bar; + + map[INDEX(KEY_UBAR)] = XK_minus; + map[INDEX(KEY_UBAR)+1] = XK_underscore; + + map[INDEX(KEY_LBRACE)] = XK_bracketleft; + map[INDEX(KEY_LBRACE)+1] = XK_braceleft; + + map[INDEX(KEY_QUOTE)] = XK_quoteright; + map[INDEX(KEY_QUOTE)+1] = XK_quotedbl; + + map[INDEX(KEY_F11)] = XK_Escape; + + return TRUE; +#undef INDEX +} + +static int +vfbKeybdProc(DeviceIntPtr pDevice, int onoff) +{ + KeySymsRec keySyms; + CARD8 modMap[MAP_LENGTH]; + DevicePtr pDev = (DevicePtr)pDevice; + + switch (onoff) + { + case DEVICE_INIT: + GetLK201Mappings(&keySyms, modMap); + InitKeyboardDeviceStruct(pDev, &keySyms, modMap, + (BellProcPtr)NoopDDA, (KbdCtrlProcPtr)NoopDDA); + break; + case DEVICE_ON: + pDev->on = TRUE; + break; + case DEVICE_OFF: + pDev->on = FALSE; + break; + case DEVICE_CLOSE: + break; + } + return Success; +} + +static int +vfbMouseProc(DeviceIntPtr pDevice, int onoff) +{ + BYTE map[4]; + DevicePtr pDev = (DevicePtr)pDevice; + + switch (onoff) + { + case DEVICE_INIT: + map[1] = 1; + map[2] = 2; + map[3] = 3; + InitPointerDeviceStruct(pDev, map, 3, miPointerGetMotionEvents, + (PtrCtrlProcPtr)NoopDDA, miPointerGetMotionBufferSize()); + break; + + case DEVICE_ON: + pDev->on = TRUE; + break; + + case DEVICE_OFF: + pDev->on = FALSE; + break; + + case DEVICE_CLOSE: + break; + } + return Success; +} + +void +InitInput(int argc, char *argv[]) +{ + DeviceIntPtr p, k; + p = AddInputDevice(vfbMouseProc, TRUE); + k = AddInputDevice(vfbKeybdProc, TRUE); + RegisterPointerDevice(p); + RegisterKeyboardDevice(k); + miRegisterPointerDevice(screenInfo.screens[0], p); + (void)mieqInit ((DevicePtr) k, (DevicePtr) p); +} + +#ifdef XTESTEXT1 +void +XTestGenerateEvent(int dev_type, int keycode, int keystate, int mousex, + int mousey) +{ +} + +void +XTestGetPointerPos(short *fmousex, short *fmousey) +{ +} + +void +XTestJumpPointer(int jx, int jy, int dev_type) +{ +} +#endif + diff --git a/nx-X11/programs/Xserver/hw/vfb/InitOutput.c b/nx-X11/programs/Xserver/hw/vfb/InitOutput.c new file mode 100644 index 000000000..630d3e133 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/vfb/InitOutput.c @@ -0,0 +1,1046 @@ +/* $Xorg: InitOutput.c,v 1.4 2001/02/09 02:04:45 xorgcvs Exp $ */ +/* + +Copyright 1993, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from The Open Group. + +*/ +/* $XFree86: xc/programs/Xserver/hw/vfb/InitOutput.c,v 3.25 2003/11/15 04:01:56 dawes Exp $ */ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#if defined(WIN32) +#include <X11/Xwinsock.h> +#endif +#include <stdio.h> +#include <X11/X.h> +#define NEED_EVENTS +#include <X11/Xproto.h> +#include <X11/Xos.h> +#include "scrnintstr.h" +#include "servermd.h" +#define PSZ 8 +#include "fb.h" +#include "mibstore.h" +#include "colormapst.h" +#include "gcstruct.h" +#include "input.h" +#include "mipointer.h" +#include "micmap.h" +#include <sys/types.h> +#ifdef HAS_MMAP +#include <sys/mman.h> +#ifndef MAP_FILE +#define MAP_FILE 0 +#endif +#endif /* HAS_MMAP */ +#include <sys/stat.h> +#include <errno.h> +#ifndef WIN32 +#include <sys/param.h> +#endif +#include <X11/XWDFile.h> +#ifdef HAS_SHM +#include <sys/ipc.h> +#include <sys/shm.h> +#endif /* HAS_SHM */ +#include "dix.h" +#include "miline.h" + +#define VFB_DEFAULT_WIDTH 1280 +#define VFB_DEFAULT_HEIGHT 1024 +#define VFB_DEFAULT_DEPTH 8 +#define VFB_DEFAULT_WHITEPIXEL 1 +#define VFB_DEFAULT_BLACKPIXEL 0 +#define VFB_DEFAULT_LINEBIAS 0 +#define XWD_WINDOW_NAME_LEN 60 + +typedef struct +{ + int scrnum; + int width; + int paddedBytesWidth; + int paddedWidth; + int height; + int depth; + int bitsPerPixel; + int sizeInBytes; + int ncolors; + char *pfbMemory; + XWDColor *pXWDCmap; + XWDFileHeader *pXWDHeader; + Pixel blackPixel; + Pixel whitePixel; + unsigned int lineBias; + CloseScreenProcPtr closeScreen; + +#ifdef HAS_MMAP + int mmap_fd; + char mmap_file[MAXPATHLEN]; +#endif + +#ifdef HAS_SHM + int shmid; +#endif +} vfbScreenInfo, *vfbScreenInfoPtr; + +static int vfbNumScreens; +static vfbScreenInfo vfbScreens[MAXSCREENS]; +static Bool vfbPixmapDepths[33]; +#ifdef HAS_MMAP +static char *pfbdir = NULL; +#endif +typedef enum { NORMAL_MEMORY_FB, SHARED_MEMORY_FB, MMAPPED_FILE_FB } fbMemType; +static fbMemType fbmemtype = NORMAL_MEMORY_FB; +static char needswap = 0; +static int lastScreen = -1; +static Bool Render = TRUE; + +#define swapcopy16(_dst, _src) \ + if (needswap) { CARD16 _s = _src; cpswaps(_s, _dst); } \ + else _dst = _src; + +#define swapcopy32(_dst, _src) \ + if (needswap) { CARD32 _s = _src; cpswapl(_s, _dst); } \ + else _dst = _src; + + +static void +vfbInitializePixmapDepths(void) +{ + int i; + vfbPixmapDepths[1] = TRUE; /* always need bitmaps */ + for (i = 2; i <= 32; i++) + vfbPixmapDepths[i] = FALSE; +} + +static void +vfbInitializeDefaultScreens(void) +{ + int i; + + for (i = 0; i < MAXSCREENS; i++) + { + vfbScreens[i].scrnum = i; + vfbScreens[i].width = VFB_DEFAULT_WIDTH; + vfbScreens[i].height = VFB_DEFAULT_HEIGHT; + vfbScreens[i].depth = VFB_DEFAULT_DEPTH; + vfbScreens[i].blackPixel = VFB_DEFAULT_BLACKPIXEL; + vfbScreens[i].whitePixel = VFB_DEFAULT_WHITEPIXEL; + vfbScreens[i].lineBias = VFB_DEFAULT_LINEBIAS; + vfbScreens[i].pfbMemory = NULL; + } + vfbNumScreens = 1; +} + +static int +vfbBitsPerPixel(int depth) +{ + if (depth == 1) return 1; + else if (depth <= 8) return 8; + else if (depth <= 16) return 16; + else return 32; +} + +void +ddxGiveUp() +{ + int i; + + /* clean up the framebuffers */ + + switch (fbmemtype) + { +#ifdef HAS_MMAP + case MMAPPED_FILE_FB: + for (i = 0; i < vfbNumScreens; i++) + { + if (-1 == unlink(vfbScreens[i].mmap_file)) + { + perror("unlink"); + ErrorF("unlink %s failed, errno %d", + vfbScreens[i].mmap_file, errno); + } + } + break; +#else /* HAS_MMAP */ + case MMAPPED_FILE_FB: + break; +#endif /* HAS_MMAP */ + +#ifdef HAS_SHM + case SHARED_MEMORY_FB: + for (i = 0; i < vfbNumScreens; i++) + { + if (-1 == shmdt((char *)vfbScreens[i].pXWDHeader)) + { + perror("shmdt"); + ErrorF("shmdt failed, errno %d", errno); + } + } + break; +#else /* HAS_SHM */ + case SHARED_MEMORY_FB: + break; +#endif /* HAS_SHM */ + + case NORMAL_MEMORY_FB: + for (i = 0; i < vfbNumScreens; i++) + { + Xfree(vfbScreens[i].pXWDHeader); + } + break; + } +} + +void +AbortDDX() +{ + ddxGiveUp(); +} + +#ifdef __DARWIN__ +void +DarwinHandleGUI(int argc, char *argv[]) +{ +} + +void GlxExtensionInit(); +void GlxWrapInitVisuals(void *procPtr); + +void +DarwinGlxExtensionInit() +{ + GlxExtensionInit(); +} + +void +DarwinGlxWrapInitVisuals( + void *procPtr) +{ + GlxWrapInitVisuals(procPtr); +} +#endif + +void +OsVendorInit() +{ +} + +void +OsVendorFatalError() +{ +} + +void ddxBeforeReset(void) +{ + return; +} + +void +ddxUseMsg() +{ + ErrorF("-screen scrn WxHxD set screen's width, height, depth\n"); + ErrorF("-pixdepths list-of-int support given pixmap depths\n"); +#ifdef RENDER + ErrorF("+/-render turn on/of RENDER extension support" + "(default on)\n"); +#endif + ErrorF("-linebias n adjust thin line pixelization\n"); + ErrorF("-blackpixel n pixel value for black\n"); + ErrorF("-whitepixel n pixel value for white\n"); + +#ifdef HAS_MMAP + ErrorF("-fbdir directory put framebuffers in mmap'ed files in directory\n"); +#endif + +#ifdef HAS_SHM + ErrorF("-shmem put framebuffers in shared memory\n"); +#endif +} + +/* ddxInitGlobals - called by |InitGlobals| from os/util.c */ +void ddxInitGlobals(void) +{ +} + +int +ddxProcessArgument(int argc, char *argv[], int i) +{ + static Bool firstTime = TRUE; + + if (firstTime) + { + vfbInitializeDefaultScreens(); + vfbInitializePixmapDepths(); + firstTime = FALSE; + } + + if (strcmp (argv[i], "-screen") == 0) /* -screen n WxHxD */ + { + int screenNum; + if (i + 2 >= argc) UseMsg(); + screenNum = atoi(argv[i+1]); + if (screenNum < 0 || screenNum >= MAXSCREENS) + { + ErrorF("Invalid screen number %d\n", screenNum); + UseMsg(); + } + if (3 != sscanf(argv[i+2], "%dx%dx%d", + &vfbScreens[screenNum].width, + &vfbScreens[screenNum].height, + &vfbScreens[screenNum].depth)) + { + ErrorF("Invalid screen configuration %s\n", argv[i+2]); + UseMsg(); + } + + if (screenNum >= vfbNumScreens) + vfbNumScreens = screenNum + 1; + lastScreen = screenNum; + return 3; + } + + if (strcmp (argv[i], "-pixdepths") == 0) /* -pixdepths list-of-depth */ + { + int depth, ret = 1; + + if (++i >= argc) UseMsg(); + while ((i < argc) && (depth = atoi(argv[i++])) != 0) + { + if (depth < 0 || depth > 32) + { + ErrorF("Invalid pixmap depth %d\n", depth); + UseMsg(); + } + vfbPixmapDepths[depth] = TRUE; + ret++; + } + return ret; + } + + if (strcmp (argv[i], "+render") == 0) /* +render */ + { + Render = TRUE; + return 1; + } + + if (strcmp (argv[i], "-render") == 0) /* -render */ + { + Render = FALSE; + return 1; + } + + if (strcmp (argv[i], "-blackpixel") == 0) /* -blackpixel n */ + { + Pixel pix; + if (++i >= argc) UseMsg(); + pix = atoi(argv[i]); + if (-1 == lastScreen) + { + int i; + for (i = 0; i < MAXSCREENS; i++) + { + vfbScreens[i].blackPixel = pix; + } + } + else + { + vfbScreens[lastScreen].blackPixel = pix; + } + return 2; + } + + if (strcmp (argv[i], "-whitepixel") == 0) /* -whitepixel n */ + { + Pixel pix; + if (++i >= argc) UseMsg(); + pix = atoi(argv[i]); + if (-1 == lastScreen) + { + int i; + for (i = 0; i < MAXSCREENS; i++) + { + vfbScreens[i].whitePixel = pix; + } + } + else + { + vfbScreens[lastScreen].whitePixel = pix; + } + return 2; + } + + if (strcmp (argv[i], "-linebias") == 0) /* -linebias n */ + { + unsigned int linebias; + if (++i >= argc) UseMsg(); + linebias = atoi(argv[i]); + if (-1 == lastScreen) + { + int i; + for (i = 0; i < MAXSCREENS; i++) + { + vfbScreens[i].lineBias = linebias; + } + } + else + { + vfbScreens[lastScreen].lineBias = linebias; + } + return 2; + } + +#ifdef HAS_MMAP + if (strcmp (argv[i], "-fbdir") == 0) /* -fbdir directory */ + { + if (++i >= argc) UseMsg(); + pfbdir = argv[i]; + fbmemtype = MMAPPED_FILE_FB; + return 2; + } +#endif /* HAS_MMAP */ + +#ifdef HAS_SHM + if (strcmp (argv[i], "-shmem") == 0) /* -shmem */ + { + fbmemtype = SHARED_MEMORY_FB; + return 1; + } +#endif + + return 0; +} + +#ifdef DDXTIME /* from ServerOSDefines */ +CARD32 +GetTimeInMillis() +{ + struct timeval tp; + + X_GETTIMEOFDAY(&tp); + return(tp.tv_sec * 1000) + (tp.tv_usec / 1000); +} +#endif + +static ColormapPtr InstalledMaps[MAXSCREENS]; + +static int +vfbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps) +{ + /* By the time we are processing requests, we can guarantee that there + * is always a colormap installed */ + *pmaps = InstalledMaps[pScreen->myNum]->mid; + return (1); +} + + +static void +vfbInstallColormap(ColormapPtr pmap) +{ + int index = pmap->pScreen->myNum; + ColormapPtr oldpmap = InstalledMaps[index]; + + if (pmap != oldpmap) + { + int entries; + XWDFileHeader *pXWDHeader; + XWDColor *pXWDCmap; + VisualPtr pVisual; + Pixel * ppix; + xrgb * prgb; + xColorItem *defs; + int i; + + if(oldpmap != (ColormapPtr)None) + WalkTree(pmap->pScreen, TellLostMap, (char *)&oldpmap->mid); + /* Install pmap */ + InstalledMaps[index] = pmap; + WalkTree(pmap->pScreen, TellGainedMap, (char *)&pmap->mid); + + entries = pmap->pVisual->ColormapEntries; + pXWDHeader = vfbScreens[pmap->pScreen->myNum].pXWDHeader; + pXWDCmap = vfbScreens[pmap->pScreen->myNum].pXWDCmap; + pVisual = pmap->pVisual; + + swapcopy32(pXWDHeader->visual_class, pVisual->class); + swapcopy32(pXWDHeader->red_mask, pVisual->redMask); + swapcopy32(pXWDHeader->green_mask, pVisual->greenMask); + swapcopy32(pXWDHeader->blue_mask, pVisual->blueMask); + swapcopy32(pXWDHeader->bits_per_rgb, pVisual->bitsPerRGBValue); + swapcopy32(pXWDHeader->colormap_entries, pVisual->ColormapEntries); + + ppix = (Pixel *)ALLOCATE_LOCAL(entries * sizeof(Pixel)); + prgb = (xrgb *)ALLOCATE_LOCAL(entries * sizeof(xrgb)); + defs = (xColorItem *)ALLOCATE_LOCAL(entries * sizeof(xColorItem)); + + for (i = 0; i < entries; i++) ppix[i] = i; + /* XXX truecolor */ + QueryColors(pmap, entries, ppix, prgb); + + for (i = 0; i < entries; i++) { /* convert xrgbs to xColorItems */ + defs[i].pixel = ppix[i] & 0xff; /* change pixel to index */ + defs[i].red = prgb[i].red; + defs[i].green = prgb[i].green; + defs[i].blue = prgb[i].blue; + defs[i].flags = DoRed|DoGreen|DoBlue; + } + (*pmap->pScreen->StoreColors)(pmap, entries, defs); + + DEALLOCATE_LOCAL(ppix); + DEALLOCATE_LOCAL(prgb); + DEALLOCATE_LOCAL(defs); + } +} + +static void +vfbUninstallColormap(ColormapPtr pmap) +{ + ColormapPtr curpmap = InstalledMaps[pmap->pScreen->myNum]; + + if(pmap == curpmap) + { + if (pmap->mid != pmap->pScreen->defColormap) + { + curpmap = (ColormapPtr) LookupIDByType(pmap->pScreen->defColormap, + RT_COLORMAP); + (*pmap->pScreen->InstallColormap)(curpmap); + } + } +} + +static void +vfbStoreColors(ColormapPtr pmap, int ndef, xColorItem *pdefs) +{ + XWDColor *pXWDCmap; + int i; + + if (pmap != InstalledMaps[pmap->pScreen->myNum]) + { + return; + } + + pXWDCmap = vfbScreens[pmap->pScreen->myNum].pXWDCmap; + + if ((pmap->pVisual->class | DynamicClass) == DirectColor) + { + return; + } + + for (i = 0; i < ndef; i++) + { + if (pdefs[i].flags & DoRed) + { + swapcopy16(pXWDCmap[pdefs[i].pixel].red, pdefs[i].red); + } + if (pdefs[i].flags & DoGreen) + { + swapcopy16(pXWDCmap[pdefs[i].pixel].green, pdefs[i].green); + } + if (pdefs[i].flags & DoBlue) + { + swapcopy16(pXWDCmap[pdefs[i].pixel].blue, pdefs[i].blue); + } + } +} + +static Bool +vfbSaveScreen(ScreenPtr pScreen, int on) +{ + return TRUE; +} + +#ifdef HAS_MMAP + +/* this flushes any changes to the screens out to the mmapped file */ +static void +vfbBlockHandler(pointer blockData, OSTimePtr pTimeout, pointer pReadmask) +{ + int i; + + for (i = 0; i < vfbNumScreens; i++) + { +#ifdef MS_ASYNC + if (-1 == msync((caddr_t)vfbScreens[i].pXWDHeader, + (size_t)vfbScreens[i].sizeInBytes, MS_ASYNC)) +#else + /* silly NetBSD and who else? */ + if (-1 == msync((caddr_t)vfbScreens[i].pXWDHeader, + (size_t)vfbScreens[i].sizeInBytes)) +#endif + { + perror("msync"); + ErrorF("msync failed, errno %d", errno); + } + } +} + + +static void +vfbWakeupHandler(pointer blockData, int result, pointer pReadmask) +{ +} + + +static void +vfbAllocateMmappedFramebuffer(vfbScreenInfoPtr pvfb) +{ +#define DUMMY_BUFFER_SIZE 65536 + char dummyBuffer[DUMMY_BUFFER_SIZE]; + int currentFileSize, writeThisTime; + + sprintf(pvfb->mmap_file, "%s/Xvfb_screen%d", pfbdir, pvfb->scrnum); + if (-1 == (pvfb->mmap_fd = open(pvfb->mmap_file, O_CREAT|O_RDWR, 0666))) + { + perror("open"); + ErrorF("open %s failed, errno %d", pvfb->mmap_file, errno); + return; + } + + /* Extend the file to be the proper size */ + + bzero(dummyBuffer, DUMMY_BUFFER_SIZE); + for (currentFileSize = 0; + currentFileSize < pvfb->sizeInBytes; + currentFileSize += writeThisTime) + { + writeThisTime = min(DUMMY_BUFFER_SIZE, + pvfb->sizeInBytes - currentFileSize); + if (-1 == write(pvfb->mmap_fd, dummyBuffer, writeThisTime)) + { + perror("write"); + ErrorF("write %s failed, errno %d", pvfb->mmap_file, errno); + return; + } + } + + /* try to mmap the file */ + + pvfb->pXWDHeader = (XWDFileHeader *)mmap((caddr_t)NULL, pvfb->sizeInBytes, + PROT_READ|PROT_WRITE, + MAP_FILE|MAP_SHARED, + pvfb->mmap_fd, 0); + if (-1 == (long)pvfb->pXWDHeader) + { + perror("mmap"); + ErrorF("mmap %s failed, errno %d", pvfb->mmap_file, errno); + pvfb->pXWDHeader = NULL; + return; + } + + if (!RegisterBlockAndWakeupHandlers(vfbBlockHandler, vfbWakeupHandler, + NULL)) + { + pvfb->pXWDHeader = NULL; + } +} +#endif /* HAS_MMAP */ + + +#ifdef HAS_SHM +static void +vfbAllocateSharedMemoryFramebuffer(vfbScreenInfoPtr pvfb) +{ + /* create the shared memory segment */ + + pvfb->shmid = shmget(IPC_PRIVATE, pvfb->sizeInBytes, IPC_CREAT|0777); + if (pvfb->shmid < 0) + { + perror("shmget"); + ErrorF("shmget %d bytes failed, errno %d", pvfb->sizeInBytes, errno); + return; + } + + /* try to attach it */ + + pvfb->pXWDHeader = (XWDFileHeader *)shmat(pvfb->shmid, 0, 0); + if (-1 == (long)pvfb->pXWDHeader) + { + perror("shmat"); + ErrorF("shmat failed, errno %d", errno); + pvfb->pXWDHeader = NULL; + return; + } + + ErrorF("screen %d shmid %d\n", pvfb->scrnum, pvfb->shmid); +} +#endif /* HAS_SHM */ + +static char * +vfbAllocateFramebufferMemory(vfbScreenInfoPtr pvfb) +{ + if (pvfb->pfbMemory) return pvfb->pfbMemory; /* already done */ + + pvfb->sizeInBytes = pvfb->paddedBytesWidth * pvfb->height; + + /* Calculate how many entries in colormap. This is rather bogus, because + * the visuals haven't even been set up yet, but we need to know because we + * have to allocate space in the file for the colormap. The number 10 + * below comes from the MAX_PSEUDO_DEPTH define in cfbcmap.c. + */ + + if (pvfb->depth <= 10) + { /* single index colormaps */ + pvfb->ncolors = 1 << pvfb->depth; + } + else + { /* decomposed colormaps */ + int nplanes_per_color_component = pvfb->depth / 3; + if (pvfb->depth % 3) nplanes_per_color_component++; + pvfb->ncolors = 1 << nplanes_per_color_component; + } + + /* add extra bytes for XWDFileHeader, window name, and colormap */ + + pvfb->sizeInBytes += SIZEOF(XWDheader) + XWD_WINDOW_NAME_LEN + + pvfb->ncolors * SIZEOF(XWDColor); + + pvfb->pXWDHeader = NULL; + switch (fbmemtype) + { +#ifdef HAS_MMAP + case MMAPPED_FILE_FB: vfbAllocateMmappedFramebuffer(pvfb); break; +#else + case MMAPPED_FILE_FB: break; +#endif + +#ifdef HAS_SHM + case SHARED_MEMORY_FB: vfbAllocateSharedMemoryFramebuffer(pvfb); break; +#else + case SHARED_MEMORY_FB: break; +#endif + + case NORMAL_MEMORY_FB: + pvfb->pXWDHeader = (XWDFileHeader *)Xalloc(pvfb->sizeInBytes); + break; + } + + if (pvfb->pXWDHeader) + { + pvfb->pXWDCmap = (XWDColor *)((char *)pvfb->pXWDHeader + + SIZEOF(XWDheader) + XWD_WINDOW_NAME_LEN); + pvfb->pfbMemory = (char *)(pvfb->pXWDCmap + pvfb->ncolors); + + return pvfb->pfbMemory; + } + else + return NULL; +} + + +static void +vfbWriteXWDFileHeader(ScreenPtr pScreen) +{ + vfbScreenInfoPtr pvfb = &vfbScreens[pScreen->myNum]; + XWDFileHeader *pXWDHeader = pvfb->pXWDHeader; + char hostname[XWD_WINDOW_NAME_LEN]; + unsigned long swaptest = 1; + int i; + + needswap = *(char *) &swaptest; + + pXWDHeader->header_size = (char *)pvfb->pXWDCmap - (char *)pvfb->pXWDHeader; + pXWDHeader->file_version = XWD_FILE_VERSION; + + pXWDHeader->pixmap_format = ZPixmap; + pXWDHeader->pixmap_depth = pvfb->depth; + pXWDHeader->pixmap_height = pXWDHeader->window_height = pvfb->height; + pXWDHeader->xoffset = 0; + pXWDHeader->byte_order = IMAGE_BYTE_ORDER; + pXWDHeader->bitmap_bit_order = BITMAP_BIT_ORDER; +#ifndef INTERNAL_VS_EXTERNAL_PADDING + pXWDHeader->pixmap_width = pXWDHeader->window_width = pvfb->width; + pXWDHeader->bitmap_unit = BITMAP_SCANLINE_UNIT; + pXWDHeader->bitmap_pad = BITMAP_SCANLINE_PAD; +#else + pXWDHeader->pixmap_width = pXWDHeader->window_width = pvfb->paddedWidth; + pXWDHeader->bitmap_unit = BITMAP_SCANLINE_UNIT_PROTO; + pXWDHeader->bitmap_pad = BITMAP_SCANLINE_PAD_PROTO; +#endif + pXWDHeader->bits_per_pixel = pvfb->bitsPerPixel; + pXWDHeader->bytes_per_line = pvfb->paddedBytesWidth; + pXWDHeader->ncolors = pvfb->ncolors; + + /* visual related fields are written when colormap is installed */ + + pXWDHeader->window_x = pXWDHeader->window_y = 0; + pXWDHeader->window_bdrwidth = 0; + + /* write xwd "window" name: Xvfb hostname:server.screen */ + + if (-1 == gethostname(hostname, sizeof(hostname))) + hostname[0] = 0; + else + hostname[XWD_WINDOW_NAME_LEN-1] = 0; + sprintf((char *)(pXWDHeader+1), "Xvfb %s:%s.%d", hostname, display, + pScreen->myNum); + + /* write colormap pixel slot values */ + + for (i = 0; i < pvfb->ncolors; i++) + { + pvfb->pXWDCmap[i].pixel = i; + } + + /* byte swap to most significant byte first */ + + if (needswap) + { + SwapLongs((CARD32 *)pXWDHeader, SIZEOF(XWDheader)/4); + for (i = 0; i < pvfb->ncolors; i++) + { + register char n; + swapl(&pvfb->pXWDCmap[i].pixel, n); + } + } +} + + +static Bool +vfbCursorOffScreen (ScreenPtr *ppScreen, int *x, int *y) +{ + return FALSE; +} + +static void +vfbCrossScreen (ScreenPtr pScreen, Bool entering) +{ +} + +static miPointerScreenFuncRec vfbPointerCursorFuncs = +{ + vfbCursorOffScreen, + vfbCrossScreen, + miPointerWarpCursor +}; + +static Bool +vfbCloseScreen(int index, ScreenPtr pScreen) +{ + vfbScreenInfoPtr pvfb = &vfbScreens[index]; + int i; + + pScreen->CloseScreen = pvfb->closeScreen; + + /* + * XXX probably lots of stuff to clean. For now, + * clear InstalledMaps[] so that server reset works correctly. + */ + for (i = 0; i < MAXSCREENS; i++) + InstalledMaps[i] = NULL; + + return pScreen->CloseScreen(index, pScreen); +} + +static Bool +vfbScreenInit(int index, ScreenPtr pScreen, int argc, char **argv) +{ + vfbScreenInfoPtr pvfb = &vfbScreens[index]; + int dpix = monitorResolution, dpiy = monitorResolution; + int ret; + char *pbits; + + if (dpix == 0) + dpix = 100; + + if (dpiy == 0) + dpiy = 100; + + pvfb->paddedBytesWidth = PixmapBytePad(pvfb->width, pvfb->depth); + pvfb->bitsPerPixel = vfbBitsPerPixel(pvfb->depth); + if (pvfb->bitsPerPixel >= 8 ) + pvfb->paddedWidth = pvfb->paddedBytesWidth / (pvfb->bitsPerPixel / 8); + else + pvfb->paddedWidth = pvfb->paddedBytesWidth * 8; + pbits = vfbAllocateFramebufferMemory(pvfb); + if (!pbits) return FALSE; + + miSetPixmapDepths (); + + switch (pvfb->depth) { + case 8: + miSetVisualTypesAndMasks (8, + ((1 << StaticGray) | + (1 << GrayScale) | + (1 << StaticColor) | + (1 << PseudoColor) | + (1 << TrueColor) | + (1 << DirectColor)), + 8, PseudoColor, 0, 0, 0); + break; +#if 0 + /* 12bit PseudoColor with 12bit color resolution + * (to simulate SGI hardware and the 12bit PseudoColor emulation layer) */ + case 12: + miSetVisualTypesAndMasks (12, + ((1 << StaticGray) | + (1 << GrayScale) | + (1 << StaticColor) | + (1 << PseudoColor) | + (1 << TrueColor) | + (1 << DirectColor)), + 12, PseudoColor, 0, 0, 0); + break; +#endif + case 15: + miSetVisualTypesAndMasks (15, + ((1 << TrueColor) | + (1 << DirectColor)), + 8, TrueColor, 0x7c00, 0x03e0, 0x001f); + break; + case 16: + miSetVisualTypesAndMasks (16, + ((1 << TrueColor) | + (1 << DirectColor)), + 8, TrueColor, 0xf800, 0x07e0, 0x001f); + break; + case 24: + miSetVisualTypesAndMasks (24, + ((1 << TrueColor) | + (1 << DirectColor)), + 8, TrueColor, 0xff0000, 0x00ff00, 0x0000ff); + break; +#if 0 + /* 30bit TrueColor (to simulate Sun's XVR-1000/-4000 high quality + * framebuffer series) */ + case 30: + miSetVisualTypesAndMasks (30, + ((1 << TrueColor) | + (1 << DirectColor)), + 10, TrueColor, 0x3ff00000, 0x000ffc00, 0x000003ff); + break; +#endif + } + + ret = fbScreenInit(pScreen, pbits, pvfb->width, pvfb->height, + dpix, dpiy, pvfb->paddedWidth,pvfb->bitsPerPixel); +#ifdef RENDER + if (ret && Render) + fbPictureInit (pScreen, 0, 0); +#endif + + if (!ret) return FALSE; + + miInitializeBackingStore(pScreen); + + /* + * Circumvent the backing store that was just initialised. This amounts + * to a truely bizarre way of initialising SaveDoomedAreas and friends. + */ + + pScreen->InstallColormap = vfbInstallColormap; + pScreen->UninstallColormap = vfbUninstallColormap; + pScreen->ListInstalledColormaps = vfbListInstalledColormaps; + + pScreen->SaveScreen = vfbSaveScreen; + pScreen->StoreColors = vfbStoreColors; + + miDCInitialize(pScreen, &vfbPointerCursorFuncs); + + vfbWriteXWDFileHeader(pScreen); + + pScreen->blackPixel = pvfb->blackPixel; + pScreen->whitePixel = pvfb->whitePixel; + + ret = fbCreateDefColormap(pScreen); + + miSetZeroLineBias(pScreen, pvfb->lineBias); + + pvfb->closeScreen = pScreen->CloseScreen; + pScreen->CloseScreen = vfbCloseScreen; + + return ret; + +} /* end vfbScreenInit */ + + +void +InitOutput(ScreenInfo *screenInfo, int argc, char **argv) +{ + int i; + int NumFormats = 0; + + /* initialize pixmap formats */ + + /* must have a pixmap depth to match every screen depth */ + for (i = 0; i < vfbNumScreens; i++) + { + vfbPixmapDepths[vfbScreens[i].depth] = TRUE; + } + + /* RENDER needs a good set of pixmaps. */ + if (Render) { + vfbPixmapDepths[1] = TRUE; + vfbPixmapDepths[4] = TRUE; + vfbPixmapDepths[8] = TRUE; +#if 0 + vfbPixmapDepths[12] = TRUE; +#endif +/* vfbPixmapDepths[15] = TRUE; */ + vfbPixmapDepths[16] = TRUE; + vfbPixmapDepths[24] = TRUE; +#if 0 + vfbPixmapDepths[30] = TRUE; +#endif + vfbPixmapDepths[32] = TRUE; + } + + for (i = 1; i <= 32; i++) + { + if (vfbPixmapDepths[i]) + { + if (NumFormats >= MAXFORMATS) + FatalError ("MAXFORMATS is too small for this server\n"); + screenInfo->formats[NumFormats].depth = i; + screenInfo->formats[NumFormats].bitsPerPixel = vfbBitsPerPixel(i); + screenInfo->formats[NumFormats].scanlinePad = BITMAP_SCANLINE_PAD; + NumFormats++; + } + } + + screenInfo->imageByteOrder = IMAGE_BYTE_ORDER; + screenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT; + screenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD; + screenInfo->bitmapBitOrder = BITMAP_BIT_ORDER; + screenInfo->numPixmapFormats = NumFormats; + + /* initialize screens */ + + for (i = 0; i < vfbNumScreens; i++) + { + if (-1 == AddScreen(vfbScreenInit, argc, argv)) + { + FatalError("Couldn't add screen %d", i); + } + } + +} /* end InitOutput */ + +/* this is just to get the server to link on AIX */ +#ifdef AIXV3 +int SelectWaitTime = 10000; /* usec */ +#endif + diff --git a/nx-X11/programs/Xserver/hw/vfb/Xvfb.man b/nx-X11/programs/Xserver/hw/vfb/Xvfb.man new file mode 100644 index 000000000..7499c49f0 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/vfb/Xvfb.man @@ -0,0 +1,132 @@ +.\" $XdotOrg: xc/programs/Xserver/hw/vfb/Xvfb.man,v 1.4 2005/09/08 01:15:47 anholt Exp $ +.\" $Xorg: Xvfb.man,v 1.4 2001/02/09 02:04:45 xorgcvs Exp $ +.\" Copyright 1993, 1998 The Open Group +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and its +.\" documentation for any purpose is hereby granted without fee, provided that +.\" the above copyright notice appear in all copies and that both that +.\" copyright notice and this permission notice appear in supporting +.\" documentation. +.\" +.\" The above copyright notice and this permission notice shall be included +.\" in all copies or substantial portions of the Software. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +.\" IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR +.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +.\" OTHER DEALINGS IN THE SOFTWARE. +.\" +.\" Except as contained in this notice, the name of The Open Group shall +.\" not be used in advertising or otherwise to promote the sale, use or +.\" other dealings in this Software without prior written authorization +.\" from The Open Group. +.\" +.\" $XFree86: xc/programs/Xserver/hw/vfb/Xvfb.man,v 1.9 2001/12/14 19:59:45 dawes Exp $ +.\" +.TH XVFB 1 __xorgversion__ +.SH NAME +Xvfb \- virtual framebuffer X server for X Version 11 +.SH SYNOPSIS +.B Xvfb +[ option ] ... +.SH DESCRIPTION +.I Xvfb +is an X server that can run on machines with no display hardware +and no physical input devices. It emulates a dumb framebuffer using +virtual memory. +.PP +The primary use of this server was intended to be server testing. The +fb code for any depth can be exercised with this server +without the need for real hardware that supports the desired depths. +The X community has found many other novel uses for \fIXvfb\fP, +including testing clients against unusual depths and screen +configurations, doing batch processing with \fIXvfb\fP as a background +rendering engine, load testing, as an aid to porting the X server to a +new platform, and providing an unobtrusive way to run applications +that don't really need an X server but insist on having one anyway. +.SH BUILDING +To build \fIXvfb\fP, put the following in your host.def and remake. +.PP +\&#define BuildServer YES /\(** if you aren't already building other servers */ +.br +\&#define XVirtualFramebufferServer YES + +.SH OPTIONS +.PP +In addition to the normal server options described in the \fIXserver(1)\fP +manual page, \fIXvfb\fP accepts the following command line switches: +.TP 4 +.B "\-screen \fIscreennum\fP \fIWxHxD\fP" +This option creates screen \fIscreennum\fP and sets its width, height, +and depth to W, H, and D respectively. By default, only screen 0 exists +and has the dimensions 1280x1024x12. +.TP 4 +.B "\-pixdepths \fIlist-of-depths\fP" +This option specifies a list of pixmap depths that the server should +support in addition to the depths implied by the supported screens. +\fIlist-of-depths\fP is a space-separated list of integers that can +have values from 1 to 32. +.TP 4 +.B "\-fbdir \fIframebuffer-directory\fP" +This option specifies the directory in which the memory mapped files +containing the framebuffer memory should be created. +See FILES. +This option only exists on machines that have the mmap and msync system +calls. +.TP 4 +.B "\-shmem" +This option specifies that the framebuffer should be put in shared memory. +The shared memory ID for each screen will be printed by the server. +The shared memory is in xwd format. +This option only exists on machines that support the System V shared memory +interface. +.PP +If neither \fB\-shmem\fP nor \fB\-fbdir\fP is specified, +the framebuffer memory will be allocated with malloc(). +.TP 4 +.B "\-linebias \fIn\fP" +This option specifies how to adjust the pixelization of thin lines. +The value \fIn\fP is a bitmask of octants in which to prefer an axial +step when the Bresenham error term is exactly zero. See the file +Xserver/mi/miline.h for more information. This option is probably only useful +to server developers to experiment with the range of line pixelization +possible with the fb code. +.TP 4 +.B "\-blackpixel \fIpixel-value\fP, \-whitepixel \fIpixel-value\fP" +These options specify the black and white pixel values the server should use. +.SH FILES +The following files are created if the \-fbdir option is given. +.TP 4 +\fIframebuffer-directory\fP/Xvfb_screen<n> +Memory mapped file containing screen n's framebuffer memory, one file +per screen. The file is in xwd format. Thus, taking a full-screen +snapshot can be done with a file copy command, and the resulting +snapshot will even contain the cursor image. +.SH EXAMPLES +.TP 8 +Xvfb :1 -screen 0 1600x1200x32 +The server will listen for connections as server number 1, and screen 0 +will be depth 32 1600x1200. +.TP 8 +Xvfb :1 -screen 1 1600x1200x16 +The server will listen for connections as server number 1, will have the +default screen configuration (one screen, 1280x1024x12), and screen 1 +will be depth 16 1600x1200. +.TP 8 +Xvfb -pixdepths 3 27 -fbdir /usr/tmp +The server will listen for connections as server number 0, will have the +default screen configuration (one screen, 1280x1024x12), +will also support pixmap +depths of 3 and 27, +and will use memory mapped files in /usr/tmp for the framebuffer. +.TP 8 +xwud -in /usr/tmp/Xvfb_screen0 +Displays screen 0 of the server started by the preceding example. +.SH "SEE ALSO" +.PP +X(__miscmansuffix__), Xserver(1), xwd(1), xwud(1), XWDFile.h +.SH AUTHORS +David P. Wiggins, The Open Group, Inc. diff --git a/nx-X11/programs/Xserver/hw/vfb/lk201kbd.h b/nx-X11/programs/Xserver/hw/vfb/lk201kbd.h new file mode 100644 index 000000000..9b4090ed0 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/vfb/lk201kbd.h @@ -0,0 +1,159 @@ +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +/* $Xorg: lk201kbd.h,v 1.4 2001/02/09 02:04:45 xorgcvs Exp $ */ + +#define MIN_LK201_KEY 86 +#define MAX_LK201_KEY 251 +#define LK201_GLYPHS_PER_KEY 2 + +#define KEY_F1 86 +#define KEY_F2 87 +#define KEY_F3 88 +#define KEY_F4 89 +#define KEY_F5 90 +#define KEY_F6 100 +#define KEY_F7 101 +#define KEY_F8 102 +#define KEY_F9 103 +#define KEY_F10 104 +#define KEY_F11 113 +#define KEY_F12 114 +#define KEY_F13 115 +#define KEY_F14 116 +#define KEY_HELP 124 +#define KEY_MENU 125 +#define KEY_F17 128 +#define KEY_F18 129 +#define KEY_F19 130 +#define KEY_F20 131 +#define KEY_FIND 138 +#define KEY_INSERT_HERE 139 +#define KEY_REMOVE 140 +#define KEY_SELECT 141 +#define KEY_PREV_SCREEN 142 +#define KEY_NEXT_SCREEN 143 +#define KEY_KP_0 146 /* key pad */ +#define KEY_KP_PERIOD 148 /* key pad */ +#define KEY_KP_ENTER 149 /* key pad */ +#define KEY_KP_1 150 /* key pad */ +#define KEY_KP_2 151 /* key pad */ +#define KEY_KP_3 152 /* key pad */ +#define KEY_KP_4 153 /* key pad */ +#define KEY_KP_5 154 /* key pad */ +#define KEY_KP_6 155 /* key pad */ +#define KEY_KP_COMMA 156 /* key pad */ +#define KEY_KP_7 157 /* key pad */ +#define KEY_KP_8 158 /* key pad */ +#define KEY_KP_9 159 /* key pad */ +#define KEY_KP_HYPHEN 160 +#define KEY_KP_PF1 161 +#define KEY_KP_PF2 162 +#define KEY_KP_PF3 163 +#define KEY_KP_PF4 164 +#define KEY_LEFT 167 +#define KEY_RIGHT 168 +#define KEY_DOWN 169 +#define KEY_UP 170 +#define KEY_SHIFT 174 +#define KEY_CTRL 175 +#define KEY_LOCK 176 +#define KEY_COMPOSE 177 +#define KEY_APPLE 177 +#define KEY_META 177 +#define KEY_DELETE 188 +#define KEY_RETURN 189 +#define KEY_TAB 190 +#define KEY_TILDE 191 +#define KEY_TR_1 192 /* Top Row */ +#define KEY_Q 193 +#define KEY_A 194 +#define KEY_Z 195 +#define KEY_TR_2 197 +#define KEY_W 198 +#define KEY_S 199 +#define KEY_X 200 +#define KEY_LANGLE_RANGLE 201 /* xxx */ +#define KEY_TR_3 203 +#define KEY_E 204 +#define KEY_D 205 +#define KEY_C 206 +#define KEY_TR_4 208 +#define KEY_R 209 +#define KEY_F 210 +#define KEY_V 211 +#define KEY_SPACE 212 +#define KEY_TR_5 214 +#define KEY_T 215 +#define KEY_G 216 +#define KEY_B 217 +#define KEY_TR_6 219 +#define KEY_Y 220 +#define KEY_H 221 +#define KEY_N 222 +#define KEY_TR_7 224 +#define KEY_U 225 +#define KEY_J 226 +#define KEY_M 227 +#define KEY_TR_8 229 +#define KEY_I 230 +#define KEY_K 231 +#define KEY_COMMA 232 /* xxx */ +#define KEY_TR_9 234 +#define KEY_O 235 +#define KEY_L 236 +#define KEY_PERIOD 237 /* xxx */ +#define KEY_TR_0 239 +#define KEY_P 240 +#define KEY_SEMICOLON 242 /* xxx */ +#define KEY_QMARK 243 +#define KEY_PLUS 245 /* xxx */ +#define KEY_RBRACE 246 +#define KEY_VBAR 247 /* xxx */ +#define KEY_UBAR 249 /* xxx */ +#define KEY_LBRACE 250 +#define KEY_QUOTE 251 |