summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichel Dänzer <michel.daenzer@amd.com>2018-12-21 18:00:09 +0100
committerMichel Dänzer <michel@daenzer.net>2018-12-28 12:09:25 +0100
commit91e557f78ad261e76a1829f54722c2c0781742d2 (patch)
tree9a01dc8976ae3e96ed87d3824e81fdb92f89780d
parent92df709786830d4e30a106dd49d8e0355c50c8f0 (diff)
Update cursor position in drmmode_show_cursor if hotspot changed
The cursor position is updated to be consistent with the new hotspot in the same ioctl call. (Ported from amdgpu commit b04697de5270e8e45744a7025c24df1f454a4cf0)
-rw-r--r--src/drmmode_display.c75
-rw-r--r--src/drmmode_display.h5
2 files changed, 48 insertions, 32 deletions
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index c2a59da7..bec309e5 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1017,6 +1017,9 @@ drmmode_set_cursor_position (xf86CrtcPtr crtc, int x, int y)
}
#endif
+ drmmode_crtc->cursor_x = x;
+ drmmode_crtc->cursor_y = y;
+
drmModeMoveCursor(pRADEONEnt->fd, drmmode_crtc->mode_crtc->crtc_id, x, y);
}
@@ -1202,6 +1205,10 @@ drmmode_show_cursor (xf86CrtcPtr crtc)
RADEONInfoPtr info = RADEONPTR(pScrn);
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+ CursorPtr cursor = xf86_config->cursor;
+ int xhot = cursor->bits->xhot;
+ int yhot = cursor->bits->yhot;
static Bool use_set_cursor2 = TRUE;
struct drm_mode_cursor2 arg;
@@ -1213,41 +1220,45 @@ drmmode_show_cursor (xf86CrtcPtr crtc)
arg.width = info->cursor_w;
arg.height = info->cursor_h;
+ if (crtc->rotation != RR_Rotate_0 &&
+ crtc->rotation != (RR_Rotate_180 | RR_Reflect_X |
+ RR_Reflect_Y)) {
+ int t;
+
+ /* Reflect & rotate hotspot position */
+ if (crtc->rotation & RR_Reflect_X)
+ xhot = info->cursor_w - xhot - 1;
+ if (crtc->rotation & RR_Reflect_Y)
+ yhot = info->cursor_h - yhot - 1;
+
+ switch (crtc->rotation & 0xf) {
+ case RR_Rotate_90:
+ t = xhot;
+ xhot = yhot;
+ yhot = info->cursor_w - t - 1;
+ break;
+ case RR_Rotate_180:
+ xhot = info->cursor_w - xhot - 1;
+ yhot = info->cursor_h - yhot - 1;
+ break;
+ case RR_Rotate_270:
+ t = xhot;
+ xhot = info->cursor_h - yhot - 1;
+ yhot = t;
+ }
+ }
+
+ if (xhot != drmmode_crtc->cursor_xhot || yhot != drmmode_crtc->cursor_yhot) {
+ arg.flags |= DRM_MODE_CURSOR_MOVE;
+ arg.x = drmmode_crtc->cursor_x += drmmode_crtc->cursor_xhot - xhot;
+ arg.y = drmmode_crtc->cursor_y += drmmode_crtc->cursor_yhot - yhot;
+ drmmode_crtc->cursor_xhot = xhot;
+ drmmode_crtc->cursor_yhot = yhot;
+ }
+
if (use_set_cursor2) {
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
- CursorPtr cursor = xf86_config->cursor;
- int xhot = cursor->bits->xhot;
- int yhot = cursor->bits->yhot;
int ret;
- if (crtc->rotation != RR_Rotate_0 &&
- crtc->rotation != (RR_Rotate_180 | RR_Reflect_X |
- RR_Reflect_Y)) {
- int t;
-
- /* Reflect & rotate hotspot position */
- if (crtc->rotation & RR_Reflect_X)
- xhot = info->cursor_w - xhot - 1;
- if (crtc->rotation & RR_Reflect_Y)
- yhot = info->cursor_h - yhot - 1;
-
- switch (crtc->rotation & 0xf) {
- case RR_Rotate_90:
- t = xhot;
- xhot = yhot;
- yhot = info->cursor_w - t - 1;
- break;
- case RR_Rotate_180:
- xhot = info->cursor_w - xhot - 1;
- yhot = info->cursor_h - yhot - 1;
- break;
- case RR_Rotate_270:
- t = xhot;
- xhot = info->cursor_h - yhot - 1;
- yhot = t;
- }
- }
-
arg.hot_x = xhot;
arg.hot_y = yhot;
diff --git a/src/drmmode_display.h b/src/drmmode_display.h
index d7ab9d7e..49893ab0 100644
--- a/src/drmmode_display.h
+++ b/src/drmmode_display.h
@@ -87,6 +87,11 @@ typedef struct {
drmmode_ptr drmmode;
drmModeCrtcPtr mode_crtc;
int hw_id;
+
+ int cursor_x;
+ int cursor_y;
+ int cursor_xhot;
+ int cursor_yhot;
struct radeon_bo *cursor_bo;
struct drmmode_scanout rotate;
struct drmmode_scanout scanout[2];