From 18d92e36d1d08affd20ae905f6a9efdb139af170 Mon Sep 17 00:00:00 2001 From: Ratchanan Srirattanamet Date: Wed, 6 Dec 2023 23:52:09 +0700 Subject: Revert "Remove orphan osd-notify remnants" As discussed in [1], these hints are essential to make the indicator functions correctly on Lomiri. These hints should not make any difference on DE's that doesn't support them. [1] https://gitlab.com/ubports/development/core/content-hub/-/merge_requests/32#note_1552217874 This reverts commit ba37bd3998252a759434a8455e52f00699b50a09. --- src/notifier.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/notifier.c b/src/notifier.c index 07c5efa..cef8a3c 100644 --- a/src/notifier.c +++ b/src/notifier.c @@ -343,6 +343,10 @@ notification_show(IndicatorPowerNotifier * self) } } + notify_notification_set_hint(nn, "x-lomiri-snap-decisions", g_variant_new_string("true")); + notify_notification_set_hint(nn, "x-lomiri-non-shaped-icon", g_variant_new_string("true")); + notify_notification_set_hint(nn, "x-lomiri-private-affirmative-tint", g_variant_new_string("true")); + notify_notification_set_hint(nn, "x-lomiri-snap-decisions-timeout", g_variant_new_int32(INT32_MAX)); notify_notification_set_timeout(nn, NOTIFY_EXPIRES_NEVER); notify_notification_add_action(nn, "dismiss", _("OK"), on_dismiss_clicked, NULL, NULL); notify_notification_add_action(nn, "settings", _("Battery settings"), on_battery_settings_clicked, NULL, NULL); -- cgit v1.2.3 From 28b0b55e98b9e955209e5a26f28acc9b1b6e43ad Mon Sep 17 00:00:00 2001 From: Ratchanan Srirattanamet Date: Fri, 8 Dec 2023 16:55:29 +0700 Subject: Guard Lomiri-specific notification hints under conditionals --- src/notifier.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/notifier.c b/src/notifier.c index cef8a3c..73f62b4 100644 --- a/src/notifier.c +++ b/src/notifier.c @@ -88,6 +88,9 @@ typedef struct gboolean caps_queried; gboolean actions_supported; + #ifdef LOMIRI_FEATURES_ENABLED + gboolean lomiri_snap_decisions_supported; + #endif GCancellable * cancellable; #ifdef LOMIRI_FEATURES_ENABLED @@ -265,8 +268,8 @@ on_dismiss_clicked(NotifyNotification * nn G_GNUC_UNUSED, /* no-op; libnotify warns if we have a NULL action callback */ } -static gboolean -are_actions_supported(IndicatorPowerNotifier * self) +static void +ensure_caps_queried(IndicatorPowerNotifier * self) { priv_t * const p = get_priv(self); @@ -276,22 +279,54 @@ are_actions_supported(IndicatorPowerNotifier * self) GList * caps; GList * l; - /* see if actions are supported */ + #ifdef LOMIRI_FEATURES_ENABLED + gboolean lomiri_snap_decisions_supported = FALSE; + #endif + + /* see if actions and snap decisions are supported */ actions_supported = FALSE; caps = notify_get_server_caps(); - for (l=caps; l!=NULL && !actions_supported; l=l->next) + for (l=caps; l!=NULL; l=l->next) { if (!g_strcmp0(l->data, "actions")) actions_supported = TRUE; + #ifdef LOMIRI_FEATURES_ENABLED + else if (!g_strcmp0(l->data, "x-lomiri-snap-decisions")) + lomiri_snap_decisions_supported = TRUE; + #endif + } p->actions_supported = actions_supported; + #ifdef LOMIRI_FEATURES_ENABLED + p->lomiri_snap_decisions_supported = lomiri_snap_decisions_supported; + #endif p->caps_queried = TRUE; g_list_free_full(caps, g_free); } +} + +static gboolean +are_actions_supported(IndicatorPowerNotifier * self) +{ + priv_t * const p = get_priv(self); + + ensure_caps_queried(self); return p->actions_supported; } +#ifdef LOMIRI_FEATURES_ENABLED +static gboolean +are_lomiri_snap_decisions_supported(IndicatorPowerNotifier * self) +{ + priv_t * const p = get_priv(self); + + ensure_caps_queried(self); + + return p->lomiri_snap_decisions_supported; +} +#endif + static void notification_show(IndicatorPowerNotifier * self) { @@ -342,11 +377,14 @@ notification_show(IndicatorPowerNotifier * self) notify_notification_set_hint(nn, "sound-file", g_variant_new_string("file://" LOMIRI_SOUNDSDIR "/notifications/" LOW_BATTERY_SOUND)); } } - - notify_notification_set_hint(nn, "x-lomiri-snap-decisions", g_variant_new_string("true")); - notify_notification_set_hint(nn, "x-lomiri-non-shaped-icon", g_variant_new_string("true")); - notify_notification_set_hint(nn, "x-lomiri-private-affirmative-tint", g_variant_new_string("true")); - notify_notification_set_hint(nn, "x-lomiri-snap-decisions-timeout", g_variant_new_int32(INT32_MAX)); + #ifdef LOMIRI_FEATURES_ENABLED + if (are_lomiri_snap_decisions_supported(self)) { + notify_notification_set_hint(nn, "x-lomiri-snap-decisions", g_variant_new_string("true")); + notify_notification_set_hint(nn, "x-lomiri-non-shaped-icon", g_variant_new_string("true")); + notify_notification_set_hint(nn, "x-lomiri-private-affirmative-tint", g_variant_new_string("true")); + notify_notification_set_hint(nn, "x-lomiri-snap-decisions-timeout", g_variant_new_int32(INT32_MAX)); + } + #endif notify_notification_set_timeout(nn, NOTIFY_EXPIRES_NEVER); notify_notification_add_action(nn, "dismiss", _("OK"), on_dismiss_clicked, NULL, NULL); notify_notification_add_action(nn, "settings", _("Battery settings"), on_battery_settings_clicked, NULL, NULL); -- cgit v1.2.3 From c96d7eda53f5eb73cf4d3c850de2f444035ae8f3 Mon Sep 17 00:00:00 2001 From: Ratchanan Srirattanamet Date: Fri, 8 Dec 2023 17:02:05 +0700 Subject: Confirm that all supposedly boolean hints take strings --- src/notifier.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/notifier.c b/src/notifier.c index 73f62b4..5f0562e 100644 --- a/src/notifier.c +++ b/src/notifier.c @@ -379,6 +379,7 @@ notification_show(IndicatorPowerNotifier * self) } #ifdef LOMIRI_FEATURES_ENABLED if (are_lomiri_snap_decisions_supported(self)) { + /* Yes, all supposedly boolean values take strings... */ notify_notification_set_hint(nn, "x-lomiri-snap-decisions", g_variant_new_string("true")); notify_notification_set_hint(nn, "x-lomiri-non-shaped-icon", g_variant_new_string("true")); notify_notification_set_hint(nn, "x-lomiri-private-affirmative-tint", g_variant_new_string("true")); -- cgit v1.2.3