diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/actions.c | 36 | ||||
-rw-r--r-- | src/actions.h | 2 | ||||
-rw-r--r-- | src/data.h | 1 | ||||
-rw-r--r-- | src/split.c | 15 |
4 files changed, 51 insertions, 3 deletions
diff --git a/src/actions.c b/src/actions.c index 511bfef..a5b2f65 100644 --- a/src/actions.c +++ b/src/actions.c @@ -82,6 +82,8 @@ static user_command user_commands[] = {"startup_message", cmd_startup_message, arg_STRING}, {"link", cmd_link, arg_STRING}, {"alias", cmd_alias, arg_STRING}, + {"prevscreen", cmd_prevscreen, arg_VOID}, + {"nextscreen", cmd_nextscreen, arg_VOID}, /*@end (tag required for genrpbindings) */ /* Commands to set default behavior. */ @@ -2430,3 +2432,37 @@ cmd_alias (int interactive, void *data) return NULL; } + +char * +cmd_nextscreen (int interactive, void *data) +{ + int new_screen; + + /* No need to go through the motions when we don't have to. */ + if (num_screens <= 1) return NULL; + + new_screen = rp_current_screen + 1; + if (new_screen >= num_screens) + new_screen = 0; + + set_active_frame (screens[new_screen].rp_current_frame); + + return NULL; +} + +char * +cmd_prevscreen (int interactive, void *data) +{ + int new_screen; + + /* No need to go through the motions when we don't have to. */ + if (num_screens <= 1) return NULL; + + new_screen = rp_current_screen - 1; + if (new_screen < 0) + new_screen = num_screens - 1; + + set_active_frame (screens[new_screen].rp_current_frame); + + return NULL; +} diff --git a/src/actions.h b/src/actions.h index a727254..cbedd60 100644 --- a/src/actions.h +++ b/src/actions.h @@ -108,6 +108,8 @@ char * cmd_defbarpadding (int interactive, void *data); char * cmd_license (int interactive, void *data); char * cmd_alias (int interactive, void *data); char *cmd_defbarborder (int interactive, void *data); +char *cmd_prevscreen (int interactive, void *data); +char *cmd_nextscreen (int interactive, void *data); void initialize_default_keybindings (void); rp_action* find_keybinding (KeySym keysym, int state); @@ -37,6 +37,7 @@ typedef struct rp_window_frame rp_window_frame; struct rp_window_frame { + int number; int x, y, width, height; rp_window *win; diff --git a/src/split.c b/src/split.c index 47efed3..f9805ce 100644 --- a/src/split.c +++ b/src/split.c @@ -611,17 +611,26 @@ remove_frame (rp_window_frame *frame) free (frame); } +/* Switch the input focus to another frame, and therefore a different + window. */ void set_active_frame (rp_window_frame *frame) { + screen_info *old_s = current_screen(); screen_info *s = frames_screen (frame); - rp_window_frame *old = s->rp_current_frame; + rp_window_frame *old = current_screen()->rp_current_frame; - give_window_focus (frame->win, s->rp_current_frame->win); + /* Make the switch */ + give_window_focus (frame->win, old->win); update_last_access (frame); s->rp_current_frame = frame; - if (old != s->rp_current_frame && num_frames(s) > 1) + /* If frame->win == NULL, then rp_current_screen is not updated. */ + rp_current_screen = s->screen_num; + + /* Possibly show the frame indicator. */ + if ((old != s->rp_current_frame && num_frames(s) > 1) + || s != old_s) { show_frame_indicator(); } |