Finds paths to icon files using libsfdo. Libsfdo is currently an

optional compile time dependency. This means the former code paths are
all retained and new ones are wrapped in #if HAVE_LIBSFDO. Behavior
should be identical now between the two code paths. Later commits will
add the handling of icons specified as absolute paths which both former
swaybar code and libsfdo have thus far avoided.
This commit is contained in:
myrslint 2025-04-29 17:37:58 +00:00
parent 3a21b8c6f1
commit aeeb99c5a3
14 changed files with 220 additions and 93 deletions

19
include/sfdo.h Normal file
View file

@ -0,0 +1,19 @@
#ifndef _SWAY_SFDO_H
#define _SWAY_SFDO_H
#include <sfdo-desktop.h>
#include <sfdo-icon.h>
#include <sfdo-basedir.h>
struct sfdo {
struct sfdo_desktop_ctx *desktop_ctx;
struct sfdo_icon_ctx *icon_ctx;
struct sfdo_desktop_db *desktop_db;
struct sfdo_icon_theme *icon_theme;
};
char *sfdo_icon_lookup_extended(struct sfdo *sfdo, char *icon_name, int target_size, int scale);
struct sfdo *sfdo_create(char *icon_theme);
void sfdo_destroy(struct sfdo *sfdo);
#endif

View file

@ -399,8 +399,11 @@ struct bar_config {
char *binding_mode_text;
} colors;
#if HAVE_TRAY
#if HAVE_TRAY || HAVE_LIBSFDO
char *icon_theme;
#endif
#if HAVE_TRAY
struct wl_list tray_bindings; // struct tray_binding::link
list_t *tray_outputs; // char *
int tray_padding;

View file

@ -8,11 +8,11 @@
#if WLR_HAS_XWAYLAND
#include "sway/xwayland.h"
#endif
#if HAVE_LIBSFDO
#include <sfdo-desktop.h>
#include <sfdo-icon.h>
#include <sfdo-basedir.h>
#include "sfdo.h"
#endif
struct sway_transaction;
struct sway_session_lock {
@ -28,15 +28,6 @@ struct sway_session_lock {
struct wl_listener destroy;
};
#if HAVE_LIBSFDO
struct sfdo {
struct sfdo_desktop_ctx *desktop_ctx;
struct sfdo_icon_ctx *icon_ctx;
struct sfdo_desktop_db *desktop_db;
struct sfdo_icon_theme *icon_theme;
};
#endif
struct sway_server {
struct wl_display *wl_display;
struct wl_event_loop *wl_event_loop;
@ -209,9 +200,4 @@ void set_rr_scheduling(void);
void handle_new_tearing_hint(struct wl_listener *listener, void *data);
#if HAVE_LIBSFDO
struct sfdo *sfdo_create(char *theme);
void sfdo_destroy(struct sfdo *sfdo);
#endif
#endif

View file

@ -16,6 +16,10 @@ struct swaybar_tray;
struct swaybar_workspace;
struct loop;
#if HAVE_LIBSFDO
struct sfdo;
#endif
struct swaybar {
char *id;
char *mode;
@ -50,6 +54,10 @@ struct swaybar {
struct swaybar_tray *tray;
#endif
#if HAVE_LIBSFDO
struct sfdo *sfdo;
#endif
bool running;
};

View file

@ -8,6 +8,10 @@
#include "util.h"
#include <pango/pangocairo.h>
#if HAVE_LIBSFDO
#include "sfdo.h"
#endif
struct box_colors {
uint32_t border;
uint32_t background;
@ -68,13 +72,20 @@ struct swaybar_config {
struct box_colors binding_mode;
} colors;
#if HAVE_TRAY
#if HAVE_TRAY || HAVE_LIBSFDO
char *icon_theme;
#endif
#if HAVE_TRAY
struct wl_list tray_bindings; // struct tray_binding::link
bool tray_hidden;
list_t *tray_outputs; // char *
int tray_padding;
#endif
#if HAVE_LIBSFDO
struct sfdo *sfdo;
#endif
};
#if HAVE_TRAY