зеркало из 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 "nsWindow.h"
|
||||||
#include "WinUtils.h"
|
#include "WinUtils.h"
|
||||||
|
|
||||||
|
#include "mozilla/Preferences.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace widget {
|
namespace widget {
|
||||||
|
|
||||||
#ifdef PR_LOGGING
|
#ifdef PR_LOGGING
|
||||||
PRLogModuleInfo* gMouseScrollLog = nsnull;
|
PRLogModuleInfo* gMouseScrollLog = nsnull;
|
||||||
|
|
||||||
|
static const char* GetBoolName(bool aBool)
|
||||||
|
{
|
||||||
|
return aBool ? "TRUE" : "FALSE";
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
MouseScrollHandler* MouseScrollHandler::sInstance = nsnull;
|
MouseScrollHandler* MouseScrollHandler::sInstance = nsnull;
|
||||||
|
@ -159,5 +166,59 @@ MouseScrollHandler::SystemSettings::MarkDirty()
|
||||||
mInitialized = false;
|
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 widget
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
|
@ -71,6 +71,48 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SystemSettings mSystemSettings;
|
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
|
} // namespace widget
|
||||||
|
|
|
@ -292,7 +292,6 @@ PRUint32 nsWindow::sOOPPPluginFocusEvent =
|
||||||
|
|
||||||
MSG nsWindow::sRedirectedKeyDown;
|
MSG nsWindow::sRedirectedKeyDown;
|
||||||
|
|
||||||
bool nsWindow::sEnablePixelScrolling = true;
|
|
||||||
bool nsWindow::sNeedsToInitMouseWheelSettings = true;
|
bool nsWindow::sNeedsToInitMouseWheelSettings = true;
|
||||||
|
|
||||||
HWND nsWindow::sLastMouseWheelWnd = NULL;
|
HWND nsWindow::sLastMouseWheelWnd = NULL;
|
||||||
|
@ -6312,9 +6311,6 @@ nsWindow::InitMouseWheelScrollData()
|
||||||
}
|
}
|
||||||
sNeedsToInitMouseWheelSettings = false;
|
sNeedsToInitMouseWheelSettings = false;
|
||||||
ResetRemainingWheelDelta();
|
ResetRemainingWheelDelta();
|
||||||
|
|
||||||
sEnablePixelScrolling =
|
|
||||||
Preferences::GetBool("mousewheel.enable_pixel_scrolling", true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
|
@ -6422,7 +6418,8 @@ nsWindow::OnMouseWheelInternal(UINT aMessage, WPARAM aWParam, LPARAM aLParam,
|
||||||
PRInt32 computedScrollAmount =
|
PRInt32 computedScrollAmount =
|
||||||
isPageScroll ? 1 : systemSettings.GetScrollAmount(isVertical);
|
isPageScroll ? 1 : systemSettings.GetScrollAmount(isVertical);
|
||||||
|
|
||||||
if (sEnablePixelScrolling) {
|
if (MouseScrollHandler::GetInstance()->
|
||||||
|
GetUserPrefs().IsPixelScrollingEnabled()) {
|
||||||
nsMouseScrollEvent testEvent(true, NS_MOUSE_SCROLL, this);
|
nsMouseScrollEvent testEvent(true, NS_MOUSE_SCROLL, this);
|
||||||
InitEvent(testEvent);
|
InitEvent(testEvent);
|
||||||
testEvent.scrollFlags = isPageScroll ? nsMouseScrollEvent::kIsFullPage : 0;
|
testEvent.scrollFlags = isPageScroll ? nsMouseScrollEvent::kIsFullPage : 0;
|
||||||
|
@ -7567,14 +7564,9 @@ nsWindow::OnMouseWheel(UINT aMsg, WPARAM aWParam, LPARAM aLParam,
|
||||||
bool
|
bool
|
||||||
nsWindow::OnScroll(UINT aMsg, WPARAM aWParam, LPARAM aLParam)
|
nsWindow::OnScroll(UINT aMsg, WPARAM aWParam, LPARAM aLParam)
|
||||||
{
|
{
|
||||||
static PRInt8 sMouseWheelEmulation = -1;
|
if (aLParam ||
|
||||||
if (sMouseWheelEmulation < 0) {
|
MouseScrollHandler::GetInstance()->
|
||||||
bool emulate =
|
GetUserPrefs().IsScrollMessageHandledAsWheelMessage()) {
|
||||||
Preferences::GetBool("mousewheel.emulate_at_wm_scroll", false);
|
|
||||||
sMouseWheelEmulation = PRInt8(emulate);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (aLParam || sMouseWheelEmulation) {
|
|
||||||
// Scroll message generated by Thinkpad Trackpoint Driver or similar
|
// Scroll message generated by Thinkpad Trackpoint Driver or similar
|
||||||
// Treat as a mousewheel message and scroll appropriately
|
// Treat as a mousewheel message and scroll appropriately
|
||||||
LRESULT retVal;
|
LRESULT retVal;
|
||||||
|
|
|
@ -608,7 +608,6 @@ protected:
|
||||||
// was reirected to SendInput() API by OnKeyDown().
|
// was reirected to SendInput() API by OnKeyDown().
|
||||||
static MSG sRedirectedKeyDown;
|
static MSG sRedirectedKeyDown;
|
||||||
|
|
||||||
static bool sEnablePixelScrolling;
|
|
||||||
static bool sNeedsToInitMouseWheelSettings;
|
static bool sNeedsToInitMouseWheelSettings;
|
||||||
static void InitMouseWheelScrollData();
|
static void InitMouseWheelScrollData();
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче