Exemple #1
0
void
RRConstrainCursorHarder(DeviceIntPtr pDev, ScreenPtr pScreen, int mode, int *x, int *y)
{
    rrScrPriv (pScreen);
    int i;

    /* intentional dead space -> let it float */
    if (pScrPriv->discontiguous)
       return;

    /* if we're moving inside a crtc, we're fine */
    for (i = 0; i < pScrPriv->numCrtcs; i++) {
       RRCrtcPtr crtc = pScrPriv->crtcs[i];

       int left, right, top, bottom;

       if (!crtc->mode)
           continue;

       crtc_bounds(crtc, &left, &right, &top, &bottom);

       if ((*x >= left) && (*x <= right) && (*y >= top) && (*y <= bottom))
           return;
    }

    /* if we're trying to escape, clamp to the CRTC we're coming from */
    for (i = 0; i < pScrPriv->numCrtcs; i++) {
       RRCrtcPtr crtc = pScrPriv->crtcs[i];
       int nx, ny;
       int left, right, top, bottom;

       if (!crtc->mode)
           continue;

       crtc_bounds(crtc, &left, &right, &top, &bottom);
       miPointerGetPosition(pDev, &nx, &ny);

       if ((nx >= left) && (nx <= right) && (ny >= top) && (ny <= bottom)) {
           if ((*x <= left) || (*x >= right)) {
               int dx = *x - nx;

               if (dx > 0)
                   *x = right;
               else if (dx < 0)
                   *x = left;
           }

           if ((*y <= top) || (*y >= bottom)) {
               int dy = *y - ny;

               if (dy > 0)
                   *y = bottom;
               else if (dy < 0)
                   *y = top;
           }

           return;
       }
    }
}
Exemple #2
0
/*
 * ProcessInputEvents --
 *      Retrieve all waiting input events and pass them to DIX in their
 *      correct chronological order. Only reads from the system pointer
 *      and keyboard.
 */
