Skip to content

lxqt-config-appearance: Add GTK 4 theming #1118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

IdfbAn
Copy link

@IdfbAn IdfbAn commented Mar 29, 2025

Two things I should say:

  1. X11 has been tested working by me, but Wayland (and thus GSettings?) hasn't been tested. Let me know if there's anything wrong.
  2. Opening gtk4-demo gives me this warning:
Error setting gtk-cursor-theme-size in /home/REDACTED/.config/gtk-4.0/settings.ini:
Key file contains key “gtk-cursor-theme-size” in group “Settings” which has a value that cannot be interpreted.

The theme seems to still work regardless, but if this actually causes any problems, and/or anyone knows how to fix this, it'd be great.

Closes #899.

@tsujan
Copy link
Member

tsujan commented Mar 29, 2025

The code is written neatly. Thanks!

Opening gtk4-demo gives me this warning:

This needs to be investigated. Perhaps gtk-cursor-theme-size doesn't work with GTK4 and another string should be used?

I don't use any GTK4 app and have forgotten everything about GTK after more than a decade of not dealing with it. So, my code review is far from enough. Thorough tests are needed.

@IdfbAn
Copy link
Author

IdfbAn commented Mar 29, 2025

Opening gtk4-demo gives me this warning:

This needs to be investigated. Perhaps gtk-cursor-theme-size doesn't work with GTK4 and another string should be used?

It actually does exist in GTK 4, which is why this is so weird.

@stefonarch
Copy link
Member

Installed some gtk4 apps, get the same warning but actually can't set any dark theme (adwaita-dark, breeze-dark), neither in X11 nor in Wayland.

@IdfbAn
Copy link
Author

IdfbAn commented Mar 29, 2025

Installed some gtk4 apps, get the same warning but actually can't set any dark theme (adwaita-dark, breeze-dark), neither in X11 nor in Wayland.

Hmm, interesting. HighContrastInverse works for me, could you try that?

Edit: Just installed gnome-themes-extra, and Adwaita-dark also works for me, so this is still weird.

@stefonarch
Copy link
Member

Hmm, interesting. HighContrastInverse works for me, could you try that?

Tried also that, same, it seems, should be dark no? gnome-themes-extra was installed already.

@IdfbAn
Copy link
Author

IdfbAn commented Mar 30, 2025

Hold on a second, are you sure the GTK apps you're using don't use libadwaita?

@stefonarch
Copy link
Member

Hold on a second, are you sure the GTK apps you're using don't use libadwaita?

I'm not really familiar with GTK4, I tried just Qeegie, Nautilus and Amberol, could well be. An example?

@IdfbAn
Copy link
Author

IdfbAn commented Mar 30, 2025

I'm not really familiar with GTK4, I tried just Qeegie, Nautilus and Amberol, could well be. An example?

Nautilus and Amberol use libadwaita, but Geeqie doesn't. I've just installed Geeqie to test it, but it seems like it actually uses GTK 3 (at least on Arch, btw).

@tsujan
Copy link
Member

tsujan commented Mar 30, 2025

Why testing with GTK4 apps when gtk4-widget-factory (belonging to gtk4-demos) exists?

For some reason, I have ~/.config/gtk-4.0/settings.ini as

[Settings]
gtk-application-prefer-dark-theme=true
gtk-cursor-theme-name=ComixCursors-White
gtk-cursor-theme-size=24
gtk-decoration-layout=close,minimize,maximize:icon
gtk-enable-animations=true
gtk-font-name=Sans 9
gtk-icon-theme-name=Plataro-GTK
gtk-primary-button-warps-slider=false

And this screenshot shows gtk4-widget-factory in front of gtk3-widget-factory here, under Wayland (labwc):

gtk4

But, I remember that I used dconf-editor too, when GTK4 came out.

The warning message I see is different and isn't our concern:

Gdk-WARNING **: 11:20:21.388: vkAcquireNextImageKHR(): A swapchain no longer matches the surface properties exactly, but can still be used to present to the surface successfully. (VK_SUBOPTIMAL_KHR) (1000001003)

