From patchwork Fri Jul 5 19:48:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dilshod Mukhtarov X-Patchwork-Id: 13824 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 8C7B4449F9C for ; Fri, 5 Jul 2019 22:48:36 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6EF6768AD1A; Fri, 5 Jul 2019 22:48:36 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5CF4F68AD08 for ; Fri, 5 Jul 2019 22:48:30 +0300 (EEST) Received: by mail-lf1-f52.google.com with SMTP id 62so7002178lfa.8 for ; Fri, 05 Jul 2019 12:48:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=k6/d/Zi8X21KXdUrME64upKOrjkY/O1kQdQBKxMIh7A=; b=ej4fgq2/SqSuVOb/iJFRTX3y2yOnzPJDjA83o7sGLDlmcoKtJlTxJedCYPtSMfaUD2 fYxGh3TL248nT8JaO3W7SlJ9qNqB+fQW4llcpIMTRo2LBG/WSEpcyJ5M8qaCh3ZtEY17 9Xq5nCJmcIthgJoZQsws7HjU/cWmHPtmg0ZL7uK4ZATMmHhNGaO1W5uuvP8v4ERvnuVz I2n7d3hemBEsFXpMU1vAiJjXSf68hAagHV2dGK7t3m23Zr4bh5H1WTnYR2xeA4D+q5tw 5fm485vPJTJp0BQv3vn7RwppzJU9uFGvrqjBAaxmujL1Gy/3iNUv9xvKPBqMHLtkfXOK bmUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language; bh=k6/d/Zi8X21KXdUrME64upKOrjkY/O1kQdQBKxMIh7A=; b=IccQu2yysKEmsYUBIcAngyxfp7taMa+2jRNKSgfCViH9XWgmWs7o6JieXnm5+YO5Ac aX15qNbj9Jk0vC+iUU+Suznwiypk9kz1bMaJSEYP7DB/OZ/oqVnPcE7rLsSyq4GzGoQE kl2OHwAn5j8klO94sh+/QUceG5gxfQrU7i3Z3mIGSDFlbmfumuHyQck0d5/XAdrki+x8 M35lcSUc+U9ICLGKpZSuQoJ4GS1dd/TDUKNaoq3PzwZQY1vyvoA6dLI+aqTmwHF9FMID 2Qetw5RrhpQl56U+XRxW5Ux1CkyqNul+qVudt8pSS+poHq9ZNOHk5j4i+X9P9YZFjExd GCvA== X-Gm-Message-State: APjAAAVu0iBLATA8RKf6MR8BHvEHFy86OnLx9bNA2c1MNJkyrYa0xcPf xIKDnQxECRJJznV26k8t507jrOa9wrM= X-Google-Smtp-Source: APXvYqwoLTdNvqFUieA0cJBgIKfvwPpf1+CCzaAZMNL8i5O8fVBqSia8AM/+dCXSEelZm4gzmIu7vg== X-Received: by 2002:a05:6512:c1:: with SMTP id c1mr2960932lfp.35.1562356109380; Fri, 05 Jul 2019 12:48:29 -0700 (PDT) Received: from [192.168.101.101] ([5.30.115.13]) by smtp.googlemail.com with ESMTPSA id e13sm1955899ljg.102.2019.07.05.12.48.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jul 2019 12:48:28 -0700 (PDT) To: ffmpeg-devel@ffmpeg.org From: Dilshod Mukhtarov Message-ID: <7eecfd0d-406e-f3ad-1dd1-d5090aa98e05@gmail.com> Date: Fri, 5 Jul 2019 23:48:26 +0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 Content-Language: en-US X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: [FFmpeg-devel] gdigrab: fix mouse position for multi-monitor setup with different scale settings 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Hi, This is the patch that fixes the drawing of cursor in incorrect position on Windows with multi-monitor setup with different scales on different monitors From 17f2a9b956d440bfedc38f8a6de50886de04b1dd Mon Sep 17 00:00:00 2001 From: Dilshod Muktharov Date: Thu, 4 Jul 2019 23:33:27 +0400 Subject: [PATCH 2/2] Cursor recording HighDPI support for Windows multi-monitor mode --- libavdevice/gdigrab.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libavdevice/gdigrab.c b/libavdevice/gdigrab.c index 276b448692..eeae9ba5a7 100644 --- a/libavdevice/gdigrab.c +++ b/libavdevice/gdigrab.c @@ -644,6 +644,10 @@ static void paint_mouse_pointer(AVFormatContext *s1, struct gdigrab *gdigrab) info.hbmMask = NULL; info.hbmColor = NULL; + int log_x = ci.ptScreenPos.x; + int log_y = ci.ptScreenPos.y; + int ind = get_monitor_id_by_logical_point(log_x, log_y); + if (ci.flags != CURSOR_SHOWING) return; @@ -663,21 +667,17 @@ static void paint_mouse_pointer(AVFormatContext *s1, struct gdigrab *gdigrab) RECT rect; if (GetWindowRect(hwnd, &rect)) { - pos.x = ci.ptScreenPos.x - clip_rect.left - info.xHotspot - rect.left; - 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; + /* make cursor's logical coordinates relative to window */ + log_x -= rect.left; + log_y -= rect.top; } else { CURSOR_ERROR("Couldn't get window rectangle"); 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 = LOGICAL_TO_PHYSICAL_X(log_x, ind) - clip_rect.left - info.xHotspot; + pos.y = LOGICAL_TO_PHYSICAL_Y(log_y, ind) - clip_rect.top - info.yHotspot; av_log(s1, AV_LOG_DEBUG, "Cursor pos (%li,%li) -> (%li,%li)\n", ci.ptScreenPos.x, ci.ptScreenPos.y, pos.x, pos.y); -- 2.21.0.windows.1