static int attach_slave(ClientPtr client, xXIAttachSlaveInfo *c, int flags[MAXDEVICES]) { DeviceIntPtr dev; DeviceIntPtr newmaster; int rc; rc = dixLookupDevice(&dev, c->deviceid, client, DixManageAccess); if (rc != Success) goto unwind; if (IsMaster(dev)) { client->errorValue = c->deviceid; rc = BadDevice; goto unwind; } /* Don't allow changes to XTest Devices, these are fixed */ if (IsXTestDevice(dev, NULL)) { client->errorValue = c->deviceid; rc = BadDevice; goto unwind; } rc = dixLookupDevice(&newmaster, c->new_master, client, DixAddAccess); if (rc != Success) goto unwind; if (!IsMaster(newmaster)) { client->errorValue = c->new_master; rc = BadDevice; goto unwind; } if (!((IsPointerDevice(newmaster) && IsPointerDevice(dev)) || (IsKeyboardDevice(newmaster) && IsKeyboardDevice(dev)))) { rc = BadDevice; goto unwind; } ReleaseButtonsAndKeys(dev); AttachDevice(client, dev, newmaster); flags[dev->id] |= XISlaveAttached; unwind: return rc; }
static void AnimCurScreenBlockHandler (int screenNum, pointer blockData, pointer pTimeout, pointer pReadmask) { ScreenPtr pScreen = screenInfo.screens[screenNum]; AnimCurScreenPtr as = GetAnimCurScreen(pScreen); DeviceIntPtr dev; Bool activeDevice = FALSE; CARD32 now = 0, soonest = ~0; /* earliest time to wakeup again */ for (dev = inputInfo.devices; dev; dev = dev->next) { if (IsPointerDevice(dev) && pScreen == dev->spriteInfo->anim.pScreen) { if (!activeDevice) { now = GetTimeInMillis (); activeDevice = TRUE; } if ((INT32) (now - dev->spriteInfo->anim.time) >= 0) { AnimCurPtr ac = GetAnimCur(dev->spriteInfo->anim.pCursor); int elt = (dev->spriteInfo->anim.elt + 1) % ac->nelt; DisplayCursorProcPtr DisplayCursor; /* * Not a simple Unwrap/Wrap as this * isn't called along the DisplayCursor * wrapper chain. */ DisplayCursor = pScreen->DisplayCursor; pScreen->DisplayCursor = as->DisplayCursor; (void) (*pScreen->DisplayCursor) (dev, pScreen, ac->elts[elt].pCursor); as->DisplayCursor = pScreen->DisplayCursor; pScreen->DisplayCursor = DisplayCursor; dev->spriteInfo->anim.elt = elt; dev->spriteInfo->anim.time = now + ac->elts[elt].delay; } if (soonest > dev->spriteInfo->anim.time) soonest = dev->spriteInfo->anim.time; } } if (activeDevice) AdjustWaitForDelay (pTimeout, soonest - now); Unwrap (as, pScreen, BlockHandler); (*pScreen->BlockHandler) (screenNum, blockData, pTimeout, pReadmask); if (activeDevice) Wrap (as, pScreen, BlockHandler, AnimCurScreenBlockHandler); else as->BlockHandler = NULL; }
int GetDeviceUse(DeviceIntPtr dev, uint16_t *attachment) { DeviceIntPtr master = dev->u.master; int use; if (IsMaster(dev)) { DeviceIntPtr paired = GetPairedDevice(dev); use = IsPointerDevice(dev) ? XIMasterPointer : XIMasterKeyboard; *attachment = (paired ? paired->id : 0); } else if (master) { use = IsPointerDevice(master) ? XISlavePointer : XISlaveKeyboard; *attachment = master->id; } else use = XIFloatingSlave; return use; }
static Bool miPointerDisplayCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor) { miPointerPtr pPointer; /* return for keyboards */ if (!IsPointerDevice(pDev)) return FALSE; pPointer = MIPOINTER(pDev); pPointer->pCursor = pCursor; pPointer->pScreen = pScreen; miPointerUpdateSprite(pDev); return TRUE; }
bool LinuxInputDevice::Open(const char *path) { if (!fd.OpenReadOnly(path)) return false; fd.SetNonBlocking(); io_loop.Add(fd.Get(), io_loop.READ, *this); is_pointer = IsPointerDevice(fd.Get()); if (is_pointer) merge.AddPointer(); rel_x = rel_y = 0; down = false; moving = pressing = releasing = false; return true; }
int ProcXIChangeCursor(ClientPtr client) { int rc; WindowPtr pWin = NULL; DeviceIntPtr pDev = NULL; CursorPtr pCursor = NULL; REQUEST(xXIChangeCursorReq); REQUEST_SIZE_MATCH(xXIChangeCursorReq); rc = dixLookupDevice(&pDev, stuff->deviceid, client, DixSetAttrAccess); if (rc != Success) return rc; if (!IsMaster(pDev) || !IsPointerDevice(pDev)) return BadDevice; if (stuff->win != None) { rc = dixLookupWindow(&pWin, stuff->win, client, DixSetAttrAccess); if (rc != Success) return rc; } if (stuff->cursor == None) { if (pWin == pWin->drawable.pScreen->root) pCursor = rootCursor; else pCursor = (CursorPtr)None; } else { rc = dixLookupResourceByType((pointer *)&pCursor, stuff->cursor, RT_CURSOR, client, DixUseAccess); if (rc != Success) return rc; } ChangeWindowDeviceCursor(pWin, pDev, pCursor); return Success; }
/* * When the screen is reconfigured, move all pointers to the nearest * CRTC */ void RRPointerScreenConfigured(ScreenPtr pScreen) { WindowPtr pRoot; ScreenPtr pCurrentScreen; int x, y; DeviceIntPtr pDev; for (pDev = inputInfo.devices; pDev; pDev = pDev->next) { if (IsPointerDevice(pDev)) { pRoot = GetCurrentRootWindow(pDev); pCurrentScreen = pRoot ? pRoot->drawable.pScreen : NULL; if (pScreen == pCurrentScreen) { GetSpritePosition(pDev, &x, &y); RRPointerToNearestCrtc(pDev, pScreen, x, y, NULL); } } } }
bool LinuxInputDevice::Open(const char *path) { FileDescriptor _fd; if (!_fd.OpenReadOnly(path)) return false; _fd.SetNonBlocking(); fd.assign(_fd.Get()); AsyncRead(); min_x = max_x = min_y = max_y = 0; is_pointer = IsPointerDevice(fd.native_handle()); if (is_pointer) { merge.AddPointer(); if (!IsKobo()) { /* obtain touch screen information */ /* no need to do that on the Kobo, because we know its touch screen is well-calibrated */ input_absinfo abs; if (ioctl(fd.native_handle(), EVIOCGABS(ABS_X), &abs) == 0) { min_x = abs.minimum; max_x = abs.maximum; } if (ioctl(fd.native_handle(), EVIOCGABS(ABS_Y), &abs) == 0) { min_y = abs.minimum; max_y = abs.maximum; } } } rel_x = rel_y = rel_wheel = 0; down = false; moving = pressing = releasing = false; return true; }
Bool xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode) { ScrnInfoPtr pScr = XF86SCRNINFO(pScreen); ScreenPtr pCursorScreen; Bool Switched; int px, py, was_blocked; DeviceIntPtr dev, it; if (!pScr->vtSema || !mode || !pScr->SwitchMode) return FALSE; #ifdef XFreeXDGA if (DGAActive(pScr->scrnIndex)) return FALSE; #endif if (mode == pScr->currentMode) return TRUE; if (mode->HDisplay > pScr->virtualX || mode->VDisplay > pScr->virtualY) return FALSE; /* Let's take an educated guess for which pointer to take here. And about as educated as it gets is to take the first pointer we find. */ for (dev = inputInfo.devices; dev; dev = dev->next) { if (IsPointerDevice(dev) && dev->spriteInfo->spriteOwner) break; } pCursorScreen = miPointerGetScreen(dev); if (pScreen == pCursorScreen) miPointerGetPosition(dev, &px, &py); was_blocked = xf86BlockSIGIO(); Switched = (*pScr->SwitchMode)(pScr->scrnIndex, mode, 0); if (Switched) { pScr->currentMode = mode; /* * Adjust frame for new display size. * Frame is centered around cursor position if cursor is on same screen. */ if (pScreen == pCursorScreen) pScr->frameX0 = px - (mode->HDisplay / 2) + 1; else pScr->frameX0 = (pScr->frameX0 + pScr->frameX1 + 1 - mode->HDisplay) / 2; if (pScr->frameX0 < 0) pScr->frameX0 = 0; pScr->frameX1 = pScr->frameX0 + mode->HDisplay - 1; if (pScr->frameX1 >= pScr->virtualX) { pScr->frameX0 = pScr->virtualX - mode->HDisplay; pScr->frameX1 = pScr->virtualX - 1; } if (pScreen == pCursorScreen) pScr->frameY0 = py - (mode->VDisplay / 2) + 1; else pScr->frameY0 = (pScr->frameY0 + pScr->frameY1 + 1 - mode->VDisplay) / 2; if (pScr->frameY0 < 0) pScr->frameY0 = 0; pScr->frameY1 = pScr->frameY0 + mode->VDisplay - 1; if (pScr->frameY1 >= pScr->virtualY) { pScr->frameY0 = pScr->virtualY - mode->VDisplay; pScr->frameY1 = pScr->virtualY - 1; } } xf86UnblockSIGIO(was_blocked); if (pScr->AdjustFrame) (*pScr->AdjustFrame)(pScr->scrnIndex, pScr->frameX0, pScr->frameY0, 0); /* The original code centered the frame around the cursor if possible. * Since this is hard to achieve with multiple cursors, we do the following: * - center around the first pointer * - move all other pointers to the nearest edge on the screen (or leave * them unmodified if they are within the boundaries). */ if (pScreen == pCursorScreen) { xf86WarpCursor(dev, pScreen, px, py); } for (it = inputInfo.devices; it; it = it->next) { if (it == dev) continue; if (IsPointerDevice(it) && it->spriteInfo->spriteOwner) { pCursorScreen = miPointerGetScreen(it); if (pScreen == pCursorScreen) { miPointerGetPosition(it, &px, &py); if (px < pScr->frameX0) px = pScr->frameX0; else if (px > pScr->frameX1) px = pScr->frameX1; if(py < pScr->frameY0) py = pScr->frameY0; else if(py > pScr->frameY1) py = pScr->frameY1; xf86WarpCursor(it, pScreen, px, py); } } } return Switched; }