From c48f75e86aea05a8b09a9e52eebe202ac2e84c3c Mon Sep 17 00:00:00 2001 From: Zed Lopez Date: Tue, 18 May 2010 09:06:26 -0700 Subject: add a titlechanged hook --- doc/ratpoison.texi | 2 ++ src/actions.c | 1 + src/events.c | 4 +++- src/globals.c | 2 ++ src/globals.h | 1 + 5 files changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/ratpoison.texi b/doc/ratpoison.texi index 9bfe8b9..7d9adfd 100644 --- a/doc/ratpoison.texi +++ b/doc/ratpoison.texi @@ -1269,6 +1269,8 @@ Run when the user switches to a different group. Run when a window is deleted. @item newwindow Run after a new window is mapped. +@item titlechanged +Run when the current window's title changes. @item quit Run when ratpoison exits. @item restart diff --git a/src/actions.c b/src/actions.c index dabb8e5..b3baadb 100644 --- a/src/actions.c +++ b/src/actions.c @@ -1407,6 +1407,7 @@ cmd_rename (int interactive UNUSED, struct cmdarg **args) 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 --git a/src/events.c b/src/events.c index d973639..6a229b8 100644 --- a/src/events.c +++ b/src/events.c @@ -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 --git a/src/globals.c b/src/globals.c index eb94db6..3029aef 100644 --- a/src/globals.c +++ b/src/globals.c @@ -232,6 +232,7 @@ LIST_HEAD (rp_quit_hook); LIST_HEAD (rp_restart_hook); LIST_HEAD (rp_delete_window_hook); LIST_HEAD (rp_new_window_hook); +LIST_HEAD (rp_title_changed_hook); struct rp_hook_db_entry rp_hook_db[]= {{"key", &rp_key_hook}, @@ -243,6 +244,7 @@ struct rp_hook_db_entry rp_hook_db[]= {"quit", &rp_quit_hook}, {"restart", &rp_restart_hook}, {"newwindow", &rp_new_window_hook}, + {"titlechanged", &rp_title_changed_hook}, {NULL, NULL}}; void diff --git a/src/globals.h b/src/globals.h index aa73451..e5ba32a 100644 --- a/src/globals.h +++ b/src/globals.h @@ -182,6 +182,7 @@ 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_new_window_hook; +extern struct list_head rp_title_changed_hook; extern struct rp_hook_db_entry rp_hook_db[]; -- cgit v1.2.3