Permalink
Browse files

Navigation by keyboard between columns.

  • Loading branch information...
1 parent e06331a commit 5796e7cb3efb4eca68e30577cff91d0ff60bc10a @nezza committed Sep 29, 2011
Showing with 57 additions and 9 deletions.
  1. +1 −1 config.h
  2. +8 −0 gwm_functions.c
  3. +4 −0 gwm_functions.h
  4. +6 −4 gwm_keys.c
  5. +2 −0 gwm_organizer.h
  6. +31 −3 gwm_tiling.c
  7. +5 −1 gwm_tiling.h
View
2 config.h
@@ -4,7 +4,7 @@
#define CONFIG_BORDERCOLOR_NORMAL "#cccccc"
#define CONFIG_BORDERCOLOR_SELECTED "#0066ff"
-#define CONFIG_FOCUS_MODE focus_on_mouse
+#define CONFIG_FOCUS_MODE focus_on_click
#define CONFIG_RAISE_MODE raise_on_click
#define CONFIG_LAUNCH_MODE launch_normal
View
8 gwm_functions.c
@@ -142,6 +142,14 @@ void resize_window_down() {_resize_window(0, CONFIG_RESIZE_BY);}
void resize_window_left() {_resize_window(-CONFIG_RESIZE_BY, 0);}
void resize_window_right() {_resize_window(CONFIG_RESIZE_BY, 0);}
+void select_left() {
+ gwm.focused->spc->organizer->select_left(gwm.focused);
+}
+
+void select_right() {
+ gwm.focused->spc->organizer->select_right(gwm.focused);
+}
+
void fullscreen() {
if(gwm.focused) {
gwm_window_fullscreen(gwm.focused);
View
4 gwm_functions.h
@@ -20,6 +20,10 @@ void resize_window_up();
void resize_window_down();
void resize_window_left();
void resize_window_right();
+void select_left();
+void select_right();
+void select_up();
+void select_down();
void fullscreen();
#endif
View
10 gwm_keys.c
@@ -7,11 +7,13 @@ gwm_keys keys[] = {
{CONFIG_MODKEY, XK_Tab, focus_next},
{CONFIG_MODKEY|ShiftMask, XK_Tab, focus_prev},
{CONFIG_MODKEY, XK_i, hide_workspace},
+ {CONFIG_MODKEY, XK_h, select_left},
+ {CONFIG_MODKEY, XK_l, select_right},
{CONFIG_MODKEY|ShiftMask, XK_i, show_workspace},
- {CONFIG_MODKEY, XK_Left, move_window_left},
- {CONFIG_MODKEY, XK_Right, move_window_right},
- {CONFIG_MODKEY, XK_Up, move_window_up},
- {CONFIG_MODKEY, XK_Down, move_window_down},
+ {CONFIG_MODKEY|ShiftMask, XK_h, move_window_left},
+ {CONFIG_MODKEY|ShiftMask, XK_l, move_window_right},
+ {CONFIG_MODKEY|ShiftMask, XK_Up, move_window_up},
+ {CONFIG_MODKEY|ShiftMask, XK_Down, move_window_down},
{CONFIG_MODKEY, XK_n, new_workspace},
{CONFIG_MODKEY, XK_o, prev_workspace},
{CONFIG_MODKEY, XK_p, next_workspace},
View
2 gwm_organizer.h
@@ -10,6 +10,8 @@ struct gwm_organizer {
void (*move_left)(gwm_window *win);
void (*move_right)(gwm_window *win);
void (*focus)(gwm_window *win);
+ void (*select_left)(gwm_window *win);
+ void (*select_right)(gwm_window *win);
void *data;
};
View
34 gwm_tiling.c
@@ -19,7 +19,9 @@ void gwm_tiling_init(gwm_workspace *spc) {
spc->organizer->free_organizer = gwm_tiling_free;
spc->organizer->move_left = gwm_tiling_move_window_left;
spc->organizer->move_right = gwm_tiling_move_window_right;
- spc->organizer->focus = gwm_tiling_focus;
+ spc->organizer->focus = gwm_tiling_received_focus;
+ spc->organizer->select_left = gwm_tiling_select_left;
+ spc->organizer->select_right = gwm_tiling_select_right;
spc->organizer->data = malloc(sizeof(gwm_tiling_data));
if(!spc->organizer->data) {
free(spc->organizer);
@@ -53,12 +55,14 @@ gwm_tiling_column *gwm_tiling_create_column(
ret->next = next;
if(next) next->prev = ret;
ret->wins = NULL;
+ ret->focus = NULL;
return ret;
}
-void gwm_tiling_focus(gwm_window *win) {
+void gwm_tiling_received_focus(gwm_window *win) {
gwm_tiling_window *wdata = win->organizer_data;
wdata->data->active_column = wdata->column;
+ wdata->column->focus = wdata;
}
void gwm_tiling_destroy_column(gwm_tiling_column *column) {
@@ -95,8 +99,9 @@ void gwm_tiling_add_window(gwm_window *win) {
} else {
wdata->prev = gwm_tiling_window_get_last(data->active_column->wins);
}
-
+ wdata->column->focus = wdata;
gwm_tiling_move_resize(win);
+ focus(win);
}
// Private function for removing a tiling window.
@@ -141,6 +146,27 @@ unsigned gwm_tiling_column_count_windows(
return ret;
}
+void gwm_tiling_select_left(gwm_window *win) {
+ gwm_tiling_window *wdata = win->organizer_data;
+ gwm_tiling_column *col = wdata->column;
+ if(col->prev) {
+ gwm_tiling_column_focus(col->prev);
+ }
+}
+
+void gwm_tiling_select_right(gwm_window *win) {
+ gwm_tiling_window *wdata = win->organizer_data;
+ gwm_tiling_column *col = wdata->column;
+ if(col->next) {
+ gwm_tiling_column_focus(col->next);
+ }
+}
+void gwm_tiling_column_focus(gwm_tiling_column *col) {
+ col->data->active_column = col;
+ if(!col->focus) return;
+ focus(col->focus->win);
+}
+
void gwm_tiling_window_change_column(
gwm_tiling_window *w,
gwm_tiling_column *col) {
@@ -176,6 +202,7 @@ void gwm_tiling_move_window_left(gwm_window *win) {
gwm_tiling_destroy_column(orig_column);
}
wdata->data->active_column = wdata->column;
+ wdata->column->focus = wdata;
gwm_tiling_reorganize_all(win->spc);
focus(win);
raise(win);
@@ -200,6 +227,7 @@ void gwm_tiling_move_window_right(gwm_window *win) {
gwm_tiling_destroy_column(orig_column);
}
wdata->data->active_column = wdata->column;
+ wdata->column->focus = wdata;
gwm_tiling_reorganize_all(win->spc);
focus(win);
raise(win);
View
6 gwm_tiling.h
@@ -11,6 +11,7 @@ struct gwm_tiling_column {
gwm_tiling_data *data;
unsigned int column_nr;
gwm_tiling_window *wins;
+ gwm_tiling_window *focus;
gwm_tiling_column *prev;
gwm_tiling_column *next;
};
@@ -43,7 +44,10 @@ void gwm_tiling_reorganize_all(gwm_workspace *spc);
void gwm_tiling_move_resize(gwm_window *win);
void gwm_tiling_move_window_left(gwm_window *win);
void gwm_tiling_move_window_right(gwm_window *win);
-void gwm_tiling_focus(gwm_window *win);
+void gwm_tiling_received_focus(gwm_window *win);
+void gwm_tiling_column_focus(gwm_tiling_column *col);
+void gwm_tiling_select_left(gwm_window *win);
+void gwm_tiling_select_right(gwm_window *win);
#endif

0 comments on commit 5796e7c

Please sign in to comment.