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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
321 screen_info.depth = dev_mode.dmBitsPerPel; | 321 screen_info.depth = dev_mode.dmBitsPerPel; |
322 screen_info.depthPerComponent = dev_mode.dmBitsPerPel / 3; // Assumes RGB | 322 screen_info.depthPerComponent = dev_mode.dmBitsPerPel / 3; // Assumes RGB |
323 screen_info.deviceScaleFactor = ui::win::GetDeviceScaleFactor(); | 323 screen_info.deviceScaleFactor = ui::win::GetDeviceScaleFactor(); |
324 screen_info.isMonochrome = dev_mode.dmColor == DMCOLOR_MONOCHROME; | 324 screen_info.isMonochrome = dev_mode.dmColor == DMCOLOR_MONOCHROME; |
325 screen_info.rect = gfx::Rect(monitor_info.rcMonitor); | 325 screen_info.rect = gfx::Rect(monitor_info.rcMonitor); |
326 screen_info.availableRect = gfx::Rect(monitor_info.rcWork); | 326 screen_info.availableRect = gfx::Rect(monitor_info.rcWork); |
327 | 327 |
328 *results = screen_info; | 328 *results = screen_info; |
329 } | 329 } |
330 | 330 |
331 // Tests the tri-state touch-events flag. Note that --touch-events is the | |
332 // same as --touch-events-enabled, but not giving the flag defaults to auto. | |
333 bool IsTouchModeEnabled() { | |
334 if (base::win::GetVersion() >= base::win::VERSION_WIN7) | |
335 return false; | |
336 | |
337 CommandLine* cmdline = CommandLine::ForCurrentProcess(); | |
338 if (cmdline->HasSwitch(switches::kTouchEvents)) { | |
339 if (cmdline->GetSwitchValueASCII(switches::kTouchEvents) == | |
340 switches::kTouchEventsDisabled) | |
341 return false; | |
342 else if (cmdline->GetSwitchValueASCII(switches::kTouchEvents) == | |
Ben Goodger (Google)
2013/07/24 19:26:13
no else after return
| |
343 switches::kTouchEventsAuto) | |
344 return ui::IsTouchDevicePresent(); | |
345 else | |
346 return true; | |
347 } | |
348 return ui::IsTouchDevicePresent(); | |
349 } | |
350 | |
331 } // namespace | 351 } // namespace |
332 | 352 |
333 const wchar_t kRenderWidgetHostHWNDClass[] = L"Chrome_RenderWidgetHostHWND"; | 353 const wchar_t kRenderWidgetHostHWNDClass[] = L"Chrome_RenderWidgetHostHWND"; |
334 | 354 |
335 // Wrapper for maintaining touchstate associated with a WebTouchEvent. | 355 // Wrapper for maintaining touchstate associated with a WebTouchEvent. |
336 class WebTouchState { | 356 class WebTouchState { |
337 public: | 357 public: |
338 explicit WebTouchState(const RenderWidgetHostViewWin* window); | 358 explicit WebTouchState(const RenderWidgetHostViewWin* window); |
339 | 359 |
340 // Updates the current touchpoint state with the supplied touches. | 360 // Updates the current touchpoint state with the supplied touches. |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
401 is_loading_(false), | 421 is_loading_(false), |
402 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 422 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
403 can_compose_inline_(true), | 423 can_compose_inline_(true), |
404 is_fullscreen_(false), | 424 is_fullscreen_(false), |
405 ignore_mouse_movement_(true), | 425 ignore_mouse_movement_(true), |
406 composition_range_(ui::Range::InvalidRange()), | 426 composition_range_(ui::Range::InvalidRange()), |
407 touch_state_(new WebTouchState(this)), | 427 touch_state_(new WebTouchState(this)), |
408 pointer_down_context_(false), | 428 pointer_down_context_(false), |
409 last_touch_location_(-1, -1), | 429 last_touch_location_(-1, -1), |
410 touch_events_enabled_(false), | 430 touch_events_enabled_(false), |
411 gesture_recognizer_(ui::GestureRecognizer::Create(this)) { | 431 gesture_recognizer_(ui::GestureRecognizer::Create(this)) { |
flackr
2013/07/24 18:41:52
Rather than duplicate the touch events settting, y
| |
412 render_widget_host_->SetView(this); | 432 render_widget_host_->SetView(this); |
413 registrar_.Add(this, | 433 registrar_.Add(this, |
414 NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 434 NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
415 NotificationService::AllBrowserContextsAndSources()); | 435 NotificationService::AllBrowserContextsAndSources()); |
416 } | 436 } |
417 | 437 |
418 RenderWidgetHostViewWin::~RenderWidgetHostViewWin() { | 438 RenderWidgetHostViewWin::~RenderWidgetHostViewWin() { |
419 UnlockMouse(); | 439 UnlockMouse(); |
420 ResetTooltip(); | 440 ResetTooltip(); |
421 } | 441 } |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
919 end = events.end(); iter != end; ++iter) { | 939 end = events.end(); iter != end; ++iter) { |
920 scoped_ptr<ui::GestureRecognizer::Gestures> gestures; | 940 scoped_ptr<ui::GestureRecognizer::Gestures> gestures; |
921 gestures.reset(gesture_recognizer_->ProcessTouchEventForGesture( | 941 gestures.reset(gesture_recognizer_->ProcessTouchEventForGesture( |
922 *(*iter), result, this)); | 942 *(*iter), result, this)); |
923 ProcessGestures(gestures.get()); | 943 ProcessGestures(gestures.get()); |
924 } | 944 } |
925 } | 945 } |
926 | 946 |
927 void RenderWidgetHostViewWin::UpdateDesiredTouchMode() { | 947 void RenderWidgetHostViewWin::UpdateDesiredTouchMode() { |
928 // Make sure that touch events even make sense. | 948 // Make sure that touch events even make sense. |
929 CommandLine* cmdline = CommandLine::ForCurrentProcess(); | 949 static bool touch_mode = IsTouchModeEnabled(); |
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 | 950 |
936 if (!touch_mode) | 951 if (touch_mode) { |
937 return; | 952 touch_events_enabled_ = RegisterTouchWindow(m_hWnd, TWF_WANTPALM) == TRUE; |
938 | 953 CHECK(touch_events_enabled_); |
939 // Now we know that the window's current state doesn't match the desired | |
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 } | 954 } |
959 } | 955 } |
960 | 956 |
961 bool RenderWidgetHostViewWin::DispatchLongPressGestureEvent( | 957 bool RenderWidgetHostViewWin::DispatchLongPressGestureEvent( |
962 ui::GestureEvent* event) { | 958 ui::GestureEvent* event) { |
963 return ForwardGestureEventToRenderer(event); | 959 return ForwardGestureEventToRenderer(event); |
964 } | 960 } |
965 | 961 |
966 bool RenderWidgetHostViewWin::DispatchCancelTouchEvent( | 962 bool RenderWidgetHostViewWin::DispatchCancelTouchEvent( |
967 ui::TouchEvent* event) { | 963 ui::TouchEvent* event) { |
(...skipping 2230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3198 return new RenderWidgetHostViewWin(widget); | 3194 return new RenderWidgetHostViewWin(widget); |
3199 } | 3195 } |
3200 | 3196 |
3201 // static | 3197 // static |
3202 void RenderWidgetHostViewPort::GetDefaultScreenInfo( | 3198 void RenderWidgetHostViewPort::GetDefaultScreenInfo( |
3203 WebKit::WebScreenInfo* results) { | 3199 WebKit::WebScreenInfo* results) { |
3204 GetScreenInfoForWindow(0, results); | 3200 GetScreenInfoForWindow(0, results); |
3205 } | 3201 } |
3206 | 3202 |
3207 } // namespace content | 3203 } // namespace content |
OLD | NEW |