From bb86014c6abbf1e859a5efc88537702dd6394836 Mon Sep 17 00:00:00 2001 From: xinbo wang Date: Mon, 8 Nov 2021 16:35:13 +0800 Subject: [PATCH] feat: When the screen is reconfigured, move all pointers to the nearest CRTC's center. when i use xrandr to reconfigrured my screens,the pointer allways be screen's egde.so that i can't find out where my pointer is. And always,screen's edge has some small components, such as 'Showing Desktop'.so, if pointer stop on screen's edge, maybe make 'Showing Desktop' take effect. so,i think make the pointer to the nearest CRTC's center maybe better. --- randr/rrpointer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/randr/rrpointer.c b/randr/rrpointer.c index b301d050d..ba31af4f5 100644 --- a/randr/rrpointer.c +++ b/randr/rrpointer.c @@ -60,6 +60,7 @@ RRPointerToNearestCrtc(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y, RRCrtcPtr nearest = NULL; int best = 0; int best_dx = 0, best_dy = 0; + int best_crtc_width = 0, best_crtc_height = 0; for (c = 0; c < pScrPriv->numCrtcs; c++) { RRCrtcPtr crtc = pScrPriv->crtcs[c]; @@ -93,10 +94,12 @@ RRPointerToNearestCrtc(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y, best_dx = dx; best_dy = dy; best = dist; + best_crtc_width = scan_width; + best_crtc_height = scan_height; } } if (best_dx || best_dy) - (*pScreen->SetCursorPosition) (pDev, pScreen, x + best_dx, y + best_dy, + (*pScreen->SetCursorPosition) (pDev, pScreen, best_crtc_width / 2, best_crtc_height / 2, TRUE); pScrPriv->pointerCrtc = nearest; } -- GitLab