Skip to content

Enhancements for night mode (inverted colors)

Aleš Nezbeda requested to merge SlouchyButton/evince:main into main

Enhanced implementation of night/dark mode for content. It doesn't just invert colors, but allows for night mode (without high contrast) and legacy inverted colors (because some users in those scattered issues mentioned preferences for both).

It also uses modified approach of fork mentioned in #1501 (comment 1344371). This approach is probably less efficient, but fully modifies individual pixels and should resolve other issues regarding antialiasing and weird font glitching. Those were especially noticeable when not doing full color invert. Those might be fixed by using CAIRO_OPERATOR_EXCLUSION (see #1501 (comment 993114)), but I haven't tested this.

This approach also allows us to ignore colors when inverting, this is hinted in a draft (working) code in comment. This shouldn't be default behavior, because it can make things more messy, but I haven't figured out a way how to implement this choice into UI without cluttering it too much.

It also redraws the surfaces so that there is no need for ridiculous math magic used in the aforementioned fork, and to allow different invert values without impacting too much code. Redraw is the easiest approach, and I feel like the most sane one. This redraw method is also needed if we would switch the logic back to the cairo_set_source_rgb method, as there is no way to revert those changes.

Originally, this should have included an option to automatically switch modes when the OS switches to and from dark mode. I removed those changes in the second commit, as dark mode switching is handled by Libhandy, and it doesn't seem to have an easy way of notifying of dark mode preference change.

I'm marking this as a draft Removed the draft, in hope that it could get more attention (I think that due to MR being marked as draft maintainers ignored it), because this is my first contribution to this project and there might be a better approach I missed, but I am open to changing the code myself based on discussion here. This MR then serves as a proposed change, but also as a discussion opener to figure out a possibly better way of handling this.

Fixes #1501 Fixes #279 Fixes #1334

Edited by Aleš Nezbeda

Merge request reports