Implement moving up/down (not complete yet)
This commit is contained in:
parent
f255ac0baf
commit
b58c24d655
108
mainx.c
108
mainx.c
@ -652,32 +652,90 @@ static void move_current_window(xcb_connection_t *connection, direction_t direct
|
|||||||
|
|
||||||
Client *current_client = container->currently_focused;
|
Client *current_client = container->currently_focused;
|
||||||
|
|
||||||
if (direction == D_RIGHT) {
|
Container *new;
|
||||||
printf("ok, moving right\n");
|
int new_current_col = current_col,
|
||||||
expand_table_cols();
|
new_current_row = current_row;
|
||||||
|
/* As soon as the client is moved away, the next client in the old
|
||||||
|
* container needs to get focus, if any. Therefore, we save it here. */
|
||||||
|
Client *to_focus = CIRCLEQ_NEXT(current_client, clients);
|
||||||
|
if (to_focus == CIRCLEQ_END(&(container->clients)))
|
||||||
|
to_focus = NULL;
|
||||||
|
|
||||||
Container *new = table[current_col+1][current_row];
|
switch (direction) {
|
||||||
|
case D_LEFT:
|
||||||
|
printf("moving left\n");
|
||||||
|
if (current_col == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
/* As soon as the client is moved away, the next client in the old
|
new = table[current_col-1][current_row];
|
||||||
* container needs to get focus, if any. Therefore, we save it here. */
|
new_current_col--;
|
||||||
Client *to_focus = CIRCLEQ_NEXT(current_client, clients);
|
break;
|
||||||
if (to_focus == CIRCLEQ_END(&(container->clients)))
|
case D_RIGHT:
|
||||||
to_focus = NULL;
|
printf("ok, moving right\n");
|
||||||
|
if (current_col == (table_dims.x-1)) {
|
||||||
|
printf("need to expand\n");
|
||||||
|
expand_table_cols();
|
||||||
|
}
|
||||||
|
|
||||||
/* Remove it from the old container and put it into the new one */
|
new = table[current_col+1][current_row];
|
||||||
CIRCLEQ_REMOVE(&(container->clients), current_client, clients);
|
new_current_col++;
|
||||||
CIRCLEQ_INSERT_TAIL(&(new->clients), current_client, clients);
|
break;
|
||||||
|
case D_UP:
|
||||||
|
/* TODO: impl */
|
||||||
|
printf("moving up\n");
|
||||||
|
Client *prev = CIRCLEQ_PREV(current_client, clients);
|
||||||
|
if (prev != CIRCLEQ_END(&(container->clients))) {
|
||||||
|
printf("i can do that\n");
|
||||||
|
/* We can move the client inside its current container */
|
||||||
|
CIRCLEQ_REMOVE(&(container->clients), current_client, clients);
|
||||||
|
CIRCLEQ_INSERT_BEFORE(&(container->clients), prev, current_client, clients);
|
||||||
|
render_layout(connection);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Update data structures */
|
/* TODO: push the client into the container above */
|
||||||
current_client->container = new;
|
return;
|
||||||
container->currently_focused = to_focus;
|
case D_DOWN:
|
||||||
new->currently_focused = current_client;
|
printf("moving down\n");
|
||||||
|
Client *next = CIRCLEQ_NEXT(current_client, clients);
|
||||||
|
if (next != CIRCLEQ_END(&(container->clients))) {
|
||||||
|
printf("i can do that\n");
|
||||||
|
/* We can move the client inside its current container */
|
||||||
|
CIRCLEQ_REMOVE(&(container->clients), current_client, clients);
|
||||||
|
CIRCLEQ_INSERT_AFTER(&(container->clients), next, current_client, clients);
|
||||||
|
render_layout(connection);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
current_col++;
|
/* We need to create a new container or push the client
|
||||||
|
into the container below */
|
||||||
|
if (current_row == (table_dims.y-1)) {
|
||||||
|
printf("creating a new container\n");
|
||||||
|
expand_table_rows();
|
||||||
|
new = table[current_col][current_row+1];
|
||||||
|
new_current_row++;
|
||||||
|
}
|
||||||
|
/* TODO: check if there is another container below and move
|
||||||
|
it there */
|
||||||
|
|
||||||
printf("done\n");
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Remove it from the old container and put it into the new one */
|
||||||
|
CIRCLEQ_REMOVE(&(container->clients), current_client, clients);
|
||||||
|
CIRCLEQ_INSERT_TAIL(&(new->clients), current_client, clients);
|
||||||
|
|
||||||
|
/* Update data structures */
|
||||||
|
current_client->container = new;
|
||||||
|
container->currently_focused = to_focus;
|
||||||
|
new->currently_focused = current_client;
|
||||||
|
|
||||||
|
/* TODO: delete all empty columns/rows */
|
||||||
|
|
||||||
|
current_col = new_current_col;
|
||||||
|
current_row = new_current_row;
|
||||||
|
|
||||||
render_layout(connection);
|
render_layout(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -987,10 +1045,16 @@ int main(int argc, char *argv[], char *env[]) {
|
|||||||
//xcb_grab_key(c, 0, root, 0, 38, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
|
//xcb_grab_key(c, 0, root, 0, 38, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
|
||||||
|
|
||||||
xcb_grab_key(c, 0, root, 0, 30, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
|
xcb_grab_key(c, 0, root, 0, 30, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
|
||||||
xcb_grab_key(c, 0, root, XCB_MOD_MASK_CONTROL | XCB_MOD_MASK_1, 57, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
|
xcb_grab_key(c, 0, root, XCB_MOD_MASK_1, 57, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
|
||||||
xcb_grab_key(c, 0, root, XCB_MOD_MASK_CONTROL | XCB_MOD_MASK_1, 28, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
|
xcb_grab_key(c, 0, root, XCB_MOD_MASK_1, 28, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
|
||||||
xcb_grab_key(c, 0, root, XCB_MOD_MASK_CONTROL | XCB_MOD_MASK_1, 27, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
|
xcb_grab_key(c, 0, root, XCB_MOD_MASK_1, 27, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
|
||||||
xcb_grab_key(c, 0, root, XCB_MOD_MASK_CONTROL | XCB_MOD_MASK_1, 40, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
|
xcb_grab_key(c, 0, root, XCB_MOD_MASK_1, 40, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
|
||||||
|
|
||||||
|
xcb_grab_key(c, 0, root, XCB_MOD_MASK_CONTROL, 57, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
|
||||||
|
xcb_grab_key(c, 0, root, XCB_MOD_MASK_CONTROL, 28, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
|
||||||
|
xcb_grab_key(c, 0, root, XCB_MOD_MASK_CONTROL, 27, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
|
||||||
|
xcb_grab_key(c, 0, root, XCB_MOD_MASK_CONTROL, 40, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
|
||||||
|
|
||||||
|
|
||||||
//xcb_grab_key(c, 0, root, XCB_BUTTON_MASK_ANY, 40, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
|
//xcb_grab_key(c, 0, root, XCB_BUTTON_MASK_ANY, 40, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
|
||||||
start_application(TERMINAL, NULL);
|
start_application(TERMINAL, NULL);
|
||||||
|
4
queue.h
4
queue.h
@ -512,12 +512,12 @@ struct { \
|
|||||||
#define CIRCLEQ_REPLACE(head, elm, elm2, field) do { \
|
#define CIRCLEQ_REPLACE(head, elm, elm2, field) do { \
|
||||||
if (((elm2)->field.cqe_next = (elm)->field.cqe_next) == \
|
if (((elm2)->field.cqe_next = (elm)->field.cqe_next) == \
|
||||||
CIRCLEQ_END(head)) \
|
CIRCLEQ_END(head)) \
|
||||||
(head).cqh_last = (elm2); \
|
(head)->cqh_last = (elm2); \
|
||||||
else \
|
else \
|
||||||
(elm2)->field.cqe_next->field.cqe_prev = (elm2); \
|
(elm2)->field.cqe_next->field.cqe_prev = (elm2); \
|
||||||
if (((elm2)->field.cqe_prev = (elm)->field.cqe_prev) == \
|
if (((elm2)->field.cqe_prev = (elm)->field.cqe_prev) == \
|
||||||
CIRCLEQ_END(head)) \
|
CIRCLEQ_END(head)) \
|
||||||
(head).cqh_first = (elm2); \
|
(head)->cqh_first = (elm2); \
|
||||||
else \
|
else \
|
||||||
(elm2)->field.cqe_prev->field.cqe_next = (elm2); \
|
(elm2)->field.cqe_prev->field.cqe_next = (elm2); \
|
||||||
_Q_INVALIDATE((elm)->field.cqe_prev); \
|
_Q_INVALIDATE((elm)->field.cqe_prev); \
|
||||||
|
Loading…
Reference in New Issue
Block a user