Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Unified Diff: ui/base/win/hwnd_subclass.cc

Issue 12317157: Fix touch scaling for high dpi windows. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Adding extra safety logic to address XP failure. Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« ui/base/win/dpi.cc ('K') | « ui/base/win/dpi.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/win/hwnd_subclass.cc
diff --git a/ui/base/win/hwnd_subclass.cc b/ui/base/win/hwnd_subclass.cc
index 94ab44cf7034af1bf261bfa4be874614f3357baa..c8102a2060dcfbdc1cb1e8f3685203014d473531 100644
--- a/ui/base/win/hwnd_subclass.cc
+++ b/ui/base/win/hwnd_subclass.cc
@@ -9,6 +9,7 @@
#include "base/logging.h"
#include "base/memory/scoped_vector.h"
#include "base/memory/singleton.h"
+#include "ui/base/win/dpi.h"
#include "ui/base/win/hwnd_util.h"
namespace {
@@ -119,6 +120,25 @@ LRESULT HWNDSubclass::OnWndProc(HWND hwnd,
UINT message,
WPARAM w_param,
LPARAM l_param) {
+
+ // Touch messages are always passed in screen coordinates. If the OS is
+ // scaled, but the app is not DPI aware, then then WM_TOUCH might be
+ // intended for a different window.
+ if (message == WM_TOUCH) {
+ TOUCHINPUT point;
+
+ if (GetTouchInputInfo((HTOUCHINPUT)l_param, 1,
+ &point, sizeof(TOUCHINPUT))) {
Ryan Sleevi 2013/03/05 18:32:56 style: indentation BUG: GetTouchInputInfo is only
+ POINT touch_location = {
+ TOUCH_COORD_TO_PIXEL(point.x) / ui::win::GetDPIScaleFromRegistry(),
+ TOUCH_COORD_TO_PIXEL(point.y) / ui::win::GetDPIScaleFromRegistry()};
+ HWND actual_target = WindowFromPoint(touch_location);
+ if (actual_target != hwnd) {
+ return SendMessage(actual_target, message, w_param, l_param);
+ }
+ }
+ }
+
for (std::vector<HWNDMessageFilter*>::iterator it = filters_.begin();
it != filters_.end(); ++it) {
LRESULT l_result = 0;
« ui/base/win/dpi.cc ('K') | « ui/base/win/dpi.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698