Support "resize set W H"

This commit is contained in:
rr-
2015-09-05 08:31:45 +02:00
parent ee2983c791
commit 23d16e1332
8 changed files with 178 additions and 1 deletions

View File

@ -823,6 +823,37 @@ void cmd_resize(I3_CMD, char *way, char *direction, char *resize_px, char *resiz
ysuccess(true);
}
/*
* Implementation of 'resize set <px> [px] <px> [px]'.
*
*/
void cmd_size(I3_CMD, char *cwidth, char *cheight) {
DLOG("resizing to %sx%s px\n", cwidth, cheight);
// TODO: We could either handle this in the parser itself as a separate token (and make the stack typed) or we need a better way to convert a string to a number with error checking
int x = atoi(cwidth);
int y = atoi(cheight);
if (x <= 0 || y <= 0) {
ELOG("Resize failed: dimensions cannot be negative (was %sx%s)\n", cwidth, cheight);
return;
}
HANDLE_EMPTY_MATCH;
owindow *current;
TAILQ_FOREACH(current, &owindows, owindows) {
Con *floating_con;
if ((floating_con = con_inside_floating(current->con))) {
floating_resize(floating_con, x, y);
} else {
ELOG("Resize failed: %p not a floating container\n", current->con);
}
}
cmd_output->needs_tree_render = true;
// XXX: default reply for now, make this a better reply
ysuccess(true);
}
/*
* Implementation of 'border normal|pixel [<n>]', 'border none|1pixel|toggle'.
*