Commit 58003b76 authored by bweinstein@apple.com's avatar bweinstein@apple.com

2009-06-19 Brian Weinstein <bweinstein@apple.com>

        Reviewed by Steve Falkenburg.
        
        https://bugs.webkit.org/show_bug.cgi?id=26488
        No Support for Single Finger or Two Finger Panning in Windows 7
        
        The code in WebCore allows us to interpret a Pan gesture as
        a mousewheel event, and we are able to reuse the scrolling code.
        Another constructor was created in WheelEventWin which takes data
        better suited to the pan guesture than what was currently there. 
        
        Unable to add tests to simulate touch behavior/gestures.

        * platform/PlatformWheelEvent.h:
        * platform/win/WheelEventWin.cpp:

2009-06-19  Brian Weinstein  <bweinstein@apple.com>

        Reviewed by Steve Falkenburg.
        
        https://bugs.webkit.org/show_bug.cgi?id=26488
        No Support for Single Finger or Two Finger Panning in Windows 7
        
        The code in WebCore allows us to interpret a Pan gesture as
        a mousewheel event, and we are able to reuse the scrolling code.
        Another constructor was created in WheelEventWin which takes data
        better suited to the pan guesture than what was currently there. 
        
        Unable to add tests to simulate touch behavior/gestures.

        * platform/PlatformWheelEvent.h:
        * platform/win/WheelEventWin.cpp:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@44883 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 40048a11
