patch: push window to frame

Jeff Abrahamson <[email protected]> Sat, 6 Sep 2014 22:25:33 +0200
Newsgroups gmane.comp.window-managers.ratpoison.devel
Message-ID <CAM4Y7zyX3tiZ+=arMbELH5e=gQyO0_Pe7ODQMcqc5yVPDH5WCA@mail.gmail.com>
I've implemented the command pushwindow, which moves the current window to
another frame, leaving the focus in the current frame. This is what I
originally called "send to frame" in this bug
<https://savannah.nongnu.org/bugs/?42223> and when I proposed to implement
this.

I've bound the command to "h", which is the last letter of "push". I'd like
to implement "pullwindow" the same way, and I'd like to bind it to "l"
(lower case "L"). This is currently bound, along with C-L, to redisplay, so
maybe that's a bad idea (changing the binding). I think the bindings for
push and pull should be thought through together.

Feedback on the code and on the naming/binding most welcome, of course.

I don't see how to make one change to the documentation so that both the
man page and the texinfo documentation both change. So maybe patch 2 is
wrong.

Jeff Abrahamson
+33 6 24 40 01 57
+44 7920 594 255    <-- only if I'm in the UK

http://jeff.purple.com/
http://blog.purple.com/jeff/

_______________________________________________
Ratpoison-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/ratpoison-devel
0001-Add-command-pushwindow.patch (text/x-patch, 2.8 KB)
From 708eeae7807a3a7ce84df967c890ec4636b0d77f Mon Sep 17 00:00:00 2001
From: Jeff Abrahamson <[email protected]>
Date: Sat, 6 Sep 2014 21:49:11 +0200
Subject: [PATCH 1/2] Add command pushwindow.

Add command to push the current window to another frame.
The current window moves to the selected frame.
The current frame gets assigned a new window.
The focus stays on the current frame (and so changes to the new window
now displayed in the current frame).
---
 src/actions.c | 30 ++++++++++++++++++++++++++++++
 src/actions.h |  1 +
 2 files changed, 31 insertions(+)

diff --git a/src/actions.c b/src/actions.c
index 7579101..7ce76c1 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -295,6 +295,8 @@ init_user_commands(void)
                "Hook: ", arg_HOOK);
   add_command ("meta",          cmd_meta,       1, 0, 0,
                "key: ", arg_KEY);
+  add_command("pushwindow",    cmd_pushwindow, 1, 1, 1,
+              "Push current window to frame: ", arg_FRAME);
   add_command ("msgwait",       cmd_msgwait,    1, 0, 0,
                "", arg_NUMBER);
   add_command ("newkmap",       cmd_newkmap,    1, 1, 1,
@@ -754,6 +756,7 @@ initialize_default_keybindings (void)
   add_keybinding (XK_colon, 0, "colon", map);
   add_keybinding (XK_exclam, 0, "exec", map);
   add_keybinding (XK_exclam, RP_CONTROL_MASK, "colon exec " TERM_PROG " -e ", map);
+  add_keybinding (XK_h, 0, "pushwindow", map);
   add_keybinding (XK_i, 0, "info", map);
   add_keybinding (XK_i, RP_CONTROL_MASK, "info", map);
   add_keybinding (XK_k, 0, "delete", map);
@@ -3684,6 +3687,33 @@ set_maxsizegravity (struct cmdarg **args)
 }
 
 cmdret *
+cmd_pushwindow (int interactive UNUSED, struct cmdarg **args)
+{
+  rp_frame *src_frame = current_frame();
+  rp_frame *dest_frame = ARG(0, frame);
+
+  rp_window *window_to_move = find_window_number(src_frame->win_number);
+  rp_window *window_to_reveal = find_window_for_frame (src_frame);
+  rp_window *window_to_cover = set_frames_window(dest_frame, window_to_move);
+  maximize (window_to_move);
+  unhide_window (window_to_move);
+  XRaiseWindow (dpy, window_to_move->w);
+
+  hide_window(window_to_cover);
+
+  set_frames_window(src_frame, window_to_reveal);
+  maximize (window_to_reveal);
+  unhide_window (window_to_reveal);
+  XRaiseWindow (dpy, window_to_reveal->w);
+
+  set_active_frame(src_frame, 0);
+
+  // Note that I haven't pushed anything to the undo stack yet.
+
+  return cmdret_new (RET_SUCCESS, NULL);
+}
+
+cmdret *
 cmd_msgwait (int interactive UNUSED, struct cmdarg **args)
 {
   if (args[0] == NULL)
diff --git a/src/actions.h b/src/actions.h
index 519c1a7..47564ec 100644
--- a/src/actions.h
+++ b/src/actions.h
@@ -165,6 +165,7 @@ RP_CMD (other);
 RP_CMD (prev);
 RP_CMD (prev_frame);
 RP_CMD (prevscreen);
+RP_CMD (pushwindow);
 RP_CMD (quit);
 RP_CMD (redisplay);
 RP_CMD (remhook);
-- 
1.9.1
0002-Add-pushwindow-to-the-man-page.patch (text/x-patch, 872 B)
From 345e3a64a25b4f4becbd4c90ed636e49b18150e3 Mon Sep 17 00:00:00 2001
From: Jeff Abrahamson <[email protected]>
Date: Sat, 6 Sep 2014 22:11:16 +0200
Subject: [PATCH 2/2] Add pushwindow to the man page.

---
 doc/ratpoison.mdoc.1 | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/doc/ratpoison.mdoc.1 b/doc/ratpoison.mdoc.1
index 2e3c356..c48f6ac 100644
--- a/doc/ratpoison.mdoc.1
+++ b/doc/ratpoison.mdoc.1
@@ -569,6 +569,10 @@ maximize this one to the size of the whole screen.
 .It Ic other Pq Ic C\-t C\-t
 Switch to the window of the current group that was last
 accessed but is not currently visible.
+.It Ic pushwindow Ar dest-frame Pq Ic C\-t h
+Move the current window to
+.Ar dest\-frame
+(or ask interactively if there is no argument)
 .It Ic prev Pq Ic C\-t p
 Switch to the previous window in the current group.
 .It Ic prevscreen Pq Ic C\-t P
-- 
1.9.1