summaryrefslogtreecommitdiffstats
path: root/ui/base
diff options
context:
space:
mode:
authorflackr@chromium.org <flackr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-05 17:53:22 +0000
committerflackr@chromium.org <flackr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-05 17:53:22 +0000
commit29b547e18837a820b3331745720c638086cb15bf (patch)
treeda4fe2e2fdf398fa14ae1c4321029a5481f45ce8 /ui/base
parentbef08a9147a9f0db64cc73912e7dc545a642407a (diff)
downloadchromium_src-29b547e18837a820b3331745720c638086cb15bf.zip
chromium_src-29b547e18837a820b3331745720c638086cb15bf.tar.gz
chromium_src-29b547e18837a820b3331745720c638086cb15bf.tar.bz2
Revert 186187 - crashing on Win XP browser_tests with "Access is denied".
> Fix touch scaling for high dpi windows. > > Touch events in windows are always expressed in screen coordinates, even if > the target app is not dpi-aware. This patch determines the dpi scale used > by the OS, and re-scales touch events accordingly. > > In some cases the touch events are sent to the wrong window. This is detected > and corrected. > > BUG=175542 > > > Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=185474 > > Review URL: https://chromiumcodereview.appspot.com/12317157 TBR=girard@chromium.org Review URL: https://codereview.chromium.org/12454004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186196 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base')
-rw-r--r--ui/base/win/dpi.cc48
-rw-r--r--ui/base/win/dpi.h2
-rw-r--r--ui/base/win/hwnd_subclass.cc20
3 files changed, 1 insertions, 69 deletions
diff --git a/ui/base/win/dpi.cc b/ui/base/win/dpi.cc
index cc71331..b618df9 100644
--- a/ui/base/win/dpi.cc
+++ b/ui/base/win/dpi.cc
@@ -8,7 +8,6 @@
#include "base/win/scoped_hdc.h"
#include "ui/base/layout.h"
-#include "base/win/registry.h"
#include "ui/gfx/display.h"
#include "ui/gfx/point_conversions.h"
#include "ui/gfx/rect_conversions.h"
@@ -31,24 +30,6 @@ float GetDeviceScaleFactorImpl() {
#endif
}
-FARPROC GetProcAddressWrapper(LPCSTR module_name, LPCSTR proc_name) {
- HMODULE module = ::GetModuleHandleA(module_name);
- if (module) {
- return ::GetProcAddress(module, proc_name);
- }
- return NULL;
-}
-
-BOOL IsProcessDPIAwareWrapper() {
- typedef BOOL(WINAPI *IsProcessDPIAwarePtr)(VOID);
- IsProcessDPIAwarePtr is_process_dpi_aware_func =
- reinterpret_cast<IsProcessDPIAwarePtr>(
- GetProcAddressWrapper("user32.dll", "IsProcessDPIAware"));
- if (is_process_dpi_aware_func)
- return is_process_dpi_aware_func();
- return FALSE;
-}
-
} // namespace
namespace ui {
@@ -84,7 +65,7 @@ void EnableHighDPISupport() {
typedef BOOL(WINAPI *SetProcessDPIAwarePtr)(VOID);
SetProcessDPIAwarePtr set_process_dpi_aware_func =
reinterpret_cast<SetProcessDPIAwarePtr>(
- GetProcAddressWrapper("user32.dll", "SetProcessDPIAware"));
+ GetProcAddress(GetModuleHandleA("user32.dll"), "SetProcessDPIAware"));
if (set_process_dpi_aware_func)
set_process_dpi_aware_func();
}
@@ -122,33 +103,6 @@ gfx::Size DIPToScreenSize(const gfx::Size& dip_size) {
return gfx::ToFlooredSize(gfx::ScaleSize(dip_size, GetDeviceScaleFactor()));
}
-double GetDPIScaleFromRegistry() {
- static double scale = -1.0;
- if (scale == -1.0) {
- double result = 1.0;
- if (!IsProcessDPIAwareWrapper()) {
- //HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics\AppliedDPI
- base::win::RegKey key(HKEY_CURRENT_USER,
- L"Control Panel\\Desktop\\WindowMetrics",
- KEY_QUERY_VALUE);
-
- if (key.Valid()) {
- DWORD value = 0;
- if (key.ReadValueDW(L"AppliedDPI", &value) == ERROR_SUCCESS) {
- result = ((double)value) / kDefaultDPIX;
- }
- }
- }
- scale = result;
- }
-
- // Safety test to ignore invalid settings.
- if (scale <= 0.0)
- scale = 1.0;
-
- return scale;
-}
-
} // namespace win
} // namespace ui
diff --git a/ui/base/win/dpi.h b/ui/base/win/dpi.h
index a33e0ab..99252c7 100644
--- a/ui/base/win/dpi.h
+++ b/ui/base/win/dpi.h
@@ -38,8 +38,6 @@ UI_EXPORT gfx::Size ScreenToDIPSize(const gfx::Size& size_in_pixels);
UI_EXPORT gfx::Size DIPToScreenSize(const gfx::Size& dip_size);
-UI_EXPORT double GetDPIScaleFromRegistry();
-
} // namespace win
} // namespace ui
diff --git a/ui/base/win/hwnd_subclass.cc b/ui/base/win/hwnd_subclass.cc
index c8102a2..94ab44c 100644
--- a/ui/base/win/hwnd_subclass.cc
+++ b/ui/base/win/hwnd_subclass.cc
@@ -9,7 +9,6 @@
#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 {
@@ -120,25 +119,6 @@ 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))) {
- 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;