home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-08-26 | 61.7 KB | 2,199 lines |
- Path: uunet!cs.utexas.edu!sun-barr!cronkite.Central.Sun.COM!exodus!crl.dec.com!treese
- From: treese@crl.dec.com
- Newsgroups: comp.sources.x
- Subject: v14i015: ddx support for ULTRIX 4.2 and X11R4, Part02/02
- Message-ID: <19079@exodus.Eng.Sun.COM>
- Date: 27 Aug 91 06:09:06 GMT
- References: <csx-14i014-ultrix.patch@uunet.UU.NET>
- Sender: news@exodus.Eng.Sun.COM
- Lines: 2187
- Approved: argv@sun.com
-
- Submitted-by: treese@crl.dec.com
- Posting-number: Volume 14, Issue 15
- Archive-name: ultrix.patch/part02
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 2 (of 2)."
- # Contents: server/ddx/dec/ws/init.c server/ddx/dec/ws/keynames.h
- # server/ddx/dec/ws/patchlevel.h server/ddx/dec/ws/ws.h
- # server/ddx/dec/ws/ws_color.c server/ddx/dec/ws/ws_io.c
- # Wrapped by treese@wachusett.crl.dec.com on Wed Jul 24 23:27:14 1991
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'server/ddx/dec/ws/init.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'server/ddx/dec/ws/init.c'\"
- else
- echo shar: Extracting \"'server/ddx/dec/ws/init.c'\" \(7097 characters\)
- sed "s/^X//" >'server/ddx/dec/ws/init.c' <<'END_OF_FILE'
- X/***********************************************************
- Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts,
- and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
- X
- X All Rights Reserved
- X
- 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 names of Digital or MIT not be
- used in advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
- X
- 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.
- X
- X******************************************************************/
- X
- X/* $Header: init.c,v 1.1 91/05/11 10:51:07 rws Exp $ */
- X
- X#include <stdio.h>
- X#include <sys/types.h>
- X#include <sys/file.h>
- X#include <sys/time.h>
- X#include <sys/tty.h>
- X#include <errno.h>
- X#include <sys/devio.h>
- X
- X#include "X.h"
- X
- X#include "scrnintstr.h"
- X#include "servermd.h"
- X
- X#include "input.h"
- X/* XXX */
- X#include <sys/workstation.h>
- X#include <sys/inputdevice.h>
- X#include "ws.h"
- X
- extern void wsMouseProc();
- extern void wsKeybdProc();
- extern void wsClick();
- extern void wsChangePointerControl();
- extern KeybdCtrl defaultKeyboardControl;
- ws_event_queue *queue;
- X
- X#define NUMFORMATS 3
- static PixmapFormatRec formats[] = {
- X {1, 1, BITMAP_SCANLINE_PAD}, /* 1 bit deep */
- X {8, 8, BITMAP_SCANLINE_PAD}, /* 8-bit deep */
- X {24, 32, BITMAP_SCANLINE_PAD},
- X};
- X
- Bool fbInitProc();
- extern int num_accelerator_types;
- X
- extern wsAcceleratorTypes types[];
- X
- ws_screen_descriptor screenDesc[MAXSCREENS];
- X
- Bool
- commandLineMatch( argc, argv, pat, pmatch)
- X int argc; /* may NOT be changed */
- X char * argv[]; /* may NOT be changed */
- X char * pat;
- X{
- X int ic;
- X
- X for ( ic=0; ic<argc; ic++)
- X if ( strcmp( argv[ic], pat) == 0)
- X return TRUE;
- X return FALSE;
- X}
- X
- Bool
- commandLinePairMatch( argc, argv, pat, pmatch)
- X int argc; /* may NOT be changed */
- X char * argv[]; /* may NOT be changed */
- X char * pat;
- X char ** pmatch; /* RETURN */
- X{
- X register int ic;
- X
- X for ( ic=0; ic<argc; ic++)
- X if ( strcmp( argv[ic], pat) == 0) {
- X *pmatch = argv[ ic+1];
- X return TRUE;
- X }
- X return FALSE;
- X}
- X
- ws_descriptor wsinfo;
- int wsFd;
- int ws_cpu;
- X
- int wsScreenPrivateIndex;
- X/* the following filth is forced by a broken dix interface */
- X
- InitOutput(screenInfo, argc, argv)
- X ScreenInfo *screenInfo;
- X int argc;
- X char **argv;
- X{
- X int i;
- X int si = 0;
- X static int inited = FALSE;
- X static int ma = 4;
- X static int mt = 4;
- X static PtrCtrl ctrl;
- X static int clicklevel;
- X
- X screenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
- X screenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
- X screenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
- X screenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
- X screenInfo->numPixmapFormats = NUMFORMATS;
- X
- X for (i=0; i< NUMFORMATS; i++) {
- X screenInfo->formats[i].depth = formats[i].depth;
- X screenInfo->formats[i].bitsPerPixel = formats[i].bitsPerPixel;
- X screenInfo->formats[i].scanlinePad = formats[i].scanlinePad;
- X }
- X
- X if (!inited) {
- X char *clickvolume;
- X char *mouseAcceleration;
- X char *mouseThreshold;
- X ws_keyboard_control control;
- X inited = TRUE;
- X if ((wsFd = open("/dev/mouse", O_RDWR, 0)) < 0) {
- X ErrorF("couldn't open device\n");
- X exit (1);
- X }
- X if (ioctl (wsFd, GET_WORKSTATION_INFO, &wsinfo) != 0) {
- X ErrorF("GET_WORKSTATION_INFO failed \n");
- X exit(1);
- X }
- X control.device_number = wsinfo.console_keyboard;
- X if (ioctl(wsFd, GET_KEYBOARD_CONTROL, &control) == -1) {
- X ErrorF("GET_KEYBOARD_CONTROL failed\n");
- X exit(1);
- X }
- X defaultKeyboardControl.click = control.click;
- X defaultKeyboardControl.bell = control.bell;
- X defaultKeyboardControl.bell_pitch = control.bell_pitch;
- X defaultKeyboardControl.bell_duration = control.bell_duration;
- X defaultKeyboardControl.autoRepeat = control.auto_repeat;
- X defaultKeyboardControl.leds = control.leds;
- X bcopy (control.autorepeats, defaultKeyboardControl.autoRepeats, 32);
- X
- X /* turn off cursors on additional screens initially */
- X/*
- X * jmg - have to do a lot of other stuff here dealing with visuals
- X * and depths
- X */
- X /*
- X * deal with arguments. Note we don't bother until we've successfully
- X * opened the device.
- X */
- X
- X if (commandLinePairMatch( argc, argv, "c", &clickvolume))
- X sscanf( clickvolume, "%d", &clicklevel);
- X if (commandLinePairMatch( argc, argv, "-a", &mouseAcceleration))
- X sscanf( mouseAcceleration, "%d", &ma);
- X if (commandLinePairMatch( argc, argv, "-t", &mouseThreshold))
- X sscanf( mouseThreshold, "%d", &mt);
- X
- X }
- X ctrl.num = ma;
- X ctrl.den = 1;
- X ctrl.threshold = mt;
- X wsChangePointerControl( (DevicePtr) NULL, &ctrl);
- X wsClick(clicklevel);
- X if (commandLineMatch(argc, argv, "-c")) wsClick(0);
- X wsScreenPrivateIndex = AllocateScreenPrivateIndex();
- X ws_cpu = wsinfo.cpu;
- X for(i = 0; i < wsinfo.num_screens_exist; i++) {
- X int j, DECaccelerator = FALSE;
- X screenDesc[si].screen = i;
- X if (ioctl(wsFd, GET_SCREEN_INFO, &screenDesc[si]) == -1) {
- X ErrorF("GET_SCREEN_INFO failed\n");
- X exit(1);
- X }
- X if (si >= MAXSCREENS) {
- X ErrorF ("Server configured for %d screens, can't configure screen %d\n", MAXSCREENS, si);
- X break;
- X }
- X for (j = 0; j < num_accelerator_types; j++) {
- X if (strcmp (screenDesc[si].moduleID, types[j].moduleID) == 0) {
- X DECaccelerator = TRUE;
- X break;
- X }
- X }
- X if(DECaccelerator)
- X j = AddScreen(types[j].createProc, argc, argv);
- X else
- X j = AddScreen(fbInitProc, argc, argv);
- X /*
- X * AddScreen either returns -1 (error) or # of screens installed
- X * (current index). screenDesc[] is exactly parallel to
- X * screenInfo.screens[] since the initProc() arg will be called
- X * with AddScreen's index, which in turn gets used for screenDesc[].
- X */
- X if (j == -1) {
- X ErrorF("Could not AddScreen, ID = %s\n",
- X screenDesc[si].moduleID);
- X } else
- X si = j+1;
- X }
- X#ifdef XINPUT
- X ExtInitOutput(screenInfo, argc, argv);
- X#endif
- X}
- X
- X
- X
- void
- InitInput(argc, argv)
- X int argc;
- X char *argv[];
- X{
- X DevicePtr p, k;
- X static int inited = FALSE;
- X
- X p = AddInputDevice(wsMouseProc, TRUE);
- X
- X k = AddInputDevice(wsKeybdProc, TRUE);
- X
- X RegisterPointerDevice(p);
- X RegisterKeyboardDevice(k);
- X
- X#ifdef XINPUT
- X ExtInitInput(argc, argv);
- X#endif
- X
- X if (!inited) {
- X inited = TRUE;
- X if (ioctl(wsFd, GET_AND_MAP_EVENT_QUEUE, &queue) == -1) {
- X ErrorF("GET_AND_MAP_EVENT_QUEUE failed\n");
- X exit(1);
- X }
- X }
- X
- X}
- END_OF_FILE
- if test 7097 -ne `wc -c <'server/ddx/dec/ws/init.c'`; then
- echo shar: \"'server/ddx/dec/ws/init.c'\" unpacked with wrong size!
- fi
- # end of 'server/ddx/dec/ws/init.c'
- fi
- if test -f 'server/ddx/dec/ws/keynames.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'server/ddx/dec/ws/keynames.h'\"
- else
- echo shar: Extracting \"'server/ddx/dec/ws/keynames.h'\" \(4272 characters\)
- sed "s/^X//" >'server/ddx/dec/ws/keynames.h' <<'END_OF_FILE'
- X/***********************************************************
- Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts,
- and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
- X
- X All Rights Reserved
- X
- 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 names of Digital or MIT not be
- used in advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
- X
- 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.
- X
- X******************************************************************/
- X/* Keycodes for lk201 and lk401 keyboards used by code in ws_io.c
- X that loads default keysym values from a file.
- X*/
- X
- X#define MIN_LK201_KEY 86
- X#define MAX_LK201_KEY 251
- X#define LK201_GLYPHS_PER_KEY 2
- X
- X/* the keys themselves */
- X
- X#define KEY_F1 86
- X#define KEY_F2 87
- X#define KEY_F3 88
- X#define KEY_F4 89
- X#define KEY_F5 90
- X#define KEY_F6 100
- X#define KEY_F7 101
- X#define KEY_F8 102
- X#define KEY_F9 103
- X#define KEY_F10 104
- X#define KEY_F11 113
- X#define KEY_F12 114
- X#define KEY_F13 115
- X#define KEY_F14 116
- X#define KEY_HELP 124
- X#define KEY_MENU 125
- X#define KEY_F17 128
- X#define KEY_F18 129
- X#define KEY_F19 130
- X#define KEY_F20 131
- X#define KEY_FIND 138
- X#define KEY_INSERT_HERE 139
- X#define KEY_REMOVE 140
- X#define KEY_SELECT 141
- X#define KEY_PREV_SCREEN 142
- X#define KEY_NEXT_SCREEN 143
- X#define KEY_KP_0 146 /* key pad */
- X#define KEY_KP_PERIOD 148 /* key pad */
- X#define KEY_KP_ENTER 149 /* key pad */
- X#define KEY_KP_1 150 /* key pad */
- X#define KEY_KP_2 151 /* key pad */
- X#define KEY_KP_3 152 /* key pad */
- X#define KEY_KP_4 153 /* key pad */
- X#define KEY_KP_5 154 /* key pad */
- X#define KEY_KP_6 155 /* key pad */
- X#define KEY_KP_COMMA 156 /* key pad */
- X#define KEY_KP_7 157 /* key pad */
- X#define KEY_KP_8 158 /* key pad */
- X#define KEY_KP_9 159 /* key pad */
- X#define KEY_KP_HYPHEN 160
- X#define KEY_KP_PF1 161
- X#define KEY_KP_PF2 162
- X#define KEY_KP_PF3 163
- X#define KEY_KP_PF4 164
- X#define KEY_LEFT 167
- X#define KEY_RIGHT 168
- X#define KEY_DOWN 169
- X#define KEY_UP 170
- X#define KEY_SHIFT_R 171 /* LK401 */
- X#define KEY_ALT_L 172 /* LK401 */
- X#define KEY_COMPOSE_R 173 /* LK401 */
- X#define KEY_SHIFT 174
- X#define KEY_SHIFT_L 174
- X#define KEY_CTRL 175
- X#define KEY_LOCK 176
- X#define KEY_COMPOSE 177
- X#define KEY_APPLE 177
- X#define KEY_META 177
- X#define KEY_ALT_R 178 /* LK401 */
- X#define KEY_DELETE 188
- X#define KEY_RETURN 189
- X#define KEY_TAB 190
- X#define KEY_TILDE 191
- X#define KEY_TR_1 192 /* Top Row */
- X#define KEY_Q 193
- X#define KEY_A 194
- X#define KEY_Z 195
- X#define KEY_TR_2 197
- X#define KEY_W 198
- X#define KEY_S 199
- X#define KEY_X 200
- X#define KEY_LANGLE_RANGLE 201 /* xxx */
- X#define KEY_TR_3 203
- X#define KEY_E 204
- X#define KEY_D 205
- X#define KEY_C 206
- X#define KEY_TR_4 208
- X#define KEY_R 209
- X#define KEY_F 210
- X#define KEY_V 211
- X#define KEY_SPACE 212
- X#define KEY_TR_5 214
- X#define KEY_T 215
- X#define KEY_G 216
- X#define KEY_B 217
- X#define KEY_TR_6 219
- X#define KEY_Y 220
- X#define KEY_H 221
- X#define KEY_N 222
- X#define KEY_TR_7 224
- X#define KEY_U 225
- X#define KEY_J 226
- X#define KEY_M 227
- X#define KEY_TR_8 229
- X#define KEY_I 230
- X#define KEY_K 231
- X#define KEY_COMMA 232 /* xxx */
- X#define KEY_TR_9 234
- X#define KEY_O 235
- X#define KEY_L 236
- X#define KEY_PERIOD 237 /* xxx */
- X#define KEY_TR_0 239
- X#define KEY_P 240
- X#define KEY_SEMICOLON 242 /* xxx */
- X#define KEY_QMARK 243
- X#define KEY_PLUS 245 /* xxx */
- X#define KEY_RBRACE 246
- X#define KEY_VBAR 247 /* xxx */
- X#define KEY_UBAR 249 /* xxx */
- X#define KEY_LBRACE 250
- X#define KEY_QUOTE 251
- END_OF_FILE
- if test 4272 -ne `wc -c <'server/ddx/dec/ws/keynames.h'`; then
- echo shar: \"'server/ddx/dec/ws/keynames.h'\" unpacked with wrong size!
- fi
- # end of 'server/ddx/dec/ws/keynames.h'
- fi
- if test -f 'server/ddx/dec/ws/patchlevel.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'server/ddx/dec/ws/patchlevel.h'\"
- else
- echo shar: Extracting \"'server/ddx/dec/ws/patchlevel.h'\" \(21 characters\)
- sed "s/^X//" >'server/ddx/dec/ws/patchlevel.h' <<'END_OF_FILE'
- X#define PATCHLEVEL 0
- END_OF_FILE
- if test 21 -ne `wc -c <'server/ddx/dec/ws/patchlevel.h'`; then
- echo shar: \"'server/ddx/dec/ws/patchlevel.h'\" unpacked with wrong size!
- fi
- # end of 'server/ddx/dec/ws/patchlevel.h'
- fi
- if test -f 'server/ddx/dec/ws/ws.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'server/ddx/dec/ws/ws.h'\"
- else
- echo shar: Extracting \"'server/ddx/dec/ws/ws.h'\" \(3160 characters\)
- sed "s/^X//" >'server/ddx/dec/ws/ws.h' <<'END_OF_FILE'
- X/***********************************************************
- Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts,
- and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
- X
- X All Rights Reserved
- X
- 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 names of Digital or MIT not be
- used in advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
- X
- 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.
- X
- X******************************************************************/
- X/* $Header: ws.h,v 1.1 91/05/11 10:51:12 rws Exp $ */
- X
- X/* $Log: ws.h,v $
- X * Revision 1.1 91/05/11 10:51:12 rws
- X * Initial revision
- X *
- X * Revision 1.5 90/07/25 17:35:19 gringort
- X * added new field for monitor type arg
- X *
- X * Revision 1.4 90/07/16 17:45:16 gringort
- X * added edge attachment command arg support
- X *
- X * Revision 1.3 90/06/21 18:56:20 gringort
- X * added wsMotionEvents
- X *
- X * Revision 1.2 90/06/07 13:31:33 gringort
- X * changes to init
- X *
- X * Revision 1.1 90/04/23 14:45:52 gringort
- X * Initial revision
- X *
- X *
- X */
- X
- X#define NOMAPYET (ColormapPtr) 1
- X
- X#define ARG_DPIX (1 << 0)
- X#define ARG_DPIY (1 << 1)
- X#define ARG_DPI (1 << 2)
- X#define ARG_BLACKVALUE (1 << 3)
- X#define ARG_WHITEVALUE (1 << 4)
- X#define ARG_CLASS (1 << 5)
- X#define ARG_EDGE_L (1 << 6)
- X#define ARG_EDGE_R (1 << 7)
- X#define ARG_EDGE_T (1 << 8)
- X#define ARG_EDGE_B (1 << 9)
- X#define ARG_MONITOR (1 << 10)
- X
- typedef struct {
- X int flags;
- X int dpix;
- X int dpiy;
- X int dpi;
- X int class;
- X char *blackValue;
- X char *whiteValue;
- X int edge_left;
- X int edge_right;
- X int edge_top;
- X int edge_bottom;
- X ws_monitor monitor;
- X} ScreenArgsRec;
- X
- typedef struct {
- X unsigned int currentmask; /* saved plane mask */
- X BoxPtr cursorConstraint;
- X ws_screen_descriptor *screenDesc;
- X ColormapPtr pInstalledMap;
- X ScreenArgsRec *args;
- X Bool (*CloseScreen)();
- X} wsScreenPrivate;
- X
- typedef struct {
- X char *moduleID; /* graphic module ID */
- X Bool (*createProc)(); /* create procedure for this hardware type */
- X} wsAcceleratorTypes;
- X
- extern void wsStoreColors();
- extern void wsInstallColormap();
- extern void wsUninstallColormap();
- extern int wsListInstalledColormaps();
- extern int wsScreenPrivateIndex;
- extern Bool wsSaveScreen();
- extern int dpix, dpiy, dpi;
- X
- extern ScreenArgsRec screenArgs[];
- X
- extern ScreenPtr wsScreens[];
- extern int class;
- extern int fdPM; /* this is the file descriptor for screen so
- X can do IOCTL to colormap */
- extern int ws_cpu;
- X
- END_OF_FILE
- if test 3160 -ne `wc -c <'server/ddx/dec/ws/ws.h'`; then
- echo shar: \"'server/ddx/dec/ws/ws.h'\" unpacked with wrong size!
- fi
- # end of 'server/ddx/dec/ws/ws.h'
- fi
- if test -f 'server/ddx/dec/ws/ws_color.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'server/ddx/dec/ws/ws_color.c'\"
- else
- echo shar: Extracting \"'server/ddx/dec/ws/ws_color.c'\" \(7788 characters\)
- sed "s/^X//" >'server/ddx/dec/ws/ws_color.c' <<'END_OF_FILE'
- X/***********************************************************
- Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts,
- and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
- X
- X All Rights Reserved
- X
- 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 names of Digital or MIT not be
- used in advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
- X
- 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.
- X
- X******************************************************************/
- X/* $Header: /ath/p1/X11R4.mips/server/ddx/dec/ws/RCS/ws_color.c,v 1.2 91/05/21 10:55:09 jg Exp Locker: jg $ */
- X
- X/*
- X * ws_color.c - device specific color routines, stored in screen
- X *
- X * Author: Jim Gettys
- X * Digital Equipment Corporation
- X * Cambridge Research Laboratory
- X * Date: Sat January 24 1990
- X */
- X
- X/* $Log: ws_color.c,v $
- X * Revision 1.2 91/05/21 10:55:09 jg
- X * fix from MIT
- X *
- X * Revision 1.1 91/05/21 10:45:33 jg
- X * Initial revision
- X *
- X * Revision 1.1 91/05/11 10:51:14 rws
- X * Initial revision
- X *
- X * Revision 1.8 90/12/12 12:33:44 edg
- X * Added trick to wsInstallColormap() so that 8-bit TrueColor visual
- X * works on color frame buffer machines. Merged in this change with
- X * earlier changes from WSE so all servers will work.
- X *
- X * Revision 1.7 90/12/04 17:18:28 edg
- X * Added extra test so that StaticGray visuals get installed correctly.
- X * This is actually a work around for changes made by Joel G. for
- X * TurboChannel mfb.
- X *
- X * Revision 1.6 90/11/27 13:55:58 kalmin
- X * in store colors, masked off pixel bit to create index for ioctl
- X *
- X * Revision 1.5 90/11/26 15:25:16 kalmin
- X * added code to support 24 planes to InstallColormap
- X *
- X * Revision 1.4 90/10/02 12:09:29 gringort
- X * fixed colormap init problems on monochrome screens
- X *
- X * Revision 1.3 90/06/21 18:55:33 gringort
- X * added wsMotionEvents
- X *
- X * Revision 1.2 90/05/11 16:57:11 gringort
- X * snapshot works with monochrome
- X *
- X * Revision 1.1 90/04/23 14:48:00 gringort
- X * Initial revision
- X *
- X * Revision 1.6 90/02/27 18:24:30 jg
- X * fix for screen numbering, so that skipped screens should work.
- X *
- X * Revision 1.5 90/02/25 12:59:49 jg
- X * more code cleanup.
- X *
- X * Revision 1.3 90/02/19 17:50:18 jg
- X * fix implementation of StoreColors.
- X *
- X * Revision 1.2 90/02/17 19:08:18 jg
- X * clean up naming.
- X *
- X * Revision 1.1 90/02/16 16:55:56 jg
- X * Initial revision
- X *
- X */
- X
- X
- X
- static char rcs_ident[] = "$Header: /ath/p1/X11R4.mips/server/ddx/dec/ws/RCS/ws_color.c,v 1.2 91/05/21 10:55:09 jg Exp Locker: jg $";
- X
- X#include <stdio.h>
- X#include <sys/types.h>
- X#include <sys/file.h>
- X#include <sys/time.h>
- X#include <sys/tty.h>
- X#include <errno.h>
- X#include <sys/devio.h>
- X#include "X.h" /* required for DoRed ... */
- X#include "Xproto.h" /* required for xColorItem */
- X
- X#include "misc.h" /* required for colormapst.h */
- X#include "resource.h"
- X#include "scrnintstr.h"
- X#include "colormapst.h"
- X/* XXX */
- X#include <sys/workstation.h>
- X
- X#include "ws.h"
- X
- X
- X
- X/* these next two are DIX routines */
- extern int TellLostMap();
- extern int TellGainedMap();
- X
- extern int wsFd;
- extern ws_screen_descriptor screenDesc[];
- X
- void
- wsStoreColors(pmap, ndef, pdefs)
- X ColormapPtr pmap;
- X int ndef;
- X xColorItem *pdefs;
- X{
- X xColorItem directDefs[256];
- X ws_color_cell cell;
- X ws_color_map_data cd;
- X wsScreenPrivate *pPrivScreen = (wsScreenPrivate *)
- X pmap->pScreen->devPrivates[wsScreenPrivateIndex].ptr;
- X if (pmap != pPrivScreen->pInstalledMap) return;
- X
- X/* the following fixes a bug (in R5), but we aren't R5, so we lose anyway
- X#ifdef R5
- X if ((pmap->pVisual->class | DynamicClass) == DirectColor)
- X {
- X ndef = cfbExpandDirectColors (pmap, ndef, pdefs, directDefs);
- X pdefs = directDefs;
- X }
- X#endif
- X cd.screen = screenDesc[pmap->pScreen->myNum].screen;
- X cd.map = 0; /* only one... */
- X cd.start = 0;
- X cd.ncells = ndef;
- X /*
- X * we will be evil, and note that the server and drive use the same
- X * structure.
- X */
- X cd.cells = (ws_color_cell *)pdefs;
- X if (ioctl(wsFd, WRITE_COLOR_MAP, &cd) == -1) {
- X ErrorF("error writing color map\n");
- X return;
- X }
- X}
- X
- X#define _DUPRGB(C,V) ( (( (C) << (V)->offsetRed ) & (V)->redMask )\
- X |(( (C) << (V)->offsetGreen ) & (V)->greenMask)\
- X |(( (C) << (V)->offsetBlue ) & (V)->blueMask ) )
- X
- void
- wsInstallColormap(pcmap)
- X ColormapPtr pcmap;
- X{
- X int entries = pcmap->pVisual->ColormapEntries;
- X Pixel * ppix;
- X xrgb * prgb;
- X xColorItem *defs;
- X int i;
- X wsScreenPrivate *pPrivScreen = (wsScreenPrivate *)
- X pcmap->pScreen->devPrivates[wsScreenPrivateIndex].ptr;
- X
- X if (pcmap == pPrivScreen->pInstalledMap) return;
- X if ( pPrivScreen->pInstalledMap != NOMAPYET)
- X WalkTree( pcmap->pScreen, TellLostMap,
- X &pPrivScreen->pInstalledMap->mid);
- X
- X pPrivScreen->pInstalledMap = pcmap;
- X
- X /* if Turbochannel mfb (2 entry StaticGray), do not store any colors */
- X if (pcmap->class != StaticGray || entries != 2) {
- X
- X /* If we have an 8 entry TrueColor map, then get all 256 pixel
- X values so we can fake a TrueColor visual with an undecomposed
- X hardware colormap (ie. devPriv == 0).
- X */
- X if (pcmap->devPriv == 0 && pcmap->class == TrueColor && entries == 8) {
- X entries = 256;
- X }
- X
- X ppix = (Pixel *)ALLOCATE_LOCAL( entries * sizeof(Pixel));
- X prgb = (xrgb *)ALLOCATE_LOCAL( entries * sizeof(xrgb));
- X defs = (xColorItem *)ALLOCATE_LOCAL(entries * sizeof(xColorItem));
- X
- X /* devPriv == 1 means decomposed hardware colormap */
- X if ((int) pcmap->devPriv == 1
- X && ((pcmap->class | DynamicClass) == DirectColor))
- X for( i = 0; i < entries; i++)
- X ppix[i] = _DUPRGB( i, pcmap->pVisual);
- X else
- X for ( i=0; i<entries; i++) ppix[i] = i;
- X
- X QueryColors( pcmap, entries, ppix, prgb);
- X
- X for ( i=0; i<entries; i++) { /* convert xrgbs to xColorItems */
- X defs[i].pixel = ppix[i] & 0xff; /* change pixel to index */
- X defs[i].red = prgb[i].red;
- X defs[i].green = prgb[i].green;
- X defs[i].blue = prgb[i].blue;
- X defs[i].flags = DoRed|DoGreen|DoBlue;
- X }
- X wsStoreColors( pcmap, entries, defs);
- X
- X DEALLOCATE_LOCAL(ppix);
- X DEALLOCATE_LOCAL(prgb);
- X DEALLOCATE_LOCAL(defs);
- X }
- X WalkTree(pcmap->pScreen, TellGainedMap, &pcmap->mid);
- X}
- X
- X
- void
- wsUninstallColormap(pcmap)
- X ColormapPtr pcmap;
- X{
- X /* Replace installed colormap with default colormap */
- X
- X ColormapPtr defColormap;
- X wsScreenPrivate *pPrivScreen = (wsScreenPrivate *)
- X pcmap->pScreen->devPrivates[wsScreenPrivateIndex].ptr;
- X
- X if ( pcmap != pPrivScreen->pInstalledMap) return;
- X
- X defColormap = (ColormapPtr) LookupIDByType( pcmap->pScreen->defColormap,
- X RT_COLORMAP);
- X
- X if (defColormap == pPrivScreen->pInstalledMap) return;
- X
- X (*pcmap->pScreen->InstallColormap) (defColormap);
- X}
- X
- int
- wsListInstalledColormaps( pscr, pcmaps)
- X ScreenPtr pscr;
- X Colormap * pcmaps;
- X{
- X wsScreenPrivate *pPrivScreen = (wsScreenPrivate *)
- X pscr->devPrivates[wsScreenPrivateIndex].ptr;
- X *pcmaps = pPrivScreen->pInstalledMap->mid;
- X return 1;
- X}
- X
- END_OF_FILE
- if test 7788 -ne `wc -c <'server/ddx/dec/ws/ws_color.c'`; then
- echo shar: \"'server/ddx/dec/ws/ws_color.c'\" unpacked with wrong size!
- fi
- # end of 'server/ddx/dec/ws/ws_color.c'
- fi
- if test -f 'server/ddx/dec/ws/ws_io.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'server/ddx/dec/ws/ws_io.c'\"
- else
- echo shar: Extracting \"'server/ddx/dec/ws/ws_io.c'\" \(34338 characters\)
- sed "s/^X//" >'server/ddx/dec/ws/ws_io.c' <<'END_OF_FILE'
- X/***********************************************************
- Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts,
- and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
- X
- X All Rights Reserved
- X
- 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 names of Digital or MIT not be
- used in advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
- X
- 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.
- X
- X******************************************************************/
- X
- X/* $Header: ws_io.c,v 1.1 91/05/11 10:51:16 rws Exp $ */
- X
- X#include <stdio.h>
- X#include <sys/types.h>
- X#include <sys/file.h>
- X#include <sys/time.h>
- X#include <sys/tty.h>
- X#include <sys/stat.h>
- X#include <errno.h>
- X#include <sys/devio.h>
- X#define NEED_EVENTS
- X#include "misc.h"
- X#include "X.h"
- X#include "Xproto.h"
- X#include "scrnintstr.h"
- X#include "pixmap.h"
- X#include "inputstr.h"
- X#include "cursorstr.h"
- X#include "regionstr.h"
- X#include "resource.h"
- X#include "dixstruct.h"
- X#include <sys/workstation.h>
- X#include <sys/inputdevice.h>
- X#include <sys/wsdevice.h>
- X#include "ws.h"
- X#include "keynames.h"
- X
- X
- X#include "mi.h"
- X
- X#define MOTION_BUFFER_SIZE 100
- X
- extern ws_descriptor wsinfo;
- void wsCursorControl();
- X
- extern ws_screen_descriptor screenDesc[];
- extern int wsFd;
- int rememberedScreen;
- static int shiftLock;
- static short lockLed;
- ScreenPtr wsScreens[MAXSCREENS];
- ScreenArgsRec screenArgs[MAXSCREENS];
- static DevicePtr wsPointer;
- static DevicePtr wsKeyboard;
- char *blackValue, *whiteValue;
- extern ws_event_queue *queue;
- int lastEventTime;
- int wsNumButtons = -1;
- X
- X#define MAX_LED 3 /* only 3 LED's can be set by user; Lock LED
- X is controlled by server */
- X
- X#define VSYNCFIXED
- X#ifdef VSYNCFIXED
- X#define CURRENT_TIME queue->time
- X#else
- X#define CURRENT_TIME GetTimeInMillis()
- X#endif
- X
- X#define NoSuchClass -1
- X
- static int
- ParseClass(className)
- X char * className;
- X{
- X static char *names[] = {
- X "StaticGray",
- X "GrayScale",
- X "StaticColor",
- X "PseudoColor",
- X "TrueColor"};
- X /*
- X * only the ones we support and must be in order from X.h, since
- X * return value depends on index into array.
- X */
- X int i;
- X for (i = 0; i < sizeof(names)/sizeof(char *); i++)
- X {
- X if (strcmp(names[i], className) == 0)
- X return i;
- X }
- X return NoSuchClass;
- X}
- X
- X/* SaveScreen does blanking, so no need to worry about the interval timer */
- X
- Bool
- wsSaveScreen(pScreen, on)
- X ScreenPtr pScreen;
- X int on;
- X{
- X ws_video_control vc;
- X vc.screen = screenDesc[pScreen->myNum].screen;
- X
- X if (on == SCREEN_SAVER_FORCER) {
- X lastEventTime = GetTimeInMillis();
- X } else if (on == SCREEN_SAVER_ON) {
- X vc.control = SCREEN_OFF;
- X if (ioctl(wsFd, VIDEO_ON_OFF, &vc) < 0)
- X ErrorF("VIDEO_ON_OFF: failed to turn screen off.\n");
- X } else {
- X lastEventTime = GetTimeInMillis();
- X vc.control = SCREEN_ON;
- X if (ioctl(wsFd, VIDEO_ON_OFF, &vc) < 0)
- X ErrorF("VIDEO_ON_OFF: failed to turn screen on.\n");
- X }
- X return TRUE;
- X}
- X
- X
- wsPixelError(index)
- int index;
- X{
- X ErrorF("Only 0 through 255 are acceptable pixels for device %d\n", index);
- X}
- X
- void
- wsClick(click)
- X int click;
- X{
- X ws_keyboard_control control;
- X control.device_number = wsinfo.console_keyboard;
- X control.flags = WSKBKeyClickPercent;
- X control.click = click;
- X if (ioctl (wsFd, SET_KEYBOARD_CONTROL, &control) == -1)
- X printf ("couldn't set click\n");
- X return;
- X}
- X
- static void
- wsChangeKeyboardControl(device, ctrl)
- X DevicePtr device;
- X KeybdCtrl *ctrl;
- X{
- X int i;
- X ws_keyboard_control control;
- X control.device_number = wsinfo.console_keyboard;
- X control.flags = 0;
- X
- X /*
- X * even though some of these are not implemented on the lk201/lk401,
- X * we should pass these to the driver, as other hardware may not
- X * lose so badly. The new driver does do auto-repeat and up down
- X * properly, however.
- X */
- X control.flags |= WSKBKeyClickPercent| WSKBBellPercent | WSKBBellPitch |
- X WSKBBellDuration | WSKBAutoRepeatMode | WSKBAutoRepeats | WSKBLed;
- X control.click = ctrl->click;
- X control.bell = ctrl->bell;
- X control.bell_pitch = ctrl->bell_pitch;
- X control.bell_duration = ctrl->bell_duration;
- X control.auto_repeat = ctrl->autoRepeat;
- X control.leds = ctrl->leds;
- X /*
- X * XXX a crock, but to have a byte interface would have implied the
- X * driver did alot more work at interrupt time, so we made it 32 bits wide.
- X */
- X bcopy(ctrl->autoRepeats, control.autorepeats, 32);
- X#ifdef notdef
- X /* LEDs */
- X for (i=1; i<=MAX_LED; i++)
- X ChangeLED(i, (ctrl->leds & (1 << (i-1))));
- X#endif
- X if (ioctl (wsFd, SET_KEYBOARD_CONTROL, &control) == -1)
- X printf ("couldn't set global autorepeat\n");
- X return;
- X
- X}
- X
- static void
- wsBell(loud, pDevice)
- X int loud;
- X DevicePtr pDevice;
- X{
- X ws_keyboard_control control;
- X control.device_number = wsinfo.console_keyboard;
- X control.flags = WSKBBellPercent;
- X control.bell = loud;
- X ioctl(wsFd, SET_KEYBOARD_CONTROL, &control);
- X
- X ioctl(wsFd, RING_KEYBOARD_BELL, &wsinfo.console_keyboard);
- X}
- X
- X/*
- X * These serve protocol requests, setting/getting acceleration and threshold.
- X * X10 analog is "SetMouseCharacteristics".
- X */
- void
- wsChangePointerControl(device, ctrl)
- X DevicePtr device;
- X PtrCtrl *ctrl;
- X{
- X ws_pointer_control pc;
- X pc.device_number = wsinfo.console_pointer;
- X pc.numerator = ctrl->num;
- X pc.denominator = ctrl->den;
- X pc.threshold = ctrl->threshold;
- X if (ioctl (wsFd, SET_POINTER_CONTROL, &pc) == -1) {
- X ErrorF ("error setting mouse properties\n");
- X }
- X}
- X
- int
- wsGetMotionEvents(pDevice, buff, start, stop)
- X CARD32 start, stop;
- X DevicePtr pDevice;
- X xTimecoord *buff;
- X{
- X register int i; /* Number of events left to process in ring */
- X ws_motion_buffer *mb = queue->mb;
- X register ws_motion_history *mh = mb->motion; /*Beginning of ring storage*/
- X int count; /* Number of events that match conditions */
- X CARD32 temptime;
- X
- X /* Loop through entire ring buffer. Technically, the driver may not have
- X actually queued this many motion events, but since they are initialized
- X to time 0 the non-events shouldn't match. If the mouse isn't moved for
- X 25 days after startup this could be a problem...but who cares? */
- X count = 0;
- X for (i = mb->size; i != 0; i--) {
- X temptime = mh->time;
- X if (start <= temptime && temptime <= stop) {
- X buff[count].time = temptime;
- X buff[count].x = mh->axis[0];
- X buff[count].y = mh->axis[1];
- X if (temptime == mh->time) count++; /* paranoid */
- X }
- X mh = (ws_motion_history *) ((int)mh + mb->entry_size);
- X }
- X return count;
- X}
- X
- int
- wsMouseProc(pDev, onoff, argc, argv)
- X DevicePtr pDev;
- X int onoff, argc;
- X char *argv[];
- X{
- X int i, numButtons;
- X BYTE map[6];
- X ws_hardware_type wht;
- X
- X switch (onoff)
- X {
- X case DEVICE_INIT:
- X wht.device_number = wsinfo.console_pointer;
- X ioctl(wsFd, GET_DEVICE_TYPE, &wht);
- X wsPointer = pDev;
- X pDev->devicePrivate = (pointer) &queue;
- X map[1] = 1; /* worst case is 5 buttons - jmg */
- X map[2] = 2;
- X map[3] = 3;
- X map[4] = 4;
- X map[5] = 5;
- X if(wsNumButtons == -1) {
- X if(wht.hardware_type == VSXXX)
- X numButtons = 3;
- X else
- X numButtons = 4;
- X }
- X else
- X numButtons = wsNumButtons;
- X InitPointerDeviceStruct(
- X wsPointer, map, numButtons, wsGetMotionEvents,
- X wsChangePointerControl, MOTION_BUFFER_SIZE);
- X SetInputCheck(&queue->head, &queue->tail);
- X break;
- X case DEVICE_ON:
- X pDev->on = TRUE;
- X AddEnabledDevice(wsFd);
- X break;
- X case DEVICE_OFF:
- X pDev->on = FALSE;
- X RemoveEnabledDevice(wsFd);
- X break;
- X case DEVICE_CLOSE:
- X break;
- X }
- X return Success;
- X}
- X
- X/* since this driver does up/down autorepeat right, any key can be a modifier*/
- Bool
- LegalModifier(key)
- X BYTE key;
- X{
- X return TRUE;
- X
- X}
- X
- int
- wsKeybdProc(pDev, onoff, argc, argv)
- X DevicePtr pDev;
- X int onoff, argc;
- X char *argv[];
- X{
- X KeySymsRec keySyms;
- X CARD8 modMap[MAP_LENGTH];
- X
- X switch (onoff)
- X {
- X case DEVICE_INIT:
- X/* Note that keyclick is off by default. The QDSS MIT server sets it
- X to 20 */
- X wsKeyboard = pDev;
- X GetKeyboardMappings( &keySyms, modMap);
- X InitKeyboardDeviceStruct(
- X wsKeyboard, &keySyms, modMap, wsBell,
- X wsChangeKeyboardControl);
- X /* Free the key sym mapping space allocated by GetKeyboardMappings. */
- X Xfree(keySyms.map);
- X break;
- X case DEVICE_ON:
- X pDev->on = TRUE;
- X AddEnabledDevice(wsFd);
- X break;
- X case DEVICE_OFF:
- X pDev->on = FALSE;
- X RemoveEnabledDevice(wsFd);
- X break;
- X case DEVICE_CLOSE:
- X break;
- X }
- X return Success;
- X}
- extern int screenIsSaved;
- static CursorPtr currentCursor;
- X
- X
- X/* The code below is for backward compatibility with DEC R3 servers.
- X * Load the keyboard map pointed to by the file "/usr/lib/X11/keymap_default"
- X */
- X
- X#define FileNameLength 256
- X#define MaxLineLength 256
- X
- X
- KeySym *LoadKeymap();
- X
- X/*
- X * Load the default keymap file.
- X */
- X
- int GetDefaultMap(ks)
- X KeySymsPtr ks;
- X{
- X char keymap_name[FileNameLength];
- X KeySym *keymap_pointer;
- X int keymap_width;
- X int keymap_loaded = FALSE;
- X
- X if (GetKeymapName (keymap_name)==TRUE) {
- X if ((keymap_pointer = LoadKeymap (keymap_name, MIN_LK201_KEY,
- X MAX_LK201_KEY, &keymap_width)) !=NULL) {
- X ks->minKeyCode = MIN_LK201_KEY;
- X ks->maxKeyCode = MAX_LK201_KEY;
- X ks->mapWidth = keymap_width;
- X ks->map = keymap_pointer;
- X keymap_loaded=TRUE;
- X }
- X }
- X return (keymap_loaded);
- X}
- X
- X
- X/*
- X * Check for keymap type file "/usr/lib/X11/keymap_default"
- X */
- X
- int GetKeymapName (name_return)
- X char *name_return;
- X{
- X char *filename = "/usr/lib/X11/keymap_default";
- X int fd;
- X int len;
- X
- X if ((fd = open(filename, O_RDONLY)) == -1)
- X return (FALSE);
- X len = strlen(filename);
- X strcpy(name_return, filename);
- X name_return[len] = '\0';
- X return (TRUE);
- X}
- X
- X
- X#define EndLine(c) (((c)=='!' || (c) =='\n' || (c) == '\0') ? TRUE : FALSE )
- X
- X/*
- X * load the keymap file into keysym table
- X */
- X
- KeySym *LoadKeymap(keymap_name, minkc, maxkc, return_ks_per_kc)
- X char *keymap_name;
- X KeyCode minkc;
- X KeyCode maxkc;
- X int *return_ks_per_kc;
- X{
- X FILE *fp;
- X KeySym *keymap = NULL;
- X char line[MaxLineLength];
- X
- X if ((fp=fopen (keymap_name, "r")) == NULL)
- X return ( (KeySym *) NULL);
- X
- X while (fgets (line, MaxLineLength, fp) != NULL) {
- X if (AddLineToKeymap (line, &keymap, minkc, maxkc, return_ks_per_kc)
- X ==FALSE) {
- X fclose (fp);
- X if (keymap != NULL) Xfree (keymap);
- X return ( (KeySym *)NULL);
- X }
- X }
- X fclose (fp);
- X return ( keymap );
- X}
- X
- X
- X/*
- X * decode keycode, and keysyms from line, allocate keymap first time round.
- X */
- X
- int AddLineToKeymap (line, keymap, minkc, maxkc, return_ncols)
- X char *line;
- X KeySym **keymap;
- X KeyCode minkc;
- X KeyCode maxkc;
- X int *return_ncols;
- X{
- X int pos;
- X KeyCode kc;
- X KeySym *offset;
- X KeySym ks;
- X int ncols;
- X int col;
- X int map_size;
- X int i;
- X
- X if (isspace(line[0]) || line[0] == '!' || line[0] == '\n' || line[0] == '\0')
- X return (TRUE); /* ignore blank lines and comments */
- X
- X if ( *keymap ==NULL) {
- X pos=0;
- X if ((kc=GetToken (line, &pos)) == -1) return (FALSE);
- X ncols=0;
- X while (GetToken (line, &pos) != -1)
- X ncols++;
- X if (ncols < 2) ncols = 2;
- X (*return_ncols) = ncols;
- X map_size = (maxkc-minkc+1) * ncols;
- X (*keymap) = (KeySym *) Xalloc ( map_size * sizeof (KeySym));
- X for (i = 0; i < map_size; i++)
- X (*keymap)[i] = NoSymbol;
- X
- X }
- X pos = 0;
- X if ((kc=GetToken (line, &pos)) == -1) return (FALSE);
- X if ( kc < minkc || kc > maxkc ) return (FALSE);
- X offset = (*keymap) + (kc-minkc)* (*return_ncols);
- X col=0;
- X while (col < (*return_ncols) && ((ks=GetToken (line, &pos)) != -1)) {
- X *(offset + col) = ks;
- X col+=1;
- X }
- X return (TRUE);
- X}
- X
- X/*
- X * return hex value of next item on line (current position held in 'pos')
- X */
- X
- int GetToken (line, pos)
- X char *line;
- X int *pos;
- X{
- X int start;
- X
- X if (EndLine(line[*pos]) == TRUE) return (-1);
- X while (isspace(line[*pos]) || EndLine(line[*pos])) {
- X if (EndLine(line[*pos]) == TRUE)
- X return (-1);
- X (*pos)++;
- X }
- X start = *pos;
- X while (!isspace (line[*pos]) && !EndLine (line[*pos])) {
- X (*pos)++;
- X }
- X return (StringToHex(&line[start], (*pos)-start));
- X}
- X
- X
- X/*
- X * convert null terminated hexadecimal string to integer
- X * return 'value', or '-1' on error
- X */
- X
- int StringToHex (str,nbytes)
- X char *str;
- X int nbytes;
- X{
- X int i;
- X int digit;
- X int scale = 1;
- X long value = 0;
- X
- X for (i=nbytes-1;i>=0;i--) {
- X if (!isxdigit(str[i])) return (-1);
- X if (isdigit(str[i]))
- X digit=str[i]-'0';
- X else
- X digit=toupper(str[i])-'A'+10;
- X value+=(digit*scale);
- X scale*=16;
- X }
- X return(value);
- X}
- X
- X#undef EndLine
- X#undef MaxLineLength
- X#undef FileNameLength
- X
- X
- Bool GetKeyboardMappings(pKeySyms, pModMap)
- X KeySymsPtr pKeySyms;
- X CARD8 *pModMap;
- X{
- X int i;
- X ws_keyboard_definition def;
- X KeySym *map;
- X KeySym rawsyms[256]; /* more than we'll ever need! */
- X unsigned char rawcodes[256]; /* more than we'll ever need! */
- X ws_keycode_modifiers mods[32]; /* more than we'll ever need! */
- X ws_keysyms_and_modifiers km;
- X int min_keycode = 256, max_keycode = 0;
- X
- X /* If it exists, load special keysym map from file instead of driver.
- X This is for backward compatibility with the i18n stuff from the
- X DEC R3 servers.
- X */
- X if (GetDefaultMap(pKeySyms) == TRUE) {
- X for (i = 0; i < MAP_LENGTH; i++)
- X pModMap[i] = NoSymbol; /* make sure it is restored */
- X pModMap[ KEY_LOCK ] = LockMask;
- X pModMap[ KEY_SHIFT ] = ShiftMask;
- X pModMap[ KEY_SHIFT_R ] = ShiftMask;
- X pModMap[ KEY_CTRL ] = ControlMask;
- X pModMap[ KEY_COMPOSE ] = Mod1Mask;
- X pModMap[ KEY_COMPOSE_R ] = Mod1Mask;
- X pModMap[ KEY_ALT_L ] = Mod2Mask;
- X pModMap[ KEY_ALT_R ] = Mod2Mask;
- X return (TRUE);
- X }
- X
- X def.device_number = wsinfo.console_keyboard;
- X if (ioctl (wsFd, GET_KEYBOARD_DEFINITION, &def) == -1) {
- X ErrorF ("error getting keyboard definition\n");
- X }
- X lockLed = def.lock_key_led;
- X km.device_number = wsinfo.console_keyboard;
- X km.modifiers = mods;
- X km.keysyms = rawsyms;
- X km.keycodes = rawcodes;
- X if (ioctl (wsFd, GET_KEYSYMS_AND_MODIFIERS, &km) == -1) {
- X ErrorF ("error getting keysyms and modifiers\n");
- X }
- X
- X#define KEYCODE(i) ((i) >> 24))
- X for (i = 0; i < def.keysyms_present; i++) {
- X if (rawcodes[i] > max_keycode) max_keycode = rawcodes[i];
- X if (rawcodes[i] < min_keycode) min_keycode = rawcodes[i];
- X }
- X
- X map = (KeySym *)Xalloc(sizeof(KeySym) *
- X (MAP_LENGTH * def.keysyms_per_keycode));
- X if (!map)
- X return FALSE;
- X
- X for (i = 0; i < MAP_LENGTH; i++)
- X pModMap[i] = NoSymbol; /* make sure it is restored */
- X
- X /* first set up modifier keys */
- X for (i = 0; i < def.modifier_keycode_count; i++)
- X pModMap[mods[i].keycode] = mods[i].modbits;
- X
- X /* initialize the keysym array */
- X for (i = 0; i < (MAP_LENGTH * def.keysyms_per_keycode); i++)
- X map[i] = NoSymbol;
- X pKeySyms->minKeyCode = min_keycode;
- X pKeySyms->maxKeyCode = max_keycode;
- X pKeySyms->mapWidth = def.keysyms_per_keycode;
- X pKeySyms->map = map;
- X#define INDEX(in) ((in - min_keycode) * def.keysyms_per_keycode)
- X for (i = 0; i < def.keysyms_present; i++) {
- X register int j;
- X for (j = 0; j < def.keysyms_per_keycode; j++) {
- X if (map[INDEX(rawcodes[i]) + j] == NoSymbol) {
- X map[INDEX(rawcodes[i]) + j] = rawsyms[i];
- X break;
- X }
- X }
- X }
- X#undef INDEX
- X return TRUE;
- X}
- X
- X
- void
- SetLockLED (on)
- X Bool on;
- X{
- X ws_keyboard_control kc;
- X kc.flags = WSKBLed;
- X kc.device_number = wsinfo.console_keyboard;
- X if (ioctl (wsFd, GET_KEYBOARD_CONTROL, &kc) == -1) {
- X ErrorF ("error getting keyboard control\n");
- X }
- X if(on)
- X kc.leds |= 1 << (lockLed -1);
- X else
- X kc.leds &= ~(1 << (lockLed -1));
- X kc.flags = WSKBLed;
- X if (ioctl (wsFd, SET_KEYBOARD_CONTROL, &kc) == -1) {
- X ErrorF ("error setting keyboard control\n");
- X }
- X}
- X
- X/*
- X * The driver has been set up to put events in the queue that are identical
- X * in shape to the events that the DDX layer has to deliver to ProcessInput
- X * in DIX.
- X */
- void
- ProcessInputEvents()
- X{
- X xEvent x;
- X register ws_event *e;
- X register int i;
- X int screen;
- X DeviceIntPtr dev = (DeviceIntPtr) wsKeyboard;
- X i = queue->head;
- X while (i != queue->tail) {
- X e = (ws_event *)((int)(queue->events) + queue->event_size * i);
- X
- X if (screenIsSaved == SCREEN_SAVER_ON)
- X SaveScreens(SCREEN_SAVER_OFF, ScreenSaverReset);
- X if(e->screen != rememberedScreen)
- X {
- X ScreenPtr pScreen;
- X short x, y;
- X
- X /* assumption -- this is a motion event */
- X wsCursorControl(rememberedScreen, CURSOR_OFF);
- X wsCursorControl(e->screen, CURSOR_ON);
- X rememberedScreen = e->screen;
- X pScreen = wsScreens[e->screen];
- X if (currentCursor)
- X wsDisplayCursor (pScreen, currentCursor);
- X x = e->e.key.x;
- X y = e->e.key.y;
- X if (i >= queue->size - 1) i = queue->head = 0;
- X else i = ++queue->head;
- X NewCurrentScreen(pScreen, x, y);
- X i = queue->head;
- X continue;
- X }
- X
- X x.u.keyButtonPointer.rootX = e->e.key.x;
- X x.u.keyButtonPointer.rootY = e->e.key.y;
- X x.u.keyButtonPointer.time = lastEventTime = e->time;
- X x.u.u.detail = e->e.key.key;
- X
- X switch (e->device_type) {
- X case KEYBOARD_DEVICE:
- X switch (e->type) {
- X case BUTTON_DOWN_TYPE:
- X x.u.u.type = KeyPress;
- X /* if key is a lock modifier then ... */
- X if (dev->key->modifierMap[e->e.key.key] & LockMask){
- X if (shiftLock) {
- X x.u.u.type = KeyRelease;
- X SetLockLED (FALSE);
- X shiftLock = FALSE;
- X } else {
- X x.u.u.type = KeyPress;
- X SetLockLED (TRUE);
- X shiftLock = TRUE;
- X }
- X }
- X (*wsKeyboard->processInputProc)
- X (&x, wsKeyboard, 1);
- X break;
- X case BUTTON_UP_TYPE:
- X /* if key is a lock modifier then ignore */
- X if (dev->key->modifierMap[e->e.key.key] & LockMask)
- X break;
- X x.u.u.type = KeyRelease;
- X (*wsKeyboard->processInputProc)
- X (&x, wsKeyboard, 1);
- X break;
- X default: /* hopefully BUTTON_RAW_TYPE */
- X break;
- X }
- X break;
- X case MOUSE_DEVICE:
- X /* someday tablet will be handled differently than a mouse */
- X case TABLET_DEVICE:
- X switch (e->type) {
- X case BUTTON_DOWN_TYPE:
- X x.u.u.type = ButtonPress;
- X break;
- X case BUTTON_UP_TYPE:
- X x.u.u.type = ButtonRelease;
- X break;
- X case MOTION_TYPE:
- X x.u.u.type = MotionNotify;
- X break;
- X default:
- X#ifdef DEBUG
- X printf("Unknown mouse or tablet event = %d\n",
- X e->type);
- X#endif
- X goto out;
- X }
- X (*wsPointer->processInputProc) (&x, wsPointer, 1);
- X break;
- X /* new input devices go here (or are ignored) */
- X default:
- X#ifdef XINPUT
- X if (!ExtProcessInputEvents(&x, e))
- X# ifdef DEBUG
- X printf("Unknown device type = %d\n",e->device_type);
- X# else
- X ; /* do nothing */
- X# endif
- X#else
- X# ifdef DEBUG
- X printf("Unknown device type = %d\n",e->device_type);
- X# endif
- X#endif
- X break;
- X }
- out:
- X if (i >= queue->size - 1) i = queue->head = 0;
- X else i = ++queue->head;
- X
- X }
- X}
- X
- TimeSinceLastInputEvent()
- X{
- X if (lastEventTime == 0)
- X lastEventTime = CURRENT_TIME;
- X return CURRENT_TIME - lastEventTime;
- X}
- X
- extern Bool PointerConfinedToScreen();
- X/*
- X * set the bounds in the device for this particular cursor
- X */
- static void
- wsConstrainCursor( pScr, pBox)
- X ScreenPtr pScr;
- X BoxPtr pBox;
- X{
- X ws_pointer_box wsbox;
- X wsbox.screen = screenDesc[pScr->myNum].screen;
- X wsbox.enable = PointerConfinedToScreen();
- X wsbox.device_number = wsinfo.console_pointer;
- X wsbox.box.bottom = pBox->y2;
- X wsbox.box.right = pBox->x2;
- X wsbox.box.top = pBox->y1;
- X wsbox.box.left = pBox->x1;
- X
- X if (ioctl(wsFd, SET_POINTER_BOX, &wsbox) == -1)
- X ErrorF("SET_POINTER_BOX: failed to set pointer box.\n");
- X}
- X
- static Bool
- wsSetCursorPosition( pScr, newx, newy, generateEvent)
- X ScreenPtr pScr;
- X unsigned int newx;
- X unsigned int newy;
- X Bool generateEvent;
- X{
- X ws_pointer_position pos;
- X xEvent motion;
- X
- X pos.screen = screenDesc[pScr->myNum].screen;
- X pos.device_number = wsinfo.console_pointer;
- X pos.x = newx;
- X pos.y = newy;
- X
- X /* if this is on a different screen, then we need to switch... */
- X if (pos.screen != rememberedScreen) {
- X wsCursorControl(rememberedScreen, CURSOR_OFF);
- X wsCursorControl(pos.screen, CURSOR_ON);
- X rememberedScreen = pos.screen;
- X }
- X if (ioctl (wsFd, SET_POINTER_POSITION, &pos) == -1) {
- X ErrorF ("error warping cursor\n");
- X return FALSE;
- X }
- X
- X if (generateEvent) {
- X if (queue->head != queue->tail)
- X ProcessInputEvents ();
- X motion.u.keyButtonPointer.rootX = newx;
- X motion.u.keyButtonPointer.rootY = newy;
- X motion.u.keyButtonPointer.time = currentTime.milliseconds;
- X motion.u.u.type = MotionNotify;
- X (wsPointer->processInputProc)(&motion, wsPointer, 1);
- X }
- X return TRUE;
- X}
- X
- static Bool
- wsDisplayCursor( pScr, pCurs)
- X ScreenPtr pScr;
- X CursorPtr pCurs;
- X{
- X ws_cursor_data cd;
- X ws_cursor_color cc;
- X cd.screen = screenDesc[pScr->myNum].screen;
- X cd.width = pCurs->bits->width;
- X cd.height = pCurs->bits->height;
- X cd.x_hot = pCurs->bits->xhot;
- X cd.y_hot = pCurs->bits->yhot;
- X cd.cursor = (unsigned int *) pCurs->bits->source;
- X cd.mask = (unsigned int *) pCurs->bits->mask;
- X if ( ioctl( wsFd, LOAD_CURSOR, &cd) == -1) {
- X ErrorF( "error loading bits of new cursor\n");
- X return FALSE;
- X }
- X cc.screen = screenDesc[pScr->myNum].screen;
- X cc.background.red = pCurs->backRed;
- X cc.background.green = pCurs->backGreen;
- X cc.background.blue = pCurs->backBlue;
- X cc.foreground.red = pCurs->foreRed;
- X cc.foreground.green = pCurs->foreGreen;
- X cc.foreground.blue = pCurs->foreBlue;
- X if ( ioctl(wsFd, RECOLOR_CURSOR, &cc) == -1) {
- X ErrorF( "error writing colors of new cursor\n");
- X return FALSE;
- X }
- X currentCursor = pCurs;
- X return (TRUE);
- X}
- X
- void
- wsCursorControl(screen, control)
- X int screen;
- X int control;
- X{
- X ws_cursor_control cc;
- X cc.screen = screenDesc[screen].screen;
- X cc.control = control;
- X if (ioctl(wsFd, CURSOR_ON_OFF, &cc) == -1) {
- X ErrorF( "error enabling/disabling cursor\n");
- X }
- X return;
- X}
- static void
- wsRecolorCursor (pScr, pCurs, displayed)
- X ScreenPtr pScr;
- X CursorPtr pCurs;
- X Bool displayed;
- X{
- X ws_cursor_color cc;
- X if (!displayed)
- X return;
- X cc.screen = screenDesc[pScr->myNum].screen;
- X cc.background.red = pCurs->backRed;
- X cc.background.green = pCurs->backGreen;
- X cc.background.blue = pCurs->backBlue;
- X cc.foreground.red = pCurs->foreRed;
- X cc.foreground.green = pCurs->foreGreen;
- X cc.foreground.blue = pCurs->foreBlue;
- X if ( ioctl(wsFd, RECOLOR_CURSOR, &cc) == -1) {
- X ErrorF( "error writing colors of new cursor\n");
- X }
- X}
- X
- static Bool
- wsRealizeCursor( pScr, pCurs)
- X ScreenPtr pScr;
- X CursorPtr pCurs; /* The new driver makes this easy */
- X{
- X return TRUE;
- X}
- X
- static Bool
- wsUnrealizeCursor( pScr, pCurs)
- X ScreenPtr pScr;
- X CursorPtr pCurs;
- X{
- X if (pCurs == currentCursor)
- X currentCursor = 0;
- X return TRUE;
- X}
- X
- static void
- wsCursorLimits( pScr, pCurs, pHotBox, pPhysBox)
- X ScreenPtr pScr;
- X CursorPtr pCurs;
- X BoxPtr pHotBox;
- X BoxPtr pPhysBox; /* return value */
- X{
- X wsScreenPrivate *wsp = (wsScreenPrivate *)
- X pScr->devPrivates[wsScreenPrivateIndex].ptr;
- X pPhysBox->x1 = max( pHotBox->x1, 0);
- X pPhysBox->y1 = max( pHotBox->y1, 0);
- X pPhysBox->x2 = min( pHotBox->x2, wsp->screenDesc->width - 1);
- X pPhysBox->y2 = min( pHotBox->y2, wsp->screenDesc->height - 1);
- X}
- X
- void
- wsPointerNonInterestBox( pScr, pBox)
- X ScreenPtr pScr;
- X BoxPtr pBox;
- X{
- X ws_pointer_box wsbox;
- X wsbox.screen = screenDesc[pScr->myNum].screen;
- X wsbox.device_number = wsinfo.console_pointer;
- X wsbox.enable = TRUE;
- X wsbox.box.top = pBox->x1;
- X wsbox.box.bottom = pBox->x2;
- X wsbox.box.left = pBox->y1;
- X wsbox.box.right = pBox->y2;;
- X if (ioctl(wsFd, SET_ESCAPE_BOX, wsbox) == -1)
- X ErrorF("SET_ESCAPE_BOX: failed to set non interest box.\n");
- X}
- X/*
- X * DDX - specific abort routine. Called by AbortServer().
- X */
- void
- AbortDDX()
- X{
- X}
- X
- X/* Called by GiveUp(). */
- void
- ddxGiveUp()
- X{
- X}
- X
- int
- ArgMatch(arg, template, screen)
- X char *arg;
- X char *template;
- X int *screen;
- X{
- X int tlen = strlen(template);
- X char next = *(arg + tlen);
- X if(strncmp(arg, template, tlen) == 0) {
- X if(tlen == strlen(arg)) {
- X /* exact match - applies to all screens */
- X *screen = -1;
- X return TRUE;
- X }
- X if(isdigit(next)) {
- X /* parse off screen number */
- X *screen = atoi(arg + tlen);
- X if(*screen < MAXSCREENS)
- X return TRUE;
- X else
- X return FALSE;
- X }
- X else
- X /* non-digit stuff at end of arg. not ours. */
- X return FALSE;
- X }
- X else
- X return FALSE;
- X}
- X
- X
- int
- ddxProcessArgument (argc, argv, i)
- X register int argc;
- X register char *argv[];
- X register int i;
- X{
- X int argind=i;
- X int skip;
- X static int Once=0;
- X void ddxUseMsg();
- X int screen;
- X
- X skip = 0;
- X if (!Once) {
- X blackValue = NULL;
- X whiteValue = NULL;
- X Once = 1;
- X }
- X if (ArgMatch( argv[argind], "-dpix", &screen)) {
- X if (++argind < argc) {
- X if(screen == -1) {
- X for(i = 0; i < MAXSCREENS; i++) {
- X screenArgs[i].flags |= ARG_DPIX;
- X screenArgs[i].dpix = atoi(argv[argind]);
- X }
- X }
- X else {
- X screenArgs[screen].flags |= ARG_DPIX;
- X screenArgs[screen].dpix = atoi(argv[argind]);
- X }
- X skip = 2;
- X }
- X else return 0; /* failed to parse */
- X }
- X else if (ArgMatch( argv[argind], "-dpiy", &screen)) {
- X if (++argind < argc) {
- X if(screen == -1) {
- X for(i = 0; i < MAXSCREENS; i++) {
- X screenArgs[i].flags |= ARG_DPIY;
- X screenArgs[i].dpiy = atoi(argv[argind]);
- X }
- X }
- X else {
- X screenArgs[screen].flags |= ARG_DPIY;
- X screenArgs[screen].dpiy = atoi(argv[argind]);
- X }
- X skip = 2;
- X }
- X else return 0;
- X }
- X else if (ArgMatch( argv[argind], "-dpi", &screen)) {
- X if (++argind < argc) {
- X if(screen == -1) {
- X for(i = 0; i < MAXSCREENS; i++) {
- X screenArgs[i].flags |= (ARG_DPI | ARG_DPIX | ARG_DPIY) ;
- X screenArgs[i].dpi = screenArgs[i].dpix =
- X screenArgs[i].dpiy = atoi(argv[argind]);
- X }
- X }
- X else {
- X screenArgs[screen].flags |= (ARG_DPI | ARG_DPIX | ARG_DPIY);
- X screenArgs[screen].dpi = screenArgs[screen].dpix =
- X screenArgs[screen].dpiy = atoi(argv[argind]);
- X }
- X skip = 2;
- X }
- X else return 0;
- X }
- X else if(ArgMatch( argv[argind], "-bp", &screen)) {
- X if (++argind < argc) {
- X if(screen == -1) {
- X for(i = 0; i < MAXSCREENS; i++) {
- X screenArgs[i].flags |= ARG_BLACKVALUE;
- X screenArgs[i].blackValue = argv[argind];
- X }
- X }
- X else {
- X screenArgs[screen].flags |= ARG_BLACKVALUE;
- X screenArgs[screen].blackValue = argv[argind];
- X }
- X skip = 2;
- X }
- X else return 0;
- X }
- X else if (ArgMatch( argv[argind], "-wp", &screen)) {
- X if (++argind < argc) {
- X if(screen == -1) {
- X for(i = 0; i < MAXSCREENS; i++) {
- X screenArgs[i].flags |= ARG_WHITEVALUE;
- X screenArgs[i].whiteValue = argv[argind];
- X }
- X }
- X else {
- X screenArgs[screen].flags |= ARG_WHITEVALUE;
- X screenArgs[screen].whiteValue = argv[argind];
- X }
- X skip = 2;
- X }
- X else return 0;
- X }
- X else if (ArgMatch(argv[argind], "-class", &screen)) {
- X if(++argind < argc) {
- X int class = ParseClass(argv[argind]);
- X if (class == NoSuchClass)
- X return 0;
- X if(screen == -1) {
- X for(i = 0; i < MAXSCREENS; i++) {
- X screenArgs[i].flags |= ARG_CLASS;
- X screenArgs[i].class = class;
- X }
- X }
- X else {
- X screenArgs[screen].flags |= ARG_CLASS;
- X screenArgs[screen].class = class;
- X }
- X skip = 2;
- X }
- X else return 0;
- X }
- X else if (ArgMatch(argv[argind], "-edge_left", &screen)) {
- X if(++argind < argc) {
- X if(screen == -1) {
- X return 0;
- X }
- X else {
- X screenArgs[screen].flags |= ARG_EDGE_L;
- X screenArgs[screen].edge_left = atoi(argv[argind]);
- X }
- X skip = 2;
- X }
- X else return 0;
- X }
- X else if (ArgMatch(argv[argind], "-edge_right", &screen)) {
- X if(++argind < argc) {
- X if(screen == -1) {
- X return 0;
- X }
- X else {
- X screenArgs[screen].flags |= ARG_EDGE_R;
- X screenArgs[screen].edge_right = atoi(argv[argind]);
- X }
- X skip = 2;
- X }
- X else return 0;
- X }
- X else if (ArgMatch(argv[argind], "-edge_top", &screen)) {
- X if(++argind < argc) {
- X if(screen == -1) {
- X return 0;
- X }
- X else {
- X screenArgs[screen].flags |= ARG_EDGE_T;
- X screenArgs[screen].edge_top = atoi(argv[argind]);
- X }
- X skip = 2;
- X }
- X else return 0;
- X }
- X else if (ArgMatch(argv[argind], "-edge_bottom", &screen)) {
- X if(++argind < argc) {
- X if(screen == -1) {
- X return 0;
- X }
- X else {
- X screenArgs[screen].flags |= ARG_EDGE_B;
- X screenArgs[screen].edge_bottom = atoi(argv[argind]);
- X }
- X skip = 2;
- X }
- X else return 0;
- X }
- X
- X else if (ArgMatch(argv[argind], "-monitor", &screen)) {
- X if(++argind + 4 < argc) {
- X if(strlen(argv[argind]) == 5) {
- X strcpy(screenArgs[screen].monitor.type, argv[argind++]);
- X screenArgs[screen].monitor.mm_width = atoi(argv[argind++]);
- X screenArgs[screen].monitor.mm_height = atoi(argv[argind++]);
- X screenArgs[screen].monitor.color_or_mono =atoi(argv[argind++]);
- X screenArgs[screen].monitor.phosphor_type =atoi(argv[argind++]);
- X screenArgs[screen].flags |= ARG_MONITOR;
- X skip = 6;
- X }
- X else return 0;
- X }
- X else return 0;
- X }
- X else if (strcmp( argv[argind], "-btn") == 0)
- X {
- X if (++argind < argc)
- X {
- X wsNumButtons = atoi(argv[argind]);
- X skip = 2;
- X if(wsNumButtons < 1 || wsNumButtons > 5)
- X return 0;
- X }
- X else return 0;
- X }
- X
- X#ifdef XINPUT
- X else
- X skip = ExtddxProcessArgument(argc, argv, argind);
- X#endif
- X
- X return skip;
- X}
- X
- initEdgeAttachments(index)
- X int index;
- X{
- X ws_edge_connection wec;
- X ScreenArgsRec *args = &screenArgs[index];
- X int mask = args->flags;
- X wec.screen = index;
- X if(mask & ARG_EDGE_L)
- X wec.adj_screens.left = args->edge_left;
- X else
- X wec.adj_screens.left = index - 1;
- X if(mask & ARG_EDGE_R)
- X wec.adj_screens.right = args->edge_right;
- X else
- X if(index + 1 < wsinfo.num_screens_exist)
- X wec.adj_screens.right = index + 1;
- X else
- X wec.adj_screens.right = -1;
- X if(mask & ARG_EDGE_T)
- X wec.adj_screens.top = args->edge_top;
- X else
- X wec.adj_screens.top = -1;
- X if(mask & ARG_EDGE_B)
- X wec.adj_screens.bottom = args->edge_bottom;
- X else
- X wec.adj_screens.bottom = -1;
- X if (ioctl(wsFd, SET_EDGE_CONNECTION, &wec) == -1)
- X ErrorF("SET_EDGE_CONNECTION, failed to set edge attachment.\n");
- X
- X}
- X
- X#define ARGFILE "/etc/screens"
- X
- void getFileArguments()
- X{
- X FILE *f = fopen(ARGFILE, "r");
- X if(f) {
- X struct stat stats;
- X if(stat(ARGFILE, &stats) == 0) {
- X int i, argcount = 0, skip;
- X char *ptr, *buf = (char *)Xalloc(stats.st_size);
- X char **arguments;
- X while(EOF != fscanf(f, "%s", buf)) argcount++;
- X arguments = (char **) Xalloc(argcount * sizeof(char *));
- X rewind(f);
- X for(ptr = buf, i = 0; i < argcount; i++) {
- X arguments[i] = ptr;
- X fscanf(f, "%s", ptr);
- X ptr += strlen(arguments[i]) + 1;
- X }
- X fclose(f);
- X for(i = 0; i < argcount; i++)
- X if(skip = ddxProcessArgument(argcount, arguments, i))
- X i += (skip - 1);
- X Xfree(arguments);
- X Xfree(buf);
- X }
- X }
- X}
- X
- X
- void
- ddxUseMsg()
- X{
- X ErrorF ("\n");
- X ErrorF ("\n");
- X ErrorF ("Device Dependent Usage\n");
- X ErrorF ("Note - most ddx arguments can take an optional screen number ``s''\n");
- X ErrorF ("\n");
- X ErrorF ("-btn <n> Number of buttons on pointer device\n");
- X ErrorF ("-dpix[s] <n> Dots per inch, x coordinate\n");
- X ErrorF ("-dpiy[s] <n> Dots per inch, y coordinate\n");
- X ErrorF ("-dpi[s] <n> Dots per inch, x and y coordinates\n");
- X ErrorF (" (overrides -dpix and -dpiy above)\n");
- X ErrorF ("-bp[s] #XXX color for BlackPixel for screen\n");
- X ErrorF ("-wp[s] #XXX color for WhitePixel for screen\n");
- X ErrorF ("-class[s] <classname> type of Visual for root window\n");
- X ErrorF (" one of StaticGray, StaticColor, PseudoColor,\n");
- X ErrorF (" GrayScale, or even TrueColor!\n");
- X ErrorF ("-edge_left<s1> <s2> Attach left edge of screen s1 to screen s2\n");
- X ErrorF ("-edge_right<s1> <s2> Attach right edge of screen s1 to screen s2\n");
- X ErrorF ("-edge_top<s1> <s2> Attach top edge of screen s1 to screen s2\n");
- X ErrorF ("-edge_bottom<s1> <s2> Attach bottom edge of screen s1 to screen s2\n");
- X
- X#ifdef XINPUT
- X ExtddxUseMsg();
- X#endif
- X}
- X
- X/* ARGSUSED */
- int wsScreenInit(index, pScreen, argc, argv)
- X int index;
- X register ScreenPtr pScreen;
- X int argc;
- X char **argv;
- X{
- X
- X pScreen->SaveScreen = wsSaveScreen;
- X pScreen->RealizeCursor = wsRealizeCursor;
- X pScreen->UnrealizeCursor = wsUnrealizeCursor;
- X pScreen->DisplayCursor = wsDisplayCursor;
- X pScreen->SetCursorPosition = wsSetCursorPosition;
- X pScreen->CursorLimits = wsCursorLimits;
- X pScreen->PointerNonInterestBox = wsPointerNonInterestBox;
- X pScreen->ConstrainCursor = wsConstrainCursor;
- X pScreen->RecolorCursor = wsRecolorCursor;
- X pScreen->StoreColors = wsStoreColors;
- X pScreen->InstallColormap = wsInstallColormap;
- X pScreen->UninstallColormap = wsUninstallColormap;
- X pScreen->ListInstalledColormaps = wsListInstalledColormaps;
- X
- X initEdgeAttachments(index);
- X if(screenArgs[index].flags & ARG_MONITOR) {
- X ws_monitor_type wmt;
- X wmt.screen = index;
- X wmt.monitor_type = screenArgs[index].monitor;
- X if (ioctl(wsFd, SET_MONITOR_TYPE, &wmt) == -1)
- X ErrorF("SET_MONITOR_TYPE, failed to set monitor type.\n");
- X }
- X wsSaveScreen(pScreen, SCREEN_SAVER_OFF);
- X return index;
- X}
- END_OF_FILE
- if test 34338 -ne `wc -c <'server/ddx/dec/ws/ws_io.c'`; then
- echo shar: \"'server/ddx/dec/ws/ws_io.c'\" unpacked with wrong size!
- fi
- # end of 'server/ddx/dec/ws/ws_io.c'
- fi
- echo shar: End of archive 2 \(of 2\).
- cp /dev/null ark2isdone
- MISSING=""
- for I in 1 2 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked both archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-
- --
- Dan Heller
- O'Reilly && Associates Z-Code Software Comp-sources-x:
- Senior Writer President comp-sources-x@uunet.uu.net
- argv@ora.com argv@zipcode.com
-