Clean up build scaffolding for libsfdo and add the creation and

destruction of an sfdo data structure associated with a sway server with
a view to future use of icon themes in places such as titlebars
This commit is contained in:
myrslint 2025-04-16 20:50:42 +00:00
parent f3cca0d86f
commit 34d2020042
4 changed files with 559 additions and 425 deletions

View file

@ -8,7 +8,11 @@
#if WLR_HAS_XWAYLAND #if WLR_HAS_XWAYLAND
#include "sway/xwayland.h" #include "sway/xwayland.h"
#endif #endif
#if HAVE_LIBSFDO
#include <sfdo-desktop.h>
#include <sfdo-icon.h>
#include <sfdo-basedir.h>
#endif
struct sway_transaction; struct sway_transaction;
struct sway_session_lock { struct sway_session_lock {
@ -24,6 +28,15 @@ struct sway_session_lock {
struct wl_listener destroy; 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 sway_server {
struct wl_display *wl_display; struct wl_display *wl_display;
struct wl_event_loop *wl_event_loop; struct wl_event_loop *wl_event_loop;
@ -146,6 +159,11 @@ struct sway_server {
list_t *dirty_nodes; list_t *dirty_nodes;
struct wl_event_source *delayed_modeset; struct wl_event_source *delayed_modeset;
#if HAVE_LIBSFDO
struct sfdo *sfdo;
#endif
}; };
extern struct sway_server server; extern struct sway_server server;
@ -192,4 +210,9 @@ void set_rr_scheduling(void);
void handle_new_tearing_hint(struct wl_listener *listener, void *data); 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 #endif

View file

@ -38,34 +38,6 @@ if is_freebsd
add_project_arguments('-D_C11_SOURCE', language: 'c') add_project_arguments('-D_C11_SOURCE', language: 'c')
endif endif
# Check for (currrently) optional libsfdo
sfdo_basedir = dependency(
'libsfdo-basedir',
default_options: ['default_library=static', 'examples=false', 'tests=false'],
version: '>=0.1.3',
required: get_option('sfdo'),
)
sfdo_desktop = dependency(
'libsfdo-desktop',
default_options: ['default_library=static', 'examples=false', 'tests=false'],
version: '>=0.1.3',
required: get_option('sfdo'),
)
sfdo_desktop_file = dependency(
'libsfdo-desktop-file',
default_options: ['default_library=static', 'examples=false', 'tests=false'],
version: '>=0.1.3',
required: get_option('sfdo'),
)
sfdo_icon = dependency(
'libsfdo-icon',
default_options: ['default_library=static', 'examples=false', 'tests=false'],
version: '>=0.1.3',
required: get_option('sfdo'),
)
have_libsfdo = sfdo_basedir.found() and sfdo_desktop.found() and sfdo_desktop_file.found() and sfdo_icon.found()
# Execute the wlroots subproject, if any # Execute the wlroots subproject, if any
wlroots_version = ['>=0.20.0', '<0.21.0'] wlroots_version = ['>=0.20.0', '<0.21.0']
subproject( subproject(
@ -88,6 +60,34 @@ endforeach
null_dep = dependency('', required: false) null_dep = dependency('', required: false)
# Check for (currrently) optional libsfdo
sfdo_basedir = dependency(
'libsfdo-basedir',
version: '>=0.1.3',
required: get_option('sfdo')
)
sfdo_desktop = dependency(
'libsfdo-desktop',
version: '>=0.1.3',
required: get_option('sfdo')
)
sfdo_desktop_file = dependency(
'libsfdo-desktop-file',
version: '>=0.1.3',
required: get_option('sfdo')
)
sfdo_icon = dependency(
'libsfdo-icon',
version: '>=0.1.3',
required: get_option('sfdo')
)
have_libsfdo = (
sfdo_basedir.found() and
sfdo_desktop.found() and
sfdo_desktop_file.found() and
sfdo_icon.found()
)
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')

View file

@ -244,6 +244,15 @@ if wlroots_features['libinput_backend']
sway_sources += 'input/libinput.c' sway_sources += 'input/libinput.c'
endif endif
if have_libsfdo
sway_deps += [
sfdo_basedir,
sfdo_desktop,
sfdo_desktop_file,
sfdo_icon
]
endif
executable( executable(
'sway', 'sway',
sway_sources + wl_protos_src, sway_sources + wl_protos_src,

View file

@ -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,22 @@
#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
#if HAVE_LIBSFDO
#include <sfdo-basedir.h>
#include <sfdo-desktop.h>
#include <sfdo-icon.h>
#endif
#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 +108,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 +217,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 +234,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 +269,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 +289,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 +330,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 +356,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 +370,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,15 +390,15 @@ 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);
sway_session_lock_init(); sway_session_lock_init();
#if WLR_HAS_DRM_BACKEND #if WLR_HAS_DRM_BACKEND
server->drm_lease_manager= server->drm_lease_manager =
wlr_drm_lease_v1_manager_create(server->wl_display, server->backend); wlr_drm_lease_v1_manager_create(server->wl_display, server->backend);
if (server->drm_lease_manager) { if (server->drm_lease_manager) {
server->drm_lease_request.notify = handle_drm_lease_request; server->drm_lease_request.notify = handle_drm_lease_request;
@ -397,13 +410,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 +430,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 +463,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 +547,9 @@ 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);
#if HAVE_LIBSFDO
sfdo_destroy(server->sfdo);
#endif
free(server->socket); free(server->socket);
} }
@ -565,6 +591,12 @@ bool server_start(struct sway_server *server) {
return false; return false;
} }
#if HAVE_LIBSFDO
// TODO: allow configurability of global sway icon theme if and when
// it is applicable (titlebar icons? ssd icons?)
server->sfdo = sfdo_create("Hicolor");
#endif
return true; return true;
} }
@ -573,3 +605,73 @@ void server_run(struct sway_server *server) {
server->socket); server->socket);
wl_display_run(server->wl_display); wl_display_run(server->wl_display);
} }
#if HAVE_LIBSFDO
struct sfdo *sfdo_create(char *theme) {
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, theme, load_options);
if (!sfdo->icon_theme) {
goto error_icon_theme;
}
sfdo_basedir_ctx_destroy(basedir_ctx);
sway_log(SWAY_DEBUG, "Successfully setup sfdo");
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:
sway_log(SWAY_ERROR, "Failed to setup sfdo");
return NULL;
}
void sfdo_destroy(struct sfdo *sfdo) {
if (!sfdo) {
sway_log(SWAY_DEBUG, "Null sfdo passed in");
return;
}
sfdo_icon_theme_destroy(sfdo->icon_theme);
sfdo_desktop_db_destroy(sfdo->desktop_db);
sfdo_icon_ctx_destroy(sfdo->icon_ctx);
sfdo_desktop_ctx_destroy(sfdo->desktop_ctx);
sway_log(SWAY_DEBUG, "Successfully destroyed sfdo");
}
#endif