Hi folks,

Here's a tiny patch that adds a "titlechanged" hook to be triggered
when the current window's title changes. I did this so I configure
titlechanged and switchwin hooks that would maintain the current
window's title in dzen.

It might be more useful to also call it whenever switchwin is
triggered, so I wouldn't have to configure them separately for that
case, but I thought I'd submit it as is for your comments.
diff -rupN ratpoison/src/actions.c ratpoison-dev/src/actions.c
--- ratpoison/src/actions.c	2009-12-11 09:33:27.000000000 -0800
+++ ratpoison-dev/src/actions.c	2009-12-11 09:33:56.000000000 -0800
@@ -1402,6 +1402,7 @@ cmd_rename (int interactive UNUSED, stru
   free (current_window()->user_name);
   current_window()->user_name = xstrdup (ARG_STRING(0));
   current_window()->named = 1;
+  hook_run (&rp_title_changed_hook);
 
   /* Update the program bar. */
   update_window_names (current_screen(), defaults.window_fmt);
diff -rupN ratpoison/src/events.c ratpoison-dev/src/events.c
--- ratpoison/src/events.c	2009-12-11 09:33:27.000000000 -0800
+++ ratpoison-dev/src/events.c	2009-12-11 09:33:56.000000000 -0800
@@ -624,8 +624,10 @@ property_notify (XEvent *ev)
           {
           case XA_WM_NAME:
             PRINT_DEBUG (("updating window name\n"));
-            if (update_window_name (win))
+            if (update_window_name (win)) {
 	      update_window_names (win->scr, defaults.window_fmt);
+	      hook_run (&rp_title_changed_hook);
+	    }
             break;
 
           case XA_WM_NORMAL_HINTS:
diff -rupN ratpoison/src/globals.c ratpoison-dev/src/globals.c
--- ratpoison/src/globals.c	2009-12-11 09:33:27.000000000 -0800
+++ ratpoison-dev/src/globals.c	2009-12-11 09:33:56.000000000 -0800
@@ -231,6 +231,7 @@ LIST_HEAD (rp_switch_screen_hook);
 LIST_HEAD (rp_quit_hook);
 LIST_HEAD (rp_restart_hook);
 LIST_HEAD (rp_delete_window_hook);
+LIST_HEAD (rp_title_changed_hook);
 
 struct rp_hook_db_entry rp_hook_db[]=
   {{"key",              &rp_key_hook},
@@ -241,6 +242,7 @@ struct rp_hook_db_entry rp_hook_db[]=
    {"deletewindow",     &rp_delete_window_hook},
    {"quit",             &rp_quit_hook},
    {"restart",          &rp_restart_hook},
+   {"titlechanged",     &rp_title_changed_hook},
    {NULL, NULL}};
 
 void
diff -rupN ratpoison/src/globals.h ratpoison-dev/src/globals.h
--- ratpoison/src/globals.h	2009-12-11 09:33:27.000000000 -0800
+++ ratpoison-dev/src/globals.h	2009-12-11 09:33:56.000000000 -0800
@@ -181,6 +181,7 @@ extern struct list_head rp_switch_screen
 extern struct list_head rp_delete_window_hook;
 extern struct list_head rp_quit_hook;
 extern struct list_head rp_restart_hook;
+extern struct list_head rp_title_changed_hook;
 
 extern struct rp_hook_db_entry rp_hook_db[];
 
_______________________________________________
Ratpoison-devel mailing list
Ratpoison-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/ratpoison-devel

Reply via email to