mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1235686 part.1 MouseScrollHandler should refresh the cache of system settings at handling wheel messages if the pref doesn't allow to cache system settings r=jimm
This commit is contained in:
parent
ce0412068a
commit
61bb408526
@ -3261,6 +3261,16 @@ pref("ui.panel.default_level_parent", false);
|
||||
|
||||
pref("mousewheel.system_scroll_override_on_root_content.enabled", true);
|
||||
|
||||
// Enable system settings cache for mouse wheel message handling.
|
||||
// Note that even if this pref is set to true, Gecko may not cache the system
|
||||
// settings if Gecko detects that the cache won't be refreshed properly when
|
||||
// the settings are changed.
|
||||
pref("mousewheel.system_settings_cache.enabled", true);
|
||||
|
||||
// This is a pref to test system settings cache for mouse wheel message
|
||||
// handling. If this is set to true, Gecko forcibly use the cache.
|
||||
pref("mousewheel.system_settings_cache.force_enabled", false);
|
||||
|
||||
// High resolution scrolling with supported mouse drivers on Vista or later.
|
||||
pref("mousewheel.enable_pixel_scrolling", true);
|
||||
|
||||
|
@ -603,6 +603,10 @@ MouseScrollHandler::HandleMouseWheelMessage(nsWindowBase* aWidget,
|
||||
|
||||
mIsWaitingInternalMessage = false;
|
||||
|
||||
// If it's not allowed to cache system settings, we need to reset the cache
|
||||
// before handling the mouse wheel message.
|
||||
mSystemSettings.TrustedScrollSettingsDriver(aMessage == MOZ_WM_MOUSEVWHEEL);
|
||||
|
||||
EventInfo eventInfo(aWidget, WinUtils::GetNativeMessage(aMessage),
|
||||
aWParam, aLParam);
|
||||
if (!eventInfo.CanDispatchWheelEvent()) {
|
||||
@ -881,30 +885,41 @@ MouseScrollHandler::SystemSettings::Init()
|
||||
return;
|
||||
}
|
||||
|
||||
InitScrollLines();
|
||||
InitScrollChars();
|
||||
|
||||
mInitialized = true;
|
||||
|
||||
MouseScrollHandler::UserPrefs& userPrefs =
|
||||
MouseScrollHandler::sInstance->mUserPrefs;
|
||||
MOZ_LOG(gMouseScrollLog, LogLevel::Info,
|
||||
("MouseScroll::SystemSettings::Init(): initialized, "
|
||||
"mScrollLines=%d, mScrollChars=%d",
|
||||
mScrollLines, mScrollChars));
|
||||
}
|
||||
|
||||
mScrollLines = userPrefs.GetOverriddenVerticalScrollAmout();
|
||||
bool
|
||||
MouseScrollHandler::SystemSettings::InitScrollLines()
|
||||
{
|
||||
int32_t oldValue = mInitialized ? mScrollLines : 0;
|
||||
mScrollLines = MouseScrollHandler::sInstance->
|
||||
mUserPrefs.GetOverriddenVerticalScrollAmout();
|
||||
if (mScrollLines >= 0) {
|
||||
// overridden by the pref.
|
||||
MOZ_LOG(gMouseScrollLog, LogLevel::Info,
|
||||
("MouseScroll::SystemSettings::Init(): mScrollLines is overridden by "
|
||||
"the pref: %d",
|
||||
("MouseScroll::SystemSettings::InitScrollLines(): mScrollLines is "
|
||||
"overridden by the pref: %d",
|
||||
mScrollLines));
|
||||
} else if (!::SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0,
|
||||
&mScrollLines, 0)) {
|
||||
MOZ_LOG(gMouseScrollLog, LogLevel::Info,
|
||||
("MouseScroll::SystemSettings::Init(): ::SystemParametersInfo("
|
||||
"SPI_GETWHEELSCROLLLINES) failed"));
|
||||
("MouseScroll::SystemSettings::InitScrollLines(): ::SystemParametersInfo("
|
||||
"SPI_GETWHEELSCROLLLINES) failed"));
|
||||
mScrollLines = 3;
|
||||
}
|
||||
|
||||
if (mScrollLines > WHEEL_DELTA) {
|
||||
MOZ_LOG(gMouseScrollLog, LogLevel::Info,
|
||||
("MouseScroll::SystemSettings::Init(): the result of "
|
||||
"::SystemParametersInfo(SPI_GETWHEELSCROLLLINES) is too large: %d",
|
||||
("MouseScroll::SystemSettings::InitScrollLines(): the result of "
|
||||
"::SystemParametersInfo(SPI_GETWHEELSCROLLLINES) is too large: %d",
|
||||
mScrollLines));
|
||||
// sScrollLines usually equals 3 or 0 (for no scrolling)
|
||||
// However, if sScrollLines > WHEEL_DELTA, we assume that
|
||||
@ -915,18 +930,26 @@ MouseScrollHandler::SystemSettings::Init()
|
||||
mScrollLines = WHEEL_PAGESCROLL;
|
||||
}
|
||||
|
||||
mScrollChars = userPrefs.GetOverriddenHorizontalScrollAmout();
|
||||
return oldValue != mScrollLines;
|
||||
}
|
||||
|
||||
bool
|
||||
MouseScrollHandler::SystemSettings::InitScrollChars()
|
||||
{
|
||||
int32_t oldValue = mInitialized ? mScrollChars : 0;
|
||||
mScrollChars = MouseScrollHandler::sInstance->
|
||||
mUserPrefs.GetOverriddenHorizontalScrollAmout();
|
||||
if (mScrollChars >= 0) {
|
||||
// overridden by the pref.
|
||||
MOZ_LOG(gMouseScrollLog, LogLevel::Info,
|
||||
("MouseScroll::SystemSettings::Init(): mScrollChars is overridden by "
|
||||
"the pref: %d",
|
||||
("MouseScroll::SystemSettings::InitScrollChars(): mScrollChars is "
|
||||
"overridden by the pref: %d",
|
||||
mScrollChars));
|
||||
} else if (!::SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0,
|
||||
&mScrollChars, 0)) {
|
||||
MOZ_LOG(gMouseScrollLog, LogLevel::Info,
|
||||
("MouseScroll::SystemSettings::Init(): ::SystemParametersInfo("
|
||||
"SPI_GETWHEELSCROLLCHARS) failed, %s",
|
||||
("MouseScroll::SystemSettings::InitScrollChars(): ::SystemParametersInfo("
|
||||
"SPI_GETWHEELSCROLLCHARS) failed, %s",
|
||||
IsVistaOrLater() ?
|
||||
"this is unexpected on Vista or later" :
|
||||
"but on XP or earlier, this is not a problem"));
|
||||
@ -935,17 +958,14 @@ MouseScrollHandler::SystemSettings::Init()
|
||||
|
||||
if (mScrollChars > WHEEL_DELTA) {
|
||||
MOZ_LOG(gMouseScrollLog, LogLevel::Info,
|
||||
("MouseScroll::SystemSettings::Init(): the result of "
|
||||
"::SystemParametersInfo(SPI_GETWHEELSCROLLCHARS) is too large: %d",
|
||||
("MouseScroll::SystemSettings::InitScrollChars(): the result of "
|
||||
"::SystemParametersInfo(SPI_GETWHEELSCROLLCHARS) is too large: %d",
|
||||
mScrollChars));
|
||||
// See the comments for the case mScrollLines > WHEEL_DELTA.
|
||||
mScrollChars = WHEEL_PAGESCROLL;
|
||||
}
|
||||
|
||||
MOZ_LOG(gMouseScrollLog, LogLevel::Info,
|
||||
("MouseScroll::SystemSettings::Init(): initialized, "
|
||||
"mScrollLines=%d, mScrollChars=%d",
|
||||
mScrollLines, mScrollChars));
|
||||
return oldValue != mScrollChars;
|
||||
}
|
||||
|
||||
void
|
||||
@ -961,6 +981,45 @@ MouseScrollHandler::SystemSettings::MarkDirty()
|
||||
MouseScrollHandler::sInstance->mLastEventInfo.ResetTransaction();
|
||||
}
|
||||
|
||||
void
|
||||
MouseScrollHandler::SystemSettings::RefreshCache(bool aForVertical)
|
||||
{
|
||||
bool isChanged = aForVertical ? InitScrollLines() : InitScrollChars();
|
||||
if (!isChanged) {
|
||||
return;
|
||||
}
|
||||
// If the scroll amount is changed, we should reset current transaction.
|
||||
MOZ_ASSERT(sInstance,
|
||||
"Must not be called at initializing MouseScrollHandler");
|
||||
MouseScrollHandler::sInstance->mLastEventInfo.ResetTransaction();
|
||||
}
|
||||
|
||||
void
|
||||
MouseScrollHandler::SystemSettings::TrustedScrollSettingsDriver(
|
||||
bool aIsVertical)
|
||||
{
|
||||
if (!mInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
MouseScrollHandler::UserPrefs& userPrefs =
|
||||
MouseScrollHandler::sInstance->mUserPrefs;
|
||||
|
||||
// If system settings cache is disabled, we should always refresh them.
|
||||
if (!userPrefs.IsSystemSettingCacheEnabled()) {
|
||||
RefreshCache(aIsVertical);
|
||||
return;
|
||||
}
|
||||
|
||||
// If pref is set to as "always trust the cache", we shouldn't refresh them
|
||||
// in any environments.
|
||||
if (userPrefs.IsSystemSettingCacheForciblyEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Implement to check if we can trust the cache in the environment.
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* UserPrefs
|
||||
@ -997,6 +1056,11 @@ MouseScrollHandler::UserPrefs::Init()
|
||||
|
||||
mScrollMessageHandledAsWheelMessage =
|
||||
Preferences::GetBool("mousewheel.emulate_at_wm_scroll", false);
|
||||
mEnableSystemSettingCache =
|
||||
Preferences::GetBool("mousewheel.system_settings_cache.enabled", true);
|
||||
mForceEnableSystemSettingCache =
|
||||
Preferences::GetBool("mousewheel.system_settings_cache.force_enabled",
|
||||
false);
|
||||
mOverriddenVerticalScrollAmount =
|
||||
Preferences::GetInt("mousewheel.windows.vertical_amount_override", -1);
|
||||
mOverriddenHorizontalScrollAmount =
|
||||
@ -1008,10 +1072,14 @@ MouseScrollHandler::UserPrefs::Init()
|
||||
MOZ_LOG(gMouseScrollLog, LogLevel::Info,
|
||||
("MouseScroll::UserPrefs::Init(): initialized, "
|
||||
"mScrollMessageHandledAsWheelMessage=%s, "
|
||||
"mEnableSystemSettingCache=%s, "
|
||||
"mForceEnableSystemSettingCache=%s, "
|
||||
"mOverriddenVerticalScrollAmount=%d, "
|
||||
"mOverriddenHorizontalScrollAmount=%d, "
|
||||
"mMouseScrollTransactionTimeout=%d",
|
||||
GetBoolName(mScrollMessageHandledAsWheelMessage),
|
||||
GetBoolName(mEnableSystemSettingCache),
|
||||
GetBoolName(mForceEnableSystemSettingCache),
|
||||
mOverriddenVerticalScrollAmount, mOverriddenHorizontalScrollAmount,
|
||||
mMouseScrollTransactionTimeout));
|
||||
}
|
||||
|
@ -273,6 +273,14 @@ private:
|
||||
void MarkDirty();
|
||||
void NotifyUserPrefsMayOverrideSystemSettings();
|
||||
|
||||
// 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.
|
||||
void TrustedScrollSettingsDriver(bool aIsVertical);
|
||||
|
||||
int32_t GetScrollAmount(bool aForVertical) const
|
||||
{
|
||||
MOZ_ASSERT(mInitialized, "SystemSettings must be initialized");
|
||||
@ -290,6 +298,12 @@ private:
|
||||
bool mInitialized;
|
||||
int32_t mScrollLines;
|
||||
int32_t mScrollChars;
|
||||
|
||||
// Returns true if cached value is changed.
|
||||
bool InitScrollLines();
|
||||
bool InitScrollChars();
|
||||
|
||||
void RefreshCache(bool aForVertical);
|
||||
};
|
||||
|
||||
SystemSettings mSystemSettings;
|
||||
@ -307,6 +321,18 @@ private:
|
||||
return mScrollMessageHandledAsWheelMessage;
|
||||
}
|
||||
|
||||
bool IsSystemSettingCacheEnabled()
|
||||
{
|
||||
Init();
|
||||
return mEnableSystemSettingCache;
|
||||
}
|
||||
|
||||
bool IsSystemSettingCacheForciblyEnabled()
|
||||
{
|
||||
Init();
|
||||
return mForceEnableSystemSettingCache;
|
||||
}
|
||||
|
||||
int32_t GetOverriddenVerticalScrollAmout()
|
||||
{
|
||||
Init();
|
||||
@ -335,6 +361,8 @@ private:
|
||||
|
||||
bool mInitialized;
|
||||
bool mScrollMessageHandledAsWheelMessage;
|
||||
bool mEnableSystemSettingCache;
|
||||
bool mForceEnableSystemSettingCache;
|
||||
int32_t mOverriddenVerticalScrollAmount;
|
||||
int32_t mOverriddenHorizontalScrollAmount;
|
||||
int32_t mMouseScrollTransactionTimeout;
|
||||
|
Loading…
Reference in New Issue
Block a user