static Output *get_output_from_string(Output *current_output, const char *output_str) {
Output *output;
- if (strcasecmp(output_str, "left") == 0) {
- output = get_output_next(D_LEFT, current_output, CLOSEST_OUTPUT);
- if (!output)
- output = get_output_most(D_RIGHT, current_output);
- } else if (strcasecmp(output_str, "right") == 0) {
- output = get_output_next(D_RIGHT, current_output, CLOSEST_OUTPUT);
- if (!output)
- output = get_output_most(D_LEFT, current_output);
- } else if (strcasecmp(output_str, "up") == 0) {
- output = get_output_next(D_UP, current_output, CLOSEST_OUTPUT);
- if (!output)
- output = get_output_most(D_DOWN, current_output);
- } else if (strcasecmp(output_str, "down") == 0) {
- output = get_output_next(D_DOWN, current_output, CLOSEST_OUTPUT);
- if (!output)
- output = get_output_most(D_UP, current_output);
- } else output = get_output_by_name(output_str);
+ if (strcasecmp(output_str, "left") == 0)
+ output = get_output_next_wrap(D_LEFT, current_output);
+ else if (strcasecmp(output_str, "right") == 0)
+ output = get_output_next_wrap(D_RIGHT, current_output);
+ else if (strcasecmp(output_str, "up") == 0)
+ output = get_output_next_wrap(D_UP, current_output);
+ else if (strcasecmp(output_str, "down") == 0)
+ output = get_output_next_wrap(D_DOWN, current_output);
+ else output = get_output_by_name(output_str);
return output;
}
}
static void cmd_resize_floating(I3_CMD, char *way, char *direction, Con *floating_con, int px) {
-
LOG("floating resize\n");
+ Rect old_rect = floating_con->rect;
+
if (strcmp(direction, "up") == 0) {
- floating_con->rect.y -= px;
floating_con->rect.height += px;
} else if (strcmp(direction, "down") == 0 || strcmp(direction, "height") == 0) {
floating_con->rect.height += px;
} else if (strcmp(direction, "left") == 0) {
- floating_con->rect.x -= px;
floating_con->rect.width += px;
} else {
floating_con->rect.width += px;
}
- floating_checkSize(floating_con);
+ floating_check_size(floating_con);
+
+ /* Did we actually resize anything or did the size constraints prevent us?
+ * If we could not resize, exit now to not move the window. */
+ if (memcmp(&old_rect, &(floating_con->rect), sizeof(Rect)) == 0)
+ return;
+
+ if (strcmp(direction, "up") == 0) {
+ floating_con->rect.y -= (floating_con->rect.height - old_rect.height);
+ } else if (strcmp(direction, "left") == 0) {
+ floating_con->rect.x -= (floating_con->rect.width - old_rect.width);
+ }
+
+ /* If this is a scratchpad window, don't auto center it from now on. */
+ if (floating_con->scratchpad_state == SCRATCHPAD_FRESH)
+ floating_con->scratchpad_state = SCRATCHPAD_CHANGED;
}
static bool cmd_resize_tiling_direction(I3_CMD, Con *current, char *way, char *direction, int ppt) {
// TODO: clean this up with commands.spec as soon as we switched away from the lex/yacc command parser
if (strcasecmp(name, "up") == 0)
- output = get_output_next(D_UP, current_output, CLOSEST_OUTPUT);
+ output = get_output_next_wrap(D_UP, current_output);
else if (strcasecmp(name, "down") == 0)
- output = get_output_next(D_DOWN, current_output, CLOSEST_OUTPUT);
+ output = get_output_next_wrap(D_DOWN, current_output);
else if (strcasecmp(name, "left") == 0)
- output = get_output_next(D_LEFT, current_output, CLOSEST_OUTPUT);
+ output = get_output_next_wrap(D_LEFT, current_output);
else if (strcasecmp(name, "right") == 0)
- output = get_output_next(D_RIGHT, current_output, CLOSEST_OUTPUT);
+ output = get_output_next_wrap(D_RIGHT, current_output);
else
output = get_output_by_name(name);
return;
}
+ Con *__i3_scratch = workspace_get("__i3_scratch", NULL);
int count = 0;
owindow *current;
TAILQ_FOREACH(current, &owindows, owindows) {
return;
}
+ /* In case this is a scratchpad window, call scratchpad_show(). */
+ if (ws == __i3_scratch) {
+ scratchpad_show(current->con);
+ count++;
+ /* While for the normal focus case we can change focus multiple
+ * times and only a single window ends up focused, we could show
+ * multiple scratchpad windows. So, rather break here. */
+ break;
+ }
+
/* If the container is not on the current workspace,
* workspace_show() will switch to a different workspace and (if
* enabled) trigger a mouse pointer warp to the currently focused
*/
void cmd_reload(I3_CMD) {
LOG("reloading\n");
- kill_configerror_nagbar(false);
- kill_commanderror_nagbar(false);
+ kill_nagbar(&config_error_nagbar_pid, false);
+ kill_nagbar(&command_error_nagbar_pid, false);
load_configuration(conn, NULL, true);
x_set_i3_atoms();
/* Send an IPC event just in case the ws names have changed */