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

Unified Diff: content/browser/renderer_host/render_widget_host_view_win.cc

Issue 19805005: Refactored touch-events flag test, correcting "enabled" logic. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 5 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
« no previous file with comments | « chrome/chrome.user32.delay.imports ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/render_widget_host_view_win.cc
diff --git a/content/browser/renderer_host/render_widget_host_view_win.cc b/content/browser/renderer_host/render_widget_host_view_win.cc
index 50a658aa5151db97e5e43a8c99040bf77252d4b5..b31598fb48991e245ff0b7df7fe3d811e0bac8f9 100644
--- a/content/browser/renderer_host/render_widget_host_view_win.cc
+++ b/content/browser/renderer_host/render_widget_host_view_win.cc
@@ -328,6 +328,26 @@ void GetScreenInfoForWindow(gfx::NativeViewId id,
*results = screen_info;
}
+// Tests the tri-state touch-events flag. Note that --touch-events is the
+// same as --touch-events-enabled, but not giving the flag defaults to auto.
+bool IsTouchModeEnabled() {
+ if (base::win::GetVersion() >= base::win::VERSION_WIN7)
+ return false;
+
+ CommandLine* cmdline = CommandLine::ForCurrentProcess();
+ if (cmdline->HasSwitch(switches::kTouchEvents)) {
+ if (cmdline->GetSwitchValueASCII(switches::kTouchEvents) ==
+ switches::kTouchEventsDisabled)
+ return false;
+ else if (cmdline->GetSwitchValueASCII(switches::kTouchEvents) ==
Ben Goodger (Google) 2013/07/24 19:26:13 no else after return
+ switches::kTouchEventsAuto)
+ return ui::IsTouchDevicePresent();
+ else
+ return true;
+ }
+ return ui::IsTouchDevicePresent();
+}
+
} // namespace
const wchar_t kRenderWidgetHostHWNDClass[] = L"Chrome_RenderWidgetHostHWND";
@@ -926,35 +946,11 @@ void RenderWidgetHostViewWin::ProcessAckedTouchEvent(
void RenderWidgetHostViewWin::UpdateDesiredTouchMode() {
// Make sure that touch events even make sense.
- CommandLine* cmdline = CommandLine::ForCurrentProcess();
- static bool touch_mode = base::win::GetVersion() >= base::win::VERSION_WIN7 &&
- ui::IsTouchDevicePresent() && (
- !cmdline->HasSwitch(switches::kTouchEvents) ||
- cmdline->GetSwitchValueASCII(switches::kTouchEvents) !=
- switches::kTouchEventsDisabled);
-
- if (!touch_mode)
- return;
+ static bool touch_mode = IsTouchModeEnabled();
- // Now we know that the window's current state doesn't match the desired
- // state. If we want touch mode, then we attempt to register for touch
- // events, and otherwise to unregister.
- touch_events_enabled_ = RegisterTouchWindow(m_hWnd, TWF_WANTPALM) == TRUE;
-
- if (!touch_events_enabled_) {
- UnregisterTouchWindow(m_hWnd);
- // Single finger panning is consistent with other windows applications.
- const DWORD gesture_allow = GC_PAN_WITH_SINGLE_FINGER_VERTICALLY |
- GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY;
- const DWORD gesture_block = GC_PAN_WITH_GUTTER;
- GESTURECONFIG gc[] = {
- { GID_ZOOM, GC_ZOOM, 0 },
- { GID_PAN, gesture_allow , gesture_block},
- { GID_TWOFINGERTAP, GC_TWOFINGERTAP , 0},
- { GID_PRESSANDTAP, GC_PRESSANDTAP , 0}
- };
- if (!SetGestureConfig(m_hWnd, 0, arraysize(gc), gc, sizeof(GESTURECONFIG)))
- NOTREACHED();
+ if (touch_mode) {
+ touch_events_enabled_ = RegisterTouchWindow(m_hWnd, TWF_WANTPALM) == TRUE;
+ CHECK(touch_events_enabled_);
}
}
« no previous file with comments | « chrome/chrome.user32.delay.imports ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698