From: Michael Stapelberg Date: Fri, 19 Jun 2009 10:57:21 +0000 (+0200) Subject: Implement moving of floating clients X-Git-Tag: 3.b~48 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=4135aaad7cefc6b5c29f04881a368c81f9c65013;p=i3%2Fi3 Implement moving of floating clients --- diff --git a/include/floating.h b/include/floating.h index 93110bc2..020e91ff 100644 --- a/include/floating.h +++ b/include/floating.h @@ -46,4 +46,10 @@ void floating_drag_window(xcb_connection_t *conn, Client *client, xcb_button_pre */ void floating_focus_direction(xcb_connection_t *conn, Client *currently_focused, direction_t direction); +/** + * Moves the client 10px to the specified direction. + * + */ +void floating_move(xcb_connection_t *conn, Client *currently_focused, direction_t direction); + #endif diff --git a/src/commands.c b/src/commands.c index 10ac35f8..3300d1f8 100644 --- a/src/commands.c +++ b/src/commands.c @@ -928,7 +928,8 @@ void parse_command(xcb_connection_t *conn, const char *command) { return; } - if (last_focused->floating >= FLOATING_AUTO_ON && action != ACTION_FOCUS) { + if (last_focused->floating >= FLOATING_AUTO_ON && + (action != ACTION_FOCUS && action != ACTION_MOVE)) { LOG("Not performing (floating)\n"); return; } @@ -947,20 +948,32 @@ void parse_command(xcb_connection_t *conn, const char *command) { LOG("unknown direction: %c\n", *rest); return; } + rest++; if (action == ACTION_FOCUS) { - if (last_focused->floating >= FLOATING_AUTO_ON) + if (last_focused->floating >= FLOATING_AUTO_ON) { floating_focus_direction(conn, last_focused, direction); - else focus_thing(conn, direction, (with == WITH_WINDOW ? THING_WINDOW : THING_CONTAINER)); - } else if (action == ACTION_MOVE) { + continue; + } + focus_thing(conn, direction, (with == WITH_WINDOW ? THING_WINDOW : THING_CONTAINER)); + continue; + } + + if (action == ACTION_MOVE) { + if (last_focused->floating >= FLOATING_AUTO_ON) { + floating_move(conn, last_focused, direction); + continue; + } if (with == WITH_WINDOW) move_current_window(conn, direction); else move_current_container(conn, direction); + continue; } - else if (action == ACTION_SNAP) - snap_current_container(conn, direction); - rest++; + if (action == ACTION_SNAP) { + snap_current_container(conn, direction); + continue; + } } LOG("--- done ---\n"); diff --git a/src/floating.c b/src/floating.c index 7cf4b6dc..fb5c9511 100644 --- a/src/floating.c +++ b/src/floating.c @@ -318,3 +318,40 @@ void floating_focus_direction(xcb_connection_t *conn, Client *currently_focused, } } } + +/* + * Moves the client 10px to the specified direction. + * + */ +void floating_move(xcb_connection_t *conn, Client *currently_focused, direction_t direction) { + LOG("floating move\n"); + + switch (direction) { + case D_LEFT: + if (currently_focused->rect.x < 10) + return; + currently_focused->rect.x -= 10; + break; + case D_RIGHT: + currently_focused->rect.x += 10; + break; + case D_UP: + if (currently_focused->rect.y < 10) + return; + currently_focused->rect.y -= 10; + break; + case D_DOWN: + currently_focused->rect.y += 10; + break; + /* to make static analyzers happy */ + default: + break; + } + + reposition_client(conn, currently_focused); + + /* Because reposition_client does not send a faked configure event (only resize does), + * we need to initiate that on our own */ + fake_absolute_configure_notify(conn, currently_focused); + /* fake_absolute_configure_notify flushes */ +}