Skip to content
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

Get accent color from system stylesheet #360

Closed
danirabbit opened this issue Oct 19, 2020 · 5 comments
Closed

Get accent color from system stylesheet #360

danirabbit opened this issue Oct 19, 2020 · 5 comments

Comments

@danirabbit
Copy link
Contributor

You can use Gtk foreign drawing API to get the correct accent color from the stylesheet. Consider this commit in Gala:

https://github.com/elementary/gala/pull/909/files#diff-7621626af936a6bd469f8302ec5666ca88e146bb87af769b507a010f30ee55d3R398

@JoseExposito
Copy link
Owner

Hi Daniel,

Thank you very much for your report!

Yes, that is something that is definitely in my wish-list and a must have for elementary OS 6.
I didn't investigate it much yet, however, I don't like the idea of adding Gtk as a dependency. It is a big one a KDE/LXQt/etc users will complain.

Do you know if there is another way of getting it? A GSetting maybe? Otherwise, I could just generate a elementary OS build with a #ifdef 🤔

@danirabbit
Copy link
Contributor Author

Hm not reliably. I guess you could try to read /org/gnome/desktop/interface/gtk-theme and guess from a set of hardcoded colors, but this solution would work for any Gtk desktop and stylesheet

@JoseExposito
Copy link
Owner

I finally decided to use GTK to get both the background color and the border color. Reading the current theme and using a hardcoded color was just too hacky and difficult to maintain:
https://github.com/JoseExposito/touchegg/blob/master/src/utils/color.cpp#L55

I don't have access to elementary OS 6, so I can not test it with the new accent color selector. It should wok ™️ but it will be nice to test it before I release v2.0.3. Could you confirm it please?

BTW, does Gala on elementary OS 6 add a border to the tiling preview? I didn't find a reference to Gtk.STYLE_PROPERTY_BORDER_COLOR. Not sure if it is a bug or the intended behaviour.


For those who prefer to not install GTK and/or leave some RAM unused (this feature increases RAM usage from 800kb to ~5MB, but c'mon guys, this flies on a Raspberry Pi 4), I added a flag to NOT compile with GTK:
https://github.com/JoseExposito/touchegg/blob/master/HACKING.md#cmake--dauto_colorsonoff

@danirabbit
Copy link
Contributor Author

I can confirm that the correct accent color is loaded on session start, but it doesn't seem to update during the session if the user changes their accent color

I don't believe we do add a border for tiling previews

Also, I added you to the allowlist for builds.elementary.io :)

@JoseExposito
Copy link
Owner

Weird, I calculate the new color just before every animated gesture...

Thank you so much for giving me access, I'll do some testing 😄

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

No branches or pull requests

2 participants