Skip to content
Snippets Groups Projects
Commit 3155509b authored by Emilio Cobos Álvarez's avatar Emilio Cobos Álvarez
Browse files

Bug 1813697 - Honor full CSS-to-device scale for native GTK widgets. r=stransky

KDE uses the GTK text scale factor to implement fractional global
scaling.

While some GTK apps really only use it for text, we interpret it as a
full DPI change (this is configurable via
browser.display.os-zoom-behavior, but that's our default behavior for a
long long time).

We're ignoring the text scale factor right now, but there's no good
reason to it, now that we support fractional scaling. After this patch,
native widgets are consistently scaled  with all the other chrome UI
elements. This includes checkbox menuitems, buttons, etc.

The exception here are scrollbars, which are special and still ignore
the text scale factor here:

  https://searchfox.org/mozilla-central/rev/8e9b4484408154b80d7ede9e1b035819fda48fd2/widget/ScrollbarDrawing.cpp#28-32

But that's fine because scrollbars are the only widget that ignores full
zoom, and that also matches what Windows does with the text scale
factor, so if we want to change it that's probably worth a separate bug.
(I also have some changes to that code in flight for bug 1812868 so I'd
rather not have gratuituous conflicts).

Depends on D168371

Differential Revision: https://phabricator.services.mozilla.com/D168372
parent 65406dde
No related branches found
No related tags found
No related merge requests found
......@@ -61,16 +61,10 @@ using namespace mozilla::widget;
static int gLastGdkError;
// Return widget scale factor of the monitor where the window is located by the
// most part.
// We prefer the root widget scale since it doesn't account for text scale
// factor, this is the same scrollbars do in GTK.
// most part. We intentionally honor the text scale factor here in order to
// have consistent scaling with other UI elements.
static inline CSSToLayoutDeviceScale GetWidgetScaleFactor(nsIFrame* aFrame) {
nsPresContext* pc = aFrame->PresContext();
nsIWidget* rootWidget = pc->GetRootWidget();
auto scale =
rootWidget ? rootWidget->GetDefaultScale() : pc->CSSToDevPixelScale();
scale.scale = std::max(1.0f, std::round(scale.scale));
return scale;
return aFrame->PresContext()->CSSToDevPixelScale();
}
nsNativeThemeGTK::nsNativeThemeGTK() : Theme(ScrollbarStyle()) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment