summaryrefslogtreecommitdiffstats
path: root/platform/linuxbsd/freedesktop_portal_desktop.h
diff options
context:
space:
mode:
authorRaul Santos <raulsntos@gmail.com>2022-08-30 17:04:17 +0200
committerRaul Santos <raulsntos@gmail.com>2022-09-02 16:49:21 +0200
commit471c9c296935fb1cf997f2ef5ef8883b3ebf941c (patch)
tree0d194fac73259bd03482d5afbd9067b3b8c28f6e /platform/linuxbsd/freedesktop_portal_desktop.h
parent6ccbc2709323c3f77f9509dcf55edad6d46e2a7c (diff)
downloadredot-engine-471c9c296935fb1cf997f2ef5ef8883b3ebf941c.tar.gz
Add support for system dark mode (Linux)
- Use `org.freedesktop.appearance color-scheme` to support system dark mode.
Diffstat (limited to 'platform/linuxbsd/freedesktop_portal_desktop.h')
-rw-r--r--platform/linuxbsd/freedesktop_portal_desktop.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/platform/linuxbsd/freedesktop_portal_desktop.h b/platform/linuxbsd/freedesktop_portal_desktop.h
new file mode 100644
index 0000000000..3d976b1ede
--- /dev/null
+++ b/platform/linuxbsd/freedesktop_portal_desktop.h
@@ -0,0 +1,59 @@
+/*************************************************************************/
+/* freedesktop_portal_desktop.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef FREEDESKTOP_PORTAL_DESKTOP_H
+#define FREEDESKTOP_PORTAL_DESKTOP_H
+
+#ifdef DBUS_ENABLED
+
+#include <stdint.h>
+
+class FreeDesktopPortalDesktop {
+private:
+ bool unsupported = false;
+
+ // Read a setting from org.freekdesktop.portal.Settings
+ bool read_setting(const char *p_namespace, const char *p_key, int p_type, void *r_value);
+
+public:
+ FreeDesktopPortalDesktop();
+
+ bool is_supported() { return !unsupported; }
+
+ // Retrieve the system's preferred color scheme.
+ // 0: No preference or unknown.
+ // 1: Prefer dark appearance.
+ // 2: Prefer light appearance.
+ uint32_t get_appearance_color_scheme();
+};
+
+#endif // DBUS_ENABLED
+
+#endif // FREEDESKTOP_PORTAL_DESKTOP_H