mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-02-04 06:08:26 +02:00
avdevice/gdigrab: Fix screen size and mouse position calculations on hi-DPI screens
Signed-off-by: Harald Gaechter <harald.gaechter@wolfvision.net> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
8b1b25a86f
commit
43e510d668
@ -235,7 +235,9 @@ gdigrab_read_header(AVFormatContext *s1)
|
|||||||
AVStream *st = NULL;
|
AVStream *st = NULL;
|
||||||
|
|
||||||
int bpp;
|
int bpp;
|
||||||
|
int horzres;
|
||||||
int vertres;
|
int vertres;
|
||||||
|
int desktophorzres;
|
||||||
int desktopvertres;
|
int desktopvertres;
|
||||||
RECT virtual_rect;
|
RECT virtual_rect;
|
||||||
RECT clip_rect;
|
RECT clip_rect;
|
||||||
@ -279,11 +281,13 @@ gdigrab_read_header(AVFormatContext *s1)
|
|||||||
GetClientRect(hwnd, &virtual_rect);
|
GetClientRect(hwnd, &virtual_rect);
|
||||||
} else {
|
} else {
|
||||||
/* desktop -- get the right height and width for scaling DPI */
|
/* desktop -- get the right height and width for scaling DPI */
|
||||||
|
horzres = GetDeviceCaps(source_hdc, HORZRES);
|
||||||
vertres = GetDeviceCaps(source_hdc, VERTRES);
|
vertres = GetDeviceCaps(source_hdc, VERTRES);
|
||||||
|
desktophorzres = GetDeviceCaps(source_hdc, DESKTOPHORZRES);
|
||||||
desktopvertres = GetDeviceCaps(source_hdc, DESKTOPVERTRES);
|
desktopvertres = GetDeviceCaps(source_hdc, DESKTOPVERTRES);
|
||||||
virtual_rect.left = GetSystemMetrics(SM_XVIRTUALSCREEN);
|
virtual_rect.left = GetSystemMetrics(SM_XVIRTUALSCREEN);
|
||||||
virtual_rect.top = GetSystemMetrics(SM_YVIRTUALSCREEN);
|
virtual_rect.top = GetSystemMetrics(SM_YVIRTUALSCREEN);
|
||||||
virtual_rect.right = (virtual_rect.left + GetSystemMetrics(SM_CXVIRTUALSCREEN)) * desktopvertres / vertres;
|
virtual_rect.right = (virtual_rect.left + GetSystemMetrics(SM_CXVIRTUALSCREEN)) * desktophorzres / horzres;
|
||||||
virtual_rect.bottom = (virtual_rect.top + GetSystemMetrics(SM_CYVIRTUALSCREEN)) * desktopvertres / vertres;
|
virtual_rect.bottom = (virtual_rect.top + GetSystemMetrics(SM_CYVIRTUALSCREEN)) * desktopvertres / vertres;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,7 +451,9 @@ static void paint_mouse_pointer(AVFormatContext *s1, struct gdigrab *gdigrab)
|
|||||||
POINT pos;
|
POINT pos;
|
||||||
RECT clip_rect = gdigrab->clip_rect;
|
RECT clip_rect = gdigrab->clip_rect;
|
||||||
HWND hwnd = gdigrab->hwnd;
|
HWND hwnd = gdigrab->hwnd;
|
||||||
|
int horzres = GetDeviceCaps(gdigrab->source_hdc, HORZRES);
|
||||||
int vertres = GetDeviceCaps(gdigrab->source_hdc, VERTRES);
|
int vertres = GetDeviceCaps(gdigrab->source_hdc, VERTRES);
|
||||||
|
int desktophorzres = GetDeviceCaps(gdigrab->source_hdc, DESKTOPHORZRES);
|
||||||
int desktopvertres = GetDeviceCaps(gdigrab->source_hdc, DESKTOPVERTRES);
|
int desktopvertres = GetDeviceCaps(gdigrab->source_hdc, DESKTOPVERTRES);
|
||||||
info.hbmMask = NULL;
|
info.hbmMask = NULL;
|
||||||
info.hbmColor = NULL;
|
info.hbmColor = NULL;
|
||||||
@ -483,7 +489,7 @@ static void paint_mouse_pointer(AVFormatContext *s1, struct gdigrab *gdigrab)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//that would keep the correct location of mouse with hidpi screens
|
//that would keep the correct location of mouse with hidpi screens
|
||||||
pos.x = pos.x * desktopvertres / vertres;
|
pos.x = pos.x * desktophorzres / horzres;
|
||||||
pos.y = pos.y * desktopvertres / vertres;
|
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",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user