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

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

Issue 11028144: touch: Cleanup touch-event mode switching on windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge Created 8 years, 2 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
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 f9fa7e94828e853ec90b7a313736e819148de637..8606cac29a7e1c8c6707125f69b3ace157475a54 100644
--- a/content/browser/renderer_host/render_widget_host_view_win.cc
+++ b/content/browser/renderer_host/render_widget_host_view_win.cc
@@ -951,8 +951,7 @@ void RenderWidgetHostViewWin::SetBackground(const SkBitmap& background) {
render_widget_host_->SetBackground(background);
}
-void RenderWidgetHostViewWin::ProcessTouchAck(
- WebKit::WebInputEvent::Type type, bool processed) {
+void RenderWidgetHostViewWin::ProcessTouchAck(bool processed) {
DCHECK(render_widget_host_->has_touch_handler() &&
touch_events_enabled_);
@@ -963,59 +962,35 @@ void RenderWidgetHostViewWin::ProcessTouchAck(
gestures.reset(gesture_recognizer_->AdvanceTouchQueue(this, processed));
ProcessGestures(gestures.get());
}
-
- if (type == WebKit::WebInputEvent::TouchStart)
- UpdateDesiredTouchMode(processed);
-}
-
-void RenderWidgetHostViewWin::SetToGestureMode() {
- if (base::win::GetVersion() < base::win::VERSION_WIN7)
- return;
- 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();
- }
- touch_events_enabled_ = false;
-}
-
-bool RenderWidgetHostViewWin::SetToTouchMode() {
- if (base::win::GetVersion() < base::win::VERSION_WIN7)
- return false;
- bool touch_mode = RegisterTouchWindow(m_hWnd, TWF_WANTPALM) == TRUE;
- touch_events_enabled_ = touch_mode;
- return touch_mode;
}
-void RenderWidgetHostViewWin::UpdateDesiredTouchMode(bool touch_mode) {
+void RenderWidgetHostViewWin::UpdateDesiredTouchMode() {
// Make sure that touch events even make sense.
- bool touch_mode_valid = base::win::GetVersion() >= base::win::VERSION_WIN7 &&
+ static bool touch_mode = base::win::GetVersion() >= base::win::VERSION_WIN7 &&
CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableTouchEvents);
- touch_mode = touch_mode_valid;
- // Already in correct mode, nothing to do.
- if ((touch_mode && touch_events_enabled_) ||
- (!touch_mode && !touch_events_enabled_))
+ if (!touch_mode)
return;
// 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.
- if (touch_mode) {
- touch_mode = SetToTouchMode();
- }
- if (!touch_mode) {
- SetToGestureMode();
+ 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();
}
}
@@ -1270,13 +1245,7 @@ LRESULT RenderWidgetHostViewWin::OnCreate(CREATESTRUCT* create_struct) {
// scrolled when under the mouse pointer even if inactive.
props_.push_back(ui::SetWindowSupportsRerouteMouseWheel(m_hWnd));
- bool touch_enabled = base::win::GetVersion() >= base::win::VERSION_WIN7 &&
- CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableTouchEvents);
- if (touch_enabled)
- SetToTouchMode();
- else
- SetToGestureMode();
-
+ UpdateDesiredTouchMode();
UpdateIMEState();
return 0;
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_win.h ('k') | content/browser/renderer_host/test_render_view_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698