summaryrefslogtreecommitdiffstats
path: root/widget/windows/nsWindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'widget/windows/nsWindow.cpp')
-rw-r--r--widget/windows/nsWindow.cpp115
1 files changed, 39 insertions, 76 deletions
diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp
index 2172f2aa0..b2bb59bd3 100644
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -266,8 +266,7 @@ LONG nsWindow::sLastMouseDownTime = 0L;
LONG nsWindow::sLastClickCount = 0L;
BYTE nsWindow::sLastMouseButton = 0;
-// Trim heap on minimize. (initialized, but still true.)
-int nsWindow::sTrimOnMinimize = 2;
+bool nsWindow::sHaveInitializedPrefs = false;
TriStateBool nsWindow::sHasBogusPopupsDropShadowOnMultiMonitor = TRI_UNKNOWN;
@@ -783,7 +782,7 @@ nsWindow::Create(nsIWidget* aParent,
parent = nullptr;
}
- if (IsVistaOrLater() && !IsWin8OrLater() &&
+ if (!IsWin8OrLater() &&
HasBogusPopupsDropShadowOnMultiMonitor()) {
extendedStyle |= WS_EX_COMPOSITED;
}
@@ -908,20 +907,13 @@ nsWindow::Create(nsIWidget* aParent,
mDefaultIMC.Init(this);
IMEHandler::InitInputContext(this, mInputContext);
- // If the internal variable set by the config.trim_on_minimize pref has not
- // been initialized, and if this is the hidden window (conveniently created
- // before any visible windows, and after the profile has been initialized),
- // do some initialization work.
- if (sTrimOnMinimize == 2 && mWindowType == eWindowType_invisible) {
- // Our internal trim prevention logic is effective on 2K/XP at maintaining
- // the working set when windows are minimized, but on Vista and up it has
- // little to no effect. Since this feature has been the source of numerous
- // bugs over the years, disable it (sTrimOnMinimize=1) on Vista and up.
- sTrimOnMinimize =
- Preferences::GetBool("config.trim_on_minimize",
- IsVistaOrLater() ? 1 : 0);
+ // Do some initialization work, but only if (a) it hasn't already been done,
+ // and (b) this is the hidden window (which is conveniently created before
+ // any visible windows but after the profile has been initialized).
+ if (!sHaveInitializedPrefs && mWindowType == eWindowType_invisible) {
sSwitchKeyboardLayout =
Preferences::GetBool("intl.keyboard.per_window_layout", false);
+ sHaveInitializedPrefs = true;
}
// Query for command button metric data for rendering the titlebar. We
@@ -1647,9 +1639,10 @@ bool nsWindow::IsVisible() const
// XP and Vista visual styles sometimes require window clipping regions to be applied for proper
// transparency. These routines are called on size and move operations.
+// XXX this is apparently still needed in Windows 7 and later
void nsWindow::ClearThemeRegion()
{
- if (IsVistaOrLater() && !HasGlass() &&
+ if (!HasGlass() &&
(mWindowType == eWindowType_popup && !IsPopupWithTitleBar() &&
(mPopupType == ePopupTypeTooltip || mPopupType == ePopupTypePanel))) {
SetWindowRgn(mWnd, nullptr, false);
@@ -1663,7 +1656,7 @@ void nsWindow::SetThemeRegion()
// so default constants are used for part and state. At some point we might need part and
// state values from nsNativeThemeWin's GetThemePartAndState, but currently windows that
// change shape based on state haven't come up.
- if (IsVistaOrLater() && !HasGlass() &&
+ if (!HasGlass() &&
(mWindowType == eWindowType_popup && !IsPopupWithTitleBar() &&
(mPopupType == ePopupTypeTooltip || mPopupType == ePopupTypePanel))) {
HRGN hRgn = nullptr;
@@ -2080,13 +2073,7 @@ nsWindow::SetSizeMode(nsSizeMode aMode)
break;
case nsSizeMode_Minimized :
- // Using SW_SHOWMINIMIZED prevents the working set from being trimmed but
- // keeps the window active in the tray. So after the window is minimized,
- // windows will fire WM_WINDOWPOSCHANGED (OnWindowPosChanged) at which point
- // we will do some additional processing to get the active window set right.
- // If sTrimOnMinimize is set, we let windows handle minimization normally
- // using SW_MINIMIZE.
- mode = sTrimOnMinimize ? SW_MINIMIZE : SW_SHOWMINIMIZED;
+ mode = SW_MINIMIZE;
break;
default :
@@ -5084,12 +5071,19 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
case WM_SETTINGCHANGE:
{
- if (IsWin10OrLater() && mWindowType == eWindowType_invisible && lParam) {
+ if (lParam) {
auto lParamString = reinterpret_cast<const wchar_t*>(lParam);
- if (!wcscmp(lParamString, L"UserInteractionMode")) {
- nsCOMPtr<nsIWindowsUIUtils> uiUtils(do_GetService("@mozilla.org/windows-ui-utils;1"));
- if (uiUtils) {
- uiUtils->UpdateTabletModeState();
+ if (!wcscmp(lParamString, L"ImmersiveColorSet")) {
+ // WM_SYSCOLORCHANGE is not dispatched for accent color changes
+ OnSysColorChanged();
+ break;
+ }
+ if (IsWin10OrLater() && mWindowType == eWindowType_invisible) {
+ if (!wcscmp(lParamString, L"UserInteractionMode")) {
+ nsCOMPtr<nsIWindowsUIUtils> uiUtils(do_GetService("@mozilla.org/windows-ui-utils;1"));
+ if (uiUtils) {
+ uiUtils->UpdateTabletModeState();
+ }
}
}
}
@@ -5582,12 +5576,13 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
DispatchPendingEvents();
break;
- // Windows doesn't provide to customize the behavior of 4th nor 5th button
- // of mouse. If 5-button mouse works with standard mouse deriver of
- // Windows, users cannot disable 4th button (browser back) nor 5th button
- // (browser forward). We should allow to do it with our prefs since we can
- // prevent Windows to generate WM_APPCOMMAND message if WM_XBUTTONUP
- // messages are not sent to DefWindowProc.
+ // Windows doesn't provide a way to customize the behavior of 4th or 5th
+ // button of a mouse. If a 5-button mouse works with the standard mouse
+ // driver of Windows, users cannot disable the 4th button (browser back)
+ // nor the 5th button (browser forward).
+ // We can disable it here with our prefs since we can prevent Windows
+ // from generating WM_APPCOMMAND messages if WM_XBUTTONUP messages are
+ // not sent to DefWindowProc.
case WM_XBUTTONDOWN:
case WM_XBUTTONUP:
case WM_NCXBUTTONDOWN:
@@ -5595,10 +5590,10 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
*aRetValue = TRUE;
switch (GET_XBUTTON_WPARAM(wParam)) {
case XBUTTON1:
- result = !Preferences::GetBool("mousebutton.4th.enabled", true);
+ result = !Preferences::GetBool("mouse.button4.enabled", true);
break;
case XBUTTON2:
- result = !Preferences::GetBool("mousebutton.5th.enabled", true);
+ result = !Preferences::GetBool("mouse.button5.enabled", true);
break;
default:
break;
@@ -5820,12 +5815,6 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
case WM_SYSCOMMAND:
{
WPARAM filteredWParam = (wParam &0xFFF0);
- // prevent Windows from trimming the working set. bug 76831
- if (!sTrimOnMinimize && filteredWParam == SC_MINIMIZE) {
- ::ShowWindow(mWnd, SW_SHOWMINIMIZED);
- result = true;
- }
-
if (mSizeMode == nsSizeMode_Fullscreen &&
filteredWParam == SC_RESTORE &&
GetCurrentShowCmd(mWnd) != SW_SHOWMINIMIZED) {
@@ -6443,14 +6432,6 @@ void nsWindow::OnWindowPosChanged(WINDOWPOS* wp)
else
mSizeMode = nsSizeMode_Normal;
- // If !sTrimOnMinimize, we minimize windows using SW_SHOWMINIMIZED (See
- // SetSizeMode for internal calls, and WM_SYSCOMMAND for external). This
- // prevents the working set from being trimmed but keeps the window active.
- // After the window is minimized, we need to do some touch up work on the
- // active window. (bugs 76831 & 499816)
- if (!sTrimOnMinimize && nsSizeMode_Minimized == mSizeMode)
- ActivateOtherWindowHelper(mWnd);
-
#ifdef WINSTATE_DEBUG_OUTPUT
switch (mSizeMode) {
case nsSizeMode_Normal:
@@ -6571,31 +6552,6 @@ void nsWindow::OnWindowPosChanged(WINDOWPOS* wp)
}
}
-// static
-void nsWindow::ActivateOtherWindowHelper(HWND aWnd)
-{
- // Find the next window that is enabled, visible, and not minimized.
- HWND hwndBelow = ::GetNextWindow(aWnd, GW_HWNDNEXT);
- while (hwndBelow && (!::IsWindowEnabled(hwndBelow) || !::IsWindowVisible(hwndBelow) ||
- ::IsIconic(hwndBelow))) {
- hwndBelow = ::GetNextWindow(hwndBelow, GW_HWNDNEXT);
- }
-
- // Push ourselves to the bottom of the stack, then activate the
- // next window.
- ::SetWindowPos(aWnd, HWND_BOTTOM, 0, 0, 0, 0,
- SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
- if (hwndBelow)
- ::SetForegroundWindow(hwndBelow);
-
- // Play the minimize sound while we're here, since that is also
- // forgotten when we use SW_SHOWMINIMIZED.
- nsCOMPtr<nsISound> sound(do_CreateInstance("@mozilla.org/sound;1"));
- if (sound) {
- sound->PlaySystemSound(NS_LITERAL_STRING("Minimize"));
- }
-}
-
void nsWindow::OnWindowPosChanging(LPWINDOWPOS& info)
{
// Update non-client margins if the frame size is changing, and let the
@@ -7131,6 +7087,13 @@ nsWindow::OnSysColorChanged()
// so all presentations get notified properly.
// See nsWindow::GlobalMsgWindowProc.
NotifySysColorChanged();
+ // On Windows 10 only, we trigger a theme change to pick up changed media
+ // queries that are needed for accent color changes.
+ // We also set a temp pref to notify the FE that the colors have changed.
+ if (IsWin10OrLater()) {
+ NotifyThemeChanged();
+ Preferences::SetBool("ui.colorChanged", true);
+ }
}
}