2009-06-19 Brian Weinstein <bweinstein@apple.com>
Reviewed by Steve Falkenburg.
https://bugs.webkit.org/show_bug.cgi?id=26488
No Support for Single Finger or Two Finger Panning in Windows 7
The code in WebCore allows us to interpret a Pan gesture as
a mousewheel event, and we are able to reuse the scrolling code.
Another constructor was created in WheelEventWin which takes data
better suited to the pan guesture than what was currently there.
Unable to add tests to simulate touch behavior/gestures.
* platform/PlatformWheelEvent.h:
* platform/win/WheelEventWin.cpp:
2009-06-19 Chris Marrin <cmarrin@apple.com>
Fixed a build error, which only shows up in the i386 compile
......
......@@ -99,6 +99,7 @@ namespace WebCore {
#if PLATFORM(WIN)
PlatformWheelEvent(HWND, WPARAM, LPARAM, bool isMouseHWheel);
PlatformWheelEvent(HWND, float deltaX, float deltaY, float xLoc, float yLoc);
#endif
#if PLATFORM(WX)
......
......@@ -62,6 +62,28 @@ static int verticalScrollLines()
return scrollLines;
}
PlatformWheelEvent::PlatformWheelEvent(HWND hWnd, float deltaX, float deltaY, float xLoc, float yLoc)
: m_isAccepted(false)
, m_shiftKey(false)
, m_ctrlKey(false)
, m_altKey(false)
, m_metaKey(false)
{
m_deltaX = deltaX;
m_deltaY = deltaY;
m_wheelTicksX = m_deltaX;
m_wheelTicksY = m_deltaY;
// Global Position is just x, y location of event
POINT point = {xLoc, yLoc};
m_globalPosition = point;
// Position needs to be translated to our client
ScreenToClient(hWnd, &point);
m_position = point;
}
PlatformWheelEvent::PlatformWheelEvent(HWND hWnd, WPARAM wParam, LPARAM lParam, bool isMouseHWheel)
: m_position(positionForEvent(hWnd, lParam))
, m_globalPosition(globalPositionForEvent(hWnd, lParam))
......
2009-06-19 Brian Weinstein <bweinstein@apple.com>
Reviewed by Steve Falkenburg.
https://bugs.webkit.org/show_bug.cgi?id=26488
No Support for Single Finger or Two Finger Panning in Windows 7
The code in WebCore allows us to interpret a Pan gesture as
a mousewheel event, and we are able to reuse the scrolling code.
Another constructor was created in WheelEventWin which takes data
better suited to the pan guesture than what was currently there.
Unable to add tests to simulate touch behavior/gestures.
* platform/PlatformWheelEvent.h:
* platform/win/WheelEventWin.cpp:
2009-06-18 Adam Barth <abarth@webkit.org>
Reviewed by Sam Weinig.
......
......@@ -737,6 +737,10 @@
RelativePath="..\WebView.h"
>
</File>
<File
RelativePath="..\WindowsTouch.h"
>
</File>
</Filter>
<Filter
Name="Classes"
......
......@@ -30,6 +30,7 @@
#include "CFDictionaryPropertyBag.h"
#include "DOMCoreClasses.h"
#include "MarshallingHelpers.h"
#include "SoftLinking.h"
#include "WebDatabaseManager.h"
#include "WebDocumentLoader.h"
#include "WebDownload.h"
......@@ -50,6 +51,7 @@
#include "WebMutableURLRequest.h"
#include "WebNotificationCenter.h"
#include "WebPreferences.h"
#include "WindowsTouch.h"
#pragma warning( push, 0 )
#include <WebCore/ApplicationCacheStorage.h>
#include <WebCore/AXObjectCache.h>
......@@ -96,6 +98,7 @@
#include <WebCore/ResourceHandle.h>
#include <WebCore/ResourceHandleClient.h>
#include <WebCore/ScriptValue.h>
#include <WebCore/Scrollbar.h>
#include <WebCore/ScrollbarTheme.h>
#include <WebCore/SecurityOrigin.h>
#include <WebCore/SelectionController.h>
......@@ -129,6 +132,16 @@
#include <tchar.h>
#include <windowsx.h>
// Soft link functions for gestures and panning feedback
SOFT_LINK_LIBRARY(USER32);
SOFT_LINK_OPTIONAL(USER32, GetGestureInfo, BOOL, WINAPI, (HGESTUREINFO, PGESTUREINFO));
SOFT_LINK_OPTIONAL(USER32, SetGestureConfig, BOOL, WINAPI, (HWND, DWORD, UINT, PGESTURECONFIG, UINT));
SOFT_LINK_OPTIONAL(USER32, CloseGestureInfoHandle, BOOL, WINAPI, (HGESTUREINFO));
SOFT_LINK_LIBRARY(Uxtheme);
SOFT_LINK_OPTIONAL(Uxtheme, BeginPanningFeedback, BOOL, WINAPI, (HWND));
SOFT_LINK_OPTIONAL(Uxtheme, EndPanningFeedback, BOOL, WINAPI, (HWND, BOOL));
SOFT_LINK_OPTIONAL(Uxtheme, UpdatePanningFeedback, BOOL, WINAPI, (HWND, LONG, LONG, BOOL));
using namespace WebCore;
using JSC::JSLock;
using std::min;
......@@ -299,6 +312,10 @@ WebView::WebView()
, m_deleteBackingStoreTimerActive(false)
, m_transparent(false)
, m_selectTrailingWhitespaceEnabled(false)
, m_lastPanX(0)
, m_lastPanY(0)
, m_xOverpan(0)
, m_yOverpan(0)
{
JSC::initializeThreading();
......@@ -1315,6 +1332,132 @@ bool WebView::handleMouseEvent(UINT message, WPARAM wParam, LPARAM lParam)
return handled;
}
bool WebView::gestureNotify(WPARAM wParam, LPARAM lParam)
{
GESTURENOTIFYSTRUCT* gn = reinterpret_cast<GESTURENOTIFYSTRUCT*>(lParam);
Frame* coreFrame = core(m_mainFrame);
if (!coreFrame)
return false;
ScrollView* view = coreFrame->view();
if (!view)
return false;
// If we don't have this function, we shouldn't be receiving this message
ASSERT(SetGestureConfigPtr());
DWORD dwPanWant;
DWORD dwPanBlock;
// Translate gesture location to client to hit test on scrollbars
POINT gestureBeginPoint = {gn->ptsLocation.x, gn->ptsLocation.y};
ScreenToClient(m_viewWindow, &gestureBeginPoint);
if (gestureBeginPoint.x > view->visibleWidth()) {
// We are in the scrollbar, turn off panning, need to be able to drag the scrollbar
dwPanWant = GC_PAN | GC_PAN_WITH_INERTIA | GC_PAN_WITH_GUTTER;
dwPanBlock = GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY | GC_PAN_WITH_SINGLE_FINGER_VERTICALLY;
} else {
dwPanWant = GC_PAN | GC_PAN_WITH_SINGLE_FINGER_VERTICALLY | GC_PAN_WITH_INERTIA | GC_PAN_WITH_GUTTER;
dwPanBlock = GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY;
}
GESTURECONFIG gc = { GID_PAN, dwPanWant , dwPanBlock } ;
return SetGestureConfigPtr()(m_viewWindow, 0, 1, &gc, sizeof(GESTURECONFIG));
}
bool WebView::gesture(WPARAM wParam, LPARAM lParam)
{
// We want to bail out if we don't have either of these functions
if (!GetGestureInfoPtr() || !CloseGestureInfoHandlePtr())
return false;
HGESTUREINFO gestureHandle = reinterpret_cast<HGESTUREINFO>(lParam);
GESTUREINFO gi = {0};
gi.cbSize = sizeof(GESTUREINFO);
if (!GetGestureInfoPtr()(gestureHandle, reinterpret_cast<PGESTUREINFO>(&gi)))
return false;
switch (gi.dwID) {
case GID_BEGIN:
m_lastPanX = gi.ptsLocation.x;
m_lastPanY = gi.ptsLocation.y;
CloseGestureInfoHandlePtr()(gestureHandle);
break;
case GID_PAN: {
Frame* coreFrame = core(m_mainFrame);
if (!coreFrame) {
CloseGestureInfoHandlePtr()(gestureHandle);
return false;
}
ScrollView* view = coreFrame->view();
if (!view) {
CloseGestureInfoHandlePtr()(gestureHandle);
return false;
}
Scrollbar* vertScrollbar = view->verticalScrollbar();
if (!vertScrollbar) {
CloseGestureInfoHandlePtr()(gestureHandle);
return true; //No panning of any kind when no vertical scrollbar, matches IE8
}
// Where are the fingers currently?
long currentX = gi.ptsLocation.x;
long currentY = gi.ptsLocation.y;
// How far did we pan in each direction?
long deltaX = currentX - m_lastPanX;
long deltaY = currentY - m_lastPanY;
// Calculate the overpan for window bounce
m_yOverpan -= m_lastPanY - currentY;
m_xOverpan -= m_lastPanX - currentX;
// Update our class variables with updated values
m_lastPanX = currentX;
m_lastPanY = currentY;
// Represent the pan gesture as a mouse wheel event
PlatformWheelEvent wheelEvent(m_viewWindow, deltaX, deltaY, currentX, currentY);
coreFrame->eventHandler()->handleWheelEvent(wheelEvent);
if (!(UpdatePanningFeedbackPtr() && BeginPanningFeedbackPtr() && EndPanningFeedbackPtr())) {
CloseGestureInfoHandlePtr()(gestureHandle);
return true;
}
// FIXME: Support Horizontal Window Bounce
if (vertScrollbar->currentPos() == 0)
UpdatePanningFeedbackPtr()(m_viewWindow, 0, m_yOverpan, gi.dwFlags & GF_INERTIA);
else if (vertScrollbar->currentPos() >= vertScrollbar->maximum())
UpdatePanningFeedbackPtr()(m_viewWindow, 0, m_yOverpan, gi.dwFlags & GF_INERTIA);
if (gi.dwFlags & GF_BEGIN) {
BeginPanningFeedbackPtr()(m_viewWindow);
m_yOverpan = 0;
} else if (gi.dwFlags & GF_END) {
EndPanningFeedbackPtr()(m_viewWindow, true);
m_yOverpan = 0;
}
CloseGestureInfoHandlePtr()(gestureHandle);
break;
}
default:
// We have encountered an unknown gesture - return false to pass it to DefWindowProc
CloseGestureInfoHandlePtr()(gestureHandle);
break;
}
return true;
}
bool WebView::mouseWheel(WPARAM wParam, LPARAM lParam, bool isMouseHWheel)
{
// Ctrl+Mouse wheel doesn't ever go into WebCore. It is used to
......@@ -1699,6 +1842,12 @@ static LRESULT CALLBACK WebViewWndProc(HWND hWnd, UINT message, WPARAM wParam, L
webView->setIsBeingDestroyed();
webView->revokeDragDrop();
break;
case WM_GESTURENOTIFY:
handled = webView->gestureNotify(wParam, lParam);
break;
case WM_GESTURE:
handled = webView->gesture(wParam, lParam);
break;
case WM_MOUSEMOVE:
case WM_LBUTTONDOWN:
case WM_MBUTTONDOWN:
......
......@@ -742,6 +742,8 @@ public:
bool onUninitMenuPopup(WPARAM, LPARAM);
void performContextMenuAction(WPARAM, LPARAM, bool byPosition);
bool mouseWheel(WPARAM, LPARAM, bool isMouseHWheel);
bool gesture(WPARAM, LPARAM);
bool gestureNotify(WPARAM, LPARAM);
bool execCommand(WPARAM wParam, LPARAM lParam);
bool keyDown(WPARAM, LPARAM, bool systemKeyDown = false);
bool keyUp(WPARAM, LPARAM, bool systemKeyDown = false);
......@@ -911,6 +913,12 @@ protected:
HWND m_topLevelParent;
OwnPtr<HashSet<WebCore::String> > m_embeddedViewMIMETypes;
//Variables needed to store gesture information
long m_lastPanX;
long m_lastPanY;
long m_xOverpan;
long m_yOverpan;
};
#endif
/*
* Copyright (C) 2009 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef WindowsTouch_h
#define WindowsTouch_h
/*
* The following constants are used to determine multitouch and gesture behavior
* for Windows 7. For more information, see:
* http://msdn.microsoft.com/en-us/library/dd562197(VS.85).aspx
*/
// Value used in WebViewWndProc for Gestures
#define WM_GESTURE 0x0119
#define WM_GESTURENOTIFY 0x011A
// Gesture Information Flags
#define GF_BEGIN 0x00000001
#define GF_INERTIA 0x00000002
#define GF_END 0x00000004
// Gesture IDs
#define GID_BEGIN 1
#define GID_END 2
#define GID_ZOOM 3
#define GID_PAN 4
#define GID_ROTATE 5
#define GID_TWOFINGERTAP 6
#define GID_PRESSANDTAP 7
#define GID_ROLLOVER GID_PRESSANDTAP
// Zoom Gesture Confiration Flags
#define GC_ZOOM 0x00000001
// Pan Gesture Configuration Flags
#define GC_PAN 0x00000001
#define GC_PAN_WITH_SINGLE_FINGER_VERTICALLY 0x00000002
#define GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY 0x00000004
#define GC_PAN_WITH_GUTTER 0x00000008
#define GC_PAN_WITH_INERTIA 0x00000010
// Rotate Gesture Configuration Flags
#define GC_ROTATE 0x00000001
// Two finger tap configuration flags
#define GC_TWOFINGERTAP 0x00000001
// Press and tap Configuration Flags
#define GC_PRESSANDTAP 0x00000001
#define GC_ROLLOVER GC_PRESSANDTAP
// GESTUREINFO struct definition
typedef struct tagGESTUREINFO {
UINT cbSize; // size, in bytes, of this structure (including variable length Args field)
DWORD dwFlags; // see GF_* flags
DWORD dwID; // gesture ID, see GID_* defines
HWND hwndTarget; // handle to window targeted by this gesture
POINTS ptsLocation; // current location of this gesture
DWORD dwInstanceID; // internally used
DWORD dwSequenceID; // internally used
ULONGLONG ullArguments; // arguments for gestures whose arguments fit in 8 BYTES
UINT cbExtraArgs; // size, in bytes, of extra arguments, if any, that accompany this gesture
} GESTUREINFO, *PGESTUREINFO;
typedef GESTUREINFO const * PCGESTUREINFO;
// GESTURECONFIG struct defintion
typedef struct tagGESTURECONFIG {
DWORD dwID; // gesture ID
DWORD dwWant; // settings related to gesture ID that are to be turned on
DWORD dwBlock; // settings related to gesture ID that are to be turned off
} GESTURECONFIG, *PGESTURECONFIG;
/*
* Gesture notification structure
* - The WM_GESTURENOTIFY message lParam contains a pointer to this structure.
* - The WM_GESTURENOTIFY message notifies a window that gesture recognition is
* in progress and a gesture will be generated if one is recognized under the
* current gesture settings.
*/
typedef struct tagGESTURENOTIFYSTRUCT {
UINT cbSize; // size, in bytes, of this structure
DWORD dwFlags; // unused
HWND hwndTarget; // handle to window targeted by the gesture
POINTS ptsLocation; // starting location
DWORD dwInstanceID; // internally used
} GESTURENOTIFYSTRUCT, *PGESTURENOTIFYSTRUCT;
DECLARE_HANDLE(HGESTUREINFO);
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment