From c1c5425bbaf9d5f6ccdcdfede5c5f5aa2629a79e Mon Sep 17 00:00:00 2001
From: Metaksakis Georgios <metaxas4@gmail.com>
Date: Fri, 12 Feb 2016 10:15:48 +0200
Subject: [PATCH] mouse dpi awareness

correct mouse location on hidpi screens.
fixes ticket #5008
---
 libavdevice/gdigrab.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libavdevice/gdigrab.c b/libavdevice/gdigrab.c
index 4428a34..cc7e39a 100644
--- a/libavdevice/gdigrab.c
+++ b/libavdevice/gdigrab.c
@@ -431,6 +431,8 @@ error:
 static void paint_mouse_pointer(AVFormatContext *s1, struct gdigrab *gdigrab)
 {
     CURSORINFO ci = {0};
+    int vertres = GetDeviceCaps(gdigrab->source_hdc, VERTRES);
+    int desktopvertres = GetDeviceCaps(gdigrab->source_hdc, DESKTOPVERTRES);
 
 #define CURSOR_ERROR(str)                 \
     if (!gdigrab->cursor_error_printed) {       \
@@ -479,6 +481,10 @@ 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.y = pos.y * desktopvertres / vertres;
+
         av_log(s1, AV_LOG_DEBUG, "Cursor pos (%li,%li) -> (%li,%li)\n",
                 ci.ptScreenPos.x, ci.ptScreenPos.y, pos.x, pos.y);
 
-- 
2.6.2.windows.1

