Implement moving of floating clients

This commit is contained in:
Michael Stapelberg 2009-06-19 12:57:21 +02:00
parent 51402b05f5
commit 4135aaad7c
3 changed files with 63 additions and 7 deletions

View File

@ -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

View File

@ -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");

View File

@ -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 */
}