Implement wrapping, selecting containers is now Mod1+Ctrl+h/j/k/l
This commit is contained in:
parent
91f98cc597
commit
bde67a179e
14
i3.config
14
i3.config
|
@ -16,11 +16,17 @@ bind Mod1+45 j
|
||||||
bind Mod1+46 k
|
bind Mod1+46 k
|
||||||
bind Mod1+47 l
|
bind Mod1+47 l
|
||||||
|
|
||||||
|
# Focus Container (Mod1+j/k/l/;)
|
||||||
|
bind Mod1+Control+44 wch
|
||||||
|
bind Mod1+Control+45 wcj
|
||||||
|
bind Mod1+Control+46 wck
|
||||||
|
bind Mod1+Control+47 wcl
|
||||||
|
|
||||||
# Snap (Mod1+Control+j/k/l/;)
|
# Snap (Mod1+Control+j/k/l/;)
|
||||||
bind Mod1+Control+44 sh
|
bind Mod1+Shift+Control+44 sh
|
||||||
bind Mod1+Control+45 sj
|
bind Mod1+Shift+Control+45 sj
|
||||||
bind Mod1+Control+46 sk
|
bind Mod1+Shift+Control+46 sk
|
||||||
bind Mod1+Control+47 sl
|
bind Mod1+Shift+Control+47 sl
|
||||||
|
|
||||||
# Move (Mod1+Shift+j/k/l/;)
|
# Move (Mod1+Shift+j/k/l/;)
|
||||||
bind Mod1+Shift+44 mh
|
bind Mod1+Shift+44 mh
|
||||||
|
|
|
@ -30,24 +30,26 @@ static bool focus_window_in_container(xcb_connection_t *conn, Container *contain
|
||||||
if (container->currently_focused == NULL)
|
if (container->currently_focused == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
/* Get the previous/next client or wrap around */
|
||||||
Client *candidate = NULL;
|
Client *candidate = NULL;
|
||||||
if (direction == D_UP)
|
if (direction == D_UP) {
|
||||||
candidate = CIRCLEQ_PREV(container->currently_focused, clients);
|
if ((candidate = CIRCLEQ_PREV_OR_NULL(&(container->clients), container->currently_focused, clients)) == NULL)
|
||||||
else if (direction == D_DOWN)
|
candidate = CIRCLEQ_LAST(&(container->clients));
|
||||||
candidate = CIRCLEQ_NEXT(container->currently_focused, clients);
|
}
|
||||||
else printf("Direction not implemented!\n");
|
else if (direction == D_DOWN) {
|
||||||
|
if ((candidate = CIRCLEQ_NEXT_OR_NULL(&(container->clients), container->currently_focused, clients)) == NULL)
|
||||||
|
candidate = CIRCLEQ_FIRST(&(container->clients));
|
||||||
|
} else printf("Direction not implemented!\n");
|
||||||
|
|
||||||
/* If we don’t have anything to select, we’re done */
|
/* Set focus */
|
||||||
if (candidate == CIRCLEQ_END(&(container->clients)))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
/* Set focus if we could successfully move */
|
|
||||||
set_focus(conn, candidate);
|
set_focus(conn, candidate);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void focus_window(xcb_connection_t *conn, direction_t direction) {
|
typedef enum { THING_WINDOW, THING_CONTAINER } thing_t;
|
||||||
|
|
||||||
|
static void focus_thing(xcb_connection_t *conn, direction_t direction, thing_t thing) {
|
||||||
printf("focusing direction %d\n", direction);
|
printf("focusing direction %d\n", direction);
|
||||||
|
|
||||||
int new_row = current_row,
|
int new_row = current_row,
|
||||||
|
@ -61,9 +63,10 @@ static void focus_window(xcb_connection_t *conn, direction_t direction) {
|
||||||
|
|
||||||
/* TODO: for horizontal default layout, this has to be expanded to LEFT/RIGHT */
|
/* TODO: for horizontal default layout, this has to be expanded to LEFT/RIGHT */
|
||||||
if (direction == D_UP || direction == D_DOWN) {
|
if (direction == D_UP || direction == D_DOWN) {
|
||||||
/* Let’s see if we can perform up/down focus in the current container */
|
if (thing == THING_WINDOW)
|
||||||
if (focus_window_in_container(conn, container, direction))
|
/* Let’s see if we can perform up/down focus in the current container */
|
||||||
return;
|
if (focus_window_in_container(conn, container, direction))
|
||||||
|
return;
|
||||||
|
|
||||||
if (direction == D_DOWN && cell_exists(current_col, current_row+1))
|
if (direction == D_DOWN && cell_exists(current_col, current_row+1))
|
||||||
new_row++;
|
new_row++;
|
||||||
|
@ -467,11 +470,19 @@ void parse_command(xcb_connection_t *conn, const char *command) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum { WITH_WINDOW, WITH_CONTAINER } with = WITH_WINDOW;
|
||||||
|
|
||||||
/* Is it a <with>? */
|
/* Is it a <with>? */
|
||||||
if (command[0] == 'w') {
|
if (command[0] == 'w') {
|
||||||
|
command++;
|
||||||
/* TODO: implement */
|
/* TODO: implement */
|
||||||
printf("not yet implemented.\n");
|
if (command[0] == 'c') {
|
||||||
return;
|
with = WITH_CONTAINER;
|
||||||
|
command++;
|
||||||
|
} else {
|
||||||
|
printf("not yet implemented.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* It's a normal <cmd> */
|
/* It's a normal <cmd> */
|
||||||
|
@ -522,8 +533,9 @@ void parse_command(xcb_connection_t *conn, const char *command) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action == ACTION_FOCUS)
|
if (action == ACTION_FOCUS) {
|
||||||
focus_window(conn, direction);
|
focus_thing(conn, direction, (with == WITH_WINDOW ? THING_WINDOW : THING_CONTAINER));
|
||||||
|
}
|
||||||
else if (action == ACTION_MOVE)
|
else if (action == ACTION_MOVE)
|
||||||
move_current_window(conn, direction);
|
move_current_window(conn, direction);
|
||||||
else if (action == ACTION_SNAP)
|
else if (action == ACTION_SNAP)
|
||||||
|
|
Loading…
Reference in New Issue