mirror of
https://github.com/swaywm/sway.git
synced 2026-04-20 06:47:03 -04:00
Merge 2d5c67afda into c7d7d56f61
This commit is contained in:
commit
0f56cd4e12
19 changed files with 641 additions and 415 deletions
|
|
@ -8,6 +8,7 @@ lib_sway_common = static_library(
|
||||||
'loop.c',
|
'loop.c',
|
||||||
'list.c',
|
'list.c',
|
||||||
'pango.c',
|
'pango.c',
|
||||||
|
'sfdo.c',
|
||||||
'stringop.c',
|
'stringop.c',
|
||||||
'util.c'
|
'util.c'
|
||||||
),
|
),
|
||||||
|
|
|
||||||
104
common/sfdo.c
Normal file
104
common/sfdo.c
Normal file
|
|
@ -0,0 +1,104 @@
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sfdo-basedir.h>
|
||||||
|
#include <sfdo-desktop.h>
|
||||||
|
#include <sfdo-icon.h>
|
||||||
|
|
||||||
|
#include "log.h"
|
||||||
|
#include "sfdo.h"
|
||||||
|
|
||||||
|
// this extends libsfdo's behavior to also handle icons specified as absolute paths
|
||||||
|
char *sfdo_icon_lookup_extended(struct sfdo *sfdo, char *icon_name, int target_size, int scale) {
|
||||||
|
char *icon_path = NULL;
|
||||||
|
if (icon_name[0] == '/') {
|
||||||
|
struct stat sb;
|
||||||
|
if (!stat(icon_name, &sb)) {
|
||||||
|
icon_path = strdup(icon_name);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
int lookup_options = SFDO_ICON_THEME_LOOKUP_OPTIONS_DEFAULT;
|
||||||
|
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) {
|
||||||
|
icon_path = strdup(sfdo_icon_file_get_path(icon_file, NULL));
|
||||||
|
}
|
||||||
|
sfdo_icon_file_destroy(icon_file);
|
||||||
|
}
|
||||||
|
return icon_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct sfdo *sfdo_create(char *icon_theme) {
|
||||||
|
if (!icon_theme) {
|
||||||
|
goto error_null;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct sfdo *sfdo = calloc(1, sizeof(struct sfdo));
|
||||||
|
if (!sfdo) {
|
||||||
|
goto error_calloc;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct sfdo_basedir_ctx *basedir_ctx = sfdo_basedir_ctx_create();
|
||||||
|
if (!basedir_ctx) {
|
||||||
|
goto error_basedir_ctx;
|
||||||
|
}
|
||||||
|
|
||||||
|
sfdo->desktop_ctx = sfdo_desktop_ctx_create(basedir_ctx);
|
||||||
|
if (!sfdo->desktop_ctx) {
|
||||||
|
goto error_desktop_ctx;
|
||||||
|
}
|
||||||
|
|
||||||
|
sfdo->icon_ctx = sfdo_icon_ctx_create(basedir_ctx);
|
||||||
|
if (!sfdo->icon_ctx) {
|
||||||
|
goto error_icon_ctx;
|
||||||
|
}
|
||||||
|
|
||||||
|
sfdo->desktop_db = sfdo_desktop_db_load(sfdo->desktop_ctx, NULL);
|
||||||
|
if (!sfdo->desktop_db) {
|
||||||
|
goto error_desktop_db;
|
||||||
|
}
|
||||||
|
|
||||||
|
int load_options = SFDO_ICON_THEME_LOAD_OPTIONS_DEFAULT
|
||||||
|
| SFDO_ICON_THEME_LOAD_OPTION_ALLOW_MISSING
|
||||||
|
| SFDO_ICON_THEME_LOAD_OPTION_RELAXED;
|
||||||
|
|
||||||
|
sfdo->icon_theme = sfdo_icon_theme_load(sfdo->icon_ctx, icon_theme, load_options);
|
||||||
|
if (!sfdo->icon_theme) {
|
||||||
|
goto error_icon_theme;
|
||||||
|
}
|
||||||
|
|
||||||
|
sfdo_basedir_ctx_destroy(basedir_ctx);
|
||||||
|
|
||||||
|
sway_log(SWAY_INFO, "Successfully setup sfdo with icon theme %s", icon_theme);
|
||||||
|
return sfdo;
|
||||||
|
|
||||||
|
error_icon_theme:
|
||||||
|
sfdo_desktop_db_destroy(sfdo->desktop_db);
|
||||||
|
error_desktop_db:
|
||||||
|
sfdo_icon_ctx_destroy(sfdo->icon_ctx);
|
||||||
|
error_icon_ctx:
|
||||||
|
sfdo_desktop_ctx_destroy(sfdo->desktop_ctx);
|
||||||
|
error_desktop_ctx:
|
||||||
|
sfdo_basedir_ctx_destroy(basedir_ctx);
|
||||||
|
error_basedir_ctx:
|
||||||
|
free(sfdo);
|
||||||
|
error_calloc:
|
||||||
|
error_null:
|
||||||
|
// it's safe to call with null
|
||||||
|
sway_log(SWAY_ERROR, "Failed to setup sfdo with icon theme %s", icon_theme);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void sfdo_destroy(struct sfdo *sfdo) {
|
||||||
|
if (!sfdo) {
|
||||||
|
sway_log(SWAY_DEBUG, "Null sfdo passed in");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sfdo_desktop_ctx_destroy(sfdo->desktop_ctx);
|
||||||
|
sfdo_icon_ctx_destroy(sfdo->icon_ctx);
|
||||||
|
sfdo_desktop_db_destroy(sfdo->desktop_db);
|
||||||
|
sfdo_icon_theme_destroy(sfdo->icon_theme);
|
||||||
|
free(sfdo);
|
||||||
|
sway_log(SWAY_DEBUG, "Successfully destroyed sfdo");
|
||||||
|
}
|
||||||
19
include/sfdo.h
Normal file
19
include/sfdo.h
Normal 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
|
||||||
|
|
@ -399,8 +399,9 @@ struct bar_config {
|
||||||
char *binding_mode_text;
|
char *binding_mode_text;
|
||||||
} colors;
|
} colors;
|
||||||
|
|
||||||
#if HAVE_TRAY
|
|
||||||
char *icon_theme;
|
char *icon_theme;
|
||||||
|
|
||||||
|
#if HAVE_TRAY
|
||||||
struct wl_list tray_bindings; // struct tray_binding::link
|
struct wl_list tray_bindings; // struct tray_binding::link
|
||||||
list_t *tray_outputs; // char *
|
list_t *tray_outputs; // char *
|
||||||
int tray_padding;
|
int tray_padding;
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@
|
||||||
#include "sway/xwayland.h"
|
#include "sway/xwayland.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "sfdo.h"
|
||||||
|
|
||||||
struct sway_transaction;
|
struct sway_transaction;
|
||||||
|
|
||||||
struct sway_session_lock {
|
struct sway_session_lock {
|
||||||
|
|
@ -146,6 +148,8 @@ struct sway_server {
|
||||||
list_t *dirty_nodes;
|
list_t *dirty_nodes;
|
||||||
|
|
||||||
struct wl_event_source *delayed_modeset;
|
struct wl_event_source *delayed_modeset;
|
||||||
|
|
||||||
|
struct sfdo *sfdo;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct sway_server server;
|
extern struct sway_server server;
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ struct swaybar_tray;
|
||||||
struct swaybar_workspace;
|
struct swaybar_workspace;
|
||||||
struct loop;
|
struct loop;
|
||||||
|
|
||||||
|
struct sfdo;
|
||||||
|
|
||||||
struct swaybar {
|
struct swaybar {
|
||||||
char *id;
|
char *id;
|
||||||
char *mode;
|
char *mode;
|
||||||
|
|
@ -50,6 +52,8 @@ struct swaybar {
|
||||||
struct swaybar_tray *tray;
|
struct swaybar_tray *tray;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct sfdo *sfdo;
|
||||||
|
|
||||||
bool running;
|
bool running;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include <pango/pangocairo.h>
|
#include <pango/pangocairo.h>
|
||||||
|
|
||||||
|
#include "sfdo.h"
|
||||||
|
|
||||||
struct box_colors {
|
struct box_colors {
|
||||||
uint32_t border;
|
uint32_t border;
|
||||||
uint32_t background;
|
uint32_t background;
|
||||||
|
|
@ -73,13 +75,16 @@ struct swaybar_config {
|
||||||
struct box_colors binding_mode;
|
struct box_colors binding_mode;
|
||||||
} colors;
|
} colors;
|
||||||
|
|
||||||
#if HAVE_TRAY
|
|
||||||
char *icon_theme;
|
char *icon_theme;
|
||||||
|
|
||||||
|
#if HAVE_TRAY
|
||||||
struct wl_list tray_bindings; // struct tray_binding::link
|
struct wl_list tray_bindings; // struct tray_binding::link
|
||||||
bool tray_hidden;
|
bool tray_hidden;
|
||||||
list_t *tray_outputs; // char *
|
list_t *tray_outputs; // char *
|
||||||
int tray_padding;
|
int tray_padding;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct sfdo *sfdo;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if HAVE_TRAY
|
#if HAVE_TRAY
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,6 @@
|
||||||
#define _SWAYBAR_IMAGE_H
|
#define _SWAYBAR_IMAGE_H
|
||||||
#include <cairo.h>
|
#include <cairo.h>
|
||||||
|
|
||||||
cairo_surface_t *load_image(const char *path);
|
cairo_surface_t *load_image(const char *path, int target_size, int scale);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,10 @@ endforeach
|
||||||
|
|
||||||
null_dep = dependency('', required: false)
|
null_dep = dependency('', required: false)
|
||||||
|
|
||||||
|
libsfdo_basedir = dependency('libsfdo-basedir', version: '>=0.1.3')
|
||||||
|
libsfdo_desktop = dependency('libsfdo-desktop', version: '>=0.1.3')
|
||||||
|
libsfdo_desktop_file = dependency('libsfdo-desktop-file', version: '>=0.1.3')
|
||||||
|
libsfdo_icon = dependency('libsfdo-icon', version: '>=0.1.3')
|
||||||
jsonc = dependency('json-c', version: '>=0.13')
|
jsonc = dependency('json-c', version: '>=0.13')
|
||||||
pcre2 = dependency('libpcre2-8')
|
pcre2 = dependency('libpcre2-8')
|
||||||
wayland_server = dependency('wayland-server', version: '>=1.21.0')
|
wayland_server = dependency('wayland-server', version: '>=1.21.0')
|
||||||
|
|
|
||||||
|
|
@ -8,3 +8,4 @@ option('tray', type: 'feature', value: 'auto', description: 'Enable support for
|
||||||
option('gdk-pixbuf', type: 'feature', value: 'auto', description: 'Enable support for more image formats in swaybar tray')
|
option('gdk-pixbuf', type: 'feature', value: 'auto', description: 'Enable support for more image formats in swaybar tray')
|
||||||
option('man-pages', type: 'feature', value: 'auto', description: 'Generate and install man pages')
|
option('man-pages', type: 'feature', value: 'auto', description: 'Generate and install man pages')
|
||||||
option('sd-bus-provider', type: 'combo', choices: ['auto', 'libsystemd', 'libelogind', 'basu'], value: 'auto', description: 'Provider of the sd-bus library')
|
option('sd-bus-provider', type: 'combo', choices: ['auto', 'libsystemd', 'libelogind', 'basu'], value: 'auto', description: 'Provider of the sd-bus library')
|
||||||
|
option('sfdo', type: 'feature', value: 'auto', description: 'Enable libsfdo integration')
|
||||||
|
|
|
||||||
|
|
@ -70,9 +70,14 @@ void free_bar_config(struct bar_config *bar) {
|
||||||
free(bar->colors.binding_mode_border);
|
free(bar->colors.binding_mode_border);
|
||||||
free(bar->colors.binding_mode_bg);
|
free(bar->colors.binding_mode_bg);
|
||||||
free(bar->colors.binding_mode_text);
|
free(bar->colors.binding_mode_text);
|
||||||
|
|
||||||
|
// since libsfdo is a hard depedency now we always have at least
|
||||||
|
// a default icon theme and need to free the string that contains
|
||||||
|
// its name
|
||||||
|
free(bar->icon_theme);
|
||||||
|
|
||||||
#if HAVE_TRAY
|
#if HAVE_TRAY
|
||||||
list_free_items_and_destroy(bar->tray_outputs);
|
list_free_items_and_destroy(bar->tray_outputs);
|
||||||
free(bar->icon_theme);
|
|
||||||
|
|
||||||
struct tray_binding *tray_bind = NULL, *tmp_tray_bind = NULL;
|
struct tray_binding *tray_bind = NULL, *tmp_tray_bind = NULL;
|
||||||
wl_list_for_each_safe(tray_bind, tmp_tray_bind, &bar->tray_bindings, link) {
|
wl_list_for_each_safe(tray_bind, tmp_tray_bind, &bar->tray_bindings, link) {
|
||||||
|
|
@ -170,6 +175,11 @@ struct bar_config *default_bar_config(void) {
|
||||||
bar->colors.binding_mode_bg = NULL;
|
bar->colors.binding_mode_bg = NULL;
|
||||||
bar->colors.binding_mode_text = NULL;
|
bar->colors.binding_mode_text = NULL;
|
||||||
|
|
||||||
|
// we need some default when we initialize sfdo
|
||||||
|
if (!(bar->icon_theme = strdup("Hicolor"))) {
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
#if HAVE_TRAY
|
#if HAVE_TRAY
|
||||||
bar->tray_padding = 2;
|
bar->tray_padding = 2;
|
||||||
wl_list_init(&bar->tray_bindings);
|
wl_list_init(&bar->tray_bindings);
|
||||||
|
|
|
||||||
|
|
@ -218,6 +218,10 @@ sway_sources = files(
|
||||||
)
|
)
|
||||||
|
|
||||||
sway_deps = [
|
sway_deps = [
|
||||||
|
libsfdo_basedir,
|
||||||
|
libsfdo_desktop,
|
||||||
|
libsfdo_desktop_file,
|
||||||
|
libsfdo_icon,
|
||||||
cairo,
|
cairo,
|
||||||
drm,
|
drm,
|
||||||
jsonc,
|
jsonc,
|
||||||
|
|
|
||||||
128
sway/server.c
128
sway/server.c
|
|
@ -1,3 +1,13 @@
|
||||||
|
#include "sway/server.h"
|
||||||
|
#include "config.h"
|
||||||
|
#include "list.h"
|
||||||
|
#include "log.h"
|
||||||
|
#include "sway/config.h"
|
||||||
|
#include "sway/desktop/idle_inhibit_v1.h"
|
||||||
|
#include "sway/input/cursor.h"
|
||||||
|
#include "sway/input/input-manager.h"
|
||||||
|
#include "sway/output.h"
|
||||||
|
#include "sway/tree/root.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
@ -14,13 +24,13 @@
|
||||||
#include <wlr/types/wlr_content_type_v1.h>
|
#include <wlr/types/wlr_content_type_v1.h>
|
||||||
#include <wlr/types/wlr_cursor_shape_v1.h>
|
#include <wlr/types/wlr_cursor_shape_v1.h>
|
||||||
#include <wlr/types/wlr_data_control_v1.h>
|
#include <wlr/types/wlr_data_control_v1.h>
|
||||||
#include <wlr/types/wlr_ext_data_control_v1.h>
|
|
||||||
#include <wlr/types/wlr_data_device.h>
|
#include <wlr/types/wlr_data_device.h>
|
||||||
#include <wlr/types/wlr_export_dmabuf_v1.h>
|
#include <wlr/types/wlr_export_dmabuf_v1.h>
|
||||||
|
#include <wlr/types/wlr_ext_data_control_v1.h>
|
||||||
#include <wlr/types/wlr_ext_foreign_toplevel_list_v1.h>
|
#include <wlr/types/wlr_ext_foreign_toplevel_list_v1.h>
|
||||||
#include <wlr/types/wlr_foreign_toplevel_management_v1.h>
|
|
||||||
#include <wlr/types/wlr_ext_image_capture_source_v1.h>
|
#include <wlr/types/wlr_ext_image_capture_source_v1.h>
|
||||||
#include <wlr/types/wlr_ext_image_copy_capture_v1.h>
|
#include <wlr/types/wlr_ext_image_copy_capture_v1.h>
|
||||||
|
#include <wlr/types/wlr_foreign_toplevel_management_v1.h>
|
||||||
#include <wlr/types/wlr_fractional_scale_v1.h>
|
#include <wlr/types/wlr_fractional_scale_v1.h>
|
||||||
#include <wlr/types/wlr_gamma_control_v1.h>
|
#include <wlr/types/wlr_gamma_control_v1.h>
|
||||||
#include <wlr/types/wlr_idle_notify_v1.h>
|
#include <wlr/types/wlr_idle_notify_v1.h>
|
||||||
|
|
@ -49,26 +59,18 @@
|
||||||
#include <wlr/types/wlr_xdg_foreign_v2.h>
|
#include <wlr/types/wlr_xdg_foreign_v2.h>
|
||||||
#include <wlr/types/wlr_xdg_output_v1.h>
|
#include <wlr/types/wlr_xdg_output_v1.h>
|
||||||
#include <xf86drm.h>
|
#include <xf86drm.h>
|
||||||
#include "config.h"
|
|
||||||
#include "list.h"
|
|
||||||
#include "log.h"
|
|
||||||
#include "sway/config.h"
|
|
||||||
#include "sway/desktop/idle_inhibit_v1.h"
|
|
||||||
#include "sway/input/input-manager.h"
|
|
||||||
#include "sway/output.h"
|
|
||||||
#include "sway/server.h"
|
|
||||||
#include "sway/input/cursor.h"
|
|
||||||
#include "sway/tree/root.h"
|
|
||||||
|
|
||||||
#if WLR_HAS_XWAYLAND
|
#if WLR_HAS_XWAYLAND
|
||||||
#include <wlr/xwayland/shell.h>
|
|
||||||
#include "sway/xwayland.h"
|
#include "sway/xwayland.h"
|
||||||
|
#include <wlr/xwayland/shell.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if WLR_HAS_DRM_BACKEND
|
#if WLR_HAS_DRM_BACKEND
|
||||||
#include <wlr/types/wlr_drm_lease_v1.h>
|
#include <wlr/types/wlr_drm_lease_v1.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "sfdo.h"
|
||||||
|
|
||||||
#define SWAY_XDG_SHELL_VERSION 5
|
#define SWAY_XDG_SHELL_VERSION 5
|
||||||
#define SWAY_LAYER_SHELL_VERSION 4
|
#define SWAY_LAYER_SHELL_VERSION 4
|
||||||
#define SWAY_FOREIGN_TOPLEVEL_LIST_VERSION 1
|
#define SWAY_FOREIGN_TOPLEVEL_LIST_VERSION 1
|
||||||
|
|
@ -102,8 +104,7 @@ static bool is_privileged(const struct wl_global *global) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return
|
return global == server.output_manager_v1->global ||
|
||||||
global == server.output_manager_v1->global ||
|
|
||||||
global == server.output_power_manager_v1->global ||
|
global == server.output_power_manager_v1->global ||
|
||||||
global == server.input_method->global ||
|
global == server.input_method->global ||
|
||||||
global == server.foreign_toplevel_list->global ||
|
global == server.foreign_toplevel_list->global ||
|
||||||
|
|
@ -212,8 +213,8 @@ static void do_renderer_recreate(void *data) {
|
||||||
|
|
||||||
struct sway_output *output;
|
struct sway_output *output;
|
||||||
wl_list_for_each(output, &root->all_outputs, link) {
|
wl_list_for_each(output, &root->all_outputs, link) {
|
||||||
wlr_output_init_render(output->wlr_output,
|
wlr_output_init_render(output->wlr_output, server->allocator,
|
||||||
server->allocator, server->renderer);
|
server->renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_allocator_destroy(old_allocator);
|
wlr_allocator_destroy(old_allocator);
|
||||||
|
|
@ -229,22 +230,29 @@ static void handle_renderer_lost(struct wl_listener *listener, void *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
sway_log(SWAY_INFO, "Scheduling re-creation of renderer after GPU reset");
|
sway_log(SWAY_INFO, "Scheduling re-creation of renderer after GPU reset");
|
||||||
server->recreating_renderer = wl_event_loop_add_idle(server->wl_event_loop, do_renderer_recreate, server);
|
server->recreating_renderer = wl_event_loop_add_idle(
|
||||||
|
server->wl_event_loop, do_renderer_recreate, server);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_new_foreign_toplevel_capture_request(struct wl_listener *listener, void *data) {
|
static void
|
||||||
struct wlr_ext_foreign_toplevel_image_capture_source_manager_v1_request *request = data;
|
handle_new_foreign_toplevel_capture_request(struct wl_listener *listener,
|
||||||
|
void *data) {
|
||||||
|
struct wlr_ext_foreign_toplevel_image_capture_source_manager_v1_request
|
||||||
|
*request = data;
|
||||||
struct sway_view *view = request->toplevel_handle->data;
|
struct sway_view *view = request->toplevel_handle->data;
|
||||||
|
|
||||||
if (view->image_capture_source == NULL) {
|
if (view->image_capture_source == NULL) {
|
||||||
view->image_capture_source = wlr_ext_image_capture_source_v1_create_with_scene_node(
|
view->image_capture_source =
|
||||||
&view->image_capture_scene->tree.node, server.wl_event_loop, server.allocator, server.renderer);
|
wlr_ext_image_capture_source_v1_create_with_scene_node(
|
||||||
|
&view->image_capture_scene->tree.node, server.wl_event_loop,
|
||||||
|
server.allocator, server.renderer);
|
||||||
if (view->image_capture_source == NULL) {
|
if (view->image_capture_source == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_ext_foreign_toplevel_image_capture_source_manager_v1_request_accept(request, view->image_capture_source);
|
wlr_ext_foreign_toplevel_image_capture_source_manager_v1_request_accept(
|
||||||
|
request, view->image_capture_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool server_init(struct sway_server *server) {
|
bool server_init(struct sway_server *server) {
|
||||||
|
|
@ -257,7 +265,8 @@ bool server_init(struct sway_server *server) {
|
||||||
|
|
||||||
root = root_create(server->wl_display);
|
root = root_create(server->wl_display);
|
||||||
|
|
||||||
server->backend = wlr_backend_autocreate(server->wl_event_loop, &server->session);
|
server->backend =
|
||||||
|
wlr_backend_autocreate(server->wl_event_loop, &server->session);
|
||||||
if (!server->backend) {
|
if (!server->backend) {
|
||||||
sway_log(SWAY_ERROR, "Unable to create backend");
|
sway_log(SWAY_ERROR, "Unable to create backend");
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -276,26 +285,27 @@ bool server_init(struct sway_server *server) {
|
||||||
|
|
||||||
wlr_renderer_init_wl_shm(server->renderer, server->wl_display);
|
wlr_renderer_init_wl_shm(server->renderer, server->wl_display);
|
||||||
|
|
||||||
if (wlr_renderer_get_texture_formats(server->renderer, WLR_BUFFER_CAP_DMABUF) != NULL) {
|
if (wlr_renderer_get_texture_formats(server->renderer,
|
||||||
|
WLR_BUFFER_CAP_DMABUF) != NULL) {
|
||||||
server->linux_dmabuf_v1 = wlr_linux_dmabuf_v1_create_with_renderer(
|
server->linux_dmabuf_v1 = wlr_linux_dmabuf_v1_create_with_renderer(
|
||||||
server->wl_display, 4, server->renderer);
|
server->wl_display, 4, server->renderer);
|
||||||
}
|
}
|
||||||
if (wlr_renderer_get_drm_fd(server->renderer) >= 0 &&
|
if (wlr_renderer_get_drm_fd(server->renderer) >= 0 &&
|
||||||
server->renderer->features.timeline &&
|
server->renderer->features.timeline &&
|
||||||
server->backend->features.timeline) {
|
server->backend->features.timeline) {
|
||||||
wlr_linux_drm_syncobj_manager_v1_create(server->wl_display, 1,
|
wlr_linux_drm_syncobj_manager_v1_create(
|
||||||
wlr_renderer_get_drm_fd(server->renderer));
|
server->wl_display, 1, wlr_renderer_get_drm_fd(server->renderer));
|
||||||
}
|
}
|
||||||
|
|
||||||
server->allocator = wlr_allocator_autocreate(server->backend,
|
server->allocator =
|
||||||
server->renderer);
|
wlr_allocator_autocreate(server->backend, server->renderer);
|
||||||
if (!server->allocator) {
|
if (!server->allocator) {
|
||||||
sway_log(SWAY_ERROR, "Failed to create allocator");
|
sway_log(SWAY_ERROR, "Failed to create allocator");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
server->compositor = wlr_compositor_create(server->wl_display, 6,
|
server->compositor =
|
||||||
server->renderer);
|
wlr_compositor_create(server->wl_display, 6, server->renderer);
|
||||||
|
|
||||||
wlr_subcompositor_create(server->wl_display);
|
wlr_subcompositor_create(server->wl_display);
|
||||||
|
|
||||||
|
|
@ -316,14 +326,14 @@ bool server_init(struct sway_server *server) {
|
||||||
server->idle_notifier_v1 = wlr_idle_notifier_v1_create(server->wl_display);
|
server->idle_notifier_v1 = wlr_idle_notifier_v1_create(server->wl_display);
|
||||||
sway_idle_inhibit_manager_v1_init();
|
sway_idle_inhibit_manager_v1_init();
|
||||||
|
|
||||||
server->layer_shell = wlr_layer_shell_v1_create(server->wl_display,
|
server->layer_shell =
|
||||||
SWAY_LAYER_SHELL_VERSION);
|
wlr_layer_shell_v1_create(server->wl_display, SWAY_LAYER_SHELL_VERSION);
|
||||||
wl_signal_add(&server->layer_shell->events.new_surface,
|
wl_signal_add(&server->layer_shell->events.new_surface,
|
||||||
&server->layer_shell_surface);
|
&server->layer_shell_surface);
|
||||||
server->layer_shell_surface.notify = handle_layer_shell_surface;
|
server->layer_shell_surface.notify = handle_layer_shell_surface;
|
||||||
|
|
||||||
server->xdg_shell = wlr_xdg_shell_create(server->wl_display,
|
server->xdg_shell =
|
||||||
SWAY_XDG_SHELL_VERSION);
|
wlr_xdg_shell_create(server->wl_display, SWAY_XDG_SHELL_VERSION);
|
||||||
wl_signal_add(&server->xdg_shell->events.new_toplevel,
|
wl_signal_add(&server->xdg_shell->events.new_toplevel,
|
||||||
&server->xdg_shell_toplevel);
|
&server->xdg_shell_toplevel);
|
||||||
server->xdg_shell_toplevel.notify = handle_xdg_shell_toplevel;
|
server->xdg_shell_toplevel.notify = handle_xdg_shell_toplevel;
|
||||||
|
|
@ -342,8 +352,7 @@ bool server_init(struct sway_server *server) {
|
||||||
|
|
||||||
server->xdg_decoration_manager =
|
server->xdg_decoration_manager =
|
||||||
wlr_xdg_decoration_manager_v1_create(server->wl_display);
|
wlr_xdg_decoration_manager_v1_create(server->wl_display);
|
||||||
wl_signal_add(
|
wl_signal_add(&server->xdg_decoration_manager->events.new_toplevel_decoration,
|
||||||
&server->xdg_decoration_manager->events.new_toplevel_decoration,
|
|
||||||
&server->xdg_decoration);
|
&server->xdg_decoration);
|
||||||
server->xdg_decoration.notify = handle_xdg_decoration;
|
server->xdg_decoration.notify = handle_xdg_decoration;
|
||||||
wl_list_init(&server->xdg_decorations);
|
wl_list_init(&server->xdg_decorations);
|
||||||
|
|
@ -357,11 +366,11 @@ bool server_init(struct sway_server *server) {
|
||||||
wl_signal_add(&server->pointer_constraints->events.new_constraint,
|
wl_signal_add(&server->pointer_constraints->events.new_constraint,
|
||||||
&server->pointer_constraint);
|
&server->pointer_constraint);
|
||||||
|
|
||||||
wlr_presentation_create(server->wl_display, server->backend, SWAY_PRESENTATION_VERSION);
|
wlr_presentation_create(server->wl_display, server->backend,
|
||||||
|
SWAY_PRESENTATION_VERSION);
|
||||||
wlr_alpha_modifier_v1_create(server->wl_display);
|
wlr_alpha_modifier_v1_create(server->wl_display);
|
||||||
|
|
||||||
server->output_manager_v1 =
|
server->output_manager_v1 = wlr_output_manager_v1_create(server->wl_display);
|
||||||
wlr_output_manager_v1_create(server->wl_display);
|
|
||||||
server->output_manager_apply.notify = handle_output_manager_apply;
|
server->output_manager_apply.notify = handle_output_manager_apply;
|
||||||
wl_signal_add(&server->output_manager_v1->events.apply,
|
wl_signal_add(&server->output_manager_v1->events.apply,
|
||||||
&server->output_manager_apply);
|
&server->output_manager_apply);
|
||||||
|
|
@ -377,8 +386,8 @@ bool server_init(struct sway_server *server) {
|
||||||
&server->output_power_manager_set_mode);
|
&server->output_power_manager_set_mode);
|
||||||
server->input_method = wlr_input_method_manager_v2_create(server->wl_display);
|
server->input_method = wlr_input_method_manager_v2_create(server->wl_display);
|
||||||
server->text_input = wlr_text_input_manager_v3_create(server->wl_display);
|
server->text_input = wlr_text_input_manager_v3_create(server->wl_display);
|
||||||
server->foreign_toplevel_list =
|
server->foreign_toplevel_list = wlr_ext_foreign_toplevel_list_v1_create(
|
||||||
wlr_ext_foreign_toplevel_list_v1_create(server->wl_display, SWAY_FOREIGN_TOPLEVEL_LIST_VERSION);
|
server->wl_display, SWAY_FOREIGN_TOPLEVEL_LIST_VERSION);
|
||||||
server->foreign_toplevel_manager =
|
server->foreign_toplevel_manager =
|
||||||
wlr_foreign_toplevel_manager_v1_create(server->wl_display);
|
wlr_foreign_toplevel_manager_v1_create(server->wl_display);
|
||||||
|
|
||||||
|
|
@ -397,13 +406,19 @@ bool server_init(struct sway_server *server) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
server->export_dmabuf_manager_v1 = wlr_export_dmabuf_manager_v1_create(server->wl_display);
|
server->export_dmabuf_manager_v1 =
|
||||||
server->screencopy_manager_v1 = wlr_screencopy_manager_v1_create(server->wl_display);
|
wlr_export_dmabuf_manager_v1_create(server->wl_display);
|
||||||
server->ext_image_copy_capture_manager_v1 = wlr_ext_image_copy_capture_manager_v1_create(server->wl_display, 1);
|
server->screencopy_manager_v1 =
|
||||||
|
wlr_screencopy_manager_v1_create(server->wl_display);
|
||||||
|
server->ext_image_copy_capture_manager_v1 =
|
||||||
|
wlr_ext_image_copy_capture_manager_v1_create(server->wl_display, 1);
|
||||||
wlr_ext_output_image_capture_source_manager_v1_create(server->wl_display, 1);
|
wlr_ext_output_image_capture_source_manager_v1_create(server->wl_display, 1);
|
||||||
server->wlr_data_control_manager_v1 = wlr_data_control_manager_v1_create(server->wl_display);
|
server->wlr_data_control_manager_v1 =
|
||||||
server->ext_data_control_manager_v1 = wlr_ext_data_control_manager_v1_create(server->wl_display, 1);
|
wlr_data_control_manager_v1_create(server->wl_display);
|
||||||
server->security_context_manager_v1 = wlr_security_context_manager_v1_create(server->wl_display);
|
server->ext_data_control_manager_v1 =
|
||||||
|
wlr_ext_data_control_manager_v1_create(server->wl_display, 1);
|
||||||
|
server->security_context_manager_v1 =
|
||||||
|
wlr_security_context_manager_v1_create(server->wl_display);
|
||||||
wlr_viewporter_create(server->wl_display);
|
wlr_viewporter_create(server->wl_display);
|
||||||
wlr_single_pixel_buffer_manager_v1_create(server->wl_display);
|
wlr_single_pixel_buffer_manager_v1_create(server->wl_display);
|
||||||
server->content_type_manager_v1 =
|
server->content_type_manager_v1 =
|
||||||
|
|
@ -411,9 +426,12 @@ bool server_init(struct sway_server *server) {
|
||||||
wlr_fractional_scale_manager_v1_create(server->wl_display, 1);
|
wlr_fractional_scale_manager_v1_create(server->wl_display, 1);
|
||||||
|
|
||||||
server->ext_foreign_toplevel_image_capture_source_manager_v1 =
|
server->ext_foreign_toplevel_image_capture_source_manager_v1 =
|
||||||
wlr_ext_foreign_toplevel_image_capture_source_manager_v1_create(server->wl_display, 1);
|
wlr_ext_foreign_toplevel_image_capture_source_manager_v1_create(
|
||||||
server->new_foreign_toplevel_capture_request.notify = handle_new_foreign_toplevel_capture_request;
|
server->wl_display, 1);
|
||||||
wl_signal_add(&server->ext_foreign_toplevel_image_capture_source_manager_v1->events.new_request,
|
server->new_foreign_toplevel_capture_request.notify =
|
||||||
|
handle_new_foreign_toplevel_capture_request;
|
||||||
|
wl_signal_add(&server->ext_foreign_toplevel_image_capture_source_manager_v1
|
||||||
|
->events.new_request,
|
||||||
&server->new_foreign_toplevel_capture_request);
|
&server->new_foreign_toplevel_capture_request);
|
||||||
|
|
||||||
server->tearing_control_v1 =
|
server->tearing_control_v1 =
|
||||||
|
|
@ -441,7 +459,8 @@ bool server_init(struct sway_server *server) {
|
||||||
struct wlr_cursor_shape_manager_v1 *cursor_shape_manager =
|
struct wlr_cursor_shape_manager_v1 *cursor_shape_manager =
|
||||||
wlr_cursor_shape_manager_v1_create(server->wl_display, 1);
|
wlr_cursor_shape_manager_v1_create(server->wl_display, 1);
|
||||||
server->request_set_cursor_shape.notify = handle_request_set_cursor_shape;
|
server->request_set_cursor_shape.notify = handle_request_set_cursor_shape;
|
||||||
wl_signal_add(&cursor_shape_manager->events.request_set_shape, &server->request_set_cursor_shape);
|
wl_signal_add(&cursor_shape_manager->events.request_set_shape,
|
||||||
|
&server->request_set_cursor_shape);
|
||||||
|
|
||||||
wl_list_init(&server->pending_launcher_ctxs);
|
wl_list_init(&server->pending_launcher_ctxs);
|
||||||
|
|
||||||
|
|
@ -524,6 +543,7 @@ void server_fini(struct sway_server *server) {
|
||||||
wlr_backend_destroy(server->backend);
|
wlr_backend_destroy(server->backend);
|
||||||
wl_display_destroy(server->wl_display);
|
wl_display_destroy(server->wl_display);
|
||||||
list_free(server->dirty_nodes);
|
list_free(server->dirty_nodes);
|
||||||
|
sfdo_destroy(server->sfdo);
|
||||||
free(server->socket);
|
free(server->socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -565,6 +585,10 @@ bool server_start(struct sway_server *server) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: allow configurability of global sway icon theme if and when
|
||||||
|
// it is applicable (titlebar icons? ssd icons?)
|
||||||
|
server->sfdo = sfdo_create("Hicolor");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -538,6 +538,7 @@ void bar_teardown(struct swaybar *bar) {
|
||||||
#if HAVE_TRAY
|
#if HAVE_TRAY
|
||||||
destroy_tray(bar->tray);
|
destroy_tray(bar->tray);
|
||||||
#endif
|
#endif
|
||||||
|
sfdo_destroy(bar->config->sfdo);
|
||||||
free_outputs(&bar->outputs);
|
free_outputs(&bar->outputs);
|
||||||
free_outputs(&bar->unused_outputs);
|
free_outputs(&bar->unused_outputs);
|
||||||
free_seats(&bar->seats);
|
free_seats(&bar->seats);
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
|
#include "sfdo.h"
|
||||||
|
|
||||||
uint32_t parse_position(const char *position) {
|
uint32_t parse_position(const char *position) {
|
||||||
uint32_t horiz = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
|
uint32_t horiz = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
|
||||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
|
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
|
||||||
|
|
@ -128,8 +130,11 @@ void free_config(struct swaybar_config *config) {
|
||||||
wl_list_remove(&tray_bind->link);
|
wl_list_remove(&tray_bind->link);
|
||||||
free_tray_binding(tray_bind);
|
free_tray_binding(tray_bind);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
free(config->icon_theme);
|
free(config->icon_theme);
|
||||||
#endif
|
sfdo_destroy(config->sfdo);
|
||||||
|
sway_log(SWAY_DEBUG, "Destroyed swaybar sfdo");
|
||||||
|
|
||||||
free(config);
|
free(config);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -104,11 +104,27 @@ static cairo_surface_t* gdk_cairo_image_surface_create_from_pixbuf(
|
||||||
}
|
}
|
||||||
#endif // HAVE_GDK_PIXBUF
|
#endif // HAVE_GDK_PIXBUF
|
||||||
|
|
||||||
cairo_surface_t *load_image(const char *path) {
|
cairo_surface_t *load_image(const char *path, int target_size, int scale) {
|
||||||
cairo_surface_t *image;
|
cairo_surface_t *image;
|
||||||
#if HAVE_GDK_PIXBUF
|
#if HAVE_GDK_PIXBUF
|
||||||
GError *err = NULL;
|
GError *err = NULL;
|
||||||
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(path, &err);
|
GdkPixbuf *pixbuf = NULL;
|
||||||
|
// svg images should be loaded at target size. the size read from an svg
|
||||||
|
// file is only nominal and can lead to an image too small for the avaialble
|
||||||
|
// space compared to bitmap icons selected at the nearest available size
|
||||||
|
int i = strlen(path) - 1;
|
||||||
|
// this is naive and assumes ascii, utf-8, or another encoding
|
||||||
|
// that encodes these letters as single bytes
|
||||||
|
if ((i > 2) &&
|
||||||
|
(path[i] == 'g' || path[i] == 'G') && \
|
||||||
|
(path[i - 1] == 'v' || path[i - 1] == 'V') && \
|
||||||
|
(path[i - 2] == 's' || path[i - 2] == 'S') && \
|
||||||
|
(path[i - 3] == '.' )) {
|
||||||
|
pixbuf = gdk_pixbuf_new_from_file_at_scale(path, -1, target_size, \
|
||||||
|
true, &err);
|
||||||
|
} else {
|
||||||
|
pixbuf = gdk_pixbuf_new_from_file(path, &err);
|
||||||
|
}
|
||||||
if (!pixbuf) {
|
if (!pixbuf) {
|
||||||
sway_log(SWAY_ERROR, "Failed to load background image (%s).",
|
sway_log(SWAY_ERROR, "Failed to load background image (%s).",
|
||||||
err->message);
|
err->message);
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@
|
||||||
#include "stringop.h"
|
#include "stringop.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
#include "sfdo.h"
|
||||||
|
|
||||||
void ipc_send_workspace_command(struct swaybar *bar, const char *ws) {
|
void ipc_send_workspace_command(struct swaybar *bar, const char *ws) {
|
||||||
uint32_t size = strlen("workspace \"\"") + strlen(ws);
|
uint32_t size = strlen("workspace \"\"") + strlen(ws);
|
||||||
for (size_t i = 0; i < strlen(ws); ++i) {
|
for (size_t i = 0; i < strlen(ws); ++i) {
|
||||||
|
|
@ -328,10 +330,14 @@ static bool ipc_parse_config(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// whether or not there is a tray, we now always have an icon theme
|
||||||
if ((json_object_object_get_ex(bar_config, "icon_theme", &icon_theme))) {
|
if ((json_object_object_get_ex(bar_config, "icon_theme", &icon_theme))) {
|
||||||
config->icon_theme = strdup(json_object_get_string(icon_theme));
|
config->icon_theme = strdup(json_object_get_string(icon_theme));
|
||||||
|
sfdo_destroy(config->sfdo);
|
||||||
|
config->sfdo = sfdo_create(config->icon_theme);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
json_object_put(bar_config);
|
json_object_put(bar_config);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,10 @@ tray_files = have_tray ? [
|
||||||
] : []
|
] : []
|
||||||
|
|
||||||
swaybar_deps = [
|
swaybar_deps = [
|
||||||
|
libsfdo_basedir,
|
||||||
|
libsfdo_desktop,
|
||||||
|
libsfdo_desktop_file,
|
||||||
|
libsfdo_icon,
|
||||||
cairo,
|
cairo,
|
||||||
gdk_pixbuf,
|
gdk_pixbuf,
|
||||||
jsonc,
|
jsonc,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <cairo.h>
|
#include <cairo.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <sfdo-common.h>
|
||||||
|
#include <sfdo-icon.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
@ -18,6 +20,8 @@
|
||||||
#include "stringop.h"
|
#include "stringop.h"
|
||||||
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
|
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
|
||||||
|
|
||||||
|
#include "sfdo.h"
|
||||||
|
|
||||||
// TODO menu
|
// TODO menu
|
||||||
|
|
||||||
static bool sni_ready(struct swaybar_sni *sni) {
|
static bool sni_ready(struct swaybar_sni *sni) {
|
||||||
|
|
@ -415,25 +419,34 @@ static enum hotspot_event_handling icon_hotspot_callback(
|
||||||
return HOTSPOT_PROCESS;
|
return HOTSPOT_PROCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void reload_sni(struct swaybar_sni *sni, char *icon_theme,
|
static void reload_sni(struct swaybar_sni *sni, char *icon_theme, int target_size) {
|
||||||
int target_size) {
|
|
||||||
char *icon_name = sni->status[0] == 'N' ?
|
char *icon_name = sni->status[0] == 'N' ?
|
||||||
sni->attention_icon_name : sni->icon_name;
|
sni->attention_icon_name : sni->icon_name;
|
||||||
if (icon_name) {
|
if (icon_name) {
|
||||||
list_t *icon_search_paths = create_list();
|
char *icon_path = NULL;
|
||||||
list_cat(icon_search_paths, sni->tray->basedirs);
|
// TODO: at some point we will need to make this scaling-aware
|
||||||
if (sni->icon_theme_path) {
|
int scale = 1;
|
||||||
list_add(icon_search_paths, sni->icon_theme_path);
|
struct sfdo *sfdo = sni->tray->bar->config->sfdo;
|
||||||
|
if (sfdo) {
|
||||||
|
icon_path = sfdo_icon_lookup_extended(sfdo, icon_name, target_size, scale);
|
||||||
|
if (!icon_path) {
|
||||||
|
sway_log(SWAY_DEBUG, "sfdo: icon %s invalid or not found in theme %s at size %d", \
|
||||||
|
icon_name, icon_theme, target_size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
char *icon_path = find_icon(sni->tray->themes, icon_search_paths,
|
|
||||||
icon_name, target_size, icon_theme,
|
|
||||||
&sni->min_size, &sni->max_size);
|
|
||||||
list_free(icon_search_paths);
|
|
||||||
if (icon_path) {
|
if (icon_path) {
|
||||||
cairo_surface_destroy(sni->icon);
|
cairo_surface_destroy(sni->icon);
|
||||||
sni->icon = load_image(icon_path);
|
sni->icon = load_image(icon_path, target_size, scale);
|
||||||
free(icon_path);
|
free(icon_path);
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
// the :( icon won't be drawn for a missing icon and whichever old icon was
|
||||||
|
// loaded will persist if this is not done. one might not have noticed this
|
||||||
|
// for tray items that have only one icon loaded only once, successfully or
|
||||||
|
// unsuccessfully. items with multiple icons, such as fcitx5 or other input
|
||||||
|
// method frameworks make the problem apparent
|
||||||
|
free(sni->icon);
|
||||||
|
sni->icon = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue