This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch main
in repository engage.
View the commit online.
commit 3fdc002e60382a36d18c0b26bcfd185e987813a3
Author: Alastair Poole <[email protected]>
AuthorDate: Sat Nov 28 16:54:35 2026 +0000
dock: Add notification count badges to dock icons
Read counts from Unity LauncherEntry updates on the session bus.
Display counts of 100 or more as 99+ and hide badges when apps
report zero or mark the count as hidden.
---
README.md | 8 +++-
docs/engage-dock-mockup.png | Bin 54465 -> 57243 bytes
e_mod_main.c | 2 +
e_mod_main.h | 4 ++
engage_badges.c | 94 ++++++++++++++++++++++++++++++++++++++++++++
engage_dock.c | 64 ++++++++++++++++++++++++++++++
meson.build | 4 +-
7 files changed, 174 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 911aa30..4a64433 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
Engage is an Enlightenment module with reorderable app icons and frozen previews of minimized windows.
-
+
This module enforces a macOS workflow. There is one instance across all displays and workspaces.
@@ -29,3 +29,9 @@ Enable **Engage** in Enlightenment’s **Settings → Modules**. Right-click the
Open **Engage Settings** and enable **Automatically hide the dock**. The dock
slides off its configured screen edge when the pointer leaves. Move the pointer
to that edge where the dock normally sits to bring it back.
+
+## App icon badges
+
+Engage shows a red count on dock icons for apps that publish
+`com.canonical.Unity.LauncherEntry.Update` signals on the session bus. The count
+is capped visually at **99+** and disappears when the app reports zero or hides it.
diff --git a/docs/engage-dock-mockup.png b/docs/engage-dock-mockup.png
index 2d548f7..cf7d850 100644
Binary files a/docs/engage-dock-mockup.png and b/docs/engage-dock-mockup.png differ
diff --git a/e_mod_main.c b/e_mod_main.c
index e6888af..bacdbe0 100644
--- a/e_mod_main.c
+++ b/e_mod_main.c
@@ -460,6 +460,7 @@ e_modapi_init(E_Module *module)
}
engage_module = module;
+ engage_badges_init();
for (i = 0; i < EINA_C_ARRAY_LENGTH(events); i++)
handlers[i] = ecore_event_handler_add(events[i], client_changed, NULL);
@@ -478,6 +479,7 @@ e_modapi_shutdown(E_Module *module EINA_UNUSED)
if (handlers[i]) ecore_event_handler_del(handlers[i]);
E_FREE_FUNC(placement_job, ecore_job_del);
engage_menu_shutdown();
+ engage_badges_shutdown();
engage_docks_cancel_refresh();
engage_dock_zone_set(NULL);
engage_dock_effects_shutdown();
diff --git a/e_mod_main.h b/e_mod_main.h
index a3abe88..0b27549 100644
--- a/e_mod_main.h
+++ b/e_mod_main.h
@@ -48,6 +48,10 @@ void engage_panel_style_apply(Evas_Object *panel);
void engage_dock_zone_set(E_Zone *zone);
+void engage_badges_init(void);
+void engage_badges_shutdown(void);
+int engage_badge_count(const Efreet_Desktop *app);
+
void engage_docks_refresh(void);
void engage_docks_cancel_refresh(void);
diff --git a/engage_badges.c b/engage_badges.c
new file mode 100644
index 0000000..4d7ef63
--- /dev/null
+++ b/engage_badges.c
@@ -0,0 +1,94 @@
+#include "e_mod_main.h"
+#include <Eldbus.h>
+#include <stdint.h>
+
+typedef struct
+{
+ int64_t count;
+ Eina_Bool visible;
+} Badge;
+
+static Eina_Hash *badges;
+static Eldbus_Connection *connection;
+static Eldbus_Signal_Handler *handler;
+
+static void
+badge_update(void *data EINA_UNUSED, const Eldbus_Message *message)
+{
+ const char *uri, *key, *id;
+ Eldbus_Message_Iter *properties, *entry, *value;
+ Badge *badge, updated = {0};
+ Eina_Bool changed = EINA_FALSE;
+ const char prefix[] = "application://";
+
+ if (!eldbus_message_arguments_get(message, "sa{sv}", &uri, &properties) ||
+ strncmp(uri, prefix, sizeof(prefix) - 1)) return;
+ id = uri + sizeof(prefix) - 1;
+ if (!*id || strchr(id, '/')) return;
+
+ badge = eina_hash_find(badges, id);
+ if (badge) updated = *badge;
+ while (eldbus_message_iter_get_and_next(properties, 'e', &entry))
+ {
+ if (!eldbus_message_iter_arguments_get(entry, "sv", &key, &value)) continue;
+ if (!strcmp(key, "count"))
+ changed |= eldbus_message_iter_arguments_get(value, "x", &updated.count);
+ else if (!strcmp(key, "count-visible"))
+ changed |= eldbus_message_iter_arguments_get(value, "b", &updated.visible);
+ }
+ if (!changed) return;
+ if (!badge)
+ {
+ badge = calloc(1, sizeof(*badge));
+ if (!badge) return;
+ if (!eina_hash_add(badges, id, badge))
+ {
+ free(badge);
+ return;
+ }
+ }
+ changed = (badge->visible ? badge->count : 0) !=
+ (updated.visible ? updated.count : 0);
+ *badge = updated;
+ if (changed) engage_docks_refresh();
+}
+
+void
+engage_badges_init(void)
+{
+ badges = eina_hash_string_superfast_new(free);
+ if (!badges) return;
+ if (!eldbus_init())
+ {
+ E_FREE_FUNC(badges, eina_hash_free);
+ return;
+ }
+ connection = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION);
+ if (connection)
+ handler = eldbus_signal_handler_add(connection, NULL, NULL,
+ "com.canonical.Unity.LauncherEntry",
+ "Update", badge_update, NULL);
+}
+
+void
+engage_badges_shutdown(void)
+{
+ if (!badges) return;
+ E_FREE_FUNC(handler, eldbus_signal_handler_del);
+ E_FREE_FUNC(connection, eldbus_connection_unref);
+ E_FREE_FUNC(badges, eina_hash_free);
+ eldbus_shutdown();
+}
+
+int
+engage_badge_count(const Efreet_Desktop *app)
+{
+ const char *id;
+ Badge *badge;
+
+ if (!badges || !app || !app->orig_path) return 0;
+ id = efreet_util_path_to_file_id(app->orig_path);
+ if (!id) return 0;
+ badge = eina_hash_find(badges, id);
+ return badge && badge->visible ? MIN(100, MAX(0, badge->count)) : 0;
+}
diff --git a/engage_dock.c b/engage_dock.c
index 15f27f5..538451f 100644
--- a/engage_dock.c
+++ b/engage_dock.c
@@ -62,6 +62,8 @@ typedef struct
Evas_Object *visual;
Evas_Object *preview_content;
Evas_Object *indicator;
+ Evas_Object *badge;
+ Evas_Object *badge_text;
Evas_Object *tooltip_anchor;
Efreet_Desktop *app;
E_Client *client;
@@ -253,6 +255,25 @@ tile_scale(Dock_Tile *tile)
return;
}
+ if (tile->badge)
+ {
+ int text_w, text_h, height, width, font_size, padding;
+
+ evas_object_geometry_get(tile->visual, &x, &y, &w, &h);
+ height = MAX(12, MIN(w, h) * 2 / 5);
+ font_size = MAX(8, (height * 3 + 2) / 5);
+ padding = MAX(2, height / 5);
+ evas_object_text_font_set(tile->badge_text, "Sans:style=Bold", font_size);
+ evas_object_geometry_get(tile->badge_text, NULL, NULL, &text_w, &text_h);
+ width = MAX(height, text_w + 2 * padding);
+ x += lround(w * (1.0 + scale) / 2) - width;
+ y += lround(h * (1.0 - scale) / 2);
+ evas_object_move(tile->badge, x, y);
+ evas_object_resize(tile->badge, width, height);
+ evas_object_move(tile->badge_text, x + (width - text_w) / 2,
+ y + (height - text_h) / 2);
+ }
+
if (scale == 1.0)
{
evas_object_map_enable_set(tile->visual, EINA_FALSE);
@@ -380,6 +401,8 @@ tile_free(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
if (tile->preview_content) evas_object_del(tile->preview_content);
evas_object_del(tile->visual);
if (tile->indicator) evas_object_del(tile->indicator);
+ if (tile->badge) evas_object_del(tile->badge);
+ if (tile->badge_text) evas_object_del(tile->badge_text);
if (tile->app) efreet_desktop_free(tile->app);
if (tile->client) e_object_unref(E_OBJECT(tile->client));
free(tile);
@@ -757,6 +780,11 @@ tile_drag(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event)
tile->position;
evas_object_raise(tile->visual);
if (tile->indicator) evas_object_raise(tile->indicator);
+ if (tile->badge)
+ {
+ evas_object_raise(tile->badge);
+ evas_object_raise(tile->badge_text);
+ }
tile_hover(tile, 1.27);
}
@@ -1053,6 +1081,40 @@ indicator_layer(Evas_Vg_Container *root, Eina_Bool vertical, int inset,
b * alpha / 255, alpha);
}
+static void
+tile_badge_add(Dock_Tile *tile, Evas *evas, int count)
+{
+ Evas_Object *badge = evas_object_vg_add(evas);
+ Evas_Object *label = evas_object_text_add(evas);
+ Evas_Vg_Container *root = badge ? evas_object_vg_root_node_get(badge) : NULL;
+ Evas_Vg_Shape *shape = root ? evas_vg_shape_add(root) : NULL;
+ char text[8];
+
+ if (!shape || !label)
+ {
+ if (badge) evas_object_del(badge);
+ if (label) evas_object_del(label);
+ return;
+ }
+ evas_object_vg_root_node_set(badge, root);
+ evas_object_vg_viewbox_set(badge, EINA_RECT(0, 0, count >= 10 ? 30 : 20, 20));
+ evas_object_vg_fill_mode_set(badge, EVAS_OBJECT_VG_FILL_MODE_STRETCH);
+ evas_vg_shape_append_rect(shape, 0, 0, count >= 10 ? 30 : 20, 20, 10, 10);
+ evas_vg_node_color_set(shape, 214, 36, 53, 255);
+ if (count == 100) strcpy(text, "99+");
+ else snprintf(text, sizeof(text), "%d", count);
+ evas_object_text_text_set(label, text);
+ evas_object_color_set(label, 255, 255, 255, 255);
+ evas_object_smart_member_add(badge, tile->dock->box);
+ evas_object_smart_member_add(label, tile->dock->box);
+ evas_object_pass_events_set(badge, EINA_TRUE);
+ evas_object_pass_events_set(label, EINA_TRUE);
+ evas_object_show(badge);
+ evas_object_show(label);
+ tile->badge = badge;
+ tile->badge_text = label;
+}
+
static Evas_Object *
running_indicator_add(Evas *evas, Eina_Bool vertical)
{
@@ -1302,6 +1364,8 @@ dock_add(Engage_Dock *dock, Efreet_Desktop *app, E_Client *client, Dock_Tile_Kin
evas_object_show(tile->indicator);
}
}
+ int count = engage_badge_count(app);
+ if (count) tile_badge_add(tile, evas, count);
evas_object_event_callback_add(hit, EVAS_CALLBACK_MOUSE_DOWN, tile_menu, tile);
if (divider)
{
diff --git a/meson.build b/meson.build
index a8e3b83..81d6c63 100644
--- a/meson.build
+++ b/meson.build
@@ -2,6 +2,7 @@ project('engage', 'c', version: '0.1.0',
default_options: ['c_std=gnu11', 'warning_level=2'])
enlightenment = dependency('enlightenment')
+eldbus = dependency('eldbus')
math = meson.get_compiler('c').find_library('m', required: false)
xcb = dependency('xcb', required: false)
module_c_args = ['-DENGAGE_VERSION="@0@"'.format(meson.project_version())]
@@ -14,6 +15,7 @@ module_arch = enlightenment.get_variable(pkgconfig: 'module_arch')
module_sources = files(
'e_mod_main.c',
'engage_dock.c',
+ 'engage_badges.c',
'engage_launchers.c',
'engage_menu.c',
'engage_settings.c',
@@ -23,7 +25,7 @@ module_sources = files(
shared_module('module', module_sources,
name_prefix: '',
gnu_symbol_visibility: 'hidden',
- dependencies: [enlightenment, math, xcb],
+ dependencies: [enlightenment, eldbus, math, xcb],
c_args: module_c_args,
install: true,
install_dir: module_dir / module_arch)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.