diff -ru ratpoison/src/actions.c ratpoison-patched/src/actions.c --- ratpoison/src/actions.c Sun Sep 23 09:43:40 2001 +++ ratpoison-patched/src/actions.c Wed Oct 10 04:00:34 2001 @@ -64,6 +64,7 @@ {"select", cmd_select, arg_STRING}, {"source", cmd_source, arg_STRING}, {"split", cmd_h_split, arg_VOID}, + {"third", cmd_third, arg_VOID}, {"title", cmd_rename, arg_STRING}, {"unbind", cmd_unbind, arg_STRING}, {"version", cmd_version, arg_VOID}, @@ -224,6 +225,7 @@ add_keybinding (XK_A, ControlMask, "title"); add_keybinding (XK_K, 0, "kill"); add_keybinding (XK_K, ControlMask, "kill"); + add_keybinding (XK_T, 0, "third"); add_keybinding (XK_Return, 0, "next"); add_keybinding (XK_Return, ControlMask, "next"); add_keybinding (XK_a, 0, "time"); @@ -614,6 +616,21 @@ if (!w) message (MESSAGE_NO_OTHER_WINDOW); + else + set_active_window (w); + + return NULL; +} + +char * +cmd_third (int interactive, void *data) +{ + rp_window *w; + + w = find_window_third (); + + if (!w) + message (MESSAGE_NO_THIRD_WINDOW); else set_active_window (w); diff -ru ratpoison/src/actions.h ratpoison-patched/src/actions.h --- ratpoison/src/actions.h Fri Sep 21 11:47:23 2001 +++ ratpoison-patched/src/actions.h Wed Oct 10 03:56:00 2001 @@ -56,6 +56,7 @@ char * cmd_prev_frame (int interactive, void *data); char * cmd_windows (int interactive, void *data); char * cmd_other (int interactive, void *data); +char * cmd_third (int interactive, void *data); char * cmd_time (int interactive, void *data); char * cmd_version (int interactive, void *data); char * cmd_unimplemented (int interactive, void *data); Only in ratpoison-patched/src: config.h.in diff -ru ratpoison/src/list.c ratpoison-patched/src/list.c --- ratpoison/src/list.c Fri Sep 21 11:47:23 2001 +++ ratpoison-patched/src/list.c Wed Oct 10 04:03:54 2001 @@ -314,6 +314,44 @@ return most_recent; } +rp_window * +find_window_third () +{ + int last_access = 0, next_last_access = 0; + rp_window *most_recent = NULL, *next_most_recent = NULL; + rp_window *cur; + + for (cur = rp_mapped_window_sentinel->next; + cur != rp_mapped_window_sentinel; + cur = cur->next) + { + if (cur->last_access >= last_access + && cur != current_window() + && !find_windows_frame (cur)) + { + next_most_recent = most_recent; + most_recent = cur; + next_last_access = last_access; + last_access = cur->last_access; + } + else if (cur->last_access >= next_last_access + && cur != current_window() + && !find_windows_frame (cur)) + { + next_most_recent = cur; + next_last_access = cur->last_access; + } + } + /* If there only are two windows (i.e. next_most_windows is still + NULL, we take the most recent */ + if (!next_most_recent && most_recent) + { + next_most_recent = most_recent; + } + + return next_most_recent; +} + /* This somewhat CPU intensive (memcpy) swap function sorta defeats the purpose of a linear linked list. */ /* static void */ diff -ru ratpoison/src/list.h ratpoison-patched/src/list.h --- ratpoison/src/list.h Fri Sep 21 11:47:23 2001 +++ ratpoison-patched/src/list.h Wed Oct 10 03:30:26 2001 @@ -49,6 +49,7 @@ /* int goto_window_name (char *name); */ rp_window *find_window_other (); +rp_window *find_window_third (); rp_window *find_window_by_number (int n); rp_window *find_window_name (char *name); rp_window *find_window_prev (rp_window *w); diff -ru ratpoison/src/messages.h ratpoison-patched/src/messages.h --- ratpoison/src/messages.h Sun Sep 9 04:59:23 2001 +++ ratpoison-patched/src/messages.h Wed Oct 10 03:51:27 2001 @@ -25,6 +25,7 @@ #include "config.h" #define MESSAGE_NO_OTHER_WINDOW " No other window " +#define MESSAGE_NO_THIRD_WINDOW " No next to last window " #define MESSAGE_NO_OTHER_FRAME " No other frame " #define MESSAGE_NO_MANAGED_WINDOWS " No managed windows " #define MESSAGE_UNKNOWN_COMMAND ": unknown command '%s' "