void
ProcessInputEvents (void)
{
  int x, y;

  mieqProcessInputEvents();

  /* FIXME: This is a problem if we have multiple pointers */
  miPointerGetPosition(inputInfo.pointer, &x, &y);
  xf86SetViewport(xf86Info.currentScreen, x, y);
}
Exemple #3
0
static Bool
xf86RandRSetConfig (ScreenPtr		pScreen,
		    Rotation		rotation,
		    int			rate,
		    RRScreenSizePtr	pSize)
{
    ScrnInfoPtr		    scrp = XF86SCRNINFO(pScreen);
    XF86RandRInfoPtr	    randrp = XF86RANDRINFO(pScreen);
    DisplayModePtr	    mode;
    int			    pos[MAXDEVICES][2];
    Bool		    useVirtual = FALSE;
    Rotation		    oldRotation = randrp->rotation;
    DeviceIntPtr	    dev;
    Bool		    view_adjusted = FALSE;

    for (dev = inputInfo.devices; dev; dev = dev->next)
    {
	if (!IsMaster(dev) && !IsFloating(dev))
		continue;

	miPointerGetPosition(dev, &pos[dev->id][0], &pos[dev->id][1]);
    }

    for (mode = scrp->modes; ; mode = mode->next)
    {
	if (mode->HDisplay == pSize->width &&
	    mode->VDisplay == pSize->height &&
	    (rate == 0 || xf86RandRModeRefresh (mode) == rate))
	    break;
	if (mode->next == scrp->modes)
	{
	    if (pSize->width == randrp->virtualX &&
		pSize->height == randrp->virtualY)
	    {
		mode = scrp->modes;
		useVirtual = TRUE;
		break;
	    }
	    return FALSE;
	}
    }

    if (randrp->rotation != rotation) {

        /* Have the driver do its thing. */
	if (scrp->DriverFunc) {
	    xorgRRRotation RRRotation;
	    RRRotation.RRConfig.rotation = rotation;
	    RRRotation.RRConfig.rate = rate;
	    RRRotation.RRConfig.width = pSize->width;
	    RRRotation.RRConfig.height = pSize->height;

	    /*
	     * Currently we need to rely on HW support for rotation.
	     */
	    if (!(*scrp->DriverFunc)(scrp, RR_SET_CONFIG, &RRRotation))
		return FALSE;
	} else
	    return FALSE;

	randrp->rotation = rotation;
    }

    if (!xf86RandRSetMode (pScreen, mode, useVirtual, pSize->mmWidth, pSize->mmHeight)) {
	if(randrp->rotation != oldRotation) {
	   /* Have the driver undo its thing. */
	   if (scrp->DriverFunc) {
	       xorgRRRotation RRRotation;
	       RRRotation.RRConfig.rotation = oldRotation;
	       RRRotation.RRConfig.rate = xf86RandRModeRefresh (scrp->currentMode);
	       RRRotation.RRConfig.width = scrp->virtualX;
	       RRRotation.RRConfig.height = scrp->virtualY;
	       (*scrp->DriverFunc)(scrp, RR_SET_CONFIG, &RRRotation);
	   }

	   randrp->rotation = oldRotation;
	}
	return FALSE;
    }

    /*
     * Move the cursor back where it belongs; SwitchMode repositions it
     * FIXME: duplicated code, see modes/xf86RandR12.c
     */
    for (dev = inputInfo.devices; dev; dev = dev->next)
    {
	if (!IsMaster(dev) && !IsFloating(dev))
		continue;

	if (pScreen == miPointerGetScreen(dev)) {
	    int px = pos[dev->id][0];
	    int py = pos[dev->id][1];

	    px = (px >= pScreen->width ? (pScreen->width - 1) : px);
	    py = (py >= pScreen->height ? (pScreen->height - 1) : py);

	    /* Setting the viewpoint makes only sense on one device */
	    if (!view_adjusted && IsMaster(dev)) {
		xf86SetViewport(pScreen, px, py);
		view_adjusted = TRUE;
	    }

	    (*pScreen->SetCursorPosition) (dev, pScreen, px, py, FALSE);
	}
    }

    return TRUE;
}
Exemple #4
0
Bool
xf86RandR12SetConfig (ScreenPtr		pScreen,
		    Rotation		rotation,
		    int			rate,
		    RRScreenSizePtr	pSize)
{
    ScrnInfoPtr		scrp = XF86SCRNINFO(pScreen);
    XF86RandRInfoPtr	randrp = XF86RANDRINFO(pScreen);
    DisplayModePtr	mode;
    int			px, py;
    Bool		useVirtual = FALSE;
    int			maxX = 0, maxY = 0;
    Rotation		oldRotation = randrp->rotation;

    randrp->rotation = rotation;

    if (randrp->virtualX == -1 || randrp->virtualY == -1)
    {
	randrp->virtualX = scrp->virtualX;
	randrp->virtualY = scrp->virtualY;
    }

    miPointerGetPosition (inputInfo.pointer, &px, &py);
    for (mode = scrp->modes; ; mode = mode->next)
    {
	if (randrp->maxX == 0 || randrp->maxY == 0)
	{
		if (maxX < mode->HDisplay)
			maxX = mode->HDisplay;
		if (maxY < mode->VDisplay)
			maxY = mode->VDisplay;
	}
	if (mode->HDisplay == pSize->width &&
	    mode->VDisplay == pSize->height &&
	    (rate == 0 || xf86RandR12ModeRefresh (mode) == rate))
	    break;
	if (mode->next == scrp->modes)
	{
	    if (pSize->width == randrp->virtualX &&
		pSize->height == randrp->virtualY)
	    {
		mode = scrp->modes;
		useVirtual = TRUE;
		break;
	    }
    	    if (randrp->maxX == 0 || randrp->maxY == 0)
    	    {
		randrp->maxX = maxX;
		randrp->maxY = maxY;
    	    }
	    return FALSE;
	}
    }

    if (randrp->maxX == 0 || randrp->maxY == 0)
    {
	randrp->maxX = maxX;
	randrp->maxY = maxY;
    }

    if (!xf86RandR12SetMode (pScreen, mode, useVirtual, pSize->mmWidth,
			   pSize->mmHeight)) {
        randrp->rotation = oldRotation;
	return FALSE;
    }

    /*
     * Move the cursor back where it belongs; SwitchMode repositions it
     */
    if (pScreen == miPointerGetScreen(inputInfo.pointer))
    {
        px = (px >= pScreen->width ? (pScreen->width - 1) : px);
        py = (py >= pScreen->height ? (pScreen->height - 1) : py);

	xf86SetViewport(pScreen, px, py);

	(*pScreen->SetCursorPosition) (inputInfo.pointer, pScreen, px, py, FALSE);
    }

    return TRUE;
}
Exemple #5
0
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;
}