コード例 #1
0
ファイル: getbmap.c プロジェクト: GrahamCobb/maemo-xsisusb
int
ProcXGetDeviceButtonMapping(register ClientPtr client)
{
    DeviceIntPtr dev;
    xGetDeviceButtonMappingReply rep;
    ButtonClassPtr b;

    REQUEST(xGetDeviceButtonMappingReq);
    REQUEST_SIZE_MATCH(xGetDeviceButtonMappingReq);

    rep.repType = X_Reply;
    rep.RepType = X_GetDeviceButtonMapping;
    rep.nElts = 0;
    rep.length = 0;
    rep.sequenceNumber = client->sequence;

    dev = LookupDeviceIntRec(stuff->deviceid);
    if (dev == NULL) {
	SendErrorToClient(client, IReqCode, X_GetDeviceButtonMapping, 0,
			  BadDevice);
	return Success;
    }

    b = dev->button;
    if (b == NULL) {
	SendErrorToClient(client, IReqCode, X_GetDeviceButtonMapping, 0,
			  BadMatch);
	return Success;
    }
    rep.nElts = b->numButtons;
    rep.length = (rep.nElts + (4 - 1)) / 4;
    WriteReplyToClient(client, sizeof(xGetDeviceButtonMappingReply), &rep);
    (void)WriteToClient(client, rep.nElts, (char *)&b->map[1]);
    return Success;
}
コード例 #2
0
ファイル: closedev.c プロジェクト: GrahamCobb/maemo-xsisusb
int
ProcXCloseDevice(register ClientPtr client)
{
    int i;
    WindowPtr pWin, p1;
    DeviceIntPtr d;

    REQUEST(xCloseDeviceReq);
    REQUEST_SIZE_MATCH(xCloseDeviceReq);

    d = LookupDeviceIntRec(stuff->deviceid);
    if (d == NULL) {
	SendErrorToClient(client, IReqCode, X_CloseDevice, 0, BadDevice);
	return Success;
    }

    if (d->grab && SameClient(d->grab, client))
	(*d->DeactivateGrab) (d);	/* release active grab */

    /* Remove event selections from all windows for events from this device 
     * and selected by this client.
     * Delete passive grabs from all windows for this device.      */

    for (i = 0; i < screenInfo.numScreens; i++) {
	pWin = WindowTable[i];
	DeleteDeviceEvents(d, pWin, client);
	p1 = pWin->firstChild;
	DeleteEventsFromChildren(d, p1, client);
    }

    CloseInputDevice(d, client);
    return Success;
}
コード例 #3
0
int
ProcXSetDeviceModifierMapping(ClientPtr client)
{
    int ret;
    xSetDeviceModifierMappingReply rep;
    DeviceIntPtr dev;
    KeyClassPtr kp;

    REQUEST(xSetDeviceModifierMappingReq);
    REQUEST_AT_LEAST_SIZE(xSetDeviceModifierMappingReq);

    dev = LookupDeviceIntRec(stuff->deviceid);
    if (dev == NULL) {
	SendErrorToClient(client, IReqCode, X_SetDeviceModifierMapping, 0,
			  BadDevice);
	return Success;
    }

    rep.repType = X_Reply;
    rep.RepType = X_SetDeviceModifierMapping;
    rep.length = 0;
    rep.sequenceNumber = client->sequence;

    ret = SetModifierMapping(client, dev, stuff->length,
			     (sizeof(xSetDeviceModifierMappingReq) >> 2),
			     stuff->numKeyPerModifier, (BYTE *) & stuff[1],
			     &kp);

    if (ret == MappingSuccess || ret == MappingBusy || ret == MappingFailed) {
	rep.success = ret;
	if (ret == MappingSuccess)
	    SendDeviceMappingNotify(client, MappingModifier, 0, 0, dev);
	WriteReplyToClient(client, sizeof(xSetDeviceModifierMappingReply),
			   &rep);
    } else {
	if (ret == -1)
	    ret = BadValue;
	SendErrorToClient(client, IReqCode, X_SetDeviceModifierMapping, 0, ret);
    }

    return Success;
}
コード例 #4
0
ファイル: opendev.c プロジェクト: mcr/xorg-xvnc4
int
ProcXOpenDevice(ClientPtr client)
{
    xInputClassInfo evbase[numInputClasses];
    int j = 0;
    int status = Success;
    xOpenDeviceReply rep;
    DeviceIntPtr dev;

    REQUEST(xOpenDeviceReq);
    REQUEST_SIZE_MATCH(xOpenDeviceReq);

    if (stuff->deviceid == inputInfo.pointer->id ||
	stuff->deviceid == inputInfo.keyboard->id) {
	SendErrorToClient(client, IReqCode, X_OpenDevice, 0, BadDevice);
	return Success;
    }

    if ((dev = LookupDeviceIntRec(stuff->deviceid)) == NULL) {	/* not open */
	for (dev = inputInfo.off_devices; dev; dev = dev->next)
	    if (dev->id == stuff->deviceid)
		break;
	if (dev == NULL) {
	    SendErrorToClient(client, IReqCode, X_OpenDevice, 0, BadDevice);
	    return Success;
	}
    }

    OpenInputDevice(dev, client, &status);
    if (status != Success) {
	SendErrorToClient(client, IReqCode, X_OpenDevice, 0, status);
	return Success;
    }

    rep.repType = X_Reply;
    rep.RepType = X_OpenDevice;
    rep.sequenceNumber = client->sequence;
    if (dev->key != NULL) {
	evbase[j].class = KeyClass;
	evbase[j++].event_type_base = event_base[KeyClass];
    }
コード例 #5
0
ファイル: devbell.c プロジェクト: GrahamCobb/maemo-xsisusb
int
ProcXDeviceBell(register ClientPtr client)
{
    DeviceIntPtr dev;
    KbdFeedbackPtr k;
    BellFeedbackPtr b;
    int base;
    int newpercent;
    CARD8 class;
    pointer ctrl;
    BellProcPtr proc;

    REQUEST(xDeviceBellReq);
    REQUEST_SIZE_MATCH(xDeviceBellReq);

    dev = LookupDeviceIntRec(stuff->deviceid);
    if (dev == NULL) {
	client->errorValue = stuff->deviceid;
	SendErrorToClient(client, IReqCode, X_DeviceBell, 0, BadDevice);
	return Success;
    }

    if (stuff->percent < -100 || stuff->percent > 100) {
	client->errorValue = stuff->percent;
	SendErrorToClient(client, IReqCode, X_DeviceBell, 0, BadValue);
	return Success;
    }
    if (stuff->feedbackclass == KbdFeedbackClass) {
	for (k = dev->kbdfeed; k; k = k->next)
	    if (k->ctrl.id == stuff->feedbackid)
		break;
	if (!k) {
	    client->errorValue = stuff->feedbackid;
	    SendErrorToClient(client, IReqCode, X_DeviceBell, 0, BadValue);
	    return Success;
	}
	base = k->ctrl.bell;
	proc = k->BellProc;
	ctrl = (pointer) & (k->ctrl);
	class = KbdFeedbackClass;
    } else if (stuff->feedbackclass == BellFeedbackClass) {
コード例 #6
0
ファイル: setfocus.c プロジェクト: mcr/xorg-xvnc4
int
ProcXSetDeviceFocus(ClientPtr client)
{
    int ret;
    DeviceIntPtr dev;

    REQUEST(xSetDeviceFocusReq);
    REQUEST_SIZE_MATCH(xSetDeviceFocusReq);

    dev = LookupDeviceIntRec(stuff->device);
    if (dev == NULL || !dev->focus) {
	SendErrorToClient(client, IReqCode, X_SetDeviceFocus, 0, BadDevice);
	return Success;
    }

    ret = SetInputFocus(client, dev, stuff->focus, stuff->revertTo,
			stuff->time, TRUE);
    if (ret != Success)
	SendErrorToClient(client, IReqCode, X_SetDeviceFocus, 0, ret);

    return Success;
}
コード例 #7
0
ファイル: xvdisp.c プロジェクト: eriytt/xserver-xsdl
int
SProcXvDispatch(ClientPtr client)
{
  REQUEST(xReq);

  UpdateCurrentTime();

  if (stuff->data >= xvNumRequests) {
    SendErrorToClient(client, XvReqCode, stuff->data, 0, BadRequest);
    return BadRequest;
  }

  return SXvProcVector[stuff->data](client);
}
コード例 #8
0
ファイル: ungrdev.c プロジェクト: mcr/xorg-xvnc4
int
ProcXUngrabDevice(ClientPtr client)
{
    DeviceIntPtr dev;
    GrabPtr grab;
    TimeStamp time;

    REQUEST(xUngrabDeviceReq);
    REQUEST_SIZE_MATCH(xUngrabDeviceReq);

    dev = LookupDeviceIntRec(stuff->deviceid);
    if (dev == NULL) {
	SendErrorToClient(client, IReqCode, X_UngrabDevice, 0, BadDevice);
	return Success;
    }
    grab = dev->grab;

    time = ClientTimeToServerTime(stuff->time);
    if ((CompareTimeStamps(time, currentTime) != LATER) &&
	(CompareTimeStamps(time, dev->grabTime) != EARLIER) &&
	(grab) && SameClient(grab, client))
	(*dev->DeactivateGrab) (dev);
    return Success;
}
コード例 #9
0
ファイル: extinit.c プロジェクト: Magister/x11rdp_xorg71
int
SProcIDispatch(register ClientPtr client)
{
    REQUEST(xReq);
    if (stuff->data == X_GetExtensionVersion)
        return (SProcXGetExtensionVersion(client));
    if (stuff->data == X_ListInputDevices)
        return (SProcXListInputDevices(client));
    else if (stuff->data == X_OpenDevice)
        return (SProcXOpenDevice(client));
    else if (stuff->data == X_CloseDevice)
        return (SProcXCloseDevice(client));
    else if (stuff->data == X_SetDeviceMode)
        return (SProcXSetDeviceMode(client));
    else if (stuff->data == X_SelectExtensionEvent)
        return (SProcXSelectExtensionEvent(client));
    else if (stuff->data == X_GetSelectedExtensionEvents)
        return (SProcXGetSelectedExtensionEvents(client));
    else if (stuff->data == X_ChangeDeviceDontPropagateList)
        return (SProcXChangeDeviceDontPropagateList(client));
    else if (stuff->data == X_GetDeviceDontPropagateList)
        return (SProcXGetDeviceDontPropagateList(client));
    else if (stuff->data == X_GetDeviceMotionEvents)
        return (SProcXGetDeviceMotionEvents(client));
    else if (stuff->data == X_ChangeKeyboardDevice)
        return (SProcXChangeKeyboardDevice(client));
    else if (stuff->data == X_ChangePointerDevice)
        return (SProcXChangePointerDevice(client));
    else if (stuff->data == X_GrabDevice)
        return (SProcXGrabDevice(client));
    else if (stuff->data == X_UngrabDevice)
        return (SProcXUngrabDevice(client));
    else if (stuff->data == X_GrabDeviceKey)
        return (SProcXGrabDeviceKey(client));
    else if (stuff->data == X_UngrabDeviceKey)
        return (SProcXUngrabDeviceKey(client));
    else if (stuff->data == X_GrabDeviceButton)
        return (SProcXGrabDeviceButton(client));
    else if (stuff->data == X_UngrabDeviceButton)
        return (SProcXUngrabDeviceButton(client));
    else if (stuff->data == X_AllowDeviceEvents)
        return (SProcXAllowDeviceEvents(client));
    else if (stuff->data == X_GetDeviceFocus)
        return (SProcXGetDeviceFocus(client));
    else if (stuff->data == X_SetDeviceFocus)
        return (SProcXSetDeviceFocus(client));
    else if (stuff->data == X_GetFeedbackControl)
        return (SProcXGetFeedbackControl(client));
    else if (stuff->data == X_ChangeFeedbackControl)
        return (SProcXChangeFeedbackControl(client));
    else if (stuff->data == X_GetDeviceKeyMapping)
        return (SProcXGetDeviceKeyMapping(client));
    else if (stuff->data == X_ChangeDeviceKeyMapping)
        return (SProcXChangeDeviceKeyMapping(client));
    else if (stuff->data == X_GetDeviceModifierMapping)
        return (SProcXGetDeviceModifierMapping(client));
    else if (stuff->data == X_SetDeviceModifierMapping)
        return (SProcXSetDeviceModifierMapping(client));
    else if (stuff->data == X_GetDeviceButtonMapping)
        return (SProcXGetDeviceButtonMapping(client));
    else if (stuff->data == X_SetDeviceButtonMapping)
        return (SProcXSetDeviceButtonMapping(client));
    else if (stuff->data == X_QueryDeviceState)
        return (SProcXQueryDeviceState(client));
    else if (stuff->data == X_SendExtensionEvent)
        return (SProcXSendExtensionEvent(client));
    else if (stuff->data == X_DeviceBell)
        return (SProcXDeviceBell(client));
    else if (stuff->data == X_SetDeviceValuators)
        return (SProcXSetDeviceValuators(client));
    else if (stuff->data == X_GetDeviceControl)
        return (SProcXGetDeviceControl(client));
    else if (stuff->data == X_ChangeDeviceControl)
        return (SProcXChangeDeviceControl(client));
    else {
        SendErrorToClient(client, IReqCode, stuff->data, 0, BadRequest);
    }
    return (BadRequest);
}
コード例 #10
0
ファイル: ungrdevk.c プロジェクト: Magister/x11rdp_xorg71
int
ProcXUngrabDeviceKey(ClientPtr client)
{
    DeviceIntPtr dev;
    DeviceIntPtr mdev;
    WindowPtr pWin;
    GrabRec temporaryGrab;

    REQUEST(xUngrabDeviceKeyReq);
    REQUEST_SIZE_MATCH(xUngrabDeviceKeyReq);

    dev = LookupDeviceIntRec(stuff->grabbed_device);
    if (dev == NULL) {
        SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadDevice);
        return Success;
    }
    if (dev->key == NULL) {
        SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadMatch);
        return Success;
    }

    if (stuff->modifier_device != UseXKeyboard) {
        mdev = LookupDeviceIntRec(stuff->modifier_device);
        if (mdev == NULL) {
            SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0,
                              BadDevice);
            return Success;
        }
        if (mdev->key == NULL) {
            SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadMatch);
            return Success;
        }
    } else
        mdev = (DeviceIntPtr) LookupKeyboardDevice();

    pWin = LookupWindow(stuff->grabWindow, client);
    if (!pWin) {
        SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadWindow);
        return Success;
    }
    if (((stuff->key > dev->key->curKeySyms.maxKeyCode) ||
            (stuff->key < dev->key->curKeySyms.minKeyCode))
            && (stuff->key != AnyKey)) {
        SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadValue);
        return Success;
    }
    if ((stuff->modifiers != AnyModifier) &&
            (stuff->modifiers & ~AllModifiersMask)) {
        SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadValue);
        return Success;
    }

    temporaryGrab.resource = client->clientAsMask;
    temporaryGrab.device = dev;
    temporaryGrab.window = pWin;
    temporaryGrab.type = DeviceKeyPress;
    temporaryGrab.modifierDevice = mdev;
    temporaryGrab.modifiersDetail.exact = stuff->modifiers;
    temporaryGrab.modifiersDetail.pMask = NULL;
    temporaryGrab.detail.exact = stuff->key;
    temporaryGrab.detail.pMask = NULL;

    DeletePassiveGrabFromList(&temporaryGrab);
    return Success;
}
コード例 #11
0
ファイル: ungrdevb.c プロジェクト: mcr/xorg-xvnc4
int
ProcXUngrabDeviceButton(ClientPtr client)
{
    DeviceIntPtr dev;
    DeviceIntPtr mdev;
    WindowPtr pWin;
    GrabRec temporaryGrab;
    int rc;

    REQUEST(xUngrabDeviceButtonReq);
    REQUEST_SIZE_MATCH(xUngrabDeviceButtonReq);

    dev = LookupDeviceIntRec(stuff->grabbed_device);
    if (dev == NULL) {
	SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0, BadDevice);
	return Success;
    }
    if (dev->button == NULL) {
	SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0, BadMatch);
	return Success;
    }

    if (stuff->modifier_device != UseXKeyboard) {
	mdev = LookupDeviceIntRec(stuff->modifier_device);
	if (mdev == NULL) {
	    SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0,
			      BadDevice);
	    return Success;
	}
	if (mdev->key == NULL) {
	    SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0,
			      BadMatch);
	    return Success;
	}
    } else
	mdev = (DeviceIntPtr) LookupKeyboardDevice();

    rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixUnknownAccess);
    if (rc != Success) {
	SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0, rc);
	return Success;
    }

    if ((stuff->modifiers != AnyModifier) &&
	(stuff->modifiers & ~AllModifiersMask)) {
	SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0, BadValue);
	return Success;
    }

    temporaryGrab.resource = client->clientAsMask;
    temporaryGrab.device = dev;
    temporaryGrab.window = pWin;
    temporaryGrab.type = DeviceButtonPress;
    temporaryGrab.modifierDevice = mdev;
    temporaryGrab.modifiersDetail.exact = stuff->modifiers;
    temporaryGrab.modifiersDetail.pMask = NULL;
    temporaryGrab.detail.exact = stuff->button;
    temporaryGrab.detail.pMask = NULL;

    DeletePassiveGrabFromList(&temporaryGrab);
    return Success;
}
コード例 #12
0
ファイル: xvdisp.c プロジェクト: eriytt/xserver-xsdl
/* redefined here since it's not in any header file */
typedef struct _ShmDesc {
    struct _ShmDesc *next;
    int shmid;
    int refcnt;
    char *addr;
    Bool writable;
    unsigned long size;
} ShmDescRec, *ShmDescPtr;

