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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/render_widget_host_view_win.h" 5 #include "content/browser/renderer_host/render_widget_host_view_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <peninputpanel_i.c> 9 #include <peninputpanel_i.c>
10 #include <stack> 10 #include <stack>
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 output->getTopDevice()->accessBitmap(true).getPixels()); 944 output->getTopDevice()->accessBitmap(true).getPixels());
945 scoped_callback_runner.Release(); 945 scoped_callback_runner.Release();
946 callback.Run(result); 946 callback.Run(result);
947 } 947 }
948 948
949 void RenderWidgetHostViewWin::SetBackground(const SkBitmap& background) { 949 void RenderWidgetHostViewWin::SetBackground(const SkBitmap& background) {
950 RenderWidgetHostViewBase::SetBackground(background); 950 RenderWidgetHostViewBase::SetBackground(background);
951 render_widget_host_->SetBackground(background); 951 render_widget_host_->SetBackground(background);
952 } 952 }
953 953
954 void RenderWidgetHostViewWin::ProcessTouchAck( 954 void RenderWidgetHostViewWin::ProcessTouchAck(bool processed) {
955 WebKit::WebInputEvent::Type type, bool processed) {
956 955
957 DCHECK(render_widget_host_->has_touch_handler() && 956 DCHECK(render_widget_host_->has_touch_handler() &&
958 touch_events_enabled_); 957 touch_events_enabled_);
959 958
960 int touch_count = touch_state_->GetNextTouchCount(); 959 int touch_count = touch_state_->GetNextTouchCount();
961 for (int i = 0; i < touch_count; ++i) { 960 for (int i = 0; i < touch_count; ++i) {
962 scoped_ptr<ui::GestureRecognizer::Gestures> gestures; 961 scoped_ptr<ui::GestureRecognizer::Gestures> gestures;
963 gestures.reset(gesture_recognizer_->AdvanceTouchQueue(this, processed)); 962 gestures.reset(gesture_recognizer_->AdvanceTouchQueue(this, processed));
964 ProcessGestures(gestures.get()); 963 ProcessGestures(gestures.get());
965 } 964 }
966
967 if (type == WebKit::WebInputEvent::TouchStart)
968 UpdateDesiredTouchMode(processed);
969 } 965 }
970 966
971 void RenderWidgetHostViewWin::SetToGestureMode() { 967 void RenderWidgetHostViewWin::SetToGestureMode() {
972 if (base::win::GetVersion() < base::win::VERSION_WIN7) 968 if (base::win::GetVersion() < base::win::VERSION_WIN7)
973 return; 969 return;
974 UnregisterTouchWindow(m_hWnd); 970 UnregisterTouchWindow(m_hWnd);
975 // Single finger panning is consistent with other windows applications. 971 // Single finger panning is consistent with other windows applications.
976 const DWORD gesture_allow = GC_PAN_WITH_SINGLE_FINGER_VERTICALLY | 972 const DWORD gesture_allow = GC_PAN_WITH_SINGLE_FINGER_VERTICALLY |
977 GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY; 973 GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY;
978 const DWORD gesture_block = GC_PAN_WITH_GUTTER; 974 const DWORD gesture_block = GC_PAN_WITH_GUTTER;
(...skipping 11 matching lines...) Expand all
990 } 986 }
991 987
992 bool RenderWidgetHostViewWin::SetToTouchMode() { 988 bool RenderWidgetHostViewWin::SetToTouchMode() {
993 if (base::win::GetVersion() < base::win::VERSION_WIN7) 989 if (base::win::GetVersion() < base::win::VERSION_WIN7)
994 return false; 990 return false;
995 bool touch_mode = RegisterTouchWindow(m_hWnd, TWF_WANTPALM) == TRUE; 991 bool touch_mode = RegisterTouchWindow(m_hWnd, TWF_WANTPALM) == TRUE;
996 touch_events_enabled_ = touch_mode; 992 touch_events_enabled_ = touch_mode;
997 return touch_mode; 993 return touch_mode;
998 } 994 }
999 995
1000 void RenderWidgetHostViewWin::UpdateDesiredTouchMode(bool touch_mode) { 996 void RenderWidgetHostViewWin::UpdateDesiredTouchMode() {
scottmg 2012/10/11 16:58:53 could probably be simplified a bit more, since it
sadrul 2012/10/11 17:02:09 Perhaps. What simplification did you have in mind?
scottmg 2012/10/11 17:09:29 Sorry, wasn't trying to be the riddler... - SetTo
sadrul 2012/10/11 17:25:10 Ah, indeed. I have made the following changes: -
1001 // Make sure that touch events even make sense. 997 // Make sure that touch events even make sense.
1002 bool touch_mode_valid = base::win::GetVersion() >= base::win::VERSION_WIN7 && 998 bool touch_mode = base::win::GetVersion() >= base::win::VERSION_WIN7 &&
1003 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableTouchEvents); 999 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableTouchEvents);
1004 touch_mode = touch_mode_valid;
1005 1000
1006 // Already in correct mode, nothing to do. 1001 // Already in correct mode, nothing to do.
1007 if ((touch_mode && touch_events_enabled_) || 1002 if ((touch_mode && touch_events_enabled_) ||
1008 (!touch_mode && !touch_events_enabled_)) 1003 (!touch_mode && !touch_events_enabled_))
1009 return; 1004 return;
1010 1005
1011 // Now we know that the window's current state doesn't match the desired 1006 // Now we know that the window's current state doesn't match the desired
1012 // state. If we want touch mode, then we attempt to register for touch 1007 // state. If we want touch mode, then we attempt to register for touch
1013 // events, and otherwise to unregister. 1008 // events, and otherwise to unregister.
1014 if (touch_mode) { 1009 if (touch_mode)
1015 touch_mode = SetToTouchMode(); 1010 touch_mode = SetToTouchMode();
1016 } 1011 if (!touch_mode)
1017 if (!touch_mode) {
1018 SetToGestureMode(); 1012 SetToGestureMode();
1019 }
1020 } 1013 }
1021 1014
1022 bool RenderWidgetHostViewWin::DispatchLongPressGestureEvent( 1015 bool RenderWidgetHostViewWin::DispatchLongPressGestureEvent(
1023 ui::GestureEvent* event) { 1016 ui::GestureEvent* event) {
1024 return ForwardGestureEventToRenderer(event); 1017 return ForwardGestureEventToRenderer(event);
1025 } 1018 }
1026 1019
1027 bool RenderWidgetHostViewWin::DispatchCancelTouchEvent( 1020 bool RenderWidgetHostViewWin::DispatchCancelTouchEvent(
1028 ui::TouchEvent* event) { 1021 ui::TouchEvent* event) {
1029 if (!render_widget_host_ || !touch_events_enabled_) 1022 if (!render_widget_host_ || !touch_events_enabled_)
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 1256
1264 LRESULT RenderWidgetHostViewWin::OnCreate(CREATESTRUCT* create_struct) { 1257 LRESULT RenderWidgetHostViewWin::OnCreate(CREATESTRUCT* create_struct) {
1265 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnCreate"); 1258 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnCreate");
1266 // Call the WM_INPUTLANGCHANGE message handler to initialize the input locale 1259 // Call the WM_INPUTLANGCHANGE message handler to initialize the input locale
1267 // of a browser process. 1260 // of a browser process.
1268 OnInputLangChange(0, 0); 1261 OnInputLangChange(0, 0);
1269 // Marks that window as supporting mouse-wheel messages rerouting so it is 1262 // Marks that window as supporting mouse-wheel messages rerouting so it is
1270 // scrolled when under the mouse pointer even if inactive. 1263 // scrolled when under the mouse pointer even if inactive.
1271 props_.push_back(ui::SetWindowSupportsRerouteMouseWheel(m_hWnd)); 1264 props_.push_back(ui::SetWindowSupportsRerouteMouseWheel(m_hWnd));
1272 1265
1273 bool touch_enabled = base::win::GetVersion() >= base::win::VERSION_WIN7 && 1266 UpdateDesiredTouchMode();
1274 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableTouchEvents);
1275 if (touch_enabled)
1276 SetToTouchMode();
1277 else
1278 SetToGestureMode();
1279
1280 UpdateIMEState(); 1267 UpdateIMEState();
1281 1268
1282 return 0; 1269 return 0;
1283 } 1270 }
1284 1271
1285 void RenderWidgetHostViewWin::OnActivate(UINT action, BOOL minimized, 1272 void RenderWidgetHostViewWin::OnActivate(UINT action, BOOL minimized,
1286 HWND window) { 1273 HWND window) {
1287 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnActivate"); 1274 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnActivate");
1288 // If the container is a popup, clicking elsewhere on screen should close the 1275 // If the container is a popup, clicking elsewhere on screen should close the
1289 // popup. 1276 // popup.
(...skipping 1840 matching lines...) Expand 10 before | Expand all | Expand 10 after
3130 // receive a focus change in the context of a pointer down message, it means 3117 // receive a focus change in the context of a pointer down message, it means
3131 // that the pointer down message occurred on the edit field and we should 3118 // that the pointer down message occurred on the edit field and we should
3132 // display the on screen keyboard 3119 // display the on screen keyboard
3133 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_) 3120 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_)
3134 DisplayOnScreenKeyboardIfNeeded(); 3121 DisplayOnScreenKeyboardIfNeeded();
3135 received_focus_change_after_pointer_down_ = false; 3122 received_focus_change_after_pointer_down_ = false;
3136 pointer_down_context_ = false; 3123 pointer_down_context_ = false;
3137 } 3124 }
3138 3125
3139 } // namespace content 3126 } // namespace content
OLDNEW
« 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