[digesting_libdecor] lift DBus desktop-settings out of gtk plugin

main
Allen Webster 2026-02-25 20:28:02 -08:00
parent 9a043fb9c9
commit cdedd70a3b
2 changed files with 16 additions and 17 deletions

View File

@ -249,6 +249,15 @@ libdecorevent__frame_bounds(struct libdecor_frame *frame,
}
int main(){
/* get desktop settings */
{
ctx.color_scheme = libdecor_get_color_scheme();
if (libdecor_get_cursor_settings(&ctx.cursor_theme_name, &ctx.cursor_size)){
ctx.cursor_theme_name = 0;
ctx.cursor_size = 24;
}
}
/*~ NOTE:
**~ initialize Wayland, Libdecor, & EGL
*/
@ -295,7 +304,6 @@ int main(){
/* setup GTK context */
int gtk_init_success = 0;
enum libdecor_color_scheme color_scheme = 0;
if (ctx.wl_display != 0 && ctx.wl_compositor != 0){
gdk_set_allowed_backends("wayland");
gtk_disable_setlocale();
@ -303,10 +311,9 @@ int main(){
gtk_init_success = 1;
}
color_scheme = libdecor_get_color_scheme();
g_object_set(gtk_settings_get_default(),
"gtk-application-prefer-dark-theme",
(color_scheme == LIBDECOR_COLOR_SCHEME_PREFER_DARK), NULL);
(ctx.color_scheme == LIBDECOR_COLOR_SCHEME_PREFER_DARK), NULL);
if (!gtk_init_success){
printf("failed to initialize gtk\n");
@ -331,13 +338,6 @@ int main(){
wl_list_init(&plugin_gtk->seat_list);
wl_list_init(&plugin_gtk->output_list);
/* fetch cursor theme and size*/
if (!libdecor_get_cursor_settings(&plugin_gtk->cursor_theme_name,
&plugin_gtk->cursor_size)){
plugin_gtk->cursor_theme_name = 0;
plugin_gtk->cursor_size = 24;
}
plugin_gtk->wl_registry = wl_display_get_registry(ctx.wl_display);
wl_registry_add_listener(plugin_gtk->wl_registry,
&registry_listener, plugin_gtk);
@ -2701,8 +2701,6 @@ libdecor_plugin_gtk_destroy(struct libdecor_plugin *plugin)
wl_list_remove(&frame->link);
}
free(plugin_gtk->cursor_theme_name);
if (plugin_gtk->wl_shm)
wl_shm_destroy(plugin_gtk->wl_shm);
@ -4207,8 +4205,7 @@ ensure_cursor_theme(struct seat *seat)
return false;
seat->cursor_scale = scale;
theme = wl_cursor_theme_load(plugin_gtk->cursor_theme_name,
plugin_gtk->cursor_size * scale,
theme = wl_cursor_theme_load(ctx.cursor_theme_name, ctx.cursor_size*scale,
plugin_gtk->wl_shm);
if (theme == NULL)
return false;

View File

@ -450,9 +450,6 @@ struct libdecor_plugin_gtk {
struct wl_list seat_list;
struct wl_list output_list;
char *cursor_theme_name;
int cursor_size;
int double_click_time_ms;
int drag_threshold;
@ -621,6 +618,11 @@ static void output_removed(struct libdecor_plugin_gtk *plugin_gtk, struct output
// digesting_libdecor
typedef struct Ctx{
/* desktop settings */
enum libdecor_color_scheme color_scheme;
char *cursor_theme_name;
int cursor_size;
/* globals */
struct wl_display *wl_display;
struct wl_registry *wl_registry;