Commit graph

10 commits

Author SHA1 Message Date
John Lindgren
36f754e662 icon-loader: update PNG and XPM loaders to use new buffer helper 2024-10-06 22:38:03 -04:00
John Lindgren
ddfaae98ad icon-loader: load SVG icons at max scale of any usable output
- Add a new function to get the maximum scale of all usable outputs
- Pass the maximum output scale through to img_svg_load(), which
  ultimately calls cairo_surface_set_device_scale() before rendering
2024-10-06 21:24:34 -04:00
John Lindgren
977d561695 icon-loader: fix a few more missing icons
By:
- stripping extensions from relative icon filenames (for example,
  gdmap.desktop has "Icon=gdmap_icon.png")
- using the WM_CLASS "instance" rather than "class" string, which
  is usually the same but lowercase
2024-10-05 21:01:55 +01:00
John Lindgren
b4bc6ffceb icon-loader: also match desktop entries StartupWMClass
GIMP for example sets its WM_CLASS to "gimp-2.10", which does not match
the "gimp.desktop" filename, but matches the StartupWMClass key listed
in it.

Thanks to @vyivel for the suggestion.
2024-10-04 22:25:37 +01:00
John Lindgren
45f3bde864 icon-loader: add a log handler for sfdo messages
Useful for debugging why an icon isn't being loaded.

v2: suggestions from @tokyo4j
2024-10-04 20:25:15 +01:00
John Lindgren
c9e0a6e125 icon-loader: add a new loader for XPM icons, used by many legacy X11 apps
Adapted from gdk-pixbuf, see the original at:

  https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/blob/master/gdk-pixbuf/io-xpm.c

rgb.txt is from X.org, see:

  https://gitlab.freedesktop.org/xorg/app/rgb/-/blob/master/rgb.txt

Differences from the gdk-pixbuf version:

- GdkPixbuf replaced with struct lab_data_buffer
- Progressive and in-memory loading code removed
- Two functions that had separate BSD copyright rewritten
- Stores colors as ARGB32 earlier in the decoding process for efficiency
- Limited to 1024x1024 px and 1024 colors to prevent abuse
- Uses struct buf to build strings, in place of manual g_new/g_realloc
- Uses xzalloc/xznew_n for other memory allocations
- Uses g_strlcpy in place of banned strcpy/strncpy/strncat
- Uses standard C types (int, bool, etc.) in place of the GLib ones
- Follows labwc coding style (whitespace, braces, letter case, etc.)
- Et cetera ...

v2: add Perl fixes from @domo141
2024-09-30 21:17:19 -04:00
John Lindgren
887ec70ba4 icon-loader: match more application icons via fuzzy match
Add fallback logic to match reverse-URL .desktop file names when
the app_id is just the base name (e.g. "thunderbird" ->
org.mozilla.Thunderbird.desktop).
2024-09-30 22:05:38 +01:00
Johan Malm
3394f191a4 icon-loader: support absolute icon names 2024-09-28 12:38:18 +01:00
Johan Malm
be5472a840 icon-loader: refactor in preparation for supporting absolute icon names
No functional change intended.
2024-09-28 12:38:18 +01:00
tokyo4j
a745f91169 ssd: support window icons
The default `titleLayout` is updated to `icon:iconify,max,close` which
replaces the window menu button with the window icon.

When the icon file is not found or could not be loaded, the window menu
icon as before is shown.

The icon theme can be selected with `<theme><icon>`.

This commit adds libsfdo as an optional dependency. `-Dicon=disabled` can
be passsed to `meson setup` command in order to disable window icon, in
which case the window icon is always replaced with a window menu button.
2024-09-25 18:04:09 +09:00