switch (direction) {
case D_UP:
- if (current->rect.y < output->rect.y && (!candidate || output->rect.y < candidate->rect.y))
+ if (output->rect.y < current->rect.y &&
+ (!candidate || output->rect.y < candidate->rect.y))
candidate = output;
break;
case D_DOWN:
- if (current->rect.y > output->rect.y && (!candidate || output->rect.y > candidate->rect.y))
+ if (output->rect.y > current->rect.y &&
+ (!candidate || output->rect.y > candidate->rect.y))
candidate = output;
break;
case D_LEFT:
- if (current->rect.x > output->rect.x && (!candidate || output->rect.x > candidate->rect.x))
+ if (output->rect.x < current->rect.x &&
+ (!candidate || output->rect.x > candidate->rect.x))
candidate = output;
break;
case D_RIGHT:
- if (current->rect.x < output->rect.x && (!candidate || output->rect.x < candidate->rect.x))
+ if (output->rect.x > current->rect.x &&
+ (!candidate || output->rect.x < candidate->rect.x))
candidate = output;
break;
}
continue;
DLOG("relevant command = %s\n", bind->command);
char *target = bind->command + strlen("workspace ");
+ /* We check if this is the workspace next/prev command. Beware: The
+ * workspace names "next" and "prev" are OK, so we check before
+ * stripping the double quotes */
+ if (strncasecmp(target, "next", strlen("next")) == 0 ||
+ strncasecmp(target, "prev", strlen("prev")) == 0)
+ continue;
if (*target == '"')
target++;
FREE(ws->name);
if (!exists) {
/* Set ->num to the number of the workspace, if the name actually
* is a number or starts with a number */
- long parsed_num = strtol(ws->name, NULL, 10);
+ char *endptr = NULL;
+ long parsed_num = strtol(ws->name, &endptr, 10);
if (parsed_num == LONG_MIN ||
parsed_num == LONG_MAX ||
- parsed_num <= 0)
+ parsed_num < 0 ||
+ endptr == ws->name)
ws->num = -1;
else ws->num = parsed_num;
LOG("Used number %d for workspace with name %s\n", ws->num, ws->name);