mirror of
https://github.com/swaywm/sway.git
synced 2026-04-19 06:46:40 -04:00
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:
parent
d9a6bdb85e
commit
3a21b8c6f1
4 changed files with 147 additions and 29 deletions
|
|
@ -8,7 +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>
|
||||
#endif
|
||||
struct sway_transaction;
|
||||
|
||||
struct sway_session_lock {
|
||||
|
|
@ -24,6 +28,15 @@ 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;
|
||||
|
|
@ -143,6 +156,11 @@ struct sway_server {
|
|||
list_t *dirty_nodes;
|
||||
|
||||
struct wl_event_source *delayed_modeset;
|
||||
|
||||
#if HAVE_LIBSFDO
|
||||
struct sfdo *sfdo;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
extern struct sway_server server;
|
||||
|
|
@ -191,4 +209,9 @@ 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
|
||||
|
|
|
|||
56
meson.build
56
meson.build
|
|
@ -37,34 +37,6 @@ if is_freebsd
|
|||
add_project_arguments('-D_C11_SOURCE', language: 'c')
|
||||
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
|
||||
wlroots_version = ['>=0.19.0', '<0.20.0']
|
||||
subproject(
|
||||
|
|
@ -87,6 +59,34 @@ endforeach
|
|||
|
||||
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')
|
||||
pcre2 = dependency('libpcre2-8')
|
||||
wayland_server = dependency('wayland-server', version: '>=1.21.0')
|
||||
|
|
|
|||
|
|
@ -244,6 +244,15 @@ if wlroots_features['libinput_backend']
|
|||
sway_sources += 'input/libinput.c'
|
||||
endif
|
||||
|
||||
if have_libsfdo
|
||||
sway_deps += [
|
||||
sfdo_basedir,
|
||||
sfdo_desktop,
|
||||
sfdo_desktop_file,
|
||||
sfdo_icon
|
||||
]
|
||||
endif
|
||||
|
||||
executable(
|
||||
'sway',
|
||||
sway_sources + wl_protos_src,
|
||||
|
|
|
|||
|
|
@ -70,6 +70,12 @@
|
|||
#include <wlr/types/wlr_drm_lease_v1.h>
|
||||
#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_LAYER_SHELL_VERSION 4
|
||||
#define SWAY_FOREIGN_TOPLEVEL_LIST_VERSION 1
|
||||
|
|
@ -506,6 +512,10 @@ void server_fini(struct sway_server *server) {
|
|||
wlr_backend_destroy(server->backend);
|
||||
wl_display_destroy(server->wl_display);
|
||||
list_free(server->dirty_nodes);
|
||||
|
||||
#if HAVE_LIBSFDO
|
||||
sfdo_destroy(server->sfdo);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool server_start(struct sway_server *server) {
|
||||
|
|
@ -546,6 +556,12 @@ bool server_start(struct sway_server *server) {
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
@ -554,3 +570,73 @@ void server_run(struct sway_server *server) {
|
|||
server->socket);
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue