On Fri, 2020-06-19 at 10:33 +0200, Sergio Acereda wrote:
> +/**
> + * Fetch titlebar height from handle.
> + *
> + * @param hwnd Handle of the window.
> + * @return titlebar height
> + */
> +static int
> +calc_titlebar_height(HWND hwnd) {
> +    TITLEBARINFOEX tinfo;
> +    tinfo.cbSize = sizeof(tinfo);
> +    SendMessage(hwnd, WM_GETTITLEBARINFOEX, 0, (LPARAM)&tinfo);
> +    return tinfo.rcTitleBar.bottom - tinfo.rcTitleBar.top;
> +}
> +
> /**
>  * Initializes the gdi grab device demuxer (public device demuxer
> API).
>  *
> @@ -284,6 +299,15 @@ gdigrab_read_header(AVFormatContext *s1)
> 
>     if (hwnd) {
>         GetClientRect(hwnd, &virtual_rect);
> +        if (gdigrab->client_only) {
> +            int cxborder = GetSystemMetrics(SM_CXBORDER);
> +            int cyborder = GetSystemMetrics(SM_CYBORDER);
> +            int titlebar_height = calc_titlebar_height(hwnd);
> +            virtual_rect.left   += cxborder;
> +            virtual_rect.right  += -cxborder;
> +            virtual_rect.top    += cxborder + titlebar_height;
> +            virtual_rect.bottom += -cyborder;
> +        }

This seems fine - my only comment is that you need to test this with
high DPI support (display scale values >100%) on both native high-dpi
applications and legacy (scaled by windows) applications to ensure the
correct adjustments are being applied where needed.


-- 
Calvin Walton <calvin.wal...@kepstin.ca>

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to