Forcing GTK4 for Chromium-Based Apps

Hi,

My original goal was to activate fcitx5 input methods in various Chromium-based apps. The search lands on passing the flag --gtk-version=4, which works on natively installed applications. However, I recently migrated my browser (Brave, in particular) from AUR to Flatpak, and I couldn’t get the same result as the natively installed version.

With ozone-platform-hint is already set to ‘auto’ in ‘brave://flags’ section, and
‘brave --gtk-version=4’ would work when natively installed (with AUR),
My first attempt is quite naive:

$ flatpak run com.brave.Browser --gtk-version=4

However, I still cannot activate fcitx5. A quick check unveils the actual processes are still referencing GTK3:

#!/bin/bash
for pid in $(pidof brave); do
        grep -i gtk /proc/"$pid"/maps
done

797853600000-797853690000 r--p 00000000 00:1e 19369435                   /usr/lib/x86_64-linux-gnu/libgtk-3.so.0.2409.32
797853690000-797853a40000 r-xp 00090000 00:1e 19369435                   /usr/lib/x86_64-linux-gnu/libgtk-3.so.0.2409.32
797853a40000-797853dbc000 r--p 00440000 00:1e 19369435                   /usr/lib/x86_64-linux-gnu/libgtk-3.so.0.2409.32
797853dbc000-797853dcc000 r--p 007bb000 00:1e 19369435                   /usr/lib/x86_64-linux-gnu/libgtk-3.so.0.2409.32
797853dcc000-797853dce000 rw-p 007cb000 00:1e 19369435                   /usr/lib/x86_64-linux-gnu/libgtk-3.so.0.2409.32
79785ccca000-79785cccb000 r--p 00000000 00:1e 6354350                    /usr/share/locale/en/LC_MESSAGES/gtk30-properties.mo
79785cccb000-79785cccc000 r--p 00000000 00:1e 211718                     /usr/share/locale/en/LC_MESSAGES/gtk30.mo

The environment variables set for com.brave.Browser are:

XMODIFIERS=@im=fcitx
QT_IM_MODULE=fcitx
GTK_IM_MODULE=fcitx
DCONF_USER_CONFIG_DIR=.config/dconf
XCURSOR_PATH=/run/host/user-share/icons:/run/host/share/icons
GTK_PATH=/app/lib/gtkmodules
GIO_EXTRA_MODULES=/app/lib/gio/modules
GSETTINGS_BACKEND=dconf

Is there a way to tell those apps to use GTK4?

Thanks

Just FYI, brave is not using electron / is not an electron app

Thanks for the correction. I assume Chromium-based application is a better term to call them?

Yes, that should be correct

Is there a way to tell those apps to use GTK4?

no.

The search lands on passing the flag --gtk-version=4, which works on natively installed applications.

where did you read that?

There were plenty of people talking about this. To name a few:
On Reddit, also on GitHub, and even on Arch Wiki.

As for Fcitx5 specific issue, as stated on their official Wiki, I could get around it by passing in --enable-wayland-ime into a few chromium-based applications, but not all. Joplin is one example that will complain it cannot recognize this flag.

Not an easy way, the runtime (org.freedesktop.Platform) doesn’t provide GTK4. It’s only available in org.gnome.Platform (or in case an application provides its own build).