summaryrefslogtreecommitdiff
path: root/src/split.c
diff options
context:
space:
mode:
authorsabetts <sabetts>2001-10-18 07:51:59 +0000
committersabetts <sabetts>2001-10-18 07:51:59 +0000
commit6ddaccd940d82362ead59ee4f5d21b3feb3d57fc (patch)
tree104db9ae26790178183e001d9d17c80bc92079cf /src/split.c
parent9784bfc548debcf70cdfd202abec95be539a32fd (diff)
downloadratpoison-6ddaccd940d82362ead59ee4f5d21b3feb3d57fc.zip
* src/split.h (find_last_frame): new prototype
* src/split.c (update_last_access): new function (find_last_frame): likewise (split_frame): update the new frame's last_access field (set_active_frame): update the new current frame's last_access field * src/input.h (x11_mask_to_rp_mask): new prototype (rp_mask_to_x11_mask): likewise * src/input.c (x11_mask_to_rp_mask): new function (rp_mask_to_x11_mask): likewise * src/events.c (handle_key): convert X11 modifier masks to rp modifier masks where appropriate. * src/actions.h (cmd_focuslast): new prototype * src/actions.c (initialize_default_keybindings): new keybinding for "focuslast" (cmd_focuslast): new function (user_command): new command "focuslast"
Diffstat (limited to 'src/split.c')
-rw-r--r--src/split.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/split.c b/src/split.c
index a27ec2b..2090b53 100644
--- a/src/split.c
+++ b/src/split.c
@@ -28,6 +28,15 @@
rp_window_frame *rp_window_frame_sentinel;
rp_window_frame *rp_current_frame;
+static void
+update_last_access (rp_window_frame *frame)
+{
+ static int counter = 0;
+
+ frame->last_access = counter;
+ counter++;
+}
+
rp_window *
set_frames_window (rp_window_frame *frame, rp_window *win)
{
@@ -82,6 +91,8 @@ create_initial_frame ()
{
rp_current_frame = xmalloc (sizeof (rp_window_frame));
+ update_last_access (rp_current_frame);
+
rp_window_frame_sentinel->next = rp_current_frame;
rp_window_frame_sentinel->prev = rp_current_frame;
rp_current_frame->next = rp_window_frame_sentinel;
@@ -103,6 +114,27 @@ init_frame_list ()
create_initial_frame();
}
+rp_window_frame *
+find_last_frame ()
+{
+ rp_window_frame *cur, *last = NULL;
+ int last_access = -1;
+
+ for (cur = rp_window_frame_sentinel->next;
+ cur != rp_window_frame_sentinel;
+ cur = cur->next)
+ {
+ if (cur != rp_current_frame
+ && cur->last_access > last_access)
+ {
+ last_access = cur->last_access;
+ last = cur;
+ }
+ }
+
+ return last;
+}
+
/* Return the frame that contains the window. */
rp_window_frame *
find_windows_frame (rp_window *win)
@@ -217,6 +249,10 @@ split_frame (rp_window_frame *frame, int way)
new_frame = xmalloc (sizeof (rp_window_frame));
+ /* It seems intuitive to make the last frame the newly created
+ frame. */
+ update_last_access (new_frame);
+
/* append the new frame to the list */
new_frame->prev = rp_window_frame_sentinel->prev;
rp_window_frame_sentinel->prev->next = new_frame;
@@ -541,6 +577,7 @@ set_active_frame (rp_window_frame *frame)
rp_window_frame *old = rp_current_frame;
give_window_focus (frame->win, rp_current_frame->win);
+ update_last_access (frame);
rp_current_frame = frame;
if (old != rp_current_frame && num_frames() > 1)