Skip to content

background: Improve background preview and refactor

This MR is quite big, but each commit is atomic and should hopefully be explained well enough. The general idea is:

  1. Make CcBackgroundPaintable reusable. There is a lot of drawing specific properties in the bg-source.c file, which makes it a) hard to change and b) specific to the chooser. By refactoring this out, we can make CcBackgroundPaintable more generic and self-contained. This also solves a bug that was not reported so far; moving the Settings window between monitors with different scale factors was broken for the chooser thumbnails.
  2. Now that CcBackgroundPaintable is reusable, we can use it inside the preview in a GtkPicture. This allows us to again remove a lot of drawing code from the preview. The preview used to be blurry at scale factors > 1 because the scale factor was not applied properly in the thumbnail generator for CcBackgroundItem. Now that CcBackgroundPaintable is more self-contained, we can fix this too, making previews at higher scale factors sharper.
  3. We let the GtkPicture in the preview do the resampling of the underlying paintable texture. This means we always grab the maximum available gnome_bg thumbnail resolution, which is 256 for some reason. This also means that resizing is now even faster than with !2057 (merged), because the thumbnail is retrieved only once. The gnome_bg code was resizing based on the 256 thumbnail anyways.
  4. Making the preview even sharper is possible, but that would require a full size load and draw again, which is terribly slow. This was precisely why !2057 (merged) got rid of that.
  5. We remove the unused BgColorsSource, and refactor some more.

Fixes #704 (closed)

Sharpness at scale factor 2 before
Screenshot_from_2023-11-30_03-05-00

Sharpness at scale factor 2 after
Screenshot_from_2023-11-30_03-04-47

Happy reviewing!

Edited by Matthijs Velsink

Merge request reports