tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 569ef287466f189b92605efa761d6524a24037ff
parent c2f95f64b771a845188ab1d5a0de94f17c831c46
Author: Greg Stoll <gstoll@mozilla.com>
Date:   Sat, 15 Nov 2025 02:51:26 +0000

Bug 1993474 - remove WS_BORDER to fix border issues with Windows App SDK r=win-reviewers,handyman

When a window with WS_BORDER is maximized on a low-ish DPI monitor, an
"extra" border on top shows up. This breaks the workflow of moving your
mouse to the very top of the screen to hover over or select tabs.

(people have reported this with non-Firefox apps so I'm guessing this is
really an OS problem)

But the WS_BORDER style doesn't actually seem necessary for us when tabs
are being shown in the toolbar - removing it still means we can resize
our window, etc.

We do need to handle the case when tabs are not being shown in the toolbar,
so we have to toggle the WS_BORDER style when that changes. I tested on my
system in a number of different configurations and it seems to work fine.

I believe this will fix bug 1994918 and possibly some others.

Differential Revision: https://phabricator.services.mozilla.com/D272653

Diffstat:
Mwidget/windows/nsWindow.cpp | 19+++++++++++++++++++
1 file changed, 19 insertions(+), 0 deletions(-)

diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp @@ -2828,6 +2828,25 @@ void nsWindow::SetCustomTitlebar(bool aCustomTitlebar) { mCustomNonClient = aCustomTitlebar; + // Because of bug 1993474, we want to properly set the WS_BORDER style + // when the titlebar is turned on or off. + // + // The documentation for window styles says that most styles can't be + // modified after the window is created. Testing shows that WS_BORDER + // seems to be OK, but make sure this is the only style we try to change + // here. + const LONG_PTR actualStyle = ::GetWindowLongPtrW(mWnd, GWL_STYLE); + LONG_PTR newStyle = actualStyle; + if (mCustomNonClient) { + newStyle &= ~WS_BORDER; + } else { + newStyle |= WS_BORDER; + } + if (newStyle != actualStyle) { + VERIFY_WINDOW_STYLE(newStyle); + ::SetWindowLongPtrW(mWnd, GWL_STYLE, newStyle); + } + // Force a reflow of content based on the new client dimensions. if (mCustomNonClient) { UpdateNonClientMargins();