summaryrefslogtreecommitdiff
path: root/libdecor
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2024-06-01 07:56:48 +0200
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2024-06-01 10:12:50 +0200
commit5365aefc6e8e244c7fa8dd8be5c9b035c45ef7af (patch)
tree4b2dba28c6b03e4b432bb02adf4f67b7139d09f5 /libdecor
parent04949f13498b5406dfe54d793fc88736ec052f5b (diff)
libdecor: update to upstream commit c2bd8ad6 (31-may-2024)
Diffstat (limited to 'libdecor')
-rw-r--r--libdecor/build/Makefile6
-rw-r--r--libdecor/src/desktop-settings.c (renamed from libdecor/src/cursor-settings.c)42
-rw-r--r--libdecor/src/desktop-settings.h (renamed from libdecor/src/cursor-settings.h)10
-rw-r--r--libdecor/src/plugins/cairo/libdecor-cairo.c2
-rw-r--r--libdecor/src/plugins/gtk/libdecor-gtk.c33
5 files changed, 76 insertions, 17 deletions
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
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 <stdlib.h>
#include <string.h>
#include <stdbool.h>
+#include <stdint.h>
#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
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 <stdbool.h>
+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 <cairo/cairo.h>
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 <cairo/cairo.h>
@@ -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;
}