From 708eeae7807a3a7ce84df967c890ec4636b0d77f Mon Sep 17 00:00:00 2001 From: Jeff Abrahamson 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