As far as I know, GNOME devs didn't like the idea of a themeable GTK. So, maybe they've removed themeablity from GTK4 — just a guess …

@IdfbAn
Copy link
Author

IdfbAn commented Mar 30, 2025

Why testing with GTK4 apps when gtk4-widget-factory (belonging to gtk4-demos) exists?

I've already tested that too, and it also works for me. Can you explicitly set the theme to Adwaita-dark to see if it also works in Wayland?

@tsujan
Copy link
Member

tsujan commented Mar 30, 2025

No, setting gtk-theme-name=Adwaita-dark inside ~/.config/gtk-4.0/settings.ini doesn't work, but gtk-application-prefer-dark-theme=true does.

However, setting Adwaita-dark inside dconf-editor → /org/gnome/desktop/interface/gtk-theme → Custom value works.

@tsujan
Copy link
Member

tsujan commented Mar 30, 2025

The irony is that dconf-editor depends on GTK3, not GTK4. GTK is a mess!

@stefonarch
Copy link
Member

I still can't get anything in dark...
Transmission-gtk is GTK4 without libadwaita, but ignores settings.

@tsujan
Copy link
Member

tsujan commented Mar 30, 2025

Oh, Adwaita and Adwaita-dark don't support GTK4. At least here, they belong to gnome-themes-extra and their directories inside /usr/share/themes/ don't include any gtk-4.0 directory.

So, I think the tooltip ("Doesn't apply to applications that use Libadwaita") may be misleading. Switching to a theme that isn't for GTK4 shouldn't do anything.

@IdfbAn
Copy link
Author

IdfbAn commented Mar 30, 2025

Switching to a theme that isn't for GTK4 shouldn't do anything.

Doesn't that mean these themes are being falsely included in the GTK 4 box?

@tsujan
Copy link
Member

tsujan commented Mar 30, 2025

Doesn't that mean these themes are being falsely included in the GTK 4 box?

It seems so — if they're provided by gnome-themes-extra in Arch — because a theme should support GTK4 in order to be applicable to GTK4 apps.

@IdfbAn
Copy link
Author

IdfbAn commented Mar 30, 2025

Like I said earlier, Adwaita-dark does work for me (at least on X11) despite there not being a gtk-4.0 directory, so I'm either missing something or something else is happening.

@tsujan
Copy link
Member

tsujan commented Mar 30, 2025

Adwaita-dark does work for me …

I don't have the illusion that GNOME's behavior is logical, but if it is, you may have an overriding theme in a user folder. If you don't have any theme with a gtk-4.0 folder, then blame GNOME devs for the inconsistent behavior. At least, what @stefonarch and I see exonerates GNOME ;)

@IdfbAn
Copy link
Author

IdfbAn commented Mar 30, 2025

