Exemplo n.º 1
0
static void
compute_extents (pixman_f_transform_t *trans, double *sx, double *sy)
{
    double min_x, max_x, min_y, max_y;
    pixman_f_vector_t v[4] =
    {
	{ { 1, 1, 1 } },
	{ { -1, 1, 1 } },
	{ { -1, -1, 1 } },
	{ { 1, -1, 1 } },
    };

    pixman_f_transform_point (trans, &v[0]);
    pixman_f_transform_point (trans, &v[1]);
    pixman_f_transform_point (trans, &v[2]);
    pixman_f_transform_point (trans, &v[3]);

    min_x = min4 (v[0].v[0], v[1].v[0], v[2].v[0], v[3].v[0]);
    max_x = max4 (v[0].v[0], v[1].v[0], v[2].v[0], v[3].v[0]);
    min_y = min4 (v[0].v[1], v[1].v[1], v[2].v[1], v[3].v[1]);
    max_y = max4 (v[0].v[1], v[1].v[1], v[2].v[1], v[3].v[1]);

    *sx = (max_x - min_x) / 2.0;
    *sy = (max_y - min_y) / 2.0;
}
Exemplo n.º 2
0
void
xf86CrtcTransformCursorPos(xf86CrtcPtr crtc, int *x, int *y)
{
    ScrnInfoPtr scrn = crtc->scrn;
    ScreenPtr screen = scrn->pScreen;
    xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
    xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
    xf86CursorScreenPtr ScreenPriv =
        (xf86CursorScreenPtr) dixLookupPrivate(&screen->devPrivates,
                                               xf86CursorScreenKey);
    struct pict_f_vector v;
    int dx, dy;

    v.v[0] = (*x + ScreenPriv->HotX) + 0.5;
    v.v[1] = (*y + ScreenPriv->HotY) + 0.5;
    v.v[2] = 1;
    pixman_f_transform_point(&crtc->f_framebuffer_to_crtc, &v);
    /* cursor will have 0.5 added to it already so floor is sufficent */
    *x = floor(v.v[0]);
    *y = floor(v.v[1]);
    /*
     * Transform position of cursor upper left corner
     */
    xf86_crtc_rotate_coord_back(crtc->rotation, cursor_info->MaxWidth,
                                cursor_info->MaxHeight, ScreenPriv->HotX,
                                ScreenPriv->HotY, &dx, &dy);
    *x -= dx;
    *y -= dy;
}
static void
xf86_crtc_set_cursor_position (xf86CrtcPtr crtc, int x, int y)
{
    ScrnInfoPtr		scrn = crtc->scrn;
    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
    xf86CursorInfoPtr	cursor_info = xf86_config->cursor_info;
    DisplayModePtr	mode = &crtc->mode;
    Bool		in_range;
    int			dx, dy;

    /*
     * Transform position of cursor on screen
     */
    if (crtc->transform_in_use)
    {
	ScreenPtr	screen = scrn->pScreen;
	xf86CursorScreenPtr ScreenPriv =
	    (xf86CursorScreenPtr)dixLookupPrivate(&screen->devPrivates,
						  xf86CursorScreenKey);
	struct pict_f_vector   v;

	v.v[0] = (x + ScreenPriv->HotX) + 0.5;
	v.v[1] = (y + ScreenPriv->HotY) + 0.5;
	v.v[2] = 1;
	pixman_f_transform_point (&crtc->f_framebuffer_to_crtc, &v);
	/* cursor will have 0.5 added to it already so floor is sufficent */
	x = floor (v.v[0]);
	y = floor (v.v[1]);
	/*
	 * Transform position of cursor upper left corner
	 */
	xf86_crtc_rotate_coord_back (crtc->rotation,
				     cursor_info->MaxWidth,
				     cursor_info->MaxHeight,
				     ScreenPriv->HotX, ScreenPriv->HotY, &dx, &dy);
	x -= dx;
	y -= dy;
   }
    else
    {
	x -= crtc->x;
	y -= crtc->y;
    }

    /*
     * Disable the cursor when it is outside the viewport
     */
    in_range = TRUE;
    if (x >= mode->HDisplay || y >= mode->VDisplay ||
	x <= -cursor_info->MaxWidth || y <= -cursor_info->MaxHeight) 
    {
	in_range = FALSE;
	x = 0;
	y = 0;
    }

    crtc->cursor_in_range = in_range;
    
    if (in_range)
    {
	crtc->funcs->set_cursor_position (crtc, x, y);
	xf86_crtc_show_cursor (crtc);
    }
    else
	xf86_crtc_hide_cursor (crtc);
}
Exemplo n.º 4
0
static void
xf86RandR13Pan (xf86CrtcPtr crtc, int x, int y)
{
    int newX, newY;
    int width, height;
    Bool panned = FALSE;

    if (crtc->version < 2)
	return;

    if (! crtc->enabled						||
	(crtc->panningTotalArea.x2 <= crtc->panningTotalArea.x1	&&
	 crtc->panningTotalArea.y2 <= crtc->panningTotalArea.y1))
	return;

    newX   = crtc->x;
    newY   = crtc->y;
    width  = crtc->mode.HDisplay;
    height = crtc->mode.VDisplay;

    if ((crtc->panningTrackingArea.x2 <= crtc->panningTrackingArea.x1 ||
	 (x >= crtc->panningTrackingArea.x1 && x < crtc->panningTrackingArea.x2)) &&
	(crtc->panningTrackingArea.y2 <= crtc->panningTrackingArea.y1 ||
	 (y >= crtc->panningTrackingArea.y1 && y < crtc->panningTrackingArea.y2)))
    {
	struct pict_f_vector    c;

	/*
	 * Pre-clip the mouse position to the panning area so that we don't
	 * push the crtc outside. This doesn't deal with changes to the
	 * panning values, only mouse position changes.
	 */
	if (crtc->panningTotalArea.x2 > crtc->panningTotalArea.x1)
	{
	    if (x < crtc->panningTotalArea.x1)
		x = crtc->panningTotalArea.x1;
	    if (x >= crtc->panningTotalArea.x2)
		x = crtc->panningTotalArea.x2 - 1;
	}
	if (crtc->panningTotalArea.y2 > crtc->panningTotalArea.y1)
	{
	    if (y < crtc->panningTotalArea.y1)
		y = crtc->panningTotalArea.y1;
	    if (y >= crtc->panningTotalArea.y2)
		y = crtc->panningTotalArea.y2 - 1;
	}

	c.v[0] = x;
	c.v[1] = y;
	c.v[2] = 1.0;
	if (crtc->transform_in_use) {
	    pixman_f_transform_point(&crtc->f_framebuffer_to_crtc, &c);
	} else {
	    c.v[0] -= crtc->x;
	    c.v[1] -= crtc->y;
	}

	if (crtc->panningTotalArea.x2 > crtc->panningTotalArea.x1) {
	    if (c.v[0] < crtc->panningBorder[0]) {
		c.v[0] = crtc->panningBorder[0];
		panned = TRUE;
	    }
	    if (c.v[0] >= width - crtc->panningBorder[2]) {
		c.v[0] = width - crtc->panningBorder[2] - 1;
		panned = TRUE;
	    }
	}
	if (crtc->panningTotalArea.y2 > crtc->panningTotalArea.y1) {
	    if (c.v[1] < crtc->panningBorder[1]) {
		c.v[1] = crtc->panningBorder[1];
		panned = TRUE;
	    }
	    if (c.v[1] >= height - crtc->panningBorder[3]) {
		c.v[1] = height - crtc->panningBorder[3] - 1;
		panned = TRUE;
	    }
	}
	if (panned)
	    xf86ComputeCrtcPan (crtc->transform_in_use,
				&crtc->f_framebuffer_to_crtc,
				x, y, c.v[0], c.v[1],
				newX, newY, &newX, &newY);
    }

    /*
     * Ensure that the crtc is within the panning region.
     *
     * XXX This computation only works when we do not have a transform
     * in use.
     */
    if (!crtc->transform_in_use)
    {
	/* Validate against [xy]1 after [xy]2, to be sure that results are > 0 for [xy]1 > 0 */
	if (crtc->panningTotalArea.x2 > crtc->panningTotalArea.x1) {
	    if (newX > crtc->panningTotalArea.x2 - width)
		newX =  crtc->panningTotalArea.x2 - width;
	    if (newX <  crtc->panningTotalArea.x1)
		newX =  crtc->panningTotalArea.x1;
	}
	if (crtc->panningTotalArea.y2 > crtc->panningTotalArea.y1) {
	    if (newY > crtc->panningTotalArea.y2 - height)
		newY =  crtc->panningTotalArea.y2 - height;
	    if (newY <  crtc->panningTotalArea.y1)
		newY =  crtc->panningTotalArea.y1;
	}
    }
    if (newX != crtc->x || newY != crtc->y)
	xf86CrtcSetOrigin (crtc, newX, newY);
}