From: a bellenir Date: Fri, 1 Aug 2014 05:00:07 +0000 (+0000) Subject: swap focused frame with next with wJ X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=aa5a3d674458f48b8fc3fda54f77ce81b38a006c;p=archive%2Fafm.git swap focused frame with next with wJ --- diff --git a/source/input.c b/source/input.c index aab3cd0..6e7d7a8 100644 --- a/source/input.c +++ b/source/input.c @@ -114,6 +114,7 @@ static binding_t Default_Bindings[] = { { "wk", &screen_focus_prev }, { "wm", &screen_focus_master }, { "w\n", &screen_swap_with_master }, + { "wJ", &screen_swap_frame_next }, { "R", &handle_force_redraw } }; diff --git a/source/screen.c b/source/screen.c index fcc94cb..1c88e07 100644 --- a/source/screen.c +++ b/source/screen.c @@ -136,6 +136,17 @@ void screen_focus_master(void){ state_set_refresh_state(REFRESH_CURR_WIN); } +//for when force refresh (R) fixes the screen, +//but setting screen REFRESH_ALL_WINS doesnt +//necessary when moving frames around +static void stoopid_redraw(Frame_T* a, Frame_T* b){ + frame_resize(a, 1, 1); + frame_move(a, 0, 0); + frame_resize(b, 1, 1); + frame_move(b, 1, 1); + state_set_refresh_state(REFRESH_ALL_WINS); +} + void screen_swap_with_master(void){ list_node_t* focused = state_get_focused_node(); list_node_t* master = Frame_List->head; @@ -151,11 +162,21 @@ void screen_swap_with_master(void){ // reset focused window (since old focused destroyed) state_set_focused_node(Frame_List->head); // Resize and move os they don't overlap when we place them. - frame_resize((Frame_T*)focused->contents, 1, 1); - frame_move((Frame_T*)focused->contents, 0, 0); - frame_resize((Frame_T*)master->contents, 1, 1); - frame_move((Frame_T*)master->contents, 1, 1); - state_set_refresh_state(REFRESH_ALL_WINS); + stoopid_redraw(fmast, ffoc); + } +} + +void screen_swap_frame_next(void){ + if(Frame_List->head != Frame_List->tail){ + list_node_t* focused = state_get_focused_node(); + list_node_t* next = focused->next; + list_node_t* new_node = NULL; + Frame_T* ffoc = (Frame_T*)focused->contents; + mem_retain(ffoc); + list_delete_node(Frame_List, focused); + new_node = list_insert_after(Frame_List, next, ffoc); + state_set_focused_node(new_node); + stoopid_redraw(ffoc, (Frame_T*) ((NULL == next) ? Frame_List->tail->contents : next->contents)); } } diff --git a/source/screen.h b/source/screen.h index 126ecc5..2049bd6 100644 --- a/source/screen.h +++ b/source/screen.h @@ -16,5 +16,6 @@ void screen_focus_next(void); void screen_focus_prev(void); void screen_focus_master(void); void screen_swap_with_master(void); +void screen_swap_frame_next(void); #endif /* SCREEN_H */