diff options
author | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-21 02:26:21 +0000 |
---|---|---|
committer | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-21 02:26:21 +0000 |
commit | 01d9c46e1fa33f3db26759642e3ba0b83270252e (patch) | |
tree | 195fcd8f363c60eef83a641322caea7e8e2adf6f | |
parent | 0dc024ae06a0109a0ddf770a5c54cf31a1202a36 (diff) | |
download | chromium_src-01d9c46e1fa33f3db26759642e3ba0b83270252e.zip chromium_src-01d9c46e1fa33f3db26759642e3ba0b83270252e.tar.gz chromium_src-01d9c46e1fa33f3db26759642e3ba0b83270252e.tar.bz2 |
Revert 106653 - hackaton: enable one finger scrolling for touch eventsIn a touch screen the current experience is horrible, finger panning just causes content selection, or image dragging (copy)if initiated from an image in the page.This happens because we don't handle WM_GESTTURE events, so windows generates mousedown+drag events.With this patch at least we scroll, selection becomes difficult but that is a much better experience.Works for windows 7 and above.BUG=52260TEST= see bugReview URL: http://codereview.chromium.org/8354030TBR=cpu@chromium.org
Review URL: http://codereview.chromium.org/8363022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106662 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/browser/renderer_host/render_widget_host_view_win.cc | 94 | ||||
-rw-r--r-- | content/browser/renderer_host/render_widget_host_view_win.h | 8 |
2 files changed, 2 insertions, 100 deletions
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 f549bb1..ec83c95 100644 --- a/content/browser/renderer_host/render_widget_host_view_win.cc +++ b/content/browser/renderer_host/render_widget_host_view_win.cc @@ -14,7 +14,6 @@ #include "base/win/scoped_comptr.h" #include "base/win/scoped_gdi_object.h" #include "base/win/win_util.h" -#include "base/win/windows_version.h" #include "base/win/wrapped_window_proc.h" #include "content/browser/accessibility/browser_accessibility_manager.h" #include "content/browser/accessibility/browser_accessibility_state.h" @@ -209,66 +208,6 @@ typedef BOOL (WINAPI *ChangeWindowMessageFilterExFunction)( PCHANGEFILTERSTRUCT change_filter_struct); ChangeWindowMessageFilterExFunction g_ChangeWindowMessageFilterEx; -bool DecodeScrollGesture(WPARAM wParam, - LPARAM lParam, - POINT* start, - POINT* delta){ - // Windows gestures are streams of messages with begin/end messages that - // separate each new gesture. We key off the begin message to reset - // the static variables. - static POINT last_pt; - static POINT start_pt; - - GESTUREINFO gi = {sizeof(GESTUREINFO)}; - HGESTUREINFO gi_handle = reinterpret_cast<HGESTUREINFO>(lParam); - if (!::GetGestureInfo(gi_handle, &gi)) { - DWORD error = GetLastError(); - NOTREACHED() << "Unable to get gesture info. Error : " << error; - } - - if (gi.dwID != GID_PAN) - return false; - - if (gi.dwFlags == GF_BEGIN) { - delta->x = 0; - delta->y = 0; - start_pt.x = gi.ptsLocation.x; - start_pt.y = gi.ptsLocation.y; - } else { - delta->x = gi.ptsLocation.x - last_pt.x; - delta->y = gi.ptsLocation.y - last_pt.y; - } - last_pt.x = gi.ptsLocation.x; - last_pt.y = gi.ptsLocation.y; - *start = start_pt; - ::CloseGestureInfoHandle(gi_handle); - return true; -} - -WebKit::WebMouseWheelEvent MakeFakeScrollWheelEvent(HWND hwnd, - POINT start, - POINT delta) { - WebKit::WebMouseWheelEvent result; - result.type = WebInputEvent::MouseWheel; - result.timeStampSeconds = ::GetMessageTime() / 1000.0; - result.button = WebMouseEvent::ButtonNone; - result.globalX = start.x; - result.globalY = start.y; - // Map to window coordinates. - POINT clientPoint = { result.globalX, result.globalY }; - MapWindowPoints(0, hwnd, &clientPoint, 1); - result.x = clientPoint.x; - result.y = clientPoint.y; - result.windowX = result.x; - result.windowY = result.y; - // Note that we support diagonal scrolling. - result.deltaX = static_cast<float>(delta.x); - result.wheelTicksX = WHEEL_DELTA; - result.deltaY = static_cast<float>(delta.y); - result.wheelTicksY = WHEEL_DELTA; - return result; -} - } // namespace /////////////////////////////////////////////////////////////////////////////// @@ -853,23 +792,6 @@ LRESULT RenderWidgetHostViewWin::OnCreate(CREATESTRUCT* create_struct) { // scrolled when under the mouse pointer even if inactive. props_.push_back(ui::SetWindowSupportsRerouteMouseWheel(m_hWnd)); - if (base::win::GetVersion() >= base::win::VERSION_WIN7) { - // 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(); - } - } - return 0; } @@ -1548,22 +1470,6 @@ LRESULT RenderWidgetHostViewWin::OnMouseActivate(UINT message, return MA_ACTIVATE; } -LRESULT RenderWidgetHostViewWin::OnGestureEvent( - UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { - // Right now we only decode scroll gestures and we forward to the page - // as scroll events. - POINT start; - POINT delta; - if (DecodeScrollGesture(wparam, lparam, &start, &delta)) { - handled = TRUE; - render_widget_host_->ForwardWheelEvent( - MakeFakeScrollWheelEvent(m_hWnd, start, delta)); - } else { - handled = FALSE; - } - return 0; -} - void RenderWidgetHostViewWin::OnAccessibilityNotifications( const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params) { if (!browser_accessibility_manager_.get()) { diff --git a/content/browser/renderer_host/render_widget_host_view_win.h b/content/browser/renderer_host/render_widget_host_view_win.h index 1ac8d13..72eec9b 100644 --- a/content/browser/renderer_host/render_widget_host_view_win.h +++ b/content/browser/renderer_host/render_widget_host_view_win.h @@ -129,7 +129,6 @@ class RenderWidgetHostViewWin MESSAGE_HANDLER(WM_MOUSEACTIVATE, OnMouseActivate) MESSAGE_HANDLER(WM_GETOBJECT, OnGetObject) MESSAGE_HANDLER(WM_PARENTNOTIFY, OnParentNotify) - MESSAGE_HANDLER(WM_GESTURE, OnGestureEvent) END_MSG_MAP() // Implementation of RenderWidgetHostView: @@ -233,16 +232,13 @@ class RenderWidgetHostViewWin // Handle MSAA requests for accessibility information. LRESULT OnGetObject(UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled); - // Handle vertical scrolling. + // Handle vertical scrolling LRESULT OnVScroll(int code, short position, HWND scrollbar_control); - // Handle horizontal scrolling. + // Handle horizontal scrolling LRESULT OnHScroll(int code, short position, HWND scrollbar_control); LRESULT OnParentNotify(UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled); - // Handle high-level touch events. - LRESULT OnGestureEvent(UINT message, WPARAM wparam, LPARAM lparam, - BOOL& handled); void OnFinalMessage(HWND window); |