📄 x_hilinit.c
字号:
* allocates the next available event to the caller and increments * the tail pointer of the events queue; sets queue_events_free as needed. * */xHPEvent *allocate_event () { xHPEvent *event; event = &( (events_queue->events)[events_queue->tail]); if ( events_queue->tail == WR_EVENTS) events_queue->tail = 0; else (events_queue->tail)++; queue_events_free--; if (queue_events_free == 0) ErrorF ("Server Internal events queue is full!!!\n"); return (event); }deallocate_event (ev) xHPEvent *ev; { xHPEvent *tmp, *tail, *last, *first; tail = &( (events_queue->events)[events_queue->tail]); last = &( (events_queue->events)[WR_EVENTS]); first = &( (events_queue->events)[0]); for (tmp=ev; tmp!=tail; tmp++) if (tmp==last) { *tmp = *first; tmp = first-1; } else *tmp = *(tmp+1); if (events_queue->tail == 0) events_queue->tail = WR_EVENTS; else events_queue->tail--; queue_events_free++; }extern int apLeave_X, apReenter_X; /* in hp/apollo/apInit2.c */CheckInput (data, result, LastSelectMask) pointer data; unsigned long result; long LastSelectMask[]; { long devicesReadable[mskcnt]; extern long EnabledDevices[]; extern Bool display_borrowed; /* in x_hil.c */ if (result <= 0) return; MASKANDSETBITS(devicesReadable, LastSelectMask, EnabledDevices);#ifdef __apollo if (apReenter_X) apReturnFromDM(); if (display_borrowed) return; while (GetSMDEvent(TRUE, NULL)) ; if (apLeave_X) apReturnToDM(); BITCLEAR (devicesReadable, fdApollo);#endif /* __apollo */#ifdef __hp_osf BITCLEAR (devicesReadable, beeper_fd);#endif /* __hp_osf */ if (ANYSET(devicesReadable)) store_inputs (devicesReadable); }#ifdef XINPUTAddOtherInputDevices () { int i; HPInputDevice *hp, *tmphp; DeviceIntPtr dev; Bool found; for (i=0, hp=l_devs; i<MAX_LOGICAL_DEVS; hp++,i++) { found = FALSE; for (dev=inputInfo.devices; dev; dev=dev->next) { tmphp = GET_HPINPUTDEVICE (dev); if (hp == tmphp) { found = TRUE; break; } } for (dev=inputInfo.off_devices; found==FALSE && dev; dev=dev->next) { tmphp = GET_HPINPUTDEVICE (dev); if (hp == tmphp) { found = TRUE; break; } } if (found == FALSE && hp->x_name[0] != '\0' && (strcmp (hp->dev_name,"/dev/null") != 0)) { dev = x_init_device (hp, TRUE); dev->inited = ((*dev->deviceProc)(dev, DEVICE_INIT) == Success); } } }ChangeKeyboardDevice (old_dev, new_dev) DeviceIntPtr old_dev; DeviceIntPtr new_dev; { CARD8 tmp; HPInputDevice *old = GET_HPINPUTDEVICE (old_dev); HPInputDevice *new = GET_HPINPUTDEVICE (new_dev); if (old->hpflags & OPEN_THIS_DEVICE) { old->open_cnt--; old->hpflags &= ~OPEN_THIS_DEVICE; }#ifdef NOT_DONE tmp = hp_device_ids[new_dev->id]; hp_device_ids[new_dev->id] = XKEYBOARD; hp_device_ids[old_dev->id] = tmp;#endif x_device_ids[XKEYBOARD] = new_dev->id; x_device_ids[tmp] = old->dev_id; hpKeyboard = new; return (Success); }ChangePointerDevice (old_dev, new_dev, x, y) DeviceIntPtr old_dev; DeviceIntPtr new_dev; unsigned char x,y; { XID tmp; HPInputDevice *old = GET_HPINPUTDEVICE (old_dev); HPInputDevice *new = GET_HPINPUTDEVICE (new_dev); if (new_dev == tablet_extension_device) return (BadDevice); x_axis = x; y_axis = y; if (x_axis != 0 || y_axis != 1) axes_changed = TRUE; else axes_changed = FALSE; new->coords[0] = old->coords[0]; new->coords[1] = old->coords[1]; if (old->hpflags & OPEN_THIS_DEVICE) { old->open_cnt--; old->hpflags &= ~OPEN_THIS_DEVICE; } screen_change_dev = new_dev;#ifdef NOT_DONE tmp = hp_device_ids[new_dev->id]; hp_device_ids[new_dev->id] = XPOINTER; hp_device_ids[old_dev->id] = tmp;#endif x_device_ids[XPOINTER] = new_dev->id; x_device_ids[tmp] = old->dev_id; hpPointer = new;#ifdef __apollo { smd_$pos_t pos; pos.column = hpPointer->coords[0]; pos.line = hpPointer->coords[1]; smd_$set_unit_cursor_pos (1, pos, &status); }#endif /* __apollo */ InitFocusClassDeviceStruct(old_dev); return (Success); }/**************************************************************************** * * Turn on a non-standard device. * */OpenInputDevice (dev, client, status) DeviceIntPtr dev; ClientPtr client; int *status; { int mode; HPInputDevice *d; DeviceClientsPtr tmp; if (*status != Success) /* kludge - if not Success, */ mode = (*status >> 8); /* called from HPSetInputDevice */ else /* mode hidden in 2nd byte */ mode = DEVICE_EVENTS | ON; *status = Success; d = GET_HPINPUTDEVICE (dev); if (d->file_ds == -1) /* device not yet open */ { if (open_device (d) < 0) /* couldn't open device */ { *status = BadDevice; return; } recalculate_x_name (); /* recalculate names */ } else { for (tmp = (DeviceClientsPtr) d->clients; tmp!=NULL; tmp=tmp->next) if (tmp->mode != mode) { *status = BadMode; return; } } SetInputDevice (d, mode); dev->startup = 1; RecordOpenRequest (client, d, dev->id, mode); }/*********************************************************************** * * Record a successful request from a client to open an input device. * */static voidRecordOpenRequest (client, d, id, token) register ClientPtr client; HPInputDevice *d; CARD8 id; int token; { DeviceClientsPtr tmp; DeviceClientsPtr new_client; d->open_cnt++; if (d->clients != NULL) { for (tmp = (DeviceClientsPtr) d->clients; tmp!=NULL; tmp=tmp->next) if (tmp->client == client) { tmp->count++; return; } else if (tmp->next == NULL) break; new_client = (DeviceClients *) Xalloc(sizeof(DeviceClients)); tmp->next = new_client; } else { new_client = (DeviceClients *) Xalloc(sizeof(DeviceClients)); d->clients = new_client; } memset ((char *) new_client, 0, sizeof (DeviceClients)); new_client->resource = FakeClientID(client->index); new_client->client = client; new_client->next = NULL; new_client->count = 1; new_client->mode = token; AddResource(new_client->resource, HPType, id); }/*********************************************************************** * * Turn off a device because a client died. * Also called when a client closes a device. * */int HPShutDownDevice (deviceid, clientid) CARD8 deviceid; int clientid; { DeviceIntPtr dev = NULL; DeviceClientsPtr tmp; DeviceClientsPtr save; HPInputDevice *d; if (deviceid == inputInfo.pointer->id) d = hpPointer; else if (deviceid == inputInfo.keyboard->id) d = hpKeyboard; else { dev = LookupDeviceIntRec(deviceid); if (dev == NULL) return; d = GET_HPINPUTDEVICE (dev); } if (d->clients != NULL) { tmp = (DeviceClientsPtr) d->clients; if (tmp->resource == clientid) { d->open_cnt -= tmp->count; d->clients = tmp->next; Xfree (tmp); } else for (save=tmp,tmp=tmp->next; tmp!=NULL; save=tmp, tmp=tmp->next) { if (tmp->resource == clientid) { d->open_cnt -= tmp->count; save->next = tmp->next; Xfree (tmp); } } if (d->clients == NULL) { if (dev && d->open_cnt == 0) DisableDevice(dev); else { d->mode = ABSOLUTE; d->hpflags |= MERGED_DEVICE; } } } }/**************************************************************************** * * Turn off an extension device. * This code does not allow the keyboard or pointer to be turned off. * */CloseInputDevice (dev, client) DeviceIntPtr dev; ClientPtr client; { HPInputDevice *d; DeviceClientsPtr tmp; d = GET_HPINPUTDEVICE (dev); for (tmp= (DeviceClientsPtr) d->clients; tmp!=NULL; tmp=tmp->next) if (tmp->client == client) { tmp->count--; d->open_cnt--; if (tmp->count == 0) { FreeResource(tmp->resource, RT_NONE); return; } } }/**************************************************************************** * * Change the state of a non-standard device. * Modes are: * ON - turn the device on. * OFF - turn the device off. * SYSTEM_EVENTS - report the standard input events. * DEVICE_EVENTS - report the extension input events. * */static voidSetInputDevice (d, mode) HPInputDevice *d; int mode; { if ((mode & DEVICE_EVENTS) == DEVICE_EVENTS) { d->mode = RELATIVE; d->hpflags &= ~MERGED_DEVICE; } else { mode |= ABSOLUTE; d->mode = ABSOLUTE; d->hpflags |= MERGED_DEVICE; } if ((mode & ABSOLUTE) == ABSOLUTE) { d->coords[0] = hpPointer->coords[0]; d->coords[1] = hpPointer->coords[1]; d->mode = ABSOLUTE; } else {#if defined(__hpux) || defined(__hp_osf) || defined(hp9000) d->coords[0] = 0; d->coords[1] = 0;#endif /* __hpux */ d->mode = RELATIVE; } }/**************************************************************************** * * Change the mode of an extension device. * This is for devices such as graphics tablets that can report either * relative or absolute motion. * We currently do not support this. * */SetDeviceMode (client, dev, mode) register ClientPtr client; DeviceIntPtr dev; int mode; { int i; HPInputDevice *d; d = GET_HPINPUTDEVICE (dev); if (d->dev_type == NULL_DEVICE) return Success; if (d->hpflags & IS_SERIAL_DEVICE) for (i=0; i<num_serial_devices; i++) if (d->file_ds==serialprocs[i].fd) if ((*(serialprocs[i].write)) (d->file_ds, _XSetDeviceMode, &mode)==WRITE_SUCCESS) return Success; return BadMatch; }/**************************************************************************** * * Set the value of valuators on an extension device. * This is needed for some devices that can report both * relative and absolute motion. Some may require that the * initial values be set when switching modes. * We currently do not support this. * */SetDeviceValuators (client, dev, valuators, first_valuator, num_valuators) register ClientPtr client; DeviceIntPtr dev; int *valuators; int first_valuator; int num_valuators; { int i; HPInputDevice *d; HPResolutionControl ctrl; d = GET_HPINPUTDEVICE (dev); if (d->dev_type == NULL_DEVICE) return Success; if (d->hpflags & IS_SERIAL_DEVICE) for (i=0; i<num_serial_devices; i++) if (d->file_ds==serialprocs[i].fd) { ctrl.first_valuator = first_valuator; ctrl.num_valuators = num_valuators; ctrl.resolutions = valuators; if ((*(serialprocs[i].write)) (d->file_ds, _XSetDeviceValuators, &ctrl)==WRITE_SUCCESS) return Success; } return BadMatch; }/**************************************************************************** * * Change the resolution of valuators on an extension device. * This is needed for some devices that have multiple resolutions. * We currently do not support this. * */intChangeDeviceControl (client, dev, control) register ClientPtr client; DeviceIntPtr dev; xDeviceCtl *control; { int i; HPInputDevice *d; xDeviceResolutionCtl *dctrl; HPResolutionControl ctrl; d = GET_HPINPUTDEVICE (dev); if (d->dev_type == NULL_DEVICE) return Success; if (d->hpflags & IS_SERIAL_DEVICE) for (i=0; i<num_serial_devices; i++) if (d->file_ds==serialprocs[i].fd) { dctrl = (xDeviceResolutionCtl *) control; ctrl.first_valuator = dctrl->first_valuator; ctrl.num_valuators = dctrl->num_valuators; ctrl.resolutions = (int *) (dctrl+1); if ((*(serialprocs[i].write)) (d->file_ds, _XChangeDeviceControl, &ctrl)==WRITE_SUCCESS) return Success; } return BadMatch; }#endif /* XINPUT */#if defined(__hpux) || defined(__hp_osf) || defined(hp9000)#define LEFT_SHIFT_CODE 0x
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -