From f84b9040f7486a445a067736d4e4ddc4c6a8a269 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Tue, 11 Jul 2017 17:19:25 +0000 Subject: WIN32 platform: Fix drag-n-drop to FLTK widget when the desktop is scaled and FLTK_HIDPI_SUPPORT is not defined. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12308 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/fl_dnd_win32.cxx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/fl_dnd_win32.cxx b/src/fl_dnd_win32.cxx index 0d7f1c1b1..51f656da8 100644 --- a/src/fl_dnd_win32.cxx +++ b/src/fl_dnd_win32.cxx @@ -3,7 +3,7 @@ // // Drag & Drop code for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2010 by Bill Spitzak and others. +// Copyright 1998-2017 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -84,6 +84,20 @@ public: if( !pDataObj ) return E_INVALIDARG; // set e_modifiers here from grfKeyState, set e_x and e_root_x // check if FLTK handles this drag and return if it can't (i.e. BMP drag without filename) +/* Tricky point here: Not DPI–aware applications use different units for the 'POINTL pt' argument +of the DragEnter, DragOver, and Drop member functions. +DragEnter receives the mouse coordinates in unscaled screen units, +whereas DragOver and Drop receive the mouse coordinates in scaled units. +In the first case, dividing coordinates by DWM_scaling_factor() gives the scaled units used everywhere else. + +DPI–aware applications transmit unscaled screen units to all 3 member functions. +These coordinates should be divided by the window's scale to get FLTK units. +*/ +#ifndef FLTK_HIDPI_SUPPORT + float dwm_s = ((Fl_WinAPI_Screen_Driver*)Fl::screen_driver())->DWM_scaling_factor(); + pt.x /= dwm_s; + pt.y /= dwm_s; +#endif POINT ppt; Fl::e_x_root = ppt.x = pt.x; Fl::e_y_root = ppt.y = pt.y; -- cgit v1.2.3