libavdevice/gdigrab: fix HIDPI support for mouse positioning

Mouse position was not calculated properly in area or window mode

Signed-off-by: Dilshod Mukhtarov <dilshodm@gmail.com>
This commit is contained in:
Dilshod Mukhtarov 2019-01-27 23:10:37 +04:00 committed by Carl Eugen Hoyos
parent d7c9ddd0c4
commit 1100862a94
1 changed files with 10 additions and 9 deletions

View File

@ -479,25 +479,26 @@ static void paint_mouse_pointer(AVFormatContext *s1, struct gdigrab *gdigrab)
goto icon_error; goto icon_error;
} }
pos.x = ci.ptScreenPos.x - clip_rect.left - info.xHotspot;
pos.y = ci.ptScreenPos.y - clip_rect.top - info.yHotspot;
if (hwnd) { if (hwnd) {
RECT rect; RECT rect;
if (GetWindowRect(hwnd, &rect)) { if (GetWindowRect(hwnd, &rect)) {
pos.x -= rect.left; pos.x = ci.ptScreenPos.x - clip_rect.left - info.xHotspot - rect.left;
pos.y -= rect.top; pos.y = ci.ptScreenPos.y - clip_rect.top - info.yHotspot - rect.top;
//that would keep the correct location of mouse with hidpi screens
pos.x = pos.x * desktophorzres / horzres;
pos.y = pos.y * desktopvertres / vertres;
} else { } else {
CURSOR_ERROR("Couldn't get window rectangle"); CURSOR_ERROR("Couldn't get window rectangle");
goto icon_error; goto icon_error;
} }
} else {
//that would keep the correct location of mouse with hidpi screens
pos.x = ci.ptScreenPos.x * desktophorzres / horzres - clip_rect.left - info.xHotspot;
pos.y = ci.ptScreenPos.y * desktopvertres / vertres - clip_rect.top - info.yHotspot;
} }
//that would keep the correct location of mouse with hidpi screens
pos.x = pos.x * desktophorzres / horzres;
pos.y = pos.y * desktopvertres / vertres;
av_log(s1, AV_LOG_DEBUG, "Cursor pos (%li,%li) -> (%li,%li)\n", av_log(s1, AV_LOG_DEBUG, "Cursor pos (%li,%li) -> (%li,%li)\n",
ci.ptScreenPos.x, ci.ptScreenPos.y, pos.x, pos.y); ci.ptScreenPos.x, ci.ptScreenPos.y, pos.x, pos.y);