Alright then, so what do we do? Do I just remove the tooltip, or do I need to do a bit more? Ignoring the cursor theme warning, of course. (Which I probably shouldn't lol)

@tsujan
Copy link
Member

tsujan commented Mar 30, 2025

Do I just remove the tooltip

IMHO, the tooltip doesn't convey correct info. So, I think, yes, it can be removed.

do I need to do a bit more?

Something should be done because it doesn't work for @stefonarch, and so, it might not work for many users. But I don't know what or how. As I mentioned earlier, I'm not a GTK expert; what I said so far was only logical. For starters, if a theme isn't applicable to a version of GTK, it shouldn't be shown for it. Now, whether GNOME should do it (as Qt does) or we should, I don't know …

@IdfbAn
Copy link
Author

IdfbAn commented Mar 30, 2025

If there's a problem with my latest commit, let me know.

@tsujan
Copy link
Member

tsujan commented Mar 30, 2025

The commit seems good. It should be tested again, especially with a theme that supports GTK4 (is there any at all?).

But a practical problem still exists: An LXQt user may not want to install any GTK4 theme (even if GTK4 accepts themes at all) but just to switch to the dark variant. Since gnome-themes-extra doesn't cover GTK4, I wonder if we should make the code more complex and add a check box for gtk-application-prefer-dark-theme, or we should wait until GTK4 is covered and see what will happen.

@IdfbAn
Copy link
Author

IdfbAn commented Mar 30, 2025

It should be tested again, especially with a theme that supports GTK4 (is there any at all?).

I've just tested Orchis-Dark, and it does seem to work with the GTK demo apps. It gives me an "Expected a valid color" warning, but this may or may not be because of the theme itself.

@tsujan
Copy link
Member

tsujan commented Mar 30, 2025

… it does seem to work with the GTK demo apps

Good.

… but this may or may not be because of the theme itself.

Yes, we don't need to worry about GTK warnings; there are lots of them.

@stefonarch
Copy link
Member

Still nothing on my side also with orchid*. What worked was https://github.com/vinceliuice/WhiteSur-gtk-theme#fix-for-libadwaita-not-perfect

and it does:

$ cat .config/gtk-4.0/
assets/         gtk.css         gtk-dark.css    gtk-Dark.css    gtk-Light.css   windows-assets/ 

Only setting which looks working is font-size.

@tsujan
Copy link
Member

tsujan commented Mar 30, 2025

Still nothing on my side also with orchid*.

Does the orchid* you tested have a gtk-4.0 subfolder?

Also, Adwaita shouldn't be listed for GTK4 now. Is that the case?

@tsujan
Copy link
Member

tsujan commented Mar 30, 2025

I confirm that the keys gtk-cursor-theme-name and gtk-cursor-theme-size don't work under Wayland, with GTK3 or GTK4, and regardless of this PR. Maybe they should be tested only under X11.

@stefonarch
Copy link
Member

stefonarch commented Mar 30, 2025

immagine
Adwaita isn't listed. Orchis-dark has a GTK4 subfolder.

Cursor is read from one file (don't remember anymore which one) to which we write, at least under Niri and Labwc.

@tsujan
Copy link
Member

tsujan commented Mar 30, 2025

Cursor is read from one file

Yes, that's for the global cursor setting. I just wanted to say that we might need to consider the differences between Wayland and X11 when testing; @IdfbAn uses X11, you and I Wayland.

@tsujan
Copy link
Member

tsujan commented Mar 30, 2025

OK, I reread the PR and found the cause of the problem. It's simple: gsettings doesn't distinguish between GTK3 and GTK4. In GTKConfig::applyGTKStyle(), the PR first sets the theme for GTK4 and then overrides it for GTK3.

@IdfbAn
Copy link
Author

IdfbAn commented Mar 30, 2025

In GTKConfig::applyGTKStyle(), the PR first sets the theme for GTK4 and then overrides it for GTK3.

What's the exact line that's apparently problematic?

@stefonarch
Copy link
Member

stefonarch commented Mar 30, 2025

Searching for info I found that using an env var export GTK_THEME=Orchis-Dark is working for all GTK4 apps here...

I tested also X11, for theme it shouldn't be different than Wayland. Cursor is a different thing.

QString themeName = ui->gtk4ComboBox->currentText();
mConfigOtherToolKits->setGTKConfig(QStringLiteral("4.0"), themeName);
if(QGuiApplication::platformName() == QStringLiteral("wayland"))
mConfigOtherToolKits->setGsettingsConfig(QStringLiteral("4.0"), themeName);
// GTK3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The call to gsettings (in setGsettingsConfig) will be repeated and overridden below, for GTK3.

I think GTK3 and GTK4 should have the same settings and be set by a single call to gsettings. If I'm right, a single combo-box should be used for both, the previous commit should be reverted, and some minor changes will be needed too.

What I say is based on what I see in dconf-editor: when I set it to HighContrast, both GTK3 and GTK4 themes change. The call to gsettings does the same.

This creates a confusing situation though: what if a theme doesn't support GTK4? I think, in that case, only the GTK3 theme will be applied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GTK4 apps theming
3 participants