extern RESTYPE ShmSegType;
extern int ShmCompletionCode;

static int 
ProcXvShmPutImage(ClientPtr client)
{
  ShmDescPtr shmdesc;
  DrawablePtr pDraw;
  XvPortPtr pPort;
  XvImagePtr pImage = NULL;
  GCPtr pGC;
  int status, size_needed, i;
  CARD16 width, height;

  REQUEST(xvShmPutImageReq);
  REQUEST_SIZE_MATCH(xvShmPutImageReq);

  VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
  VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);

  if ((status = _AllocatePort(stuff->port, pPort)) != Success)
    {
      client->errorValue = stuff->port;
      return status;
    }

  if (!(pPort->pAdaptor->type & XvImageMask) ||
	!(pPort->pAdaptor->type & XvInputMask))
    {
      client->errorValue = stuff->port;
      return BadMatch;
    }

  status = XvdiMatchPort(pPort, pDraw);
  if (status != Success)
    {
      return status;
    }

  for(i = 0; i < pPort->pAdaptor->nImages; i++) {
      if(pPort->pAdaptor->pImages[i].id == stuff->id) {
	  pImage = &(pPort->pAdaptor->pImages[i]);
	  break;
      }
  }

  if(!pImage)
     return BadMatch;

  status = dixLookupResourceByType((pointer *)&shmdesc, stuff->shmseg,
				   ShmSegType, serverClient, DixReadAccess);
  if (status != Success)
      return status;
 
  width = stuff->width;
  height = stuff->height;
  size_needed = (*pPort->pAdaptor->ddQueryImageAttributes)(client, 
			pPort, pImage, &width, &height, NULL, NULL);
  if((size_needed + stuff->offset) > shmdesc->size)
      return BadAccess;

  if((width < stuff->width) || (height < stuff->height))
     return BadValue;
     
  status = XvdiPutImage(client, pDraw, pPort, pGC, stuff->src_x, stuff->src_y,
			stuff->src_w, stuff->src_h, stuff->drw_x, stuff->drw_y,
			stuff->drw_w, stuff->drw_h, pImage,
			(unsigned char *)shmdesc->addr + stuff->offset, 
			stuff->send_event, stuff->width, stuff->height);

  if((status == Success) && stuff->send_event) {
        xShmCompletionEvent ev;

        ev.type = ShmCompletionCode;
        ev.drawable = stuff->drawable;
        ev.minorEvent = xv_ShmPutImage;
        ev.majorEvent = XvReqCode;
        ev.shmseg = stuff->shmseg;
        ev.offset = stuff->offset;
        WriteEventsToClient(client, 1, (xEvent *) &ev);
  }

  return status;
}
#else /* !MITSHM */
static int
ProcXvShmPutImage(ClientPtr client)
{
    SendErrorToClient(client, XvReqCode, xv_ShmPutImage, 0, BadImplementation);
    return BadImplementation;
}
コード例 #13
0
int
ProcXIQueryPointer(ClientPtr client)
{
    int rc;
    xXIQueryPointerReply rep;
    DeviceIntPtr pDev, kbd;
    WindowPtr pWin, t;
    SpritePtr pSprite;
    XkbStatePtr state;
    char *buttons = NULL;
    int buttons_size = 0; /* size of buttons array */

    REQUEST(xXIQueryPointerReq);
    REQUEST_SIZE_MATCH(xXIQueryPointerReq);

    rc = dixLookupDevice(&pDev, stuff->deviceid, client, DixReadAccess);
    if (rc != Success)
    {
        client->errorValue = stuff->deviceid;
        return rc;
    }

    if (pDev->valuator == NULL || IsKeyboardDevice(pDev) ||
        (!IsMaster(pDev) && pDev->u.master)) /* no attached devices */
    {
        client->errorValue = stuff->deviceid;
        return BadDevice;
    }

    rc = dixLookupWindow(&pWin, stuff->win, client, DixGetAttrAccess);
    if (rc != Success)
    {
        SendErrorToClient(client, IReqCode, X_XIQueryPointer,
                stuff->win, rc);
        return Success;
    }

    if (pDev->valuator->motionHintWindow)
        MaybeStopHint(pDev, client);

    if (IsMaster(pDev))
        kbd = GetPairedDevice(pDev);
    else
        kbd = (pDev->key) ? pDev : NULL;

    pSprite = pDev->spriteInfo->sprite;

    memset(&rep, 0, sizeof(rep));
    rep.repType = X_Reply;
    rep.RepType = X_XIQueryPointer;
    rep.length = 6;
    rep.sequenceNumber = client->sequence;
    rep.root = (GetCurrentRootWindow(pDev))->drawable.id;
    rep.root_x = FP1616(pSprite->hot.x, 0);
    rep.root_y = FP1616(pSprite->hot.y, 0);
    rep.child = None;

    if (kbd)
    {
        state = &kbd->key->xkbInfo->prev_state;
        rep.mods.base_mods = state->base_mods;
        rep.mods.latched_mods = state->latched_mods;
        rep.mods.locked_mods = state->locked_mods;

        rep.group.base_group = state->base_group;
        rep.group.latched_group = state->latched_group;
        rep.group.locked_group = state->locked_group;
    }

    if (pDev->button)
    {
        int i, down;
        rep.buttons_len = bytes_to_int32(bits_to_bytes(pDev->button->numButtons));
        rep.length += rep.buttons_len;
        buttons_size = rep.buttons_len * 4;
        buttons = xcalloc(1, buttons_size);
        if (!buttons)
            return BadAlloc;

        down = pDev->button->buttonsDown;

        for (i = 0; i < pDev->button->numButtons && down; i++)
        {
            if (BitIsOn(pDev->button->down, i))
            {
                SetBit(buttons, i);
                down--;
            }
        }
    } else
        rep.buttons_len = 0;

    if (pSprite->hot.pScreen == pWin->drawable.pScreen)
    {
        rep.same_screen = xTrue;
        rep.win_x = FP1616(pSprite->hot.x - pWin->drawable.x, 0);
        rep.win_y = FP1616(pSprite->hot.y - pWin->drawable.y, 0);
        for (t = pSprite->win; t; t = t->parent)
            if (t->parent == pWin)
            {
                rep.child = t->drawable.id;
                break;
            }
    } else
    {
        rep.same_screen = xFalse;
        rep.win_x = 0;
        rep.win_y = 0;
    }

#ifdef PANORAMIX
    if(!noPanoramiXExtension) {
        rep.root_x += FP1616(panoramiXdataPtr[0].x, 0);
        rep.root_y += FP1616(panoramiXdataPtr[0].y, 0);
        if (stuff->win == rep.root)
        {
            rep.win_x += FP1616(panoramiXdataPtr[0].x, 0);
            rep.win_y += FP1616(panoramiXdataPtr[0].y, 0);
        }
    }
#endif

    WriteReplyToClient(client, sizeof(xXIQueryPointerReply), &rep);
    if (buttons)
        WriteToClient(client, buttons_size, buttons);

    xfree(buttons);

    return Success;
}
コード例 #14
0
int
ProcXIQueryPointer(ClientPtr client)
{
    int rc;
    xXIQueryPointerReply rep;
    DeviceIntPtr pDev, kbd;
    WindowPtr pWin, t;
    SpritePtr pSprite;
    XkbStatePtr state;
    char *buttons = NULL;
    int buttons_size = 0;       /* size of buttons array */
    XIClientPtr xi_client;
    Bool have_xi22 = FALSE;

    REQUEST(xXIQueryPointerReq);
    REQUEST_SIZE_MATCH(xXIQueryPointerReq);

    /* Check if client is compliant with XInput 2.2 or later. Earlier clients
     * do not know about touches, so we must report emulated button presses. 2.2
     * and later clients are aware of touches, so we don't include emulated
     * button presses in the reply. */
    xi_client = dixLookupPrivate(&client->devPrivates, XIClientPrivateKey);
    if (version_compare(xi_client->major_version,
                        xi_client->minor_version, 2, 2) >= 0)
        have_xi22 = TRUE;

    rc = dixLookupDevice(&pDev, stuff->deviceid, client, DixReadAccess);
    if (rc != Success) {
        client->errorValue = stuff->deviceid;
        return rc;
    }

    if (pDev->valuator == NULL || IsKeyboardDevice(pDev) || (!IsMaster(pDev) && !IsFloating(pDev))) {   /* no attached devices */
        client->errorValue = stuff->deviceid;
        return BadDevice;
    }

    rc = dixLookupWindow(&pWin, stuff->win, client, DixGetAttrAccess);
    if (rc != Success) {
        SendErrorToClient(client, IReqCode, X_XIQueryPointer, stuff->win, rc);
        return Success;
    }

    if (pDev->valuator->motionHintWindow)
        MaybeStopHint(pDev, client);

    if (IsMaster(pDev))
        kbd = GetMaster(pDev, MASTER_KEYBOARD);
    else
        kbd = (pDev->key) ? pDev : NULL;

    pSprite = pDev->spriteInfo->sprite;

    rep = (xXIQueryPointerReply) {
        .repType = X_Reply,
         .RepType = X_XIQueryPointer,
          .sequenceNumber = client->sequence,
           .length = 6,
            .root = (GetCurrentRootWindow(pDev))->drawable.id,
             .root_x = double_to_fp1616(pSprite->hot.x),
              .root_y = double_to_fp1616(pSprite->hot.y),
               .child = None
    };

    if (kbd) {
        state = &kbd->key->xkbInfo->state;
        rep.mods.base_mods = state->base_mods;
        rep.mods.latched_mods = state->latched_mods;
        rep.mods.locked_mods = state->locked_mods;

        rep.group.base_group = state->base_group;
        rep.group.latched_group = state->latched_group;
        rep.group.locked_group = state->locked_group;
    }

    if (pDev->button) {
        int i;

        rep.buttons_len =
            bytes_to_int32(bits_to_bytes(pDev->button->numButtons));
        rep.length += rep.buttons_len;
        buttons_size = rep.buttons_len * 4;
        buttons = calloc(1, buttons_size);
        if (!buttons)
            return BadAlloc;

        for (i = 1; i < pDev->button->numButtons; i++)
            if (BitIsOn(pDev->button->down, i))
                SetBit(buttons, pDev->button->map[i]);

        if (!have_xi22 && pDev->touch && pDev->touch->buttonsDown > 0)
            SetBit(buttons, pDev->button->map[1]);
    }
    else
        rep.buttons_len = 0;

    if (pSprite->hot.pScreen == pWin->drawable.pScreen) {
        rep.same_screen = xTrue;
        rep.win_x = double_to_fp1616(pSprite->hot.x - pWin->drawable.x);
        rep.win_y = double_to_fp1616(pSprite->hot.y - pWin->drawable.y);
        for (t = pSprite->win; t; t = t->parent)
            if (t->parent == pWin) {
                rep.child = t->drawable.id;
                break;
            }
    }
    else {
        rep.same_screen = xFalse;
        rep.win_x = 0;
        rep.win_y = 0;
    }

#ifdef PANORAMIX
    if (!noPanoramiXExtension) {
        rep.root_x += double_to_fp1616(screenInfo.screens[0]->x);
        rep.root_y += double_to_fp1616(screenInfo.screens[0]->y);
        if (stuff->win == rep.root) {
            rep.win_x += double_to_fp1616(screenInfo.screens[0]->x);
            rep.win_y += double_to_fp1616(screenInfo.screens[0]->y);
        }
    }
#endif

    WriteReplyToClient(client, sizeof(xXIQueryPointerReply), &rep);
    if (buttons)
        WriteToClient(client, buttons_size, buttons);

    free(buttons);

    return Success;
}

