- * Parses the preferred_screen property of a workspace. You can either specify
- * the screen number (it is not given that the screen numbering always stays
- * the same) or the screen coordinates (exact coordinates, e.g. 1280 will match
- * the screen starting at x=1280, but 1281 will not). For coordinates, you can
- * either specify an x coordinate ("1280") or an y coordinate ("x800") or both
- * ("1280x800").
- *
- */
-static i3Screen *get_screen_from_preference(struct screens_head *slist, char *preference) {
- i3Screen *screen;
- char *rest;
- int preferred_screen = strtol(preference, &rest, 10);
-
- DLOG("Getting screen for preference \"%s\" (%d)\n", preference, preferred_screen);
-
- if ((rest == preference) || (preferred_screen >= num_screens)) {
- int x = INT_MAX, y = INT_MAX;
- if (strchr(preference, 'x') != NULL) {
- /* Check if only the y coordinate was specified */
- if (*preference == 'x')
- y = atoi(preference+1);
- else {
- x = atoi(preference);
- y = atoi(strchr(preference, 'x') + 1);
- }
- } else {
- x = atoi(preference);
- }
-
- DLOG("Looking for screen at %d x %d\n", x, y);
-
- TAILQ_FOREACH(screen, slist, screens)
- if ((x == INT_MAX || screen->rect.x == x) &&
- (y == INT_MAX || screen->rect.y == y)) {
- DLOG("found %p\n", screen);
- return screen;
- }
-
- DLOG("none found\n");
- return NULL;
- } else {
- int c = 0;
- TAILQ_FOREACH(screen, slist, screens)
- if (c++ == preferred_screen)
- return screen;
- }
-
- return NULL;
-}
-
-/*
- * Assigns the given workspace to the given screen by correctly updating its