summaryrefslogtreecommitdiff
path: root/src/bar.c
diff options
context:
space:
mode:
authorsabetts <sabetts>2000-12-09 11:34:43 +0000
committersabetts <sabetts>2000-12-09 11:34:43 +0000
commit1a8458cd5a3252f9d2141de13ef67a30b215476c (patch)
tree4d4b0b7c70c141f83c66c2adff651cb5b8c9d49e /src/bar.c
parent7ee9190d0849e8df707611b63b42e976bbd8d827 (diff)
downloadratpoison-1a8458cd5a3252f9d2141de13ef67a30b215476c.zip
* input.c (cook_keycode): properly handle LockMask
* input.h: added prototype for keysym_to_string * input.c (keysym_to_string): added * bar.c (show_bar): update_window_names(s) is called whether the bar is raised or not. * conf.h: Added BAR_Y_PADDING BAR_X_PADDING * list.c (goto_window_name): return success or failure * list.h: updated prototype for goto_window_name * events.c (handle_key): Added a message indicating an unbound key. * bar.c (display_msg_in_bar): added (update_window_names): uses BAR_X_PADDING instead of `5' (update_window_names): Updated BAR_PADDING to BAR_Y_PADDING * input.c (cook_keycode): mod is now an usigned int (read_key): Ignores modifier keys. Now returns keysym and modifiers. (get_input): Updated BAR_PADDING to BAR_Y_PADDING and BAR_X_PADDING. * events.c (handle_key): uses read_key instead of XMaskEvent to read a key. * actions.c (goto_window_number): window list is displayed on failure. (bye): added (switch_to): added (execute_command): no longer seg faults when no windows exist.
Diffstat (limited to 'src/bar.c')
-rw-r--r--src/bar.c54
1 files changed, 47 insertions, 7 deletions
diff --git a/src/bar.c b/src/bar.c
index e61c9cd..c69e0d9 100644
--- a/src/bar.c
+++ b/src/bar.c
@@ -29,6 +29,11 @@
#include "ratpoison.h"
+/* Possible values for bar_is_raised status. */
+#define BAR_IS_WINDOW_LIST 1
+#define BAR_IS_MESSAGE 2
+
+/* Hide the bar from sight. */
int
hide_bar (screen_info *s)
{
@@ -42,12 +47,13 @@ hide_bar (screen_info *s)
return 0;
}
+/* Show window listing in bar. */
int
show_bar (screen_info *s)
{
if (!s->bar_is_raised)
{
- s->bar_is_raised = 1;
+ s->bar_is_raised = BAR_IS_WINDOW_LIST;
XMapWindow (dpy, s->bar_window);
update_window_names (s);
@@ -56,9 +62,14 @@ show_bar (screen_info *s)
return 1;
}
+ /* If the bar is raised we still need to display the window
+ names. */
+ update_window_names (s);
return 0;
}
+/* Calculate the width required for the bar to display the window
+ list. */
static int
calc_bar_width (XFontStruct *font)
{
@@ -88,7 +99,7 @@ int
bar_y (screen_info *s)
{
if (BAR_LOCATION % 2) return 0;
- else return s->root_attr.height - (FONT_HEIGHT (s->font) + BAR_PADDING * 2) - 2;
+ else return s->root_attr.height - (FONT_HEIGHT (s->font) + BAR_Y_PADDING * 2) - 2;
}
void
@@ -97,14 +108,14 @@ update_window_names (screen_info *s)
char str[100]; /* window names are capped at 99 chars */
int width = calc_bar_width (s->font);
rp_window *cur;
- int cur_x = 5;
+ int cur_x = BAR_X_PADDING;
if (!s->bar_is_raised) return;
XMoveResizeWindow (dpy, s->bar_window,
bar_x (s, width), bar_y (s),
width,
- (FONT_HEIGHT (s->font) + BAR_PADDING * 2));
+ (FONT_HEIGHT (s->font) + BAR_Y_PADDING * 2));
XClearWindow (dpy, s->bar_window);
XRaiseWindow (dpy, s->bar_window);
@@ -112,7 +123,7 @@ update_window_names (screen_info *s)
/* Draw them in reverse order they were added in, so the oldest
windows appear on the left and the newest on the right end of the
- program bar. */
+ bar. */
for (cur = rp_window_head; cur; cur = cur->next)
{
if (cur->state == STATE_UNMAPPED) continue;
@@ -121,14 +132,43 @@ update_window_names (screen_info *s)
if ( rp_current_window == cur)
{
XDrawString (dpy, s->bar_window, s->bold_gc, cur_x,
- BAR_PADDING + s->font->max_bounds.ascent, str, strlen (str));
+ BAR_Y_PADDING + s->font->max_bounds.ascent, str,
+ strlen (str));
}
else
{
XDrawString (dpy, s->bar_window, s->normal_gc, cur_x,
- BAR_PADDING + s->font->max_bounds.ascent, str, strlen (str));
+ BAR_Y_PADDING + s->font->max_bounds.ascent, str,
+ strlen (str));
}
cur_x += 10 + XTextWidth (s->font, str, strlen (str));
}
}
+
+void
+display_msg_in_bar (screen_info *s, char *msg)
+{
+ int width = BAR_X_PADDING * 2 + XTextWidth (s->font, msg, strlen (msg));
+
+ /* Map the bar if needed */
+ if (!s->bar_is_raised)
+ {
+ s->bar_is_raised = BAR_IS_MESSAGE;
+ XMapWindow (dpy, s->bar_window);
+ }
+
+ /* Reset the alarm to auto-hide the bar in BAR_TIMEOUT seconds. */
+ alarm (BAR_TIMEOUT);
+
+ XMoveResizeWindow (dpy, s->bar_window,
+ bar_x (s, width), bar_y (s),
+ width,
+ (FONT_HEIGHT (s->font) + BAR_Y_PADDING * 2));
+ XClearWindow (dpy, s->bar_window);
+ XRaiseWindow (dpy, s->bar_window);
+
+ XDrawString (dpy, s->bar_window, s->bold_gc, BAR_X_PADDING,
+ BAR_Y_PADDING + s->font->max_bounds.ascent, msg,
+ strlen (msg));
+}