From 5365aefc6e8e244c7fa8dd8be5c9b035c45ef7af Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Sat, 1 Jun 2024 07:56:48 +0200 Subject: [PATCH] libdecor: update to upstream commit c2bd8ad6 (31-may-2024) --- libdecor/build/Makefile | 6 +-- .../{cursor-settings.c => desktop-settings.c} | 42 ++++++++++++++++++- .../{cursor-settings.h => desktop-settings.h} | 10 +++++ libdecor/src/plugins/cairo/libdecor-cairo.c | 2 +- libdecor/src/plugins/gtk/libdecor-gtk.c | 33 +++++++++------ src/CMakeLists.txt | 6 +-- src/Makefile | 2 +- 7 files changed, 80 insertions(+), 21 deletions(-) rename libdecor/src/{cursor-settings.c => desktop-settings.c} (84%) rename libdecor/src/{cursor-settings.h => desktop-settings.h} (84%) diff --git a/libdecor/build/Makefile b/libdecor/build/Makefile index 19cdbb8da..65952ca06 100644 --- a/libdecor/build/Makefile +++ b/libdecor/build/Makefile @@ -18,7 +18,7 @@ include ../../makeinclude OBJECTS = fl_libdecor.o libdecor-cairo-blur.o fl_libdecor-plugins.o \ ../../src/xdg-decoration-protocol.o ../../src/xdg-shell-protocol.o \ - ../../src/text-input-protocol.o ../../src/gtk-shell-protocol.o cursor-settings.o os-compatibility.o + ../../src/text-input-protocol.o ../../src/gtk-shell-protocol.o desktop-settings.o os-compatibility.o PROTOCOLS = `pkg-config --variable=pkgdatadir wayland-protocols` @@ -46,8 +46,8 @@ libdecor-cairo-blur.o : ../src/plugins/common/libdecor-cairo-blur.c os-compatibility.o : ../src/os-compatibility.c $(CC) $(CFLAGS_DECOR) -c ../src/os-compatibility.c -cursor-settings.o : ../src/cursor-settings.c - $(CC) $(CFLAGS_DECOR) -c ../src/cursor-settings.c $(LIBDECORDBUS) +desktop-settings.o : ../src/desktop-settings.c + $(CC) $(CFLAGS_DECOR) -c ../src/desktop-settings.c $(LIBDECORDBUS) ../../src/xdg-shell-protocol.c : wayland-scanner private-code $(PROTOCOLS)/stable/xdg-shell/xdg-shell.xml \ diff --git a/libdecor/src/cursor-settings.c b/libdecor/src/desktop-settings.c similarity index 84% rename from libdecor/src/cursor-settings.c rename to libdecor/src/desktop-settings.c index 75c42d194..28067ac3e 100644 --- a/libdecor/src/cursor-settings.c +++ b/libdecor/src/desktop-settings.c @@ -1,5 +1,6 @@ /* * Copyright © 2019 Christian Rauch + * Copyright © 2024 Colin Kinloch * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -23,10 +24,11 @@ * SOFTWARE. */ -#include "cursor-settings.h" +#include "desktop-settings.h" #include #include #include +#include #include "config.h" static bool @@ -164,10 +166,48 @@ libdecor_get_cursor_settings(char **theme, int *size) fallback: return get_cursor_settings_from_env(theme, size); } + +enum libdecor_color_scheme +libdecor_get_color_scheme() +{ + static const char name[] = "org.freedesktop.appearance"; + static const char key_color_scheme[] = "color-scheme"; + uint32_t color = 0; + + DBusError error; + DBusConnection *connection; + DBusMessage *reply; + + dbus_error_init(&error); + + connection = dbus_bus_get(DBUS_BUS_SESSION, &error); + + if (dbus_error_is_set(&error)) + return 0; + + reply = get_setting_sync(connection, name, key_color_scheme); + if (!reply) + return 0; + + if (!parse_type(reply, DBUS_TYPE_UINT32, &color)) { + dbus_message_unref(reply); + return 0; + } + + dbus_message_unref(reply); + + return color; +} #else bool libdecor_get_cursor_settings(char **theme, int *size) { return get_cursor_settings_from_env(theme, size); } + +uint32_t +libdecor_get_color_scheme() +{ + return LIBDECOR_COLOR_SCHEME_DEFAULT; +} #endif diff --git a/libdecor/src/cursor-settings.h b/libdecor/src/desktop-settings.h similarity index 84% rename from libdecor/src/cursor-settings.h rename to libdecor/src/desktop-settings.h index 0cc1cb6bf..5747d3168 100644 --- a/libdecor/src/cursor-settings.h +++ b/libdecor/src/desktop-settings.h @@ -1,5 +1,6 @@ /* * Copyright © 2019 Christian Rauch + * Copyright © 2024 Colin Kinloch * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -27,5 +28,14 @@ #include +enum libdecor_color_scheme { + LIBDECOR_COLOR_SCHEME_DEFAULT, + LIBDECOR_COLOR_SCHEME_PREFER_DARK, + LIBDECOR_COLOR_SCHEME_PREFER_LIGHT, +}; + bool libdecor_get_cursor_settings(char **theme, int *size); + +enum libdecor_color_scheme +libdecor_get_color_scheme(); diff --git a/libdecor/src/plugins/cairo/libdecor-cairo.c b/libdecor/src/plugins/cairo/libdecor-cairo.c index 30f6f8720..5978d431d 100644 --- a/libdecor/src/plugins/cairo/libdecor-cairo.c +++ b/libdecor/src/plugins/cairo/libdecor-cairo.c @@ -39,7 +39,7 @@ #include "libdecor-plugin.h" #include "utils.h" -#include "cursor-settings.h" +#include "desktop-settings.h" #include "os-compatibility.h" #include diff --git a/libdecor/src/plugins/gtk/libdecor-gtk.c b/libdecor/src/plugins/gtk/libdecor-gtk.c index de6ec90c6..7ce38ddc6 100644 --- a/libdecor/src/plugins/gtk/libdecor-gtk.c +++ b/libdecor/src/plugins/gtk/libdecor-gtk.c @@ -38,7 +38,7 @@ #include "libdecor-plugin.h" #include "utils.h" -#include "cursor-settings.h" +#include "desktop-settings.h" #include "os-compatibility.h" #include @@ -338,6 +338,8 @@ struct libdecor_plugin_gtk { char *cursor_theme_name; int cursor_size; + uint32_t color_scheme_setting; + int double_click_time_ms; int drag_threshold; }; @@ -2246,16 +2248,16 @@ handle_titlebar_gesture(struct libdecor_frame_gtk *frame_gtk, break; case TITLEBAR_GESTURE_MIDDLE_CLICK: break; - case TITLEBAR_GESTURE_RIGHT_CLICK: { /* FLTK */ - const int title_height = gtk_widget_get_allocated_height(frame_gtk->header); - - libdecor_frame_show_window_menu(&frame_gtk->frame, - seat->wl_seat, - serial, - seat->pointer_x, - seat->pointer_y - -title_height); - } /* FLTK */ + case TITLEBAR_GESTURE_RIGHT_CLICK: + { + const int title_height = gtk_widget_get_allocated_height(frame_gtk->header); + libdecor_frame_show_window_menu(&frame_gtk->frame, + seat->wl_seat, + serial, + seat->pointer_x, + seat->pointer_y + -title_height); + } break; } } @@ -2410,7 +2412,7 @@ pointer_button(void *data, handle_button_on_header (frame_gtk, seat, serial, time, button, state); break; default: - break; /* FLTK */ + break; } } @@ -2930,6 +2932,8 @@ libdecor_plugin_new(struct libdecor *context) plugin_gtk->cursor_size = 24; } + plugin_gtk->color_scheme_setting = libdecor_get_color_scheme(); + wl_display = libdecor_get_wl_display(context); plugin_gtk->wl_registry = wl_display_get_registry(wl_display); wl_registry_add_listener(plugin_gtk->wl_registry, @@ -2958,6 +2962,11 @@ libdecor_plugin_new(struct libdecor *context) return NULL; } + g_object_set(gtk_settings_get_default(), + "gtk-application-prefer-dark-theme", + plugin_gtk->color_scheme_setting == LIBDECOR_COLOR_SCHEME_PREFER_DARK, + NULL); + return &plugin_gtk->plugin; } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index acb00ec3b..a543b4f93 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -547,7 +547,7 @@ if(FLTK_BACKEND_WAYLAND) set_source_files_properties( ${FLTK_SOURCE_DIR}/libdecor/build/fl_libdecor-plugins.c ${FLTK_SOURCE_DIR}/libdecor/src/os-compatibility.c - ${FLTK_SOURCE_DIR}/libdecor/src/cursor-settings.c + ${FLTK_SOURCE_DIR}/libdecor/src/desktop-settings.c PROPERTIES COMPILE_DEFINITIONS "${CDEFS}" INCLUDE_DIRECTORIES "${IDIRS}" COMPILE_OPTIONS "${COPTS}" @@ -564,7 +564,7 @@ if(FLTK_BACKEND_WAYLAND) ${FLTK_SOURCE_DIR}/libdecor/build/fl_libdecor.c ${FLTK_SOURCE_DIR}/libdecor/build/fl_libdecor-plugins.c ${FLTK_SOURCE_DIR}/libdecor/src/os-compatibility.c - ${FLTK_SOURCE_DIR}/libdecor/src/cursor-settings.c + ${FLTK_SOURCE_DIR}/libdecor/src/desktop-settings.c PROPERTIES COMPILE_DEFINITIONS "${CDEFS}" INCLUDE_DIRECTORIES "${IDIRS}" @@ -579,7 +579,7 @@ if(FLTK_BACKEND_WAYLAND) list(APPEND CFILES scandir_posix.c - ../libdecor/src/cursor-settings.c + ../libdecor/src/desktop-settings.c ../libdecor/src/os-compatibility.c ../libdecor/build/fl_libdecor-plugins.c ) diff --git a/src/Makefile b/src/Makefile index 8bc50e809..ff151ace5 100644 --- a/src/Makefile +++ b/src/Makefile @@ -428,7 +428,7 @@ EXTRA_OBJECTS_WAYLAND = ../libdecor/build/fl_libdecor.o ../libdecor/build/libde ../libdecor/build/fl_libdecor-plugins.o \ xdg-decoration-protocol.o xdg-shell-protocol.o text-input-protocol.o \ gtk-shell-protocol.o \ - ../libdecor/build/cursor-settings.o ../libdecor/build/os-compatibility.o + ../libdecor/build/desktop-settings.o ../libdecor/build/os-compatibility.o EXTRA_OBJECTS_WAYLANDX11 = $(EXTRA_OBJECTS_WAYLAND) EXTRA_CXXFLAGS_WAYLAND = -I. EXTRA_CXXFLAGS_WAYLANDX11 = $(EXTRA_CXXFLAGS_WAYLAND)