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 <InputScope.h> | 7 #include <InputScope.h> |
8 #include <wtsapi32.h> | 8 #include <wtsapi32.h> |
9 #pragma comment(lib, "wtsapi32.lib") | 9 #pragma comment(lib, "wtsapi32.lib") |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... |
41 #include "content/common/gpu/gpu_messages.h" | 41 #include "content/common/gpu/gpu_messages.h" |
42 #include "content/common/plugin_constants_win.h" | 42 #include "content/common/plugin_constants_win.h" |
43 #include "content/common/view_messages.h" | 43 #include "content/common/view_messages.h" |
44 #include "content/common/webplugin_geometry.h" | 44 #include "content/common/webplugin_geometry.h" |
45 #include "content/public/browser/browser_thread.h" | 45 #include "content/public/browser/browser_thread.h" |
46 #include "content/public/browser/child_process_data.h" | 46 #include "content/public/browser/child_process_data.h" |
47 #include "content/public/browser/content_browser_client.h" | 47 #include "content/public/browser/content_browser_client.h" |
48 #include "content/public/browser/native_web_keyboard_event.h" | 48 #include "content/public/browser/native_web_keyboard_event.h" |
49 #include "content/public/browser/notification_service.h" | 49 #include "content/public/browser/notification_service.h" |
50 #include "content/public/browser/notification_types.h" | 50 #include "content/public/browser/notification_types.h" |
| 51 #include "content/public/browser/render_view_host.h" |
51 #include "content/public/common/content_switches.h" | 52 #include "content/public/common/content_switches.h" |
52 #include "content/public/common/page_zoom.h" | 53 #include "content/public/common/page_zoom.h" |
53 #include "content/public/common/process_type.h" | 54 #include "content/public/common/process_type.h" |
54 #include "skia/ext/skia_utils_win.h" | 55 #include "skia/ext/skia_utils_win.h" |
55 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" | 56 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" |
56 #include "third_party/WebKit/public/web/WebInputEvent.h" | 57 #include "third_party/WebKit/public/web/WebInputEvent.h" |
57 #include "third_party/skia/include/core/SkRegion.h" | 58 #include "third_party/skia/include/core/SkRegion.h" |
58 #include "ui/base/events/event.h" | 59 #include "ui/base/events/event.h" |
59 #include "ui/base/events/event_utils.h" | 60 #include "ui/base/events/event_utils.h" |
60 #include "ui/base/ime/composition_text.h" | 61 #include "ui/base/ime/composition_text.h" |
61 #include "ui/base/ime/win/tsf_input_scope.h" | 62 #include "ui/base/ime/win/tsf_input_scope.h" |
62 #include "ui/base/l10n/l10n_util_win.h" | 63 #include "ui/base/l10n/l10n_util_win.h" |
63 #include "ui/base/text/text_elider.h" | 64 #include "ui/base/text/text_elider.h" |
64 #include "ui/base/touch/touch_device.h" | 65 #include "ui/base/touch/touch_device.h" |
| 66 #include "ui/base/touch/touch_enabled.h" |
65 #include "ui/base/ui_base_switches.h" | 67 #include "ui/base/ui_base_switches.h" |
66 #include "ui/base/view_prop.h" | 68 #include "ui/base/view_prop.h" |
67 #include "ui/base/win/dpi.h" | 69 #include "ui/base/win/dpi.h" |
68 #include "ui/base/win/hwnd_util.h" | 70 #include "ui/base/win/hwnd_util.h" |
69 #include "ui/base/win/mouse_wheel_util.h" | 71 #include "ui/base/win/mouse_wheel_util.h" |
70 #include "ui/base/win/touch_input.h" | 72 #include "ui/base/win/touch_input.h" |
71 #include "ui/gfx/canvas.h" | 73 #include "ui/gfx/canvas.h" |
72 #include "ui/gfx/rect.h" | 74 #include "ui/gfx/rect.h" |
73 #include "ui/gfx/rect_conversions.h" | 75 #include "ui/gfx/rect_conversions.h" |
74 #include "ui/gfx/screen.h" | 76 #include "ui/gfx/screen.h" |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 weak_factory_(this), | 402 weak_factory_(this), |
401 is_loading_(false), | 403 is_loading_(false), |
402 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 404 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
403 can_compose_inline_(true), | 405 can_compose_inline_(true), |
404 is_fullscreen_(false), | 406 is_fullscreen_(false), |
405 ignore_mouse_movement_(true), | 407 ignore_mouse_movement_(true), |
406 composition_range_(ui::Range::InvalidRange()), | 408 composition_range_(ui::Range::InvalidRange()), |
407 touch_state_(new WebTouchState(this)), | 409 touch_state_(new WebTouchState(this)), |
408 pointer_down_context_(false), | 410 pointer_down_context_(false), |
409 last_touch_location_(-1, -1), | 411 last_touch_location_(-1, -1), |
410 touch_events_enabled_(false), | 412 touch_events_enabled_(ui::IsTouchEnabled()), |
411 gesture_recognizer_(ui::GestureRecognizer::Create(this)) { | 413 gesture_recognizer_(ui::GestureRecognizer::Create(this)) { |
412 render_widget_host_->SetView(this); | 414 render_widget_host_->SetView(this); |
413 registrar_.Add(this, | 415 registrar_.Add(this, |
414 NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 416 NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
415 NotificationService::AllBrowserContextsAndSources()); | 417 NotificationService::AllBrowserContextsAndSources()); |
416 } | 418 } |
417 | 419 |
418 RenderWidgetHostViewWin::~RenderWidgetHostViewWin() { | 420 RenderWidgetHostViewWin::~RenderWidgetHostViewWin() { |
419 UnlockMouse(); | 421 UnlockMouse(); |
420 ResetTooltip(); | 422 ResetTooltip(); |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
919 end = events.end(); iter != end; ++iter) { | 921 end = events.end(); iter != end; ++iter) { |
920 scoped_ptr<ui::GestureRecognizer::Gestures> gestures; | 922 scoped_ptr<ui::GestureRecognizer::Gestures> gestures; |
921 gestures.reset(gesture_recognizer_->ProcessTouchEventForGesture( | 923 gestures.reset(gesture_recognizer_->ProcessTouchEventForGesture( |
922 *(*iter), result, this)); | 924 *(*iter), result, this)); |
923 ProcessGestures(gestures.get()); | 925 ProcessGestures(gestures.get()); |
924 } | 926 } |
925 } | 927 } |
926 | 928 |
927 void RenderWidgetHostViewWin::UpdateDesiredTouchMode() { | 929 void RenderWidgetHostViewWin::UpdateDesiredTouchMode() { |
928 // Make sure that touch events even make sense. | 930 // Make sure that touch events even make sense. |
929 CommandLine* cmdline = CommandLine::ForCurrentProcess(); | 931 if (base::win::GetVersion() < base::win::VERSION_WIN7) |
930 static bool touch_mode = base::win::GetVersion() >= base::win::VERSION_WIN7 && | |
931 ui::IsTouchDevicePresent() && ( | |
932 !cmdline->HasSwitch(switches::kTouchEvents) || | |
933 cmdline->GetSwitchValueASCII(switches::kTouchEvents) != | |
934 switches::kTouchEventsDisabled); | |
935 | |
936 if (!touch_mode) | |
937 return; | 932 return; |
938 | 933 if (touch_events_enabled_) { |
939 // Now we know that the window's current state doesn't match the desired | 934 CHECK(RegisterTouchWindow(m_hWnd, TWF_WANTPALM)); |
940 // state. If we want touch mode, then we attempt to register for touch | |
941 // events, and otherwise to unregister. | |
942 touch_events_enabled_ = RegisterTouchWindow(m_hWnd, TWF_WANTPALM) == TRUE; | |
943 | |
944 if (!touch_events_enabled_) { | |
945 UnregisterTouchWindow(m_hWnd); | |
946 // Single finger panning is consistent with other windows applications. | |
947 const DWORD gesture_allow = GC_PAN_WITH_SINGLE_FINGER_VERTICALLY | | |
948 GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY; | |
949 const DWORD gesture_block = GC_PAN_WITH_GUTTER; | |
950 GESTURECONFIG gc[] = { | |
951 { GID_ZOOM, GC_ZOOM, 0 }, | |
952 { GID_PAN, gesture_allow , gesture_block}, | |
953 { GID_TWOFINGERTAP, GC_TWOFINGERTAP , 0}, | |
954 { GID_PRESSANDTAP, GC_PRESSANDTAP , 0} | |
955 }; | |
956 if (!SetGestureConfig(m_hWnd, 0, arraysize(gc), gc, sizeof(GESTURECONFIG))) | |
957 NOTREACHED(); | |
958 } | 935 } |
959 } | 936 } |
960 | 937 |
961 bool RenderWidgetHostViewWin::DispatchLongPressGestureEvent( | 938 bool RenderWidgetHostViewWin::DispatchLongPressGestureEvent( |
962 ui::GestureEvent* event) { | 939 ui::GestureEvent* event) { |
963 return ForwardGestureEventToRenderer(event); | 940 return ForwardGestureEventToRenderer(event); |
964 } | 941 } |
965 | 942 |
966 bool RenderWidgetHostViewWin::DispatchCancelTouchEvent( | 943 bool RenderWidgetHostViewWin::DispatchCancelTouchEvent( |
967 ui::TouchEvent* event) { | 944 ui::TouchEvent* event) { |
(...skipping 1358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2326 } | 2303 } |
2327 handled = FALSE; | 2304 handled = FALSE; |
2328 render_widget_host_->OnPointerEventActivate(); | 2305 render_widget_host_->OnPointerEventActivate(); |
2329 return MA_ACTIVATE; | 2306 return MA_ACTIVATE; |
2330 } | 2307 } |
2331 | 2308 |
2332 LRESULT RenderWidgetHostViewWin::OnGestureEvent( | 2309 LRESULT RenderWidgetHostViewWin::OnGestureEvent( |
2333 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { | 2310 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { |
2334 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnGestureEvent"); | 2311 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnGestureEvent"); |
2335 | 2312 |
2336 // Note that as of M22, touch events are enabled by default on Windows. | |
2337 // This code should not be reachable. | |
2338 DCHECK(!touch_events_enabled_); | 2313 DCHECK(!touch_events_enabled_); |
2339 handled = FALSE; | 2314 handled = FALSE; |
2340 | 2315 |
2341 GESTUREINFO gi = {sizeof(GESTUREINFO)}; | 2316 GESTUREINFO gi = {sizeof(GESTUREINFO)}; |
2342 HGESTUREINFO gi_handle = reinterpret_cast<HGESTUREINFO>(lparam); | 2317 HGESTUREINFO gi_handle = reinterpret_cast<HGESTUREINFO>(lparam); |
2343 if (!::GetGestureInfo(gi_handle, &gi)) { | 2318 if (!::GetGestureInfo(gi_handle, &gi)) { |
2344 DWORD error = GetLastError(); | 2319 DWORD error = GetLastError(); |
2345 NOTREACHED() << "Unable to get gesture info. Error : " << error; | 2320 NOTREACHED() << "Unable to get gesture info. Error : " << error; |
2346 return 0; | 2321 return 0; |
2347 } | 2322 } |
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3198 return new RenderWidgetHostViewWin(widget); | 3173 return new RenderWidgetHostViewWin(widget); |
3199 } | 3174 } |
3200 | 3175 |
3201 // static | 3176 // static |
3202 void RenderWidgetHostViewPort::GetDefaultScreenInfo( | 3177 void RenderWidgetHostViewPort::GetDefaultScreenInfo( |
3203 WebKit::WebScreenInfo* results) { | 3178 WebKit::WebScreenInfo* results) { |
3204 GetScreenInfoForWindow(0, results); | 3179 GetScreenInfoForWindow(0, results); |
3205 } | 3180 } |
3206 | 3181 |
3207 } // namespace content | 3182 } // namespace content |
OLD | NEW |