| OLD | NEW |
| 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 Loading... |
| 944 output->GetBitmap().getPixels()); | 944 output->GetBitmap().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::UpdateDesiredTouchMode() { |
| 972 if (base::win::GetVersion() < base::win::VERSION_WIN7) | 968 // Make sure that touch events even make sense. |
| 973 return; | 969 static bool touch_mode = base::win::GetVersion() >= base::win::VERSION_WIN7 && |
| 974 UnregisterTouchWindow(m_hWnd); | 970 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableTouchEvents); |
| 975 // Single finger panning is consistent with other windows applications. | |
| 976 const DWORD gesture_allow = GC_PAN_WITH_SINGLE_FINGER_VERTICALLY | | |
| 977 GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY; | |
| 978 const DWORD gesture_block = GC_PAN_WITH_GUTTER; | |
| 979 GESTURECONFIG gc[] = { | |
| 980 { GID_ZOOM, GC_ZOOM, 0 }, | |
| 981 { GID_PAN, gesture_allow , gesture_block}, | |
| 982 { GID_TWOFINGERTAP, GC_TWOFINGERTAP , 0}, | |
| 983 { GID_PRESSANDTAP, GC_PRESSANDTAP , 0} | |
| 984 }; | |
| 985 if (!SetGestureConfig(m_hWnd, 0, arraysize(gc), gc, | |
| 986 sizeof(GESTURECONFIG))) { | |
| 987 NOTREACHED(); | |
| 988 } | |
| 989 touch_events_enabled_ = false; | |
| 990 } | |
| 991 | 971 |
| 992 bool RenderWidgetHostViewWin::SetToTouchMode() { | 972 if (!touch_mode) |
| 993 if (base::win::GetVersion() < base::win::VERSION_WIN7) | |
| 994 return false; | |
| 995 bool touch_mode = RegisterTouchWindow(m_hWnd, TWF_WANTPALM) == TRUE; | |
| 996 touch_events_enabled_ = touch_mode; | |
| 997 return touch_mode; | |
| 998 } | |
| 999 | |
| 1000 void RenderWidgetHostViewWin::UpdateDesiredTouchMode(bool touch_mode) { | |
| 1001 // Make sure that touch events even make sense. | |
| 1002 bool touch_mode_valid = base::win::GetVersion() >= base::win::VERSION_WIN7 && | |
| 1003 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableTouchEvents); | |
| 1004 touch_mode = touch_mode_valid; | |
| 1005 | |
| 1006 // Already in correct mode, nothing to do. | |
| 1007 if ((touch_mode && touch_events_enabled_) || | |
| 1008 (!touch_mode && !touch_events_enabled_)) | |
| 1009 return; | 973 return; |
| 1010 | 974 |
| 1011 // Now we know that the window's current state doesn't match the desired | 975 // 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 | 976 // state. If we want touch mode, then we attempt to register for touch |
| 1013 // events, and otherwise to unregister. | 977 // events, and otherwise to unregister. |
| 1014 if (touch_mode) { | 978 touch_events_enabled_ = RegisterTouchWindow(m_hWnd, TWF_WANTPALM) == TRUE; |
| 1015 touch_mode = SetToTouchMode(); | 979 |
| 1016 } | 980 if (!touch_events_enabled_) { |
| 1017 if (!touch_mode) { | 981 UnregisterTouchWindow(m_hWnd); |
| 1018 SetToGestureMode(); | 982 // Single finger panning is consistent with other windows applications. |
| 983 const DWORD gesture_allow = GC_PAN_WITH_SINGLE_FINGER_VERTICALLY | |
| 984 GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY; |
| 985 const DWORD gesture_block = GC_PAN_WITH_GUTTER; |
| 986 GESTURECONFIG gc[] = { |
| 987 { GID_ZOOM, GC_ZOOM, 0 }, |
| 988 { GID_PAN, gesture_allow , gesture_block}, |
| 989 { GID_TWOFINGERTAP, GC_TWOFINGERTAP , 0}, |
| 990 { GID_PRESSANDTAP, GC_PRESSANDTAP , 0} |
| 991 }; |
| 992 if (!SetGestureConfig(m_hWnd, 0, arraysize(gc), gc, sizeof(GESTURECONFIG))) |
| 993 NOTREACHED(); |
| 1019 } | 994 } |
| 1020 } | 995 } |
| 1021 | 996 |
| 1022 bool RenderWidgetHostViewWin::DispatchLongPressGestureEvent( | 997 bool RenderWidgetHostViewWin::DispatchLongPressGestureEvent( |
| 1023 ui::GestureEvent* event) { | 998 ui::GestureEvent* event) { |
| 1024 return ForwardGestureEventToRenderer(event); | 999 return ForwardGestureEventToRenderer(event); |
| 1025 } | 1000 } |
| 1026 | 1001 |
| 1027 bool RenderWidgetHostViewWin::DispatchCancelTouchEvent( | 1002 bool RenderWidgetHostViewWin::DispatchCancelTouchEvent( |
| 1028 ui::TouchEvent* event) { | 1003 ui::TouchEvent* event) { |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1263 | 1238 |
| 1264 LRESULT RenderWidgetHostViewWin::OnCreate(CREATESTRUCT* create_struct) { | 1239 LRESULT RenderWidgetHostViewWin::OnCreate(CREATESTRUCT* create_struct) { |
| 1265 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnCreate"); | 1240 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnCreate"); |
| 1266 // Call the WM_INPUTLANGCHANGE message handler to initialize the input locale | 1241 // Call the WM_INPUTLANGCHANGE message handler to initialize the input locale |
| 1267 // of a browser process. | 1242 // of a browser process. |
| 1268 OnInputLangChange(0, 0); | 1243 OnInputLangChange(0, 0); |
| 1269 // Marks that window as supporting mouse-wheel messages rerouting so it is | 1244 // Marks that window as supporting mouse-wheel messages rerouting so it is |
| 1270 // scrolled when under the mouse pointer even if inactive. | 1245 // scrolled when under the mouse pointer even if inactive. |
| 1271 props_.push_back(ui::SetWindowSupportsRerouteMouseWheel(m_hWnd)); | 1246 props_.push_back(ui::SetWindowSupportsRerouteMouseWheel(m_hWnd)); |
| 1272 | 1247 |
| 1273 bool touch_enabled = base::win::GetVersion() >= base::win::VERSION_WIN7 && | 1248 UpdateDesiredTouchMode(); |
| 1274 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableTouchEvents); | |
| 1275 if (touch_enabled) | |
| 1276 SetToTouchMode(); | |
| 1277 else | |
| 1278 SetToGestureMode(); | |
| 1279 | |
| 1280 UpdateIMEState(); | 1249 UpdateIMEState(); |
| 1281 | 1250 |
| 1282 return 0; | 1251 return 0; |
| 1283 } | 1252 } |
| 1284 | 1253 |
| 1285 void RenderWidgetHostViewWin::OnActivate(UINT action, BOOL minimized, | 1254 void RenderWidgetHostViewWin::OnActivate(UINT action, BOOL minimized, |
| 1286 HWND window) { | 1255 HWND window) { |
| 1287 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnActivate"); | 1256 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnActivate"); |
| 1288 // If the container is a popup, clicking elsewhere on screen should close the | 1257 // If the container is a popup, clicking elsewhere on screen should close the |
| 1289 // popup. | 1258 // popup. |
| (...skipping 1840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3130 // receive a focus change in the context of a pointer down message, it means | 3099 // 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 | 3100 // that the pointer down message occurred on the edit field and we should |
| 3132 // display the on screen keyboard | 3101 // display the on screen keyboard |
| 3133 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_) | 3102 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_) |
| 3134 DisplayOnScreenKeyboardIfNeeded(); | 3103 DisplayOnScreenKeyboardIfNeeded(); |
| 3135 received_focus_change_after_pointer_down_ = false; | 3104 received_focus_change_after_pointer_down_ = false; |
| 3136 pointer_down_context_ = false; | 3105 pointer_down_context_ = false; |
| 3137 } | 3106 } |
| 3138 | 3107 |
| 3139 } // namespace content | 3108 } // namespace content |
| OLD | NEW |