[PATCH v6 xserver 6/7] xf86Cursor: Deal with rotation on GPU screens using a hw-cursor

Hans de Goede hdegoede at redhat.com
Wed Sep 7 12:26:30 UTC 2016


When a slave-output is rotated the transformation is done on the blit
from master to slave GPU, so crtc->transform_in_use is not set, but we
still need to adjust the mouse position for things to work.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 hw/xfree86/modes/xf86Cursors.c | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c
index bf98d7e..7d6829d 100644
--- a/hw/xfree86/modes/xf86Cursors.c
+++ b/hw/xfree86/modes/xf86Cursors.c
@@ -394,6 +394,34 @@ xf86_crtc_transform_cursor_position(xf86CrtcPtr crtc, int *x, int *y)
     /* 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_transform_gpu_cursor_position(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);
+    int dx, dy;
+
+    *x = *x - crtc->x + ScreenPriv->HotX;
+    *y = *y - crtc->y + ScreenPriv->HotY;
+
+    xf86_crtc_rotate_coord_back(crtc->rotation, crtc->mode.HDisplay,
+                                crtc->mode.VDisplay, *x, *y, x, y);
     /*
      * Transform position of cursor upper left corner
      */
@@ -408,6 +436,7 @@ static void
 xf86_crtc_set_cursor_position(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;
     DisplayModePtr mode = &crtc->mode;
@@ -416,7 +445,9 @@ xf86_crtc_set_cursor_position(xf86CrtcPtr crtc, int x, int y)
     /*
      * Transform position of cursor on screen
      */
-    if (crtc->transform_in_use)
+    if (screen->isGPU)
+        xf86_crtc_transform_gpu_cursor_position(crtc, &crtc_x, &crtc_y);
+    else if (crtc->transform_in_use)
         xf86_crtc_transform_cursor_position(crtc, &crtc_x, &crtc_y);
     else {
         crtc_x -= crtc->x;
-- 
2.9.3



More information about the xorg-devel mailing list