Subject: Re: bug#53457: 29.0.50; pgtk: [Request] Expose GtkSettings to emacs

From: Po Lu <[email-masked]>
Date: Tue, 25 Jan 2022 19:52:39 +0800

Maximiliano Sandoval <[email-masked]> writes:

> That works for me, but I have to stress out that this is not GNOME
> specific.  Such a patch would only require
>
> ```
> hdy_init ();
> hdy_style_manager_set_color_scheme (hdy_style_manager_get_default (),
>                                     HDY_COLOR_SCHEME_PREFER_LIGHT);
> ```
>
> after `gtk_init ()` is called to opt-in into following the user
> preference.  Note that this requires libhandy >= 1.5, meaning that
> there are no stable releases that support this yet, we will have one
> before GNOME 42 in march.

No worries, we can wait until it is released this March to add such an option.

> If you are using Adwaita-dark, whatever color scheme you declare in
> the xdg-desktop-portal will be override by it (and thus ignored). The
> reason Adwaita-dark is broken is because apps cannot tell that they
> are in a dark mode, which leads to broken visuals, e.g. in gedit the
> highlight for the current line is white, making text invisible in
> Adwaita-dark.

That can be remedied by selecting a different color theme in gedit's
preferences, I think.

> How does this affect Emacs? For example you might want to sync emacs'
> theme with the headerbar stylesheet, and without hacks it is not
> possible to tell if emacs is using a stylesheet that correspond to a
> dark mode. The only way this is possible is by reading the xdg backed
> preference and for doing so, it is desirable to have emacs being able
> to declare its own GTK theme.

There is no "headerbar stylesheet" we control, not even on PGTK.  GTK
only draws decorations in our usage when none are available from the
display server and/or window manager, so it isn't right for us to
advertise a feature for "changing the window decoration color" that
doesn't work as such.

> Those options are there only to avoid breakage with existing setups
> and they are not going away as you point out, that does not mean they
> are *supported*. The only supported way to tell a GTK 3 app that it
> should use a dark mode stylesheet is via the
> `gtk-application-prefer-dark-theme` setting.

No, the gsettings setting is explictly supported inside GTK code, and is
not a by-product of trying to not break existing setups.

Programs which want to follow the new XDG preference for preferring dark
stylesheets should use libadwatia or libhandy.  A configuration option
for Emacs to use that is the right way forward, so I suggest any
interested party to begin hacking on that now.

Thanks.