Closed Bug 1934040 Opened 1 year ago Closed 1 year ago

Wrong titlebar buttonbox height with Mica effect enabled

Categories

(Core :: Widget: Win32, defect, P3)

Firefox 135
Desktop
Windows 11
defect

Tracking

()

RESOLVED FIXED
135 Branch
Tracking Status
firefox135 --- fixed

People

(Reporter: nopeac+github, Assigned: emilio)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

Steps to reproduce:

  1. Set "widget.windows.mica" to true in about:config (Nightly)
  2. Set Firefox theme to system theme - auto
  3. Restart

Actual results:

I found a comment in the buttonbox CSS that explains it very well

@media (-moz-windows-accent-color-in-titlebar) or (-moz-windows-mica) {
:root[tabsintitlebar] {
@media (-moz-windows-mica) {
&:not([lwtheme]) {
background-color: transparent;

    /* Accent color in titlebar overrides Mica. */
    @media not (-moz-windows-accent-color-in-titlebar) {
      /* Hide the Firefox buttons since Windows draws their own.
       * FIXME(emilio): Find a way of hiding the native buttons, or make them
       * taller, this is very hacky. */
      .titlebar-buttonbox {
        opacity: 0;
      }
    }
  }
}

}
}

I didn't saw any bug report about it, hopefully this is being worked on (by emilio I guess?).

Expected results:

The button box should be the same height as its parent container as before.

The Bugbug bot thinks this bug should belong to the 'Core::Audio/Video' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Audio/Video
Product: Firefox → Core
Component: Audio/Video → Theme
OS: Unspecified → Windows 11
Product: Core → Firefox
Hardware: Unspecified → Desktop
Blocks: 1764822
Component: Theme → Widget: Win32
Product: Firefox → Core
See Also: → 1934139

Yes, I know about this, and I've looked into it. But so far I haven't found a way to make it work that doesn't regress other things (like snap layouts). I'll post some more context in a bit...

In the Aero days, we basically just dealt with this by hiding our own controls and reserving that space for DWM. It seems that's what chromium is doing too. But that's not great.

The only reliable way I found to hide the DWM caption buttons is to flip the relevant WS_{SYSMENU,MINIMIZEBOX,MAXIMIZEBOX} bits in the window style, or flip WS_CAPTION entirely. But that has too many side effects:

  • Maximize covers the task bar (documented quirk).
  • tiling, double-click, snap layouts, etc all stop working.

I realized Edge manages to stash its own window controls on its mica titlebar, so there's probably something that can be done about this? But I haven't found it so far. I'm aware of the AppWindowTitlebar.PreferredHeightOption thing exposed in the Windows SDK, but whatever lower level mechanism that uses, which is what we'd have to use (maybe a custom DWMWindowAttribute or something?) doesn't seem to be documented.

Blocks: windows-mica
No longer blocks: 1764822
Status: UNCONFIRMED → NEW
Ever confirmed: true
Blocks: 1934139
See Also: 1934139
Blocks: 1934138
Duplicate of this bug: 1934137

I don't know if it's helpful, but the settings page on Microsoft’s PowerToys, which is open source, has Mica implemented, and from what I can see, the buttonbox is tall, or at least taller than what Firefox is showing. Perhaps their code can help us understand how they are handling the issue.

No longer blocks: 1934138

Yeah they use the .PreferredHeightOption = Tall mentioned above (here).

Was bug 1934138 removed intentionally from the blocking list? Custom-drawing our buttons would fix it.

Blocks: 1934138

No, sorry I'm not really familiar with Bugzilla. The interface is a bit overwhelming and I might have messed something up when I replied. Feel free to reverse that, I have no clue how to do it myself.

Unhide our buttons instead, which fixes the caption button sizes when
Mica is enabled.

Crucially (and this is what I had failed to do in my original attempts),
we need to keep WS_MAXIMIZEBOX for Snap Layouts and Aero snap to keep
working. WS_MINIMIZEBOX doesn't hurt either.

This is a bit scary, because we're in undocumented territory, but afaict
(looking with winspy), MS Edge does the same for its custom titlebar, so
I think this is probably safe. It's early in the cycle anyways...

Assignee: nobody → emilio
Status: NEW → ASSIGNED

Ok, I think I found something that doesn't cause side effects...

Severity: -- → S3
Priority: -- → P3

FWIW, I noticed that the tabbed version of File Explorer also has buttons shorter than its Mica titlebar. Given that it ships with the OS and is a core app, maybe this isn't necessarily an issue and more of a preference?

Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/838165f60521 Remove WS_SYSMENU when using custom titlebar, so that DWM doesn't draw caption buttons. r=win-reviewers,rkraesig
Duplicate of this bug: 1934139
Duplicate of this bug: 1934138
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 135 Branch
Regressions: 1935542
No longer blocks: 1934138, 1934139
QA Whiteboard: [qa-135b-p2]
Regressions: 1947324
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: