mirror of
https://github.com/swaywm/sway.git
synced 2026-04-17 06:46:32 -04:00
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:
parent
3a21b8c6f1
commit
aeeb99c5a3
14 changed files with 220 additions and 93 deletions
|
|
@ -537,6 +537,9 @@ static void free_seats(struct wl_list *list) {
|
|||
void bar_teardown(struct swaybar *bar) {
|
||||
#if HAVE_TRAY
|
||||
destroy_tray(bar->tray);
|
||||
#endif
|
||||
#if HAVE_LIBSFDO
|
||||
sfdo_destroy(bar->config->sfdo);
|
||||
#endif
|
||||
free_outputs(&bar->outputs);
|
||||
free_outputs(&bar->unused_outputs);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,10 @@
|
|||
#include "list.h"
|
||||
#include "log.h"
|
||||
|
||||
#if HAVE_LIBSFDO
|
||||
#include "sfdo.h"
|
||||
#endif
|
||||
|
||||
uint32_t parse_position(const char *position) {
|
||||
uint32_t horiz = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
|
||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
|
||||
|
|
@ -131,5 +135,15 @@ void free_config(struct swaybar_config *config) {
|
|||
|
||||
free(config->icon_theme);
|
||||
#endif
|
||||
|
||||
#if HAVE_LIBSFDO && !HAVE_TRAY
|
||||
free(config->icon_theme);
|
||||
#endif
|
||||
|
||||
#if HAVE_LIBSFDO
|
||||
sfdo_destroy(config->sfdo);
|
||||
sway_log(SWAY_DEBUG, "Destroyed swaybar sfdo");
|
||||
#endif
|
||||
|
||||
free(config);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,10 @@
|
|||
#include "stringop.h"
|
||||
#include "util.h"
|
||||
|
||||
#if HAVE_LIBSFDO
|
||||
#include "sfdo.h"
|
||||
#endif
|
||||
|
||||
void ipc_send_workspace_command(struct swaybar *bar, const char *ws) {
|
||||
uint32_t size = strlen("workspace \"\"") + strlen(ws);
|
||||
for (size_t i = 0; i < strlen(ws); ++i) {
|
||||
|
|
@ -330,6 +334,10 @@ static bool ipc_parse_config(
|
|||
|
||||
if ((json_object_object_get_ex(bar_config, "icon_theme", &icon_theme))) {
|
||||
config->icon_theme = strdup(json_object_get_string(icon_theme));
|
||||
#if HAVE_LIBSFDO
|
||||
sfdo_destroy(config->sfdo);
|
||||
config->sfdo = sfdo_create(config->icon_theme);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,15 @@ if have_tray
|
|||
swaybar_deps += sdbus
|
||||
endif
|
||||
|
||||
if have_libsfdo
|
||||
swaybar_deps += [
|
||||
sfdo_basedir,
|
||||
sfdo_desktop,
|
||||
sfdo_desktop_file,
|
||||
sfdo_icon
|
||||
]
|
||||
endif
|
||||
|
||||
executable(
|
||||
'swaybar', [
|
||||
'bar.c',
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#include <arpa/inet.h>
|
||||
#include <cairo.h>
|
||||
#include <limits.h>
|
||||
#include <sfdo-common.h>
|
||||
#include <sfdo-icon.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
|
@ -18,6 +20,10 @@
|
|||
#include "stringop.h"
|
||||
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
|
||||
|
||||
#if HAVE_LIBSFDO
|
||||
#include "sfdo.h"
|
||||
#endif
|
||||
|
||||
// TODO menu
|
||||
|
||||
static bool sni_ready(struct swaybar_sni *sni) {
|
||||
|
|
@ -420,15 +426,36 @@ static void reload_sni(struct swaybar_sni *sni, char *icon_theme,
|
|||
char *icon_name = sni->status[0] == 'N' ?
|
||||
sni->attention_icon_name : sni->icon_name;
|
||||
if (icon_name) {
|
||||
char *icon_path = NULL;
|
||||
#if !HAVE_LIBSFDO
|
||||
list_t *icon_search_paths = create_list();
|
||||
list_cat(icon_search_paths, sni->tray->basedirs);
|
||||
if (sni->icon_theme_path) {
|
||||
list_add(icon_search_paths, sni->icon_theme_path);
|
||||
}
|
||||
char *icon_path = find_icon(sni->tray->themes, icon_search_paths,
|
||||
icon_path = find_icon(sni->tray->themes, icon_search_paths,
|
||||
icon_name, target_size, icon_theme,
|
||||
&sni->min_size, &sni->max_size);
|
||||
#else
|
||||
struct sfdo *sfdo = sni->tray->bar->config->sfdo;
|
||||
if (sfdo) {
|
||||
int lookup_options = SFDO_ICON_THEME_LOOKUP_OPTIONS_DEFAULT;
|
||||
int scale = 1;
|
||||
struct sfdo_icon_file *icon_file = \
|
||||
sfdo_icon_theme_lookup(sfdo->icon_theme, icon_name, SFDO_NT, \
|
||||
target_size, scale, lookup_options);
|
||||
if (!icon_file || icon_file == SFDO_ICON_FILE_INVALID) {
|
||||
sway_log(SWAY_ERROR, "sfdo: icon %s invalid or not found in theme %s at size %d", \
|
||||
icon_name, icon_theme, target_size);
|
||||
} else {
|
||||
icon_path = strdup(sfdo_icon_file_get_path(icon_file, NULL));
|
||||
}
|
||||
sfdo_icon_file_destroy(icon_file);
|
||||
}
|
||||
#endif
|
||||
#if !HAVE_LIBSFDO
|
||||
list_free(icon_search_paths);
|
||||
#endif
|
||||
if (icon_path) {
|
||||
cairo_surface_destroy(sni->icon);
|
||||
sni->icon = load_image(icon_path);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue