2012-03-06 07:20:28 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_widget_WinMouseScrollHandler_h__
|
|
|
|
#define mozilla_widget_WinMouseScrollHandler_h__
|
|
|
|
|
|
|
|
#include "nscore.h"
|
|
|
|
#include "nsDebug.h"
|
|
|
|
#include "mozilla/Assertions.h"
|
2013-09-24 14:04:14 +04:00
|
|
|
#include "mozilla/EventForwards.h"
|
2012-03-06 07:20:28 +04:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2015-02-15 21:52:28 +03:00
|
|
|
#include "Units.h"
|
2012-03-06 07:20:28 +04:00
|
|
|
#include <windows.h>
|
2015-04-21 18:04:57 +03:00
|
|
|
#include "nsPoint.h"
|
2012-03-06 07:20:28 +04:00
|
|
|
|
2013-08-09 14:12:38 +04:00
|
|
|
class nsWindowBase;
|
2012-03-06 07:20:28 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace widget {
|
|
|
|
|
2012-06-15 13:52:50 +04:00
|
|
|
class ModifierKeyState;
|
|
|
|
|
2013-07-18 12:12:31 +04:00
|
|
|
struct MSGResult;
|
|
|
|
|
2012-03-06 07:20:28 +04:00
|
|
|
class MouseScrollHandler {
|
|
|
|
public:
|
|
|
|
static MouseScrollHandler* GetInstance();
|
|
|
|
|
|
|
|
static void Initialize();
|
|
|
|
static void Shutdown();
|
|
|
|
|
2013-09-06 17:11:15 +04:00
|
|
|
static bool NeedsMessage(UINT aMsg);
|
2013-08-09 14:12:38 +04:00
|
|
|
static bool ProcessMessage(nsWindowBase* aWidget,
|
2012-03-06 07:20:28 +04:00
|
|
|
UINT msg,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam,
|
2013-07-18 12:12:31 +04:00
|
|
|
MSGResult& aResult);
|
2012-03-06 07:20:28 +04:00
|
|
|
|
2012-03-22 04:59:12 +04:00
|
|
|
/**
|
|
|
|
* See nsIWidget::SynthesizeNativeMouseScrollEvent() for the detail about
|
|
|
|
* this method.
|
|
|
|
*/
|
2013-08-09 14:12:38 +04:00
|
|
|
static nsresult SynthesizeNativeMouseScrollEvent(nsWindowBase* aWidget,
|
2015-02-15 21:52:28 +03:00
|
|
|
const LayoutDeviceIntPoint& aPoint,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aNativeMessage,
|
|
|
|
int32_t aDelta,
|
|
|
|
uint32_t aModifierFlags,
|
|
|
|
uint32_t aAdditionalFlags);
|
2012-03-22 04:59:12 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* IsWaitingInternalMessage() returns true if MouseScrollHandler posted
|
|
|
|
* an internal message for a native mouse wheel message and has not
|
|
|
|
* received it. Otherwise, false.
|
|
|
|
*/
|
|
|
|
static bool IsWaitingInternalMessage()
|
|
|
|
{
|
|
|
|
return sInstance && sInstance->mIsWaitingInternalMessage;
|
|
|
|
}
|
|
|
|
|
2012-03-06 07:20:28 +04:00
|
|
|
private:
|
|
|
|
MouseScrollHandler();
|
|
|
|
~MouseScrollHandler();
|
|
|
|
|
2012-03-22 04:59:12 +04:00
|
|
|
bool mIsWaitingInternalMessage;
|
|
|
|
|
2012-03-06 07:20:28 +04:00
|
|
|
static MouseScrollHandler* sInstance;
|
2012-03-06 07:20:28 +04:00
|
|
|
|
2012-03-22 04:59:12 +04:00
|
|
|
/**
|
|
|
|
* InitEvent() initializes the aEvent. If aPoint is null, the result of
|
|
|
|
* GetCurrentMessagePos() will be used.
|
|
|
|
*/
|
2013-08-09 14:12:38 +04:00
|
|
|
static void InitEvent(nsWindowBase* aWidget,
|
2013-10-02 07:46:03 +04:00
|
|
|
WidgetGUIEvent& aEvent,
|
2015-11-10 08:37:32 +03:00
|
|
|
LayoutDeviceIntPoint* aPoint = nullptr);
|
2012-03-22 04:59:12 +04:00
|
|
|
|
2012-03-06 07:20:29 +04:00
|
|
|
/**
|
|
|
|
* GetModifierKeyState() returns current modifier key state.
|
|
|
|
* Note that some devices need some hack for the modifier key state.
|
|
|
|
* This method does it automatically.
|
2012-03-06 07:20:29 +04:00
|
|
|
*
|
|
|
|
* @param aMessage Handling message.
|
2012-03-06 07:20:29 +04:00
|
|
|
*/
|
2012-06-15 13:52:50 +04:00
|
|
|
static ModifierKeyState GetModifierKeyState(UINT aMessage);
|
2012-03-06 07:20:29 +04:00
|
|
|
|
2012-03-22 04:59:12 +04:00
|
|
|
/**
|
|
|
|
* MozGetMessagePos() returns the mouse cursor position when GetMessage()
|
|
|
|
* was called last time. However, if we're sending a native message,
|
|
|
|
* this returns the specified cursor position by
|
|
|
|
* SynthesizeNativeMouseScrollEvent().
|
|
|
|
*/
|
|
|
|
static POINTS GetCurrentMessagePos();
|
|
|
|
|
2012-03-06 07:20:29 +04:00
|
|
|
/**
|
|
|
|
* ProcessNativeMouseWheelMessage() processes WM_MOUSEWHEEL and
|
|
|
|
* WM_MOUSEHWHEEL. Additionally, processes WM_VSCROLL and WM_HSCROLL if they
|
|
|
|
* should be processed as mouse wheel message.
|
|
|
|
* This method posts MOZ_WM_MOUSEVWHEEL, MOZ_WM_MOUSEHWHEEL,
|
|
|
|
* MOZ_WM_VSCROLL or MOZ_WM_HSCROLL if we need to dispatch mouse scroll
|
|
|
|
* events. That avoids deadlock with plugin process.
|
|
|
|
*
|
2013-08-09 14:12:38 +04:00
|
|
|
* @param aWidget A window which receives the message.
|
2012-03-06 07:20:29 +04:00
|
|
|
* @param aMessage WM_MOUSEWHEEL, WM_MOUSEHWHEEL, WM_VSCROLL or
|
|
|
|
* WM_HSCROLL.
|
|
|
|
* @param aWParam The wParam value of the message.
|
|
|
|
* @param aLParam The lParam value of the message.
|
|
|
|
*/
|
2013-08-09 14:12:38 +04:00
|
|
|
void ProcessNativeMouseWheelMessage(nsWindowBase* aWidget,
|
2012-03-06 07:20:29 +04:00
|
|
|
UINT aMessage,
|
|
|
|
WPARAM aWParam,
|
|
|
|
LPARAM aLParam);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ProcessNativeScrollMessage() processes WM_VSCROLL and WM_HSCROLL.
|
|
|
|
* This method just call ProcessMouseWheelMessage() if the message should be
|
|
|
|
* processed as mouse wheel message. Otherwise, dispatches a content
|
|
|
|
* command event.
|
|
|
|
*
|
2013-08-09 14:12:38 +04:00
|
|
|
* @param aWidget A window which receives the message.
|
2012-03-06 07:20:29 +04:00
|
|
|
* @param aMessage WM_VSCROLL or WM_HSCROLL.
|
|
|
|
* @param aWParam The wParam value of the message.
|
|
|
|
* @param aLParam The lParam value of the message.
|
|
|
|
* @return TRUE if the message is processed. Otherwise, FALSE.
|
|
|
|
*/
|
2013-08-09 14:12:38 +04:00
|
|
|
bool ProcessNativeScrollMessage(nsWindowBase* aWidget,
|
2012-03-06 07:20:29 +04:00
|
|
|
UINT aMessage,
|
|
|
|
WPARAM aWParam,
|
|
|
|
LPARAM aLParam);
|
|
|
|
|
2012-03-06 07:20:29 +04:00
|
|
|
/**
|
|
|
|
* HandleMouseWheelMessage() processes MOZ_WM_MOUSEVWHEEL and
|
|
|
|
* MOZ_WM_MOUSEHWHEEL which are posted when one of our windows received
|
|
|
|
* WM_MOUSEWHEEL or WM_MOUSEHWHEEL for avoiding deadlock with OOPP.
|
|
|
|
*
|
2013-08-09 14:12:38 +04:00
|
|
|
* @param aWidget A window which receives the wheel message.
|
2012-03-06 07:20:29 +04:00
|
|
|
* @param aMessage MOZ_WM_MOUSEWHEEL or MOZ_WM_MOUSEHWHEEL.
|
|
|
|
* @param aWParam The wParam value of the original message.
|
|
|
|
* @param aLParam The lParam value of the original message.
|
|
|
|
*/
|
2013-08-09 14:12:38 +04:00
|
|
|
void HandleMouseWheelMessage(nsWindowBase* aWidget,
|
2012-03-06 07:20:29 +04:00
|
|
|
UINT aMessage,
|
|
|
|
WPARAM aWParam,
|
|
|
|
LPARAM aLParam);
|
2012-03-06 07:20:29 +04:00
|
|
|
|
2012-03-06 07:20:29 +04:00
|
|
|
/**
|
|
|
|
* HandleScrollMessageAsMouseWheelMessage() processes the MOZ_WM_VSCROLL and
|
|
|
|
* MOZ_WM_HSCROLL which are posted when one of mouse windows received
|
|
|
|
* WM_VSCROLL or WM_HSCROLL and user wants them to emulate mouse wheel
|
|
|
|
* message's behavior.
|
|
|
|
*
|
2013-08-09 14:12:38 +04:00
|
|
|
* @param aWidget A window which receives the scroll message.
|
2012-03-06 07:20:29 +04:00
|
|
|
* @param aMessage MOZ_WM_VSCROLL or MOZ_WM_HSCROLL.
|
|
|
|
* @param aWParam The wParam value of the original message.
|
|
|
|
* @param aLParam The lParam value of the original message.
|
|
|
|
*/
|
2013-08-09 14:12:38 +04:00
|
|
|
void HandleScrollMessageAsMouseWheelMessage(nsWindowBase* aWidget,
|
2012-03-06 07:20:29 +04:00
|
|
|
UINT aMessage,
|
|
|
|
WPARAM aWParam,
|
|
|
|
LPARAM aLParam);
|
|
|
|
|
2012-03-06 07:20:29 +04:00
|
|
|
/**
|
|
|
|
* ComputeMessagePos() computes the cursor position when the message was
|
|
|
|
* added to the queue.
|
|
|
|
*
|
|
|
|
* @param aMessage Handling message.
|
|
|
|
* @param aWParam Handling message's wParam.
|
|
|
|
* @param aLParam Handling message's lParam.
|
|
|
|
* @return Mouse cursor position when the message is added to
|
|
|
|
* the queue or current cursor position if the result of
|
|
|
|
* ::GetMessagePos() is broken.
|
|
|
|
*/
|
|
|
|
POINT ComputeMessagePos(UINT aMessage,
|
|
|
|
WPARAM aWParam,
|
|
|
|
LPARAM aLParam);
|
|
|
|
|
2012-03-06 07:20:28 +04:00
|
|
|
class EventInfo {
|
|
|
|
public:
|
|
|
|
/**
|
2013-08-09 14:12:38 +04:00
|
|
|
* @param aWidget An nsWindow which is handling the event.
|
2012-03-06 07:20:28 +04:00
|
|
|
* @param aMessage Must be WM_MOUSEWHEEL or WM_MOUSEHWHEEL.
|
|
|
|
*/
|
2013-08-09 14:12:38 +04:00
|
|
|
EventInfo(nsWindowBase* aWidget, UINT aMessage, WPARAM aWParam, LPARAM aLParam);
|
2012-03-06 07:20:28 +04:00
|
|
|
|
2012-08-12 05:42:37 +04:00
|
|
|
bool CanDispatchWheelEvent() const;
|
2012-03-06 07:20:28 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t GetNativeDelta() const { return mDelta; }
|
2012-03-06 07:20:28 +04:00
|
|
|
HWND GetWindowHandle() const { return mWnd; }
|
|
|
|
const TimeStamp& GetTimeStamp() const { return mTimeStamp; }
|
2012-03-06 07:20:28 +04:00
|
|
|
bool IsVertical() const { return mIsVertical; }
|
|
|
|
bool IsPositive() const { return (mDelta > 0); }
|
|
|
|
bool IsPage() const { return mIsPage; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Number of lines or pages scrolled per WHEEL_DELTA.
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t GetScrollAmount() const;
|
2012-03-06 07:20:28 +04:00
|
|
|
|
2012-03-06 07:20:28 +04:00
|
|
|
protected:
|
|
|
|
EventInfo() :
|
2012-07-30 18:20:58 +04:00
|
|
|
mIsVertical(false), mIsPage(false), mDelta(0), mWnd(nullptr)
|
2012-03-06 07:20:28 +04:00
|
|
|
{
|
|
|
|
}
|
2012-03-06 07:20:28 +04:00
|
|
|
|
|
|
|
// TRUE if event is for vertical scroll. Otherwise, FALSE.
|
|
|
|
bool mIsVertical;
|
|
|
|
// TRUE if event scrolls per page, otherwise, FALSE.
|
|
|
|
bool mIsPage;
|
|
|
|
// The native delta value.
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mDelta;
|
2012-03-06 07:20:28 +04:00
|
|
|
// The window handle which is handling the event.
|
|
|
|
HWND mWnd;
|
|
|
|
// Timestamp of the event.
|
|
|
|
TimeStamp mTimeStamp;
|
|
|
|
};
|
|
|
|
|
|
|
|
class LastEventInfo : public EventInfo {
|
|
|
|
public:
|
|
|
|
LastEventInfo() :
|
2012-08-12 05:42:37 +04:00
|
|
|
EventInfo(), mAccumulatedDelta(0)
|
2012-03-06 07:20:28 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CanContinueTransaction() checks whether the new event can continue the
|
|
|
|
* last transaction or not. Note that if there is no transaction, this
|
|
|
|
* returns true.
|
|
|
|
*/
|
|
|
|
bool CanContinueTransaction(const EventInfo& aNewEvent);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ResetTransaction() resets the transaction, i.e., the instance forgets
|
|
|
|
* the last event information.
|
|
|
|
*/
|
|
|
|
void ResetTransaction();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* RecordEvent() saves the information of new event.
|
|
|
|
*/
|
|
|
|
void RecordEvent(const EventInfo& aEvent);
|
|
|
|
|
2012-03-06 07:20:29 +04:00
|
|
|
/**
|
2012-08-12 05:42:37 +04:00
|
|
|
* InitWheelEvent() initializes NS_WHEEL_WHEEL event and
|
2012-03-06 07:20:29 +04:00
|
|
|
* recomputes the remaning detla for the event.
|
|
|
|
* This must be called only once during handling a message and after
|
|
|
|
* RecordEvent() is called.
|
|
|
|
*
|
2013-08-09 14:12:38 +04:00
|
|
|
* @param aWidget A window which will dispatch the event.
|
2012-08-12 05:42:37 +04:00
|
|
|
* @param aWheelEvent An NS_WHEEL_WHEEL event, this will be
|
2012-03-06 07:20:29 +04:00
|
|
|
* initialized.
|
|
|
|
* @param aModKeyState Current modifier key state.
|
|
|
|
* @return TRUE if the event is ready to dispatch.
|
|
|
|
* Otherwise, FALSE.
|
|
|
|
*/
|
2013-08-09 14:12:38 +04:00
|
|
|
bool InitWheelEvent(nsWindowBase* aWidget,
|
2013-10-16 13:37:36 +04:00
|
|
|
WidgetWheelEvent& aWheelEvent,
|
2012-08-12 05:42:37 +04:00
|
|
|
const ModifierKeyState& aModKeyState);
|
2012-03-06 07:20:29 +04:00
|
|
|
|
|
|
|
private:
|
2012-08-22 19:56:38 +04:00
|
|
|
static int32_t RoundDelta(double aDelta);
|
2012-03-06 07:20:29 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mAccumulatedDelta;
|
2012-03-06 07:20:28 +04:00
|
|
|
};
|
|
|
|
|
2012-03-06 07:20:28 +04:00
|
|
|
LastEventInfo mLastEventInfo;
|
|
|
|
|
2012-03-06 07:20:28 +04:00
|
|
|
class SystemSettings {
|
|
|
|
public:
|
|
|
|
SystemSettings() : mInitialized(false) {}
|
|
|
|
|
|
|
|
void Init();
|
|
|
|
void MarkDirty();
|
2012-03-22 04:59:12 +04:00
|
|
|
void NotifyUserPrefsMayOverrideSystemSettings();
|
2012-03-06 07:20:28 +04:00
|
|
|
|
2016-01-13 04:49:38 +03:00
|
|
|
// On some environments, SystemParametersInfo() may be hooked by touchpad
|
|
|
|
// utility or something. In such case, when user changes active pointing
|
|
|
|
// device to another one, the result of SystemParametersInfo() may be
|
|
|
|
// changed without WM_SETTINGCHANGE message. For avoiding this trouble,
|
|
|
|
// we need to modify cache of system settings at every wheel message
|
|
|
|
// handling if we meet known device whose utility may hook the API.
|
2016-01-27 09:09:13 +03:00
|
|
|
void TrustedScrollSettingsDriver();
|
|
|
|
|
|
|
|
// Returns true if the system scroll may be overridden for faster scroll.
|
|
|
|
// Otherwise, false. For example, if the user maybe uses an expensive
|
|
|
|
// mouse which supports acceleration of scroll speed, faster scroll makes
|
|
|
|
// the user inconvenient.
|
|
|
|
bool IsOverridingSystemScrollSpeedAllowed();
|
2016-01-13 04:49:38 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t GetScrollAmount(bool aForVertical) const
|
2012-03-06 07:20:28 +04:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(mInitialized, "SystemSettings must be initialized");
|
|
|
|
return aForVertical ? mScrollLines : mScrollChars;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsPageScroll(bool aForVertical) const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mInitialized, "SystemSettings must be initialized");
|
2015-02-24 17:07:00 +03:00
|
|
|
return aForVertical ? (uint32_t(mScrollLines) == WHEEL_PAGESCROLL) :
|
|
|
|
(uint32_t(mScrollChars) == WHEEL_PAGESCROLL);
|
2012-03-06 07:20:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool mInitialized;
|
2016-01-13 04:49:38 +03:00
|
|
|
// The result of SystemParametersInfo() may not be reliable since it may
|
|
|
|
// be hooked. So, if the values are initialized with prefs, we can trust
|
|
|
|
// the value. Following mIsReliableScroll* are set true when mScroll* are
|
|
|
|
// initialized with prefs.
|
|
|
|
bool mIsReliableScrollLines;
|
|
|
|
bool mIsReliableScrollChars;
|
|
|
|
|
2015-02-24 17:07:00 +03:00
|
|
|
int32_t mScrollLines;
|
|
|
|
int32_t mScrollChars;
|
2016-01-13 04:49:38 +03:00
|
|
|
|
|
|
|
// Returns true if cached value is changed.
|
|
|
|
bool InitScrollLines();
|
|
|
|
bool InitScrollChars();
|
|
|
|
|
2016-01-27 09:09:13 +03:00
|
|
|
void RefreshCache();
|
2012-03-06 07:20:28 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
SystemSettings mSystemSettings;
|
2012-03-06 07:20:28 +04:00
|
|
|
|
|
|
|
class UserPrefs {
|
|
|
|
public:
|
|
|
|
UserPrefs();
|
|
|
|
~UserPrefs();
|
|
|
|
|
|
|
|
void MarkDirty();
|
|
|
|
|
|
|
|
bool IsScrollMessageHandledAsWheelMessage()
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
return mScrollMessageHandledAsWheelMessage;
|
|
|
|
}
|
|
|
|
|
2016-01-13 04:49:38 +03:00
|
|
|
bool IsSystemSettingCacheEnabled()
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
return mEnableSystemSettingCache;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsSystemSettingCacheForciblyEnabled()
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
return mForceEnableSystemSettingCache;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t GetOverriddenVerticalScrollAmout()
|
2012-03-22 04:59:12 +04:00
|
|
|
{
|
|
|
|
Init();
|
|
|
|
return mOverriddenVerticalScrollAmount;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t GetOverriddenHorizontalScrollAmout()
|
2012-03-22 04:59:12 +04:00
|
|
|
{
|
|
|
|
Init();
|
|
|
|
return mOverriddenHorizontalScrollAmount;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t GetMouseScrollTransactionTimeout()
|
2012-03-22 04:59:12 +04:00
|
|
|
{
|
|
|
|
Init();
|
|
|
|
return mMouseScrollTransactionTimeout;
|
|
|
|
}
|
|
|
|
|
2012-03-06 07:20:28 +04:00
|
|
|
private:
|
|
|
|
void Init();
|
|
|
|
|
2013-12-11 03:10:01 +04:00
|
|
|
static void OnChange(const char* aPrefName, void* aClosure)
|
2012-03-06 07:20:28 +04:00
|
|
|
{
|
|
|
|
static_cast<UserPrefs*>(aClosure)->MarkDirty();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool mInitialized;
|
|
|
|
bool mScrollMessageHandledAsWheelMessage;
|
2016-01-13 04:49:38 +03:00
|
|
|
bool mEnableSystemSettingCache;
|
|
|
|
bool mForceEnableSystemSettingCache;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mOverriddenVerticalScrollAmount;
|
|
|
|
int32_t mOverriddenHorizontalScrollAmount;
|
|
|
|
int32_t mMouseScrollTransactionTimeout;
|
2012-03-06 07:20:28 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
UserPrefs mUserPrefs;
|
2012-03-06 07:20:28 +04:00
|
|
|
|
2012-03-22 04:59:12 +04:00
|
|
|
class SynthesizingEvent {
|
|
|
|
public:
|
|
|
|
SynthesizingEvent() :
|
2013-10-08 22:48:20 +04:00
|
|
|
mWnd(nullptr), mMessage(0), mWParam(0), mLParam(0),
|
2012-03-22 04:59:12 +04:00
|
|
|
mStatus(NOT_SYNTHESIZING)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~SynthesizingEvent() {}
|
|
|
|
|
|
|
|
static bool IsSynthesizing();
|
|
|
|
|
|
|
|
nsresult Synthesize(const POINTS& aCursorPoint, HWND aWnd,
|
|
|
|
UINT aMessage, WPARAM aWParam, LPARAM aLParam,
|
|
|
|
const BYTE (&aKeyStates)[256]);
|
|
|
|
|
2013-08-09 14:12:38 +04:00
|
|
|
void NativeMessageReceived(nsWindowBase* aWidget, UINT aMessage,
|
2012-03-22 04:59:12 +04:00
|
|
|
WPARAM aWParam, LPARAM aLParam);
|
|
|
|
|
|
|
|
void NotifyNativeMessageHandlingFinished();
|
|
|
|
void NotifyInternalMessageHandlingFinished();
|
|
|
|
|
|
|
|
const POINTS& GetCursorPoint() const { return mCursorPoint; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
POINTS mCursorPoint;
|
|
|
|
HWND mWnd;
|
|
|
|
UINT mMessage;
|
|
|
|
WPARAM mWParam;
|
|
|
|
LPARAM mLParam;
|
|
|
|
BYTE mKeyState[256];
|
|
|
|
BYTE mOriginalKeyState[256];
|
|
|
|
|
|
|
|
enum Status {
|
|
|
|
NOT_SYNTHESIZING,
|
|
|
|
SENDING_MESSAGE,
|
|
|
|
NATIVE_MESSAGE_RECEIVED,
|
|
|
|
INTERNAL_MESSAGE_POSTED,
|
|
|
|
};
|
|
|
|
Status mStatus;
|
|
|
|
|
|
|
|
const char* GetStatusName()
|
|
|
|
{
|
|
|
|
switch (mStatus) {
|
|
|
|
case NOT_SYNTHESIZING:
|
|
|
|
return "NOT_SYNTHESIZING";
|
|
|
|
case SENDING_MESSAGE:
|
|
|
|
return "SENDING_MESSAGE";
|
|
|
|
case NATIVE_MESSAGE_RECEIVED:
|
|
|
|
return "NATIVE_MESSAGE_RECEIVED";
|
|
|
|
case INTERNAL_MESSAGE_POSTED:
|
|
|
|
return "INTERNAL_MESSAGE_POSTED";
|
|
|
|
default:
|
|
|
|
return "Unknown";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Finish();
|
|
|
|
}; // SynthesizingEvent
|
|
|
|
|
|
|
|
SynthesizingEvent* mSynthesizingEvent;
|
|
|
|
|
2012-03-06 07:20:28 +04:00
|
|
|
public:
|
|
|
|
|
|
|
|
class Device {
|
|
|
|
public:
|
2016-01-13 04:49:38 +03:00
|
|
|
// SynTP is a touchpad driver of Synaptics.
|
|
|
|
class SynTP
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static bool IsDriverInstalled()
|
|
|
|
{
|
|
|
|
return sMajorVersion != 0;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* GetDriverMajorVersion() returns the installed driver's major version.
|
|
|
|
* If SynTP driver isn't installed, this returns 0.
|
|
|
|
*/
|
|
|
|
static int32_t GetDriverMajorVersion()
|
|
|
|
{
|
|
|
|
return sMajorVersion;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* GetDriverMinorVersion() returns the installed driver's minor version.
|
|
|
|
* If SynTP driver isn't installed, this returns -1.
|
|
|
|
*/
|
|
|
|
static int32_t GetDriverMinorVersion()
|
|
|
|
{
|
|
|
|
return sMinorVersion;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void Init();
|
|
|
|
|
|
|
|
private:
|
|
|
|
static bool sInitialized;
|
|
|
|
static int32_t sMajorVersion;
|
|
|
|
static int32_t sMinorVersion;
|
|
|
|
};
|
|
|
|
|
2012-03-06 07:20:28 +04:00
|
|
|
class Elantech {
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* GetDriverMajorVersion() returns the installed driver's major version.
|
|
|
|
* If Elantech's driver was installed, returns 0.
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
static int32_t GetDriverMajorVersion();
|
2012-03-06 07:20:28 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* IsHelperWindow() checks whether aWnd is a helper window of Elantech's
|
|
|
|
* touchpad. Returns TRUE if so. Otherwise, FALSE.
|
|
|
|
*/
|
|
|
|
static bool IsHelperWindow(HWND aWnd);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Key message handler for Elantech's hack. Returns TRUE if the message
|
|
|
|
* is consumed by this handler. Otherwise, FALSE.
|
|
|
|
*/
|
2013-08-09 14:12:38 +04:00
|
|
|
static bool HandleKeyMessage(nsWindowBase* aWidget,
|
2012-03-06 07:20:28 +04:00
|
|
|
UINT aMsg,
|
2016-01-07 07:31:35 +03:00
|
|
|
WPARAM aWParam,
|
|
|
|
LPARAM aLParam);
|
2012-03-06 07:20:28 +04:00
|
|
|
|
|
|
|
static void UpdateZoomUntil();
|
|
|
|
static bool IsZooming();
|
|
|
|
|
|
|
|
static void Init();
|
|
|
|
|
|
|
|
static bool IsPinchHackNeeded() { return sUsePinchHack; }
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Whether to enable the Elantech swipe gesture hack.
|
|
|
|
static bool sUseSwipeHack;
|
|
|
|
// Whether to enable the Elantech pinch-to-zoom gesture hack.
|
|
|
|
static bool sUsePinchHack;
|
|
|
|
static DWORD sZoomUntil;
|
|
|
|
}; // class Elantech
|
|
|
|
|
2016-01-13 04:49:38 +03:00
|
|
|
// Apoint is a touchpad driver of Alps.
|
|
|
|
class Apoint
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static bool IsDriverInstalled()
|
|
|
|
{
|
|
|
|
return sMajorVersion != 0;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* GetDriverMajorVersion() returns the installed driver's major version.
|
|
|
|
* If Apoint driver isn't installed, this returns 0.
|
|
|
|
*/
|
|
|
|
static int32_t GetDriverMajorVersion()
|
|
|
|
{
|
|
|
|
return sMajorVersion;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* GetDriverMinorVersion() returns the installed driver's minor version.
|
|
|
|
* If Apoint driver isn't installed, this returns -1.
|
|
|
|
*/
|
|
|
|
static int32_t GetDriverMinorVersion()
|
|
|
|
{
|
|
|
|
return sMinorVersion;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void Init();
|
|
|
|
|
|
|
|
private:
|
|
|
|
static bool sInitialized;
|
|
|
|
static int32_t sMajorVersion;
|
|
|
|
static int32_t sMinorVersion;
|
|
|
|
};
|
|
|
|
|
2012-03-06 07:20:28 +04:00
|
|
|
class TrackPoint {
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* IsDriverInstalled() returns TRUE if TrackPoint's driver is installed.
|
|
|
|
* Otherwise, returns FALSE.
|
|
|
|
*/
|
|
|
|
static bool IsDriverInstalled();
|
|
|
|
}; // class TrackPoint
|
|
|
|
|
|
|
|
class UltraNav {
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* IsObsoleteDriverInstalled() checks whether obsoleted UltraNav
|
|
|
|
* is installed on the environment.
|
|
|
|
* Returns TRUE if it was installed. Otherwise, FALSE.
|
|
|
|
*/
|
|
|
|
static bool IsObsoleteDriverInstalled();
|
|
|
|
}; // class UltraNav
|
|
|
|
|
2012-03-06 07:20:29 +04:00
|
|
|
class SetPoint {
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* SetPoint, Logitech's mouse driver, may report wrong cursor position
|
|
|
|
* for WM_MOUSEHWHEEL message. See comment in the implementation for
|
|
|
|
* the detail.
|
|
|
|
*/
|
|
|
|
static bool IsGetMessagePosResponseValid(UINT aMessage,
|
|
|
|
WPARAM aWParam,
|
|
|
|
LPARAM aLParam);
|
|
|
|
private:
|
|
|
|
static bool sMightBeUsing;
|
|
|
|
};
|
|
|
|
|
2012-03-06 07:20:28 +04:00
|
|
|
static void Init();
|
|
|
|
|
|
|
|
static bool IsFakeScrollableWindowNeeded()
|
|
|
|
{
|
|
|
|
return sFakeScrollableWindowNeeded;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* Gets the bool value of aPrefName used to enable or disable an input
|
|
|
|
* workaround (like the Trackpoint hack). The pref can take values 0 (for
|
|
|
|
* disabled), 1 (for enabled) or -1 (to automatically detect whether to
|
|
|
|
* enable the workaround).
|
|
|
|
*
|
|
|
|
* @param aPrefName The name of the pref.
|
|
|
|
* @param aValueIfAutomatic Whether the given input workaround should be
|
|
|
|
* enabled by default.
|
|
|
|
*/
|
|
|
|
static bool GetWorkaroundPref(const char* aPrefName,
|
|
|
|
bool aValueIfAutomatic);
|
|
|
|
|
|
|
|
static bool sFakeScrollableWindowNeeded;
|
|
|
|
}; // class Device
|
2012-03-06 07:20:28 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace widget
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2013-12-11 03:10:01 +04:00
|
|
|
#endif // mozilla_widget_WinMouseScrollHandler_h__
|