From 6ddaccd940d82362ead59ee4f5d21b3feb3d57fc Mon Sep 17 00:00:00 2001 From: sabetts Date: Thu, 18 Oct 2001 07:51:59 +0000 Subject: * 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" --- src/split.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'src/split.c') 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) -- cgit v1.2.3