[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RP] Patch for new command - focuslast
From: |
Mike Meyer |
Subject: |
[RP] Patch for new command - focuslast |
Date: |
Sun Oct 7 16:46:02 2001 |
I find that I use "other" to switch back and forth between two
frames. Then after taking care of something else in a third window in
one of those two frames, I'm surprised when "other" displays a window
I don't need instead of taking me where I wanted to go.
My solution is another focus changing command "focuslast". The
attached patch adds that. It also includes a correct fix for "sh -c"'s
hanging around until the process they started exits.
Next I'll look into the rude raise magical migrating focus.
<mike
--
Mike Meyer <address@hidden> http://www.mired.org/home/mwm/
Q: How do you make the gods laugh? A: Tell them your plans.
Index: src/actions.c
===================================================================
RCS file: /cvsroot/ratpoison/ratpoison/src/actions.c,v
retrieving revision 1.93
diff -u -r1.93 actions.c
--- src/actions.c 2001/09/23 07:43:40 1.93
+++ src/actions.c 2001/10/07 23:34:15
@@ -42,6 +42,7 @@
{"escape", cmd_escape, arg_STRING},
{"exec", cmd_exec, arg_STRING},
{"focus", cmd_next_frame, arg_VOID},
+ {"focuslast", cmd_old_frame, arg_VOID},
{"focusup", cmd_focusup, arg_VOID},
{"focusdown", cmd_focusdown, arg_VOID},
{"focusleft", cmd_focusleft, arg_VOID},
@@ -606,6 +607,15 @@
}
char *
+cmd_old_frame (int interactive, void *data)
+{
+ if (rp_current_frame != NULL && rp_old_frame != rp_current_frame)
+ set_active_frame (rp_old_frame);
+
+ return NULL;
+}
+
+char *
cmd_other (int interactive, void *data)
{
rp_window *w;
@@ -865,7 +875,30 @@
void
spawn(void *data)
{
- char *cmd = data;
+ char *cmd ;
+ /* ugly dance to avoid leaving shells laying around. */
+ cmd = strrchr((char *) data, '&');
+
+ /* If we have an &, see if it's the last non-white on the line */
+ if (cmd != NULL)
+ {
+ do {
+ cmd++;
+ } while (*cmd == ' ') ;
+ if (*cmd != '\0') cmd = NULL;
+ }
+
+ /* cmd doesn't end in an &, so we add one */
+ if (cmd == NULL)
+ {
+ cmd = xmalloc(strlen((char *) data) + 3);
+ sprintf(cmd, "%s &", (char *) data);
+ }
+ else
+ {
+ cmd = xstrdup((char *) data);
+ }
+
/*
* ugly dance to avoid leaving zombies. Could use SIGCHLD,
* but it's not very portable.
@@ -891,6 +924,7 @@
_exit(EXIT_SUCCESS);
}
wait((int *) 0);
+ free(cmd);
PRINT_DEBUG ("spawned %s\n", cmd);
}
Index: src/actions.h
===================================================================
RCS file: /cvsroot/ratpoison/ratpoison/src/actions.h,v
retrieving revision 1.39
diff -u -r1.39 actions.h
--- src/actions.h 2001/09/21 09:47:23 1.39
+++ src/actions.h 2001/10/07 23:34:15
@@ -52,6 +52,7 @@
char * cmd_last (int interactive, void *data);
char * cmd_next (int interactive, void *data);
char * cmd_next_frame (int interactive, void *data);
+char * cmd_old_frame (int interactive, void *data);
char * cmd_prev (int interactive, void *data);
char * cmd_prev_frame (int interactive, void *data);
char * cmd_windows (int interactive, void *data);
Index: src/conf.h
===================================================================
RCS file: /cvsroot/ratpoison/ratpoison/src/data.h,v
retrieving revision 1.32
diff -u -r1.32 data.h
--- src/data.h 2001/09/21 09:47:23 1.32
+++ src/data.h 2001/10/07 23:34:15
@@ -176,6 +176,7 @@
/* Pointer to the currently focused frame. */
extern rp_window_frame *rp_current_frame;
+extern rp_window_frame *rp_old_frame;
extern screen_info *screens;
extern int num_screens;
Index: src/split.c
===================================================================
RCS file: /cvsroot/ratpoison/ratpoison/src/split.c,v
retrieving revision 1.17
diff -u -r1.17 split.c
--- src/split.c 2001/09/21 09:47:23 1.17
+++ src/split.c 2001/10/07 23:34:16
@@ -27,6 +27,7 @@
rp_window_frame *rp_window_frame_sentinel;
rp_window_frame *rp_current_frame;
+rp_window_frame *rp_old_frame;
rp_window *
set_frames_window (rp_window_frame *frame, rp_window *win)
@@ -81,6 +82,7 @@
create_initial_frame ()
{
rp_current_frame = xmalloc (sizeof (rp_window_frame));
+ rp_old_frame = NULL ;
rp_window_frame_sentinel->next = rp_current_frame;
rp_window_frame_sentinel->prev = rp_current_frame;
@@ -430,6 +432,12 @@
if (frame == NULL) return;
+ /* This shouldn't be possible.... */
+ if (frame == rp_old_frame) {
+ message (" remove_frame: removing old frame ");
+ rp_old_frame = NULL;
+ }
+
area = total_frame_area();
PRINT_DEBUG ("Total Area: %d\n", area);
@@ -522,6 +530,7 @@
rp_window_frame *old = rp_current_frame;
give_window_focus (frame->win, rp_current_frame->win);
+ rp_old_frame = rp_current_frame;
rp_current_frame = frame;
if (old != rp_current_frame && num_frames() > 1)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [RP] Patch for new command - focuslast,
Mike Meyer <=