minor adjustments for compliance

This commit is contained in:
maelstrom 2026-04-17 09:22:30 +02:00 • committed by Nishi
commit e4bd49ab83
3 changed files with 29 additions and 29 deletions

View file

@ -454,6 +454,7 @@ struct _MwLLWayland {
#endif #endif
MwBool dark_theme_detection; MwBool dark_theme_detection;
MwU32 dark_theme;
/* clipboard related stuff. /* clipboard related stuff.
* Note that unlike most interfaces, we don't keep zwp_primary_selection stuff in a wayland_protocol_t because we use wl_data_device as a fallback and want to have it share memory space.*/ * Note that unlike most interfaces, we don't keep zwp_primary_selection stuff in a wayland_protocol_t because we use wl_data_device as a fallback and want to have it share memory space.*/

View file

@ -17,8 +17,6 @@
wayland_call_table_t wl_call_tbl; wayland_call_table_t wl_call_tbl;
MwBool MwWaylandAlwaysRender = MwFALSE; MwBool MwWaylandAlwaysRender = MwFALSE;
MwU32 wl_dark_theme = -1;
/* Standard procedure before most event callbacks in Wayland ("most" because the setup ones don't need this). Wait for the Mutex to be freed, if we're deadlocking for longer then a quarter of a second then do nothing with the event. */ /* Standard procedure before most event callbacks in Wayland ("most" because the setup ones don't need this). Wait for the Mutex to be freed, if we're deadlocking for longer then a quarter of a second then do nothing with the event. */
#define WAYLAND_EVENT_OP_START(self) \ #define WAYLAND_EVENT_OP_START(self) \
do { \ do { \
@ -1782,20 +1780,20 @@ static void widget_setup(MwLL r, MwLL parent, int x, int y, int width, int heigh
#ifdef USE_DBUS #ifdef USE_DBUS
static void dark_theme_listener(MwLL handle, MwU32 new_value) { static void dark_theme_listener(MwLL handle, MwU32 new_value) {
wl_dark_theme = (new_value == 1) ? 1 : 0; handle->wayland.dark_theme = (new_value == 1) ? 1 : 0;
MwLLDispatch(handle, dark_theme, &wl_dark_theme); MwLLDispatch(handle, dark_theme, &handle->wayland.dark_theme);
} }
static void detect_dark_theme(MwLL handle) { static void detect_dark_theme(MwLL handle) {
MwU32 value = 0; MwU32 value = 0;
MwLLDBusPortalGet(&wl_call_tbl.dbus, &handle->wayland.dbus, "org.freedesktop.portal.Settings", "org.freedesktop.appearance", "color-scheme", &value); MwLLDBusPortalGet(&wl_call_tbl.dbus, &handle->wayland.dbus, "org.freedesktop.portal.Settings", "org.freedesktop.appearance", "color-scheme", &value);
wl_dark_theme = (value == 1) ? 1 : 0; handle->wayland.dark_theme = (value == 1) ? 1 : 0;
MwLLDBusPortalWatch(&wl_call_tbl.dbus, &handle->wayland.dbus, "org.freedesktop.portal.Settings"); MwLLDBusPortalWatch(&wl_call_tbl.dbus, &handle->wayland.dbus, "org.freedesktop.portal.Settings");
MwLLDispatch(handle, dark_theme, &wl_dark_theme); MwLLDispatch(handle, dark_theme, &handle->wayland.dark_theme);
} }
#endif #endif
@ -1811,6 +1809,7 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
if(!parent && wl_call_tbl.has_dbus) { if(!parent && wl_call_tbl.has_dbus) {
wl_call_tbl.has_dbus = MwLLDBusNewContext(&wl_call_tbl.dbus, &r->wayland.dbus); wl_call_tbl.has_dbus = MwLLDBusNewContext(&wl_call_tbl.dbus, &r->wayland.dbus);
r->wayland.dark_theme_detection = MwTRUE; r->wayland.dark_theme_detection = MwTRUE;
r->wayland.dark_theme = -1;
} }
#endif #endif
@ -2439,7 +2438,7 @@ static void MwLLShowImpl(MwLL handle, int show) {
static void MwLLMakePopupImpl(MwLL handle, MwLL parent) { static void MwLLMakePopupImpl(MwLL handle, MwLL parent) {
(void)handle; (void)handle;
(void)parent; (void)parent;
/* Wayland doesn't have "popups" in the Milsko sense persay. xdg_popup is closer to ToolWindow and as such is what we use there. So just like the Mac backend, this is just left alone. */ /* Wayland doesn't have "popups" in the Milsko sense per se. xdg_popup is closer to ToolWindow and as such is what we use there. So just like the Mac backend, this is just left alone. */
} }
static void MwLLSetSizeHintsImpl(MwLL handle, int minx, int miny, int maxx, int maxy) { static void MwLLSetSizeHintsImpl(MwLL handle, int minx, int miny, int maxx, int maxy) {

View file

@ -184,48 +184,48 @@ MWDECL MwBool MwLLDBusPortalWatch(MwLLDBusFuncTable* tbl, MwLLDBusContext* ctx,
char filter_string[2048]; char filter_string[2048];
MwStringPrintIntoBuffer(filter_string, sizeof(filter_string), "type='%s',interface=%s", "signal", portal); MwStringPrintIntoBuffer(filter_string, sizeof(filter_string), "type='%s',interface=%s", "signal", portal);
dbus_bus_add_match(ctx->dbus_conn, filter_string, &ctx->dbus_err); dbus_bus_add_match(ctx->dbus_conn, filter_string, &ctx->dbus_err);
dbus_connection_flush(ctx->dbus_conn); dbus_connection_flush(ctx->dbus_conn);
return MwTRUE; return MwTRUE;
} }
// Technically this will swallow all other results, so this is not usable multiple times. /* Technically this will swallow all other results, so this is not usable multiple times.
// TODO: Use a hashmap instead TODO: Use a hashmap instead */
MWDECL MwBool MwLLDBusPortalPoll(MwLLDBusFuncTable* tbl, MwLLDBusContext* ctx, MwLL handle, const char* portal, const char* namespace, const char* key, MwLLDBusPortalPollListener listener) { MWDECL MwBool MwLLDBusPortalPoll(MwLLDBusFuncTable* tbl, MwLLDBusContext* ctx, MwLL handle, const char* portal, const char* namespace, const char* key, MwLLDBusPortalPollListener listener) {
DBusMessage* msg; DBusMessage* msg;
DBusMessageIter args, msg_value; DBusMessageIter args, msg_value;
const char* msg_namespace; const char* msg_namespace;
const char* msg_key; const char* msg_key;
MwU32 msg_value_content; MwU32 msg_value_content;
if(!ctx->dbus_conn) { if(!ctx->dbus_conn) {
return MwFALSE; return MwFALSE;
} }
dbus_connection_read_write(ctx->dbus_conn, 0); dbus_connection_read_write(ctx->dbus_conn, 0);
msg = dbus_connection_pop_message(ctx->dbus_conn); msg = dbus_connection_pop_message(ctx->dbus_conn);
if (NULL == msg) { if(NULL == msg) {
return MwFALSE; return MwFALSE;
} }
// check if the message is a signal from the correct interface and with the correct name /* check if the message is a signal from the correct interface and with the correct name */
if (dbus_message_is_signal(msg, portal, "SettingChanged")) { if(dbus_message_is_signal(msg, portal, "SettingChanged")) {
// read the parameters /* read the parameters */
if (!dbus_message_iter_init(msg, &args)) if(!dbus_message_iter_init(msg, &args))
fprintf(stderr, "[WARNING] Message has no arguments\n"); fprintf(stderr, "[WARNING] Message has no arguments\n");
else if (DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&args)) else if(DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&args))
fprintf(stderr, "[WARNING] Argument is not string\n"); fprintf(stderr, "[WARNING] Argument is not string\n");
else { else {
dbus_message_iter_get_basic(&args, &msg_namespace); dbus_message_iter_get_basic(&args, &msg_namespace);
dbus_message_iter_next(&args); dbus_message_iter_next(&args);
dbus_message_iter_get_basic(&args, &msg_key); dbus_message_iter_get_basic(&args, &msg_key);
// Check that key and namespace match /* Check that key and namespace match */
if (strcmp(msg_namespace, namespace) == 0 && strcmp(msg_key, key) == 0) { if(strcmp(msg_namespace, namespace) == 0 && strcmp(msg_key, key) == 0) {
// Assuming the value is a basic type /* Assuming the value is a basic type */
dbus_message_iter_next(&args); dbus_message_iter_next(&args);
dbus_message_iter_recurse(&args, &msg_value); dbus_message_iter_recurse(&args, &msg_value);
dbus_message_iter_get_basic(&msg_value, &msg_value_content); dbus_message_iter_get_basic(&msg_value, &msg_value_content);
@ -235,7 +235,7 @@ MWDECL MwBool MwLLDBusPortalPoll(MwLLDBusFuncTable* tbl, MwLLDBusContext* ctx, M
} }
} }
// free the message /* free the message */
dbus_message_unref(msg); dbus_message_unref(msg);
} }