/***********************************************************************
 *
 * This procedure writes the reply for the XIQueryPointer function,
 * if the client and server have a different byte ordering.
 *
 */

void
SRepXIQueryPointer(ClientPtr client, int size, xXIQueryPointerReply * rep)
{
    swaps(&rep->sequenceNumber);
    swapl(&rep->length);
    swapl(&rep->root);
    swapl(&rep->child);
    swapl(&rep->root_x);
    swapl(&rep->root_y);
    swapl(&rep->win_x);
    swapl(&rep->win_y);
    swaps(&rep->buttons_len);

    WriteToClient(client, size, rep);
}
コード例 #15
0
ファイル: getselev.c プロジェクト: Magister/x11rdp_xorg71
int
ProcXGetSelectedExtensionEvents(register ClientPtr client)
{
    int i;
    int total_length = 0;
    xGetSelectedExtensionEventsReply rep;
    WindowPtr pWin;
    XEventClass *buf = NULL;
    XEventClass *tclient;
    XEventClass *aclient;
    OtherInputMasks *pOthers;
    InputClientsPtr others;

    REQUEST(xGetSelectedExtensionEventsReq);
    REQUEST_SIZE_MATCH(xGetSelectedExtensionEventsReq);

    rep.repType = X_Reply;
    rep.RepType = X_GetSelectedExtensionEvents;
    rep.length = 0;
    rep.sequenceNumber = client->sequence;
    rep.this_client_count = 0;
    rep.all_clients_count = 0;

    if (!(pWin = LookupWindow(stuff->window, client))) {
        SendErrorToClient(client, IReqCode, X_GetSelectedExtensionEvents, 0,
                          BadWindow);
        return Success;
    }

    if ((pOthers = wOtherInputMasks(pWin)) != 0) {
        for (others = pOthers->inputClients; others; others = others->next)
            for (i = 0; i < EMASKSIZE; i++)
                tclient = ClassFromMask(NULL, others->mask[i], i,
                                        &rep.all_clients_count, COUNT);

        for (others = pOthers->inputClients; others; others = others->next)
            if (SameClient(others, client)) {
                for (i = 0; i < EMASKSIZE; i++)
                    tclient = ClassFromMask(NULL, others->mask[i], i,
                                            &rep.this_client_count, COUNT);
                break;
            }

        total_length = (rep.all_clients_count + rep.this_client_count) *
                       sizeof(XEventClass);
        rep.length = (total_length + 3) >> 2;
        buf = (XEventClass *) xalloc(total_length);

        tclient = buf;
        aclient = buf + rep.this_client_count;
        if (others)
            for (i = 0; i < EMASKSIZE; i++)
                tclient =
                    ClassFromMask(tclient, others->mask[i], i, NULL, CREATE);

        for (others = pOthers->inputClients; others; others = others->next)
            for (i = 0; i < EMASKSIZE; i++)
                aclient =
                    ClassFromMask(aclient, others->mask[i], i, NULL, CREATE);
    }

    WriteReplyToClient(client, sizeof(xGetSelectedExtensionEventsReply), &rep);

    if (total_length) {
        client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
        WriteSwappedDataToClient(client, total_length, buf);
        xfree(buf);
    }
    return Success;
}