зеркало из https://github.com/mozilla/pjs.git
Bug 672175 part.3 MouseScrollHandler should manage user prefs r=jimm
This commit is contained in:
Родитель
f00be25d7f
Коммит
f87e92733d
|
@ -13,11 +13,18 @@
|
|||
#include "nsWindow.h"
|
||||
#include "WinUtils.h"
|
||||
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
PRLogModuleInfo* gMouseScrollLog = nsnull;
|
||||
|
||||
static const char* GetBoolName(bool aBool)
|
||||
{
|
||||
return aBool ? "TRUE" : "FALSE";
|
||||
}
|
||||
#endif
|
||||
|
||||
MouseScrollHandler* MouseScrollHandler::sInstance = nsnull;
|
||||
|
@ -159,5 +166,59 @@ MouseScrollHandler::SystemSettings::MarkDirty()
|
|||
mInitialized = false;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* UserPrefs
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
MouseScrollHandler::UserPrefs::UserPrefs() :
|
||||
mInitialized(false)
|
||||
{
|
||||
// We need to reset mouse wheel transaction when all of mousewheel related
|
||||
// prefs are changed.
|
||||
DebugOnly<nsresult> rv =
|
||||
Preferences::RegisterCallback(OnChange, "mousewheel.", this);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv),
|
||||
"Failed to register callback for mousewheel.");
|
||||
}
|
||||
|
||||
MouseScrollHandler::UserPrefs::~UserPrefs()
|
||||
{
|
||||
DebugOnly<nsresult> rv =
|
||||
Preferences::UnregisterCallback(OnChange, "mousewheel.", this);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv),
|
||||
"Failed to unregister callback for mousewheel.");
|
||||
}
|
||||
|
||||
void
|
||||
MouseScrollHandler::UserPrefs::Init()
|
||||
{
|
||||
if (mInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
mInitialized = true;
|
||||
|
||||
mPixelScrollingEnabled =
|
||||
Preferences::GetBool("mousewheel.enable_pixel_scrolling", true);
|
||||
mScrollMessageHandledAsWheelMessage =
|
||||
Preferences::GetBool("mousewheel.emulate_at_wm_scroll", false);
|
||||
|
||||
PR_LOG(gMouseScrollLog, PR_LOG_ALWAYS,
|
||||
("MouseScroll::UserPrefs::Init(): initialized, "
|
||||
"mPixelScrollingEnabled=%s, mScrollMessageHandledAsWheelMessage=%s",
|
||||
GetBoolName(mPixelScrollingEnabled),
|
||||
GetBoolName(mScrollMessageHandledAsWheelMessage)));
|
||||
}
|
||||
|
||||
void
|
||||
MouseScrollHandler::UserPrefs::MarkDirty()
|
||||
{
|
||||
PR_LOG(gMouseScrollLog, PR_LOG_ALWAYS,
|
||||
("MouseScrollHandler::UserPrefs::MarkDirty(): Marking UserPrefs dirty"));
|
||||
mInitialized = false;
|
||||
}
|
||||
|
||||
} // namespace widget
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -71,6 +71,48 @@ public:
|
|||
|
||||
private:
|
||||
SystemSettings mSystemSettings;
|
||||
|
||||
public:
|
||||
class UserPrefs {
|
||||
public:
|
||||
UserPrefs();
|
||||
~UserPrefs();
|
||||
|
||||
void MarkDirty();
|
||||
|
||||
bool IsPixelScrollingEnabled()
|
||||
{
|
||||
Init();
|
||||
return mPixelScrollingEnabled;
|
||||
}
|
||||
|
||||
bool IsScrollMessageHandledAsWheelMessage()
|
||||
{
|
||||
Init();
|
||||
return mScrollMessageHandledAsWheelMessage;
|
||||
}
|
||||
|
||||
private:
|
||||
void Init();
|
||||
|
||||
static int OnChange(const char* aPrefName, void* aClosure)
|
||||
{
|
||||
static_cast<UserPrefs*>(aClosure)->MarkDirty();
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool mInitialized;
|
||||
bool mPixelScrollingEnabled;
|
||||
bool mScrollMessageHandledAsWheelMessage;
|
||||
};
|
||||
|
||||
UserPrefs& GetUserPrefs()
|
||||
{
|
||||
return mUserPrefs;
|
||||
}
|
||||
|
||||
private:
|
||||
UserPrefs mUserPrefs;
|
||||
};
|
||||
|
||||
} // namespace widget
|
||||
|
|
|
@ -292,7 +292,6 @@ PRUint32 nsWindow::sOOPPPluginFocusEvent =
|
|||
|
||||
MSG nsWindow::sRedirectedKeyDown;
|
||||
|
||||
bool nsWindow::sEnablePixelScrolling = true;
|
||||
bool nsWindow::sNeedsToInitMouseWheelSettings = true;
|
||||
|
||||
HWND nsWindow::sLastMouseWheelWnd = NULL;
|
||||
|
@ -6312,9 +6311,6 @@ nsWindow::InitMouseWheelScrollData()
|
|||
}
|
||||
sNeedsToInitMouseWheelSettings = false;
|
||||
ResetRemainingWheelDelta();
|
||||
|
||||
sEnablePixelScrolling =
|
||||
Preferences::GetBool("mousewheel.enable_pixel_scrolling", true);
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
@ -6422,7 +6418,8 @@ nsWindow::OnMouseWheelInternal(UINT aMessage, WPARAM aWParam, LPARAM aLParam,
|
|||
PRInt32 computedScrollAmount =
|
||||
isPageScroll ? 1 : systemSettings.GetScrollAmount(isVertical);
|
||||
|
||||
if (sEnablePixelScrolling) {
|
||||
if (MouseScrollHandler::GetInstance()->
|
||||
GetUserPrefs().IsPixelScrollingEnabled()) {
|
||||
nsMouseScrollEvent testEvent(true, NS_MOUSE_SCROLL, this);
|
||||
InitEvent(testEvent);
|
||||
testEvent.scrollFlags = isPageScroll ? nsMouseScrollEvent::kIsFullPage : 0;
|
||||
|
@ -7567,14 +7564,9 @@ nsWindow::OnMouseWheel(UINT aMsg, WPARAM aWParam, LPARAM aLParam,
|
|||
bool
|
||||
nsWindow::OnScroll(UINT aMsg, WPARAM aWParam, LPARAM aLParam)
|
||||
{
|
||||
static PRInt8 sMouseWheelEmulation = -1;
|
||||
if (sMouseWheelEmulation < 0) {
|
||||
bool emulate =
|
||||
Preferences::GetBool("mousewheel.emulate_at_wm_scroll", false);
|
||||
sMouseWheelEmulation = PRInt8(emulate);
|
||||
}
|
||||
|
||||
if (aLParam || sMouseWheelEmulation) {
|
||||
if (aLParam ||
|
||||
MouseScrollHandler::GetInstance()->
|
||||
GetUserPrefs().IsScrollMessageHandledAsWheelMessage()) {
|
||||
// Scroll message generated by Thinkpad Trackpoint Driver or similar
|
||||
// Treat as a mousewheel message and scroll appropriately
|
||||
LRESULT retVal;
|
||||
|
|
|
@ -608,7 +608,6 @@ protected:
|
|||
// was reirected to SendInput() API by OnKeyDown().
|
||||
static MSG sRedirectedKeyDown;
|
||||
|
||||
static bool sEnablePixelScrolling;
|
||||
static bool sNeedsToInitMouseWheelSettings;
|
||||
static void InitMouseWheelScrollData();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче