summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsabetts <sabetts>2006-09-26 23:44:36 +0000
committersabetts <sabetts>2006-09-26 23:44:36 +0000
commitad859c2d9b0f19ff55ea016d23a97853ef99b89e (patch)
treefdd75d9d29e23a21ba6b44cc0af1af257ad234e6
parent7977c0c3508e1437f50a900d827e9259f0b962bf (diff)
downloadratpoison-ad859c2d9b0f19ff55ea016d23a97853ef99b89e.zip
* src/manage.c (update_window_name): return 1 if anything changed. 0 otherwise.
* src/events.c (property_notify): only update the window names if the window name actually changed. * src/bar.h (redraw_last_message): new prototype * src/bar.c (update_bar): update the window list if that's what's displayed. call redraw_last_message. (update_window_names): call marked_message_internal. (marked_message): call marked_message_internal. (marked_message_internal): ripped body from old marked_message minus alarm reset. (redraw_last_message): new function (show_last_message): call redraw_last_message * src/actions.c: include ctype.h (cmd_license): use redraw_last_message (cmd_help): likewise
-rw-r--r--ChangeLog22
-rw-r--r--src/actions.c5
-rw-r--r--src/bar.c39
-rw-r--r--src/bar.h1
-rw-r--r--src/events.c4
-rw-r--r--src/manage.c9
6 files changed, 66 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 59643ce..79ddf94 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2006-09-26 Shawn Betts <sabetts@vcn.bc.ca>
+
+ * src/manage.c (update_window_name): return 1 if anything changed. 0 otherwise.
+
+ * src/events.c (property_notify): only update the window names if
+ the window name actually changed.
+
+ * src/bar.h (redraw_last_message): new prototype
+
+ * src/bar.c (update_bar): update the window list if that's what's
+ displayed. call redraw_last_message.
+ (update_window_names): call marked_message_internal.
+ (marked_message): call marked_message_internal.
+ (marked_message_internal): ripped body from old marked_message
+ minus alarm reset.
+ (redraw_last_message): new function
+ (show_last_message): call redraw_last_message
+
+ * src/actions.c: include ctype.h
+ (cmd_license): use redraw_last_message
+ (cmd_help): likewise
+
2006-08-27 Shawn Betts <sabetts@vcn.bc.ca>
* src/actions.c (parse_args): gobble spaces at the beginning of
diff --git a/src/actions.c b/src/actions.c
index d73ad1e..a455b26 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -19,6 +19,7 @@
*/
#include <unistd.h>
+#include <ctype.h> /* for isspace */
#include <sys/wait.h>
#include <X11/keysym.h>
#include <X11/extensions/XTest.h>
@@ -3128,7 +3129,7 @@ cmd_license (int interactive, struct cmdarg **args)
/* The help window overlaps the bar, so redraw it. */
if (current_screen()->bar_is_raised)
- show_last_message();
+ redraw_last_message();
return cmdret_new (RET_SUCCESS, NULL);
}
@@ -3246,7 +3247,7 @@ cmd_help (int interactive, struct cmdarg **args)
/* The help window overlaps the bar, so redraw it. */
if (current_screen()->bar_is_raised)
- show_last_message();
+ redraw_last_message();
return cmdret_new (RET_SUCCESS, NULL);
}
diff --git a/src/bar.c b/src/bar.c
index b459a5e..769b3b7 100644
--- a/src/bar.c
+++ b/src/bar.c
@@ -44,6 +44,8 @@ static char *last_msg = NULL;
static int last_mark_start = 0;
static int last_mark_end = 0;
+static void marked_message_internal (char *msg, int mark_start, int mark_end);
+
/* Reset the alarm to auto-hide the bar in BAR_TIMEOUT seconds. */
static void
reset_alarm (void)
@@ -145,12 +147,19 @@ bar_y (rp_screen *s, int height)
void
update_bar (rp_screen *s)
{
+ if (s->bar_is_raised == BAR_IS_WINDOW_LIST) {
+ update_window_names (s, defaults.window_fmt);
+ return;
+ }
+
if (s->bar_is_raised == BAR_IS_HIDDEN)
return;
- show_last_message();
+ redraw_last_message();
}
+/* Note that we use marked_message_internal to avoid resetting the
+ alarm. */
void
update_window_names (rp_screen *s, char *fmt)
{
@@ -165,12 +174,12 @@ update_window_names (rp_screen *s, char *fmt)
if(defaults.window_list_style == STYLE_ROW)
{
get_window_list (fmt, NULL, bar_buffer, &mark_start, &mark_end);
- marked_message (sbuf_get (bar_buffer), mark_start, mark_end);
+ marked_message_internal (sbuf_get (bar_buffer), mark_start, mark_end);
}
else
{
get_window_list (fmt, "\n", bar_buffer, &mark_start, &mark_end);
- marked_message (sbuf_get (bar_buffer), mark_start, mark_end);
+ marked_message_internal (sbuf_get (bar_buffer), mark_start, mark_end);
}
@@ -492,6 +501,14 @@ update_last_message (char *msg, int mark_start, int mark_end)
void
marked_message (char *msg, int mark_start, int mark_end)
{
+ /* Schedule the bar to be hidden after some amount of time. */
+ reset_alarm ();
+ marked_message_internal (msg, mark_start, mark_end);
+}
+
+static void
+marked_message_internal (char *msg, int mark_start, int mark_end)
+{
rp_screen *s = current_screen ();
int num_lines;
int width;
@@ -500,9 +517,6 @@ marked_message (char *msg, int mark_start, int mark_end)
PRINT_DEBUG (("msg = %s\n", msg?msg:"NULL"));
PRINT_DEBUG (("mark_start = %d, mark_end = %d\n", mark_start, mark_end));
- /* Schedule the bar to be hidden after some amount of time. */
- reset_alarm ();
-
/* Calculate the width and height of the window. */
num_lines = count_lines (msg, strlen(msg));
width = defaults.bar_x_padding * 2 + max_line_length(msg);
@@ -520,8 +534,10 @@ marked_message (char *msg, int mark_start, int mark_end)
update_last_message (msg, mark_start, mark_end);
}
+/* Use this just to update the bar. show_last_message will draw it and
+ leave it up for a period of time. */
void
-show_last_message (void)
+redraw_last_message (void)
{
char *msg;
@@ -532,10 +548,17 @@ show_last_message (void)
marked_message's msg arg would have been the same as
last_msg. */
msg = xstrdup (last_msg);
- marked_message (msg, last_mark_start, last_mark_end);
+ marked_message_internal (msg, last_mark_start, last_mark_end);
free (msg);
}
+void
+show_last_message (void)
+{
+ redraw_last_message();
+ reset_alarm();
+}
+
/* Free any memory associated with the bar. */
void
free_bar (void)
diff --git a/src/bar.h b/src/bar.h
index f5a4110..2156802 100644
--- a/src/bar.h
+++ b/src/bar.h
@@ -32,6 +32,7 @@ int bar_x (rp_screen *s, int width);
void message (char *s);
void marked_message (char *s, int mark_start, int mark_end);
void marked_message_printf (int mark_start, int mark_end, char *fmt, ...);
+void redraw_last_message (void);
void show_last_message (void);
void free_bar (void);
diff --git a/src/events.c b/src/events.c
index 5098ef0..406e743 100644
--- a/src/events.c
+++ b/src/events.c
@@ -621,8 +621,8 @@ property_notify (XEvent *ev)
{
case XA_WM_NAME:
PRINT_DEBUG (("updating window name\n"));
- update_window_name (win);
- update_window_names (win->scr, defaults.window_fmt);
+ if (update_window_name (win))
+ update_window_names (win->scr, defaults.window_fmt);
break;
case XA_WM_NORMAL_HINTS:
diff --git a/src/manage.c b/src/manage.c
index 9e9ba2f..50743b4 100644
--- a/src/manage.c
+++ b/src/manage.c
@@ -300,15 +300,18 @@ get_res_class (Window w)
return name;
}
-/* Reget the WM_NAME property for the window and update its name. */
+/* Reget the WM_NAME property for the window and update its
+ name. Return 1 if the name changed. */
int
update_window_name (rp_window *win)
{
char *newstr;
+ int changed = 0;
newstr = get_wmname (win->w);
if (newstr != NULL)
{
+ changed = changed || win->wm_name == NULL || strcmp (newstr, win->wm_name);
free (win->wm_name);
win->wm_name = newstr;
}
@@ -316,6 +319,7 @@ update_window_name (rp_window *win)
newstr = get_res_class (win->w);
if (newstr != NULL)
{
+ changed = changed || win->res_class == NULL || strcmp (newstr, win->res_class);
free (win->res_class);
win->res_class = newstr;
}
@@ -323,11 +327,12 @@ update_window_name (rp_window *win)
newstr = get_res_name (win->w);
if (newstr != NULL)
{
+ changed = changed || win->res_name == NULL || strcmp (newstr, win->res_name);
free (win->res_name);
win->res_name = newstr;
}
- return 1;
+ return changed;
}
/* Send an artificial configure event to the window. */