summaryrefslogtreecommitdiff
path: root/src/bar.c
diff options
context:
space:
mode:
authorcos <cos>2013-05-24 18:55:31 +0200
committercos <cos>2013-05-26 20:31:42 +0200
commitd3793dba2a57d2512ca0a7987b3385986ec2c9ea (patch)
tree953a2510d92495a9625878c7954d9d6c7af4b3d7 /src/bar.c
parent472a958a2ce149313239fb5eb4244f7607887b31 (diff)
downloadratpoison-d3793dba2a57d2512ca0a7987b3385986ec2c9ea.zip
Adapt group bar to be updated on group number or name change.cr/implement_gnumber-with_winliststyle
Diffstat (limited to 'src/bar.c')
-rw-r--r--src/bar.c60
1 files changed, 59 insertions, 1 deletions
diff --git a/src/bar.c b/src/bar.c
index 25d9a46..d9982c2 100644
--- a/src/bar.c
+++ b/src/bar.c
@@ -40,7 +40,8 @@
/* Possible values for bar_is_raised status. */
#define BAR_IS_HIDDEN 0
#define BAR_IS_WINDOW_LIST 1
-#define BAR_IS_MESSAGE 2
+#define BAR_IS_GROUP_LIST 2
+#define BAR_IS_MESSAGE 3
/* A copy of the last message displayed in the message bar. */
static char *last_msg = NULL;
@@ -104,6 +105,31 @@ show_bar (rp_screen *s, char *fmt)
return 0;
}
+/* Show group listing in bar. */
+int
+show_group_bar (rp_screen *s)
+{
+ if (!s->bar_is_raised)
+ {
+ s->bar_is_raised = BAR_IS_GROUP_LIST;
+ XMapRaised (dpy, s->bar_window);
+ update_group_names (s);
+
+ /* Switch to the default colormap */
+ if (current_window())
+ XUninstallColormap (dpy, current_window()->colormap);
+ XInstallColormap (dpy, s->def_cmap);
+
+ reset_alarm();
+ return 1;
+ }
+
+ /* If the bar is raised we still need to display the window
+ names. */
+ update_group_names (s);
+ return 0;
+}
+
int
bar_x (rp_screen *s, int width)
{
@@ -172,6 +198,11 @@ update_bar (rp_screen *s)
return;
}
+ if (s->bar_is_raised == BAR_IS_GROUP_LIST) {
+ update_group_names (s);
+ return;
+ }
+
if (s->bar_is_raised == BAR_IS_HIDDEN)
return;
@@ -207,6 +238,33 @@ update_window_names (rp_screen *s, char *fmt)
sbuf_free (bar_buffer);
}
+/* Note that we use marked_message_internal to avoid resetting the
+ alarm. */
+void
+update_group_names (rp_screen *s)
+{
+ struct sbuf *bar_buffer;
+ int mark_start = 0;
+ int mark_end = 0;
+
+ if (s->bar_is_raised != BAR_IS_GROUP_LIST) return;
+
+ bar_buffer = sbuf_new (0);
+
+ if (defaults.window_list_style == STYLE_ROW)
+ {
+ get_group_list (NULL, bar_buffer, &mark_start, &mark_end);
+ marked_message_internal (sbuf_get (bar_buffer), mark_start, mark_end);
+ }
+ else
+ {
+ get_group_list ("\n", bar_buffer, &mark_start, &mark_end);
+ marked_message_internal (sbuf_get (bar_buffer), mark_start, mark_end);
+ }
+
+ sbuf_free (bar_buffer);
+}
+
void
message (char *s)
{