From patchwork Tue Nov 28 08:59:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Gaechter X-Patchwork-Id: 6420 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.94 with SMTP id m30csp2919665jah; Tue, 28 Nov 2017 00:59:21 -0800 (PST) X-Google-Smtp-Source: AGs4zMaaKC4o5QRcRCKbB28kc2wjUaDvQ/7YyledgLqF4qKP1C5rhbej9mbeVY4ztJKCOyQ2u/XX X-Received: by 10.28.111.218 with SMTP id c87mr18673543wmi.91.1511859561459; Tue, 28 Nov 2017 00:59:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511859561; cv=none; d=google.com; s=arc-20160816; b=f7SA1Ug2umMx/VNcbuBTUiDdbgpmTqAlauSAwsYTwLPBD65rjvcZsOE+eMI1cF1lDk WKhuf4bqIic8xXNFQmCPksBUrkmDWp41bbE4+jtmNyNcpf/DUkFs/polUlcVM0T1ZUaq e7aLlzvdBqjKCmNiB4DWpOYTPkIKObcbXklDQvaCi6LqIc1Ttq8c1uv8Q/K7g2TrSIvf 9I/PcI1lQyYx/4X3+eUNLfBRQThUpNu8Ja37ny+DjM+jb+nnaL35aJ1SAzd/ox5EiG8B M1YZSug19CWS2L+UMrzQbQbSyHckvBU9+Fsct2jquPHIqXWW9pzEYJxIDeziLCkmPSPG e+sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :delivered-to:arc-authentication-results; bh=cy4dMr3/cX6mmSjuZg+oNbX74RckOYVYnd4NVEEcXv0=; b=OkZgg37el+PU6t/26CtyXN565U0+ADMZ0oaDj0ewb2UpaWQk59nMxJyQAbIDvAjM// KyOxvQ7DeJw/33xM+XOprbCHp2JYHliSmAV39qcPb7BqqDlyxNGmECOm0zBwdADyp2oR OL8Rn/o+ppItrSQljCjYX8Vs6DuRFmxd4ZPeNVcDJWFTg2gzfcsIQ4mvZKBF8e3f/9TV 3AFy+svn08XEacwInStrjuu4PLS4sNqlXUUfjDq47endsOjz6/zuMXm7CvOJz0LmS54/ QVaqe6CI6AHe0pjkNiq0nw82ZVSTn58827iQ7Q0byqSoTGNpKK2wQOdVpUn6+ikySa4e ZFVQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 75si9633070wrl.79.2017.11.28.00.59.21; Tue, 28 Nov 2017 00:59:21 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A588568A0DF; Tue, 28 Nov 2017 10:59:17 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from ems.wolfvision.net (ems.wolfvision.net [91.118.163.38]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 84BE86883D4 for ; Tue, 28 Nov 2017 10:59:10 +0200 (EET) From: Harald Gaechter To: Date: Tue, 28 Nov 2017 09:59:02 +0100 Message-ID: <20171128085902.20047-1-harald.gaechter@wolfvision.net> X-Mailer: git-send-email 2.15.0 MIME-Version: 1.0 Received-SPF: none Subject: [FFmpeg-devel] [PATCH] avdevice/gdigrab: Fix screen size and mouse position calculations on hi-DPI screens X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Harald Gaechter Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Harald Gaechter --- libavdevice/gdigrab.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libavdevice/gdigrab.c b/libavdevice/gdigrab.c index 87f5012034..ff2ef3b162 100644 --- a/libavdevice/gdigrab.c +++ b/libavdevice/gdigrab.c @@ -235,7 +235,9 @@ gdigrab_read_header(AVFormatContext *s1) AVStream *st = NULL; int bpp; + int horzres; int vertres; + int desktophorzres; int desktopvertres; RECT virtual_rect; RECT clip_rect; @@ -279,11 +281,13 @@ gdigrab_read_header(AVFormatContext *s1) GetClientRect(hwnd, &virtual_rect); } else { /* desktop -- get the right height and width for scaling DPI */ + horzres = GetDeviceCaps(source_hdc, HORZRES); vertres = GetDeviceCaps(source_hdc, VERTRES); + desktophorzres = GetDeviceCaps(source_hdc, DESKTOPHORZRES); desktopvertres = GetDeviceCaps(source_hdc, DESKTOPVERTRES); virtual_rect.left = GetSystemMetrics(SM_XVIRTUALSCREEN); 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; } @@ -447,7 +451,9 @@ static void paint_mouse_pointer(AVFormatContext *s1, struct gdigrab *gdigrab) POINT pos; RECT clip_rect = gdigrab->clip_rect; HWND hwnd = gdigrab->hwnd; + int horzres = GetDeviceCaps(gdigrab->source_hdc, HORZRES); int vertres = GetDeviceCaps(gdigrab->source_hdc, VERTRES); + int desktophorzres = GetDeviceCaps(gdigrab->source_hdc, DESKTOPHORZRES); int desktopvertres = GetDeviceCaps(gdigrab->source_hdc, DESKTOPVERTRES); info.hbmMask = 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 - pos.x = pos.x * desktopvertres / vertres; + 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",