Re: How to put windows into groups by application type.

Eric A <[email protected]>
Newsgroups gmane.comp.window-managers.ratpoison.devel
Message-ID <[email protected]>
On Mon, Mar 15, 2010 at 11:16 PM, Shawn Betts <[email protected]> wrote:
>
> The hook should be called when the window is mapped, not when it is
> created. Applications create a bunch of windows at start up that
> you're not interested in. It's a quirk of ratpoison that it keeps
> track of all created windows instead of simply waiting for a map
> request.
>
> -Shawn
>

Ok, I added a hook to the map_window function of manage.c. It looks
like the right place. Everything is working perfectly for me, so if it
looks good to you, it would be awesome if you could commit it. I know
very little about coding and naming conventions, so it might need some
tweaks though.

A diff against HEAD is attached.

Thanks,
Eric

_______________________________________________
Ratpoison-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/ratpoison-devel
rp_new_window_hook_20100316.diff (application/octet-stream, 1.6 KB)
diff --git a/doc/ratpoison.1 b/doc/ratpoison.1
index a453414..8d9924e 100644
--- a/doc/ratpoison.1
+++ b/doc/ratpoison.1
@@ -204,6 +204,8 @@ Possible events are:
 .br
 \fBdeletewindow\fP	Run after a window is withdrawn.
 .br
+\fBnewwindow\fP	Run after a new window is mapped.
+.br
 \fBkey\fP	Run whenever a top level key is pressed.
 (by default \fBC\-t\fP)
 .br
diff --git a/src/globals.c b/src/globals.c
index 9ebc8e3..eb94db6 100644
--- a/src/globals.c
+++ b/src/globals.c
@@ -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_new_window_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},
+   {"newwindow",	&rp_new_window_hook},
    {NULL, NULL}};
 
 void
diff --git a/src/globals.h b/src/globals.h
index 00af94d..aa73451 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -181,6 +181,7 @@ extern struct list_head rp_switch_screen_hook;
 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 rp_hook_db_entry rp_hook_db[];
 
diff --git a/src/manage.c b/src/manage.c
index 8aaec31..f822c53 100644
--- a/src/manage.c
+++ b/src/manage.c
@@ -815,6 +815,8 @@ map_window (rp_window *win)
     set_active_window (win);
   else
     show_rudeness_msg (win, 0);
+
+  hook_run (&rp_new_window_hook);
 }
 
 void
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.