2009-04-02 23:34:31 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2009-04-02 23:34:31 +04:00
|
|
|
|
2009-06-30 10:00:16 +04:00
|
|
|
/*
|
|
|
|
* nsWinGesture - Touch input handling for tablet displays.
|
|
|
|
*/
|
2009-04-02 23:34:31 +04:00
|
|
|
|
|
|
|
#include "nscore.h"
|
|
|
|
#include "nsWinGesture.h"
|
2010-08-14 11:05:03 +04:00
|
|
|
#include "nsUXThemeData.h"
|
2009-04-02 23:34:31 +04:00
|
|
|
#include "nsIDOMSimpleGestureEvent.h"
|
2012-08-12 05:42:37 +04:00
|
|
|
#include "nsIDOMWheelEvent.h"
|
2016-12-01 06:48:32 +03:00
|
|
|
#include "mozilla/Logging.h"
|
2013-09-25 15:21:18 +04:00
|
|
|
#include "mozilla/MouseEvents.h"
|
2011-05-27 12:15:20 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2013-09-25 15:21:16 +04:00
|
|
|
#include "mozilla/TouchEvents.h"
|
2011-05-27 12:15:20 +04:00
|
|
|
|
2015-11-28 07:49:55 +03:00
|
|
|
#include <cmath>
|
|
|
|
|
2011-05-27 12:15:20 +04:00
|
|
|
using namespace mozilla;
|
2012-08-12 05:42:37 +04:00
|
|
|
using namespace mozilla::widget;
|
2009-04-02 23:34:31 +04:00
|
|
|
|
2016-12-01 06:48:32 +03:00
|
|
|
extern mozilla::LazyLogModule gWindowsLog;
|
2011-08-16 23:30:44 +04:00
|
|
|
|
2010-08-02 17:34:54 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool gEnableSingleFingerPanEvents = false;
|
2009-04-02 23:34:31 +04:00
|
|
|
|
|
|
|
nsWinGesture::nsWinGesture() :
|
2011-10-02 06:16:19 +04:00
|
|
|
mPanActive(false),
|
|
|
|
mFeedbackActive(false),
|
|
|
|
mXAxisFeedback(false),
|
|
|
|
mYAxisFeedback(false),
|
|
|
|
mPanInertiaActive(false)
|
2009-04-02 23:34:31 +04:00
|
|
|
{
|
|
|
|
(void)InitLibrary();
|
2009-05-20 06:05:59 +04:00
|
|
|
mPixelScrollOverflow = 0;
|
2009-04-02 23:34:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Load and shutdown */
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool nsWinGesture::InitLibrary()
|
2009-04-02 23:34:31 +04:00
|
|
|
{
|
|
|
|
// Check to see if we want single finger gesture input. Only do this once
|
|
|
|
// for the app so we don't have to look it up on every window create.
|
2011-05-27 12:15:20 +04:00
|
|
|
gEnableSingleFingerPanEvents =
|
2011-09-29 10:19:26 +04:00
|
|
|
Preferences::GetBool("gestures.enable_single_finger_input", false);
|
2009-04-02 23:34:31 +04:00
|
|
|
|
2011-10-02 06:16:19 +04:00
|
|
|
return true;
|
2009-04-02 23:34:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#define GCOUNT 5
|
|
|
|
|
2013-09-27 10:20:57 +04:00
|
|
|
bool nsWinGesture::SetWinGestureSupport(HWND hWnd,
|
2016-04-22 05:32:59 +03:00
|
|
|
WidgetGestureNotifyEvent::PanDirection aDirection)
|
2009-04-02 23:34:31 +04:00
|
|
|
{
|
|
|
|
GESTURECONFIG config[GCOUNT];
|
|
|
|
|
|
|
|
memset(&config, 0, sizeof(config));
|
|
|
|
|
|
|
|
config[0].dwID = GID_ZOOM;
|
|
|
|
config[0].dwWant = GC_ZOOM;
|
|
|
|
config[0].dwBlock = 0;
|
|
|
|
|
|
|
|
config[1].dwID = GID_ROTATE;
|
|
|
|
config[1].dwWant = GC_ROTATE;
|
|
|
|
config[1].dwBlock = 0;
|
|
|
|
|
|
|
|
config[2].dwID = GID_PAN;
|
2009-08-14 00:54:09 +04:00
|
|
|
config[2].dwWant = GC_PAN|GC_PAN_WITH_INERTIA|
|
|
|
|
GC_PAN_WITH_GUTTER;
|
|
|
|
config[2].dwBlock = GC_PAN_WITH_SINGLE_FINGER_VERTICALLY|
|
|
|
|
GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY;
|
|
|
|
|
2009-04-02 23:34:31 +04:00
|
|
|
if (gEnableSingleFingerPanEvents) {
|
2009-08-14 00:54:09 +04:00
|
|
|
|
2013-09-27 10:20:57 +04:00
|
|
|
if (aDirection == WidgetGestureNotifyEvent::ePanVertical ||
|
|
|
|
aDirection == WidgetGestureNotifyEvent::ePanBoth)
|
2009-08-14 00:54:09 +04:00
|
|
|
{
|
|
|
|
config[2].dwWant |= GC_PAN_WITH_SINGLE_FINGER_VERTICALLY;
|
|
|
|
config[2].dwBlock -= GC_PAN_WITH_SINGLE_FINGER_VERTICALLY;
|
|
|
|
}
|
|
|
|
|
2013-09-27 10:20:57 +04:00
|
|
|
if (aDirection == WidgetGestureNotifyEvent::ePanHorizontal ||
|
|
|
|
aDirection == WidgetGestureNotifyEvent::ePanBoth)
|
2009-08-14 00:54:09 +04:00
|
|
|
{
|
|
|
|
config[2].dwWant |= GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY;
|
|
|
|
config[2].dwBlock -= GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY;
|
|
|
|
}
|
|
|
|
|
2009-04-02 23:34:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
config[3].dwWant = GC_TWOFINGERTAP;
|
|
|
|
config[3].dwID = GID_TWOFINGERTAP;
|
|
|
|
config[3].dwBlock = 0;
|
|
|
|
|
2009-05-20 06:05:59 +04:00
|
|
|
config[4].dwWant = GC_PRESSANDTAP;
|
|
|
|
config[4].dwID = GID_PRESSANDTAP;
|
2009-04-02 23:34:31 +04:00
|
|
|
config[4].dwBlock = 0;
|
|
|
|
|
2017-08-18 03:47:36 +03:00
|
|
|
return SetGestureConfig(hWnd, 0, GCOUNT, (PGESTURECONFIG)&config,
|
|
|
|
sizeof(GESTURECONFIG));
|
2009-04-02 23:34:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Helpers */
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool nsWinGesture::IsPanEvent(LPARAM lParam)
|
2009-04-02 23:34:31 +04:00
|
|
|
{
|
|
|
|
GESTUREINFO gi;
|
|
|
|
|
|
|
|
ZeroMemory(&gi,sizeof(GESTUREINFO));
|
|
|
|
gi.cbSize = sizeof(GESTUREINFO);
|
|
|
|
|
|
|
|
BOOL result = GetGestureInfo((HGESTUREINFO)lParam, &gi);
|
|
|
|
if (!result)
|
2011-10-02 06:16:19 +04:00
|
|
|
return false;
|
2009-04-02 23:34:31 +04:00
|
|
|
|
|
|
|
if (gi.dwID == GID_PAN)
|
2011-10-02 06:16:19 +04:00
|
|
|
return true;
|
2009-04-02 23:34:31 +04:00
|
|
|
|
2011-10-02 06:16:19 +04:00
|
|
|
return false;
|
2009-04-02 23:34:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Gesture event processing */
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2013-09-27 10:20:57 +04:00
|
|
|
nsWinGesture::ProcessGestureMessage(HWND hWnd, WPARAM wParam, LPARAM lParam,
|
|
|
|
WidgetSimpleGestureEvent& evt)
|
2009-04-02 23:34:31 +04:00
|
|
|
{
|
|
|
|
GESTUREINFO gi;
|
|
|
|
|
|
|
|
ZeroMemory(&gi,sizeof(GESTUREINFO));
|
|
|
|
gi.cbSize = sizeof(GESTUREINFO);
|
|
|
|
|
|
|
|
BOOL result = GetGestureInfo((HGESTUREINFO)lParam, &gi);
|
|
|
|
if (!result)
|
2011-10-02 06:16:19 +04:00
|
|
|
return false;
|
2009-04-02 23:34:31 +04:00
|
|
|
|
|
|
|
// The coordinates of this event
|
|
|
|
nsPointWin coord;
|
|
|
|
coord = gi.ptsLocation;
|
|
|
|
coord.ScreenToClient(hWnd);
|
|
|
|
|
2016-04-18 17:09:02 +03:00
|
|
|
evt.mRefPoint = LayoutDeviceIntPoint(coord.x, coord.y);
|
2009-04-02 23:34:31 +04:00
|
|
|
|
|
|
|
// Multiple gesture can occur at the same time so gesture state
|
|
|
|
// info can't be shared.
|
|
|
|
switch(gi.dwID)
|
|
|
|
{
|
|
|
|
case GID_BEGIN:
|
|
|
|
case GID_END:
|
|
|
|
// These should always fall through to DefWndProc
|
2011-10-02 06:16:19 +04:00
|
|
|
return false;
|
2009-04-02 23:34:31 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GID_ZOOM:
|
|
|
|
{
|
|
|
|
if (gi.dwFlags & GF_BEGIN) {
|
|
|
|
// Send a zoom start event
|
|
|
|
|
|
|
|
// The low 32 bits are the distance in pixels.
|
|
|
|
mZoomIntermediate = (float)gi.ullArguments;
|
|
|
|
|
2015-09-14 18:14:37 +03:00
|
|
|
evt.mMessage = eMagnifyGestureStart;
|
2016-05-09 22:16:55 +03:00
|
|
|
evt.mDelta = 0.0;
|
2009-04-02 23:34:31 +04:00
|
|
|
}
|
2013-03-22 23:23:53 +04:00
|
|
|
else if (gi.dwFlags & GF_END) {
|
|
|
|
// Send a zoom end event, the delta is the change
|
|
|
|
// in touch points.
|
2015-09-14 18:14:37 +03:00
|
|
|
evt.mMessage = eMagnifyGesture;
|
2013-03-22 23:23:53 +04:00
|
|
|
// (positive for a "zoom in")
|
2016-05-09 22:16:55 +03:00
|
|
|
evt.mDelta = -1.0 * (mZoomIntermediate - (float)gi.ullArguments);
|
2013-03-22 23:23:53 +04:00
|
|
|
mZoomIntermediate = (float)gi.ullArguments;
|
|
|
|
}
|
2009-04-02 23:34:31 +04:00
|
|
|
else {
|
2013-03-22 23:23:53 +04:00
|
|
|
// Send a zoom intermediate event, the delta is the change
|
2009-04-02 23:34:31 +04:00
|
|
|
// in touch points.
|
2015-09-14 18:14:37 +03:00
|
|
|
evt.mMessage = eMagnifyGestureUpdate;
|
2009-04-02 23:34:31 +04:00
|
|
|
// (positive for a "zoom in")
|
2016-05-09 22:16:55 +03:00
|
|
|
evt.mDelta = -1.0 * (mZoomIntermediate - (float)gi.ullArguments);
|
2009-04-02 23:34:31 +04:00
|
|
|
mZoomIntermediate = (float)gi.ullArguments;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GID_ROTATE:
|
|
|
|
{
|
|
|
|
// Send a rotate start event
|
|
|
|
double radians = 0.0;
|
|
|
|
|
|
|
|
// On GF_BEGIN, ullArguments contains the absolute rotation at the
|
|
|
|
// start of the gesture. In later events it contains the offset from
|
|
|
|
// the start angle.
|
|
|
|
if (gi.ullArguments != 0)
|
|
|
|
radians = GID_ROTATE_ANGLE_FROM_ARGUMENT(gi.ullArguments);
|
|
|
|
|
|
|
|
double degrees = -1 * radians * (180/M_PI);
|
|
|
|
|
|
|
|
if (gi.dwFlags & GF_BEGIN) {
|
|
|
|
// At some point we should pass the initial angle in
|
|
|
|
// along with delta. It's useful.
|
|
|
|
degrees = mRotateIntermediate = 0.0;
|
|
|
|
}
|
|
|
|
|
2016-05-09 22:16:54 +03:00
|
|
|
evt.mDirection = 0;
|
2016-05-09 22:16:55 +03:00
|
|
|
evt.mDelta = degrees - mRotateIntermediate;
|
2009-04-02 23:34:31 +04:00
|
|
|
mRotateIntermediate = degrees;
|
|
|
|
|
2016-05-09 22:16:55 +03:00
|
|
|
if (evt.mDelta > 0)
|
2016-05-09 22:16:54 +03:00
|
|
|
evt.mDirection = nsIDOMSimpleGestureEvent::ROTATION_COUNTERCLOCKWISE;
|
2016-05-09 22:16:55 +03:00
|
|
|
else if (evt.mDelta < 0)
|
2016-05-09 22:16:54 +03:00
|
|
|
evt.mDirection = nsIDOMSimpleGestureEvent::ROTATION_CLOCKWISE;
|
2009-04-02 23:34:31 +04:00
|
|
|
|
2015-09-14 18:14:37 +03:00
|
|
|
if (gi.dwFlags & GF_BEGIN) {
|
|
|
|
evt.mMessage = eRotateGestureStart;
|
|
|
|
} else if (gi.dwFlags & GF_END) {
|
2015-09-14 18:14:36 +03:00
|
|
|
evt.mMessage = eRotateGesture;
|
2015-09-14 18:14:36 +03:00
|
|
|
} else {
|
|
|
|
evt.mMessage = eRotateGestureUpdate;
|
|
|
|
}
|
2009-04-02 23:34:31 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GID_TWOFINGERTAP:
|
2015-09-14 18:14:36 +03:00
|
|
|
// Normally maps to "restore" from whatever you may have recently changed.
|
|
|
|
// A simple double click.
|
|
|
|
evt.mMessage = eTapGesture;
|
2016-05-09 22:16:54 +03:00
|
|
|
evt.mClickCount = 1;
|
2015-09-14 18:14:36 +03:00
|
|
|
break;
|
2009-04-02 23:34:31 +04:00
|
|
|
|
2009-05-20 06:05:59 +04:00
|
|
|
case GID_PRESSANDTAP:
|
|
|
|
// Two finger right click. Defaults to right click if it falls through.
|
2015-09-14 18:14:36 +03:00
|
|
|
evt.mMessage = ePressTapGesture;
|
2016-05-09 22:16:54 +03:00
|
|
|
evt.mClickCount = 1;
|
2015-09-14 18:14:36 +03:00
|
|
|
break;
|
2009-04-02 23:34:31 +04:00
|
|
|
}
|
|
|
|
|
2011-10-02 06:16:19 +04:00
|
|
|
return true;
|
2009-04-02 23:34:31 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2009-04-02 23:34:31 +04:00
|
|
|
nsWinGesture::ProcessPanMessage(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
GESTUREINFO gi;
|
|
|
|
|
|
|
|
ZeroMemory(&gi,sizeof(GESTUREINFO));
|
|
|
|
gi.cbSize = sizeof(GESTUREINFO);
|
|
|
|
|
|
|
|
BOOL result = GetGestureInfo((HGESTUREINFO)lParam, &gi);
|
|
|
|
if (!result)
|
2011-10-02 06:16:19 +04:00
|
|
|
return false;
|
2009-04-02 23:34:31 +04:00
|
|
|
|
|
|
|
// The coordinates of this event
|
|
|
|
nsPointWin coord;
|
2009-05-20 06:05:59 +04:00
|
|
|
coord = mPanRefPoint = gi.ptsLocation;
|
|
|
|
// We want screen coordinates in our local offsets as client coordinates will change
|
|
|
|
// when feedback is taking place. Gui events though require client coordinates.
|
|
|
|
mPanRefPoint.ScreenToClient(hWnd);
|
2009-04-02 23:34:31 +04:00
|
|
|
|
|
|
|
switch(gi.dwID)
|
|
|
|
{
|
|
|
|
case GID_BEGIN:
|
|
|
|
case GID_END:
|
|
|
|
// These should always fall through to DefWndProc
|
2011-10-02 06:16:19 +04:00
|
|
|
return false;
|
2009-04-02 23:34:31 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
// Setup pixel scroll events for both axis
|
|
|
|
case GID_PAN:
|
|
|
|
{
|
|
|
|
if (gi.dwFlags & GF_BEGIN) {
|
|
|
|
mPanIntermediate = coord;
|
|
|
|
mPixelScrollDelta = 0;
|
2011-10-02 06:16:19 +04:00
|
|
|
mPanActive = true;
|
|
|
|
mPanInertiaActive = false;
|
2009-05-20 06:05:59 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
#ifdef DBG_jimm
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t deltaX = mPanIntermediate.x - coord.x;
|
|
|
|
int32_t deltaY = mPanIntermediate.y - coord.y;
|
2015-06-04 01:25:57 +03:00
|
|
|
MOZ_LOG(gWindowsLog, LogLevel::Info,
|
2011-08-16 23:30:44 +04:00
|
|
|
("coordX=%d coordY=%d deltaX=%d deltaY=%d x:%d y:%d\n", coord.x,
|
|
|
|
coord.y, deltaX, deltaY, mXAxisFeedback, mYAxisFeedback));
|
2009-05-20 06:05:59 +04:00
|
|
|
#endif
|
|
|
|
|
2009-04-02 23:34:31 +04:00
|
|
|
mPixelScrollDelta.x = mPanIntermediate.x - coord.x;
|
|
|
|
mPixelScrollDelta.y = mPanIntermediate.y - coord.y;
|
|
|
|
mPanIntermediate = coord;
|
2009-05-20 06:05:59 +04:00
|
|
|
|
|
|
|
if (gi.dwFlags & GF_INERTIA)
|
2011-10-02 06:16:19 +04:00
|
|
|
mPanInertiaActive = true;
|
2009-05-20 06:05:59 +04:00
|
|
|
|
|
|
|
if (gi.dwFlags & GF_END) {
|
2011-10-02 06:16:19 +04:00
|
|
|
mPanActive = false;
|
|
|
|
mPanInertiaActive = false;
|
|
|
|
PanFeedbackFinalize(hWnd, true);
|
2009-05-20 06:05:59 +04:00
|
|
|
}
|
2009-04-02 23:34:31 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2011-10-02 06:16:19 +04:00
|
|
|
return true;
|
2009-04-02 23:34:31 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
inline bool TestTransition(int32_t a, int32_t b)
|
2009-05-20 06:05:59 +04:00
|
|
|
{
|
|
|
|
// If a is zero, overflow is zero, implying the cursor has moved back to the start position.
|
|
|
|
// If b is zero, cached overscroll is zero, implying feedback just begun.
|
2011-10-02 06:16:19 +04:00
|
|
|
if (a == 0 || b == 0) return true;
|
2009-05-20 06:05:59 +04:00
|
|
|
// Test for different signs.
|
|
|
|
return (a < 0) == (b < 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsWinGesture::UpdatePanFeedbackX(HWND hWnd, int32_t scrollOverflow, bool& endFeedback)
|
2009-05-20 06:05:59 +04:00
|
|
|
{
|
|
|
|
// If scroll overflow was returned indicating we panned past the bounds of
|
|
|
|
// the scrollable view port, start feeback.
|
2009-07-30 10:01:27 +04:00
|
|
|
if (scrollOverflow != 0) {
|
2009-05-20 06:05:59 +04:00
|
|
|
if (!mFeedbackActive) {
|
|
|
|
BeginPanningFeedback(hWnd);
|
2011-10-02 06:16:19 +04:00
|
|
|
mFeedbackActive = true;
|
2009-05-20 06:05:59 +04:00
|
|
|
}
|
2011-10-02 06:16:19 +04:00
|
|
|
endFeedback = false;
|
|
|
|
mXAxisFeedback = true;
|
2009-05-20 06:05:59 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mXAxisFeedback) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t newOverflow = mPixelScrollOverflow.x - mPixelScrollDelta.x;
|
2009-05-20 06:05:59 +04:00
|
|
|
|
|
|
|
// Detect a reverse transition past the starting drag point. This tells us the user
|
|
|
|
// has panned all the way back so we can stop providing feedback for this axis.
|
|
|
|
if (!TestTransition(newOverflow, mPixelScrollOverflow.x) || newOverflow == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Cache the total over scroll in pixels.
|
|
|
|
mPixelScrollOverflow.x = newOverflow;
|
2011-10-02 06:16:19 +04:00
|
|
|
endFeedback = false;
|
2009-05-20 06:05:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsWinGesture::UpdatePanFeedbackY(HWND hWnd, int32_t scrollOverflow, bool& endFeedback)
|
2009-05-20 06:05:59 +04:00
|
|
|
{
|
|
|
|
// If scroll overflow was returned indicating we panned past the bounds of
|
|
|
|
// the scrollable view port, start feeback.
|
2009-07-30 10:01:27 +04:00
|
|
|
if (scrollOverflow != 0) {
|
2009-05-20 06:05:59 +04:00
|
|
|
if (!mFeedbackActive) {
|
|
|
|
BeginPanningFeedback(hWnd);
|
2011-10-02 06:16:19 +04:00
|
|
|
mFeedbackActive = true;
|
2009-05-20 06:05:59 +04:00
|
|
|
}
|
2011-10-02 06:16:19 +04:00
|
|
|
endFeedback = false;
|
|
|
|
mYAxisFeedback = true;
|
2009-05-20 06:05:59 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mYAxisFeedback) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t newOverflow = mPixelScrollOverflow.y - mPixelScrollDelta.y;
|
2009-05-20 06:05:59 +04:00
|
|
|
|
|
|
|
// Detect a reverse transition past the starting drag point. This tells us the user
|
|
|
|
// has panned all the way back so we can stop providing feedback for this axis.
|
|
|
|
if (!TestTransition(newOverflow, mPixelScrollOverflow.y) || newOverflow == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Cache the total over scroll in pixels.
|
|
|
|
mPixelScrollOverflow.y = newOverflow;
|
2011-10-02 06:16:19 +04:00
|
|
|
endFeedback = false;
|
2009-05-20 06:05:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-09-29 10:19:26 +04:00
|
|
|
nsWinGesture::PanFeedbackFinalize(HWND hWnd, bool endFeedback)
|
2009-05-20 06:05:59 +04:00
|
|
|
{
|
|
|
|
if (!mFeedbackActive)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (endFeedback) {
|
2011-10-02 06:16:19 +04:00
|
|
|
mFeedbackActive = false;
|
|
|
|
mXAxisFeedback = false;
|
|
|
|
mYAxisFeedback = false;
|
2009-05-20 06:05:59 +04:00
|
|
|
mPixelScrollOverflow = 0;
|
2017-08-18 03:47:36 +03:00
|
|
|
EndPanningFeedback(hWnd, TRUE);
|
2009-05-20 06:05:59 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdatePanningFeedback(hWnd, mPixelScrollOverflow.x, mPixelScrollOverflow.y, mPanInertiaActive);
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2013-10-16 13:37:36 +04:00
|
|
|
nsWinGesture::PanDeltaToPixelScroll(WidgetWheelEvent& aWheelEvent)
|
2009-04-02 23:34:31 +04:00
|
|
|
{
|
2016-03-31 12:18:34 +03:00
|
|
|
aWheelEvent.mDeltaX = aWheelEvent.mDeltaY = aWheelEvent.mDeltaZ = 0.0;
|
2016-03-31 18:10:09 +03:00
|
|
|
aWheelEvent.mLineOrPageDeltaX = aWheelEvent.mLineOrPageDeltaY = 0;
|
2009-05-20 06:05:59 +04:00
|
|
|
|
2016-04-18 17:09:02 +03:00
|
|
|
aWheelEvent.mRefPoint = LayoutDeviceIntPoint(mPanRefPoint.x, mPanRefPoint.y);
|
2016-03-31 12:35:24 +03:00
|
|
|
aWheelEvent.mDeltaMode = nsIDOMWheelEvent::DOM_DELTA_PIXEL;
|
2016-03-31 17:54:42 +03:00
|
|
|
aWheelEvent.mScrollType = WidgetWheelEvent::SCROLL_SYNCHRONOUSLY;
|
2014-07-07 13:54:14 +04:00
|
|
|
aWheelEvent.mIsNoLineOrPageDelta = true;
|
2009-05-20 06:05:59 +04:00
|
|
|
|
2016-03-31 18:27:45 +03:00
|
|
|
aWheelEvent.mOverflowDeltaX = 0.0;
|
2016-03-31 18:36:55 +03:00
|
|
|
aWheelEvent.mOverflowDeltaY = 0.0;
|
2009-05-20 06:05:59 +04:00
|
|
|
|
|
|
|
// Don't scroll the view if we are currently at a bounds, or, if we are
|
|
|
|
// panning back from a max feedback position. This keeps the original drag point
|
|
|
|
// constant.
|
2012-08-12 05:42:37 +04:00
|
|
|
if (!mXAxisFeedback) {
|
2016-03-31 12:55:59 +03:00
|
|
|
aWheelEvent.mDeltaX = mPixelScrollDelta.x;
|
2009-04-02 23:34:31 +04:00
|
|
|
}
|
2012-08-12 05:42:37 +04:00
|
|
|
if (!mYAxisFeedback) {
|
2016-03-31 12:09:47 +03:00
|
|
|
aWheelEvent.mDeltaY = mPixelScrollDelta.y;
|
2012-08-12 05:42:37 +04:00
|
|
|
}
|
|
|
|
|
2016-03-31 12:09:47 +03:00
|
|
|
return (aWheelEvent.mDeltaX != 0 || aWheelEvent.mDeltaY != 0);
|
2009-07-18 00:57:05 +04:00
|
|
|
}
|