diff options
author | cos <cos> | 2013-05-24 18:55:31 +0200 |
---|---|---|
committer | cos <cos> | 2013-05-25 17:31:45 +0200 |
commit | 41c4248c0bdb582df012a81022dcbcc30780c1cb (patch) | |
tree | 06ff9945ae08345978f4c93f1ca98ae9efbdc642 /src/bar.c | |
parent | 0bd37ab4ca56a587d4768735e63095c395341c26 (diff) | |
download | ratpoison-41c4248c0bdb582df012a81022dcbcc30780c1cb.zip |
Adapt group bar to be updated on group number or name change.cr/implement_gnumber
Diffstat (limited to 'src/bar.c')
-rw-r--r-- | src/bar.c | 52 |
1 files changed, 51 insertions, 1 deletions
@@ -41,7 +41,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; @@ -105,6 +106,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) { @@ -173,6 +199,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; @@ -210,6 +241,25 @@ 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); + + 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) { |