allow ppt values in move direction and move position commands
make ppt values clear in userguide chore: move is_ppt and DLOG out of TAILQ_FOREACH loop
This commit is contained in:
@ -1490,34 +1490,37 @@ void cmd_sticky(I3_CMD, const char *action) {
|
||||
}
|
||||
|
||||
/*
|
||||
* Implementation of 'move <direction> [<pixels> [px]]'.
|
||||
* Implementation of 'move <direction> [<amount> [px|ppt]]'.
|
||||
*
|
||||
*/
|
||||
void cmd_move_direction(I3_CMD, const char *direction_str, long move_px) {
|
||||
void cmd_move_direction(I3_CMD, const char *direction_str, long amount, const char *mode) {
|
||||
owindow *current;
|
||||
HANDLE_EMPTY_MATCH;
|
||||
|
||||
Con *initially_focused = focused;
|
||||
direction_t direction = parse_direction(direction_str);
|
||||
|
||||
const bool is_ppt = mode && strcmp(mode, "ppt") == 0;
|
||||
|
||||
DLOG("moving in direction %s, %ld %s\n", direction_str, amount, mode);
|
||||
TAILQ_FOREACH (current, &owindows, owindows) {
|
||||
DLOG("moving in direction %s, px %ld\n", direction_str, move_px);
|
||||
if (con_is_floating(current->con)) {
|
||||
DLOG("floating move with %ld pixels\n", move_px);
|
||||
DLOG("floating move with %ld %s\n", amount, mode);
|
||||
Rect newrect = current->con->parent->rect;
|
||||
Con *output = con_get_output(current->con);
|
||||
|
||||
switch (direction) {
|
||||
case D_LEFT:
|
||||
newrect.x -= move_px;
|
||||
newrect.x -= is_ppt ? output->rect.width * ((double)amount / 100.0) : amount;
|
||||
break;
|
||||
case D_RIGHT:
|
||||
newrect.x += move_px;
|
||||
newrect.x += is_ppt ? output->rect.width * ((double)amount / 100.0) : amount;
|
||||
break;
|
||||
case D_UP:
|
||||
newrect.y -= move_px;
|
||||
newrect.y -= is_ppt ? output->rect.height * ((double)amount / 100.0) : amount;
|
||||
break;
|
||||
case D_DOWN:
|
||||
newrect.y += move_px;
|
||||
newrect.y += is_ppt ? output->rect.height * ((double)amount / 100.0) : amount;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1721,10 +1724,10 @@ void cmd_focus_output(I3_CMD, const char *name) {
|
||||
}
|
||||
|
||||
/*
|
||||
* Implementation of 'move [window|container] [to] [absolute] position <px> [px] <px> [px]
|
||||
* Implementation of 'move [window|container] [to] [absolute] position [<pos_x> [px|ppt] <pos_y> [px|ppt]]
|
||||
*
|
||||
*/
|
||||
void cmd_move_window_to_position(I3_CMD, long x, long y) {
|
||||
void cmd_move_window_to_position(I3_CMD, long x, const char *mode_x, long y, const char *mode_y) {
|
||||
bool has_error = false;
|
||||
|
||||
owindow *current;
|
||||
@ -1743,10 +1746,11 @@ void cmd_move_window_to_position(I3_CMD, long x, long y) {
|
||||
}
|
||||
|
||||
Rect newrect = current->con->parent->rect;
|
||||
Con *output = con_get_output(current->con);
|
||||
|
||||
DLOG("moving to position %ld %ld\n", x, y);
|
||||
newrect.x = x;
|
||||
newrect.y = y;
|
||||
newrect.x = mode_x && strcmp(mode_x, "ppt") == 0 ? output->rect.width * ((double)x / 100.0) : x;
|
||||
newrect.y = mode_y && strcmp(mode_y, "ppt") == 0 ? output->rect.height * ((double)y / 100.0) : y;
|
||||
DLOG("moving to position %d %s %d %s\n", newrect.x, mode_x, newrect.y, mode_y);
|
||||
|
||||
if (!floating_reposition(current->con->parent, newrect)) {
|
||||
yerror("Cannot move window/container out of bounds.");
|
||||
|
Reference in New Issue
Block a user