Skip to content

Commit 43a33af

Browse files
author
Aaron R
committed
add hidden notification count emersion#25
1 parent 258f6ab commit 43a33af

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
*.idb
4343
*.pdb
4444

45+
# vim ctags
46+
tags
47+
4548
# Kernel Module Compile Results
4649
*.mod*
4750
*.cmd

render.c

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,46 @@ int render(struct mako_state *state, struct pool_buffer *buffer) {
114114
notif->hotspot.width = notif_width;
115115
notif->hotspot.height = notif_height;
116116

117-
g_object_unref(layout);
118-
119117
++i;
118+
if(i == (size_t)config->max_visible &&
119+
i < (size_t)wl_list_length(&state->notifications) ) {
120+
121+
int hidden = wl_list_length(&state->notifications) - i;
122+
int hidden_ln = snprintf(NULL, 0, "[%d]", hidden);
123+
124+
char *hidden_text;
125+
hidden_text = malloc(hidden_ln + 1);
126+
snprintf(hidden_text, hidden_ln + 1, "[%d]", hidden);
127+
128+
pango_layout_set_text(layout, hidden_text, -1);
129+
130+
int hidden_width = 0, hidden_height = 0;
131+
pango_layout_get_pixel_size(layout, &hidden_width, &hidden_height);
132+
133+
int hidden_y = height + border_size;
134+
height += hidden_height;
135+
136+
//Set cairo path to our "hidden" draw area and clear
137+
cairo_rectangle(cairo, 0, hidden_y , notif_width, hidden_height + border_size);
138+
cairo_set_operator(cairo, CAIRO_OPERATOR_CLEAR);
139+
set_cairo_source_u32(cairo, 0xFFFFFFFF);
140+
cairo_fill(cairo);
141+
142+
cairo_set_operator(cairo, CAIRO_OPERATOR_OVER);
143+
set_cairo_source_u32(cairo, config->colors.text);
144+
145+
//Right align the text. Maybe we can do count alignment as a config option?
146+
cairo_move_to(cairo, notif_width - border_size - hidden_width,
147+
hidden_y);
148+
149+
//Draw current hidden count
150+
pango_cairo_update_layout(cairo, layout);
151+
pango_cairo_show_layout(cairo, layout);
152+
153+
free(hidden_text);
154+
}
155+
156+
g_object_unref(layout);
120157
if (config->max_visible >= 0 &&
121158
i >= (size_t)config->max_visible) {
122159
break;

0 commit comments

Comments
 (0)