Zren / material-decoration

Material-ish window decoration theme for KWin, with LIM, based on zzag's original design.
GNU General Public License v2.0
197 stars 17 forks source link

Close, maximize and minimize buttons are very small in gtk apps with CSDs since Plasma 5.20 #22

Closed mthw0 closed 3 years ago

mthw0 commented 3 years ago

In Plasma 5.20, close, maximize, and minimize buttons now try to use the same look as buttons in SSDs resulting in very small buttons when your window decorations are used. Is this an issue on your side or is there something wrong on the Plasma side? This is a screenshot from Firefox with CSDs enabled:

Screenshot_20200918_083041

It looks the same in gtk3-demo. This issue was also reported on the KDE bug tracker: https://bugs.kde.org/show_bug.cgi?id=426670 Could you look into this?

Zren commented 3 years ago

I can reproduce in Gnome Chess. My Firefox has a userChrome.css that swapped the Breeze for Window's like buttons, so I'll test that later.

2020-09-19___09-27-35

CSD should be controlled by the GTK theme. Atm I can't even find the "Gtk Theme" module in System Settings however. Or the Qt theme module (which should be the same module now). Weird.

Zren commented 3 years ago

Wow, neat. It appears changing Windows Decorations will now "paint" the decorations as .svg in ~/.config/gtk-3.0/assets/. So cool!

Zren commented 3 years ago

It's drawing a 50x50 icon. However my icon is only 10x10.

Normally my buttons are 32x24. With the icon 11x11.

image

Since my Gtk theme only has a 39px tall headerbar, the icon is even smaller. 39/50 * 10 = 7.8px.

There must be padding above/below the icon button however, as the icon looks like it's only 6x6 in the CSD. Perhaps the button is only 32x32? 32/50 * 10 = 6.4px

Zren commented 3 years ago

I don't appear to scale the buttons in Qt apps. VeryLarge = 34px tall, Medium = 24px tall, Tiny = 20px tall. Icons are always 11x11.

Hmm, do I even scale the buttons for HiDPI?

I need to scale the 10x10 rect in Button::paint.

Zren commented 3 years ago

If I scale the icon by buttonRect.height() * 10/24, I get:

Unfortunately, it doesn't appear to affect the gtk theme in ~/.config/gtk-3.0/assets/*.svg. I event switched to Breeze then back to Material.

Button.cc Code:

    const QRectF buttonRect = geometry();
    int iconSize = qRound(buttonRect.height() * 10/24);
    QRectF iconRect = QRectF(0, 0, iconSize, iconSize);
    qCDebug(category) << "Button::paint" << buttonRect << (buttonRect.height() * 10/24) << iconSize << iconRect;
    iconRect.moveCenter(buttonRect.center().toPoint());
Zren commented 3 years ago

There's a cache of some sort I think. I added an extra line the maximize icon, but it was not reflected in the gtk assets.

2020-09-19___10-34-06

Zren commented 3 years ago

Looks like it renders to /tmp/plasma-csd-generator/ first. It's empty though, so it's not cached.

Zren commented 3 years ago

I needed to reboot for changes to take effect. So whatever process uses kde-gtk-config is loaded in needs to be restarted, just like I need to restart kwin_x11 to test changes to the normal window decorations.

2020-09-19___15-47-56

Zren commented 3 years ago

Had to also scale the line thickness. It's a bit blurry still since we're scaling the icon by 50/18 = 2.777 so it's a pain to get sharp lines for the minimize and maximize lines.

"Very Large" KWin buttons on top, with Chess Gtk CSD below:

2020-09-19___21-29-34

Zren commented 3 years ago

In https://github.com/Zren/material-decoration/commit/65fe6f577a978a9e601241d29bea35185eb7f69c, I check if the process is kded5, and use a smaller padding around the icon. I can't easily get the button to use sharp lines, but at least the icons are visible now.

mthw0 commented 3 years ago

It looks good now, thanks.