Implement assignments for (named) workspaces, with '~' compatibility (floating)

This commit is contained in:
Michael Stapelberg
2011-05-23 18:41:17 +02:00
parent 272a86745e
commit 2c68c234ea
10 changed files with 123 additions and 89 deletions

View File

@ -45,6 +45,25 @@ bool match_is_empty(Match *match) {
match->floating == M_ANY);
}
/*
* Copies the data of a match from src to dest.
*
*/
void match_copy(Match *dest, Match *src) {
memcpy(dest, src, sizeof(Match));
#define STRDUP(field) do { \
if (src->field != NULL) \
dest->field = sstrdup(src->field); \
} while (0)
STRDUP(title);
STRDUP(mark);
STRDUP(application);
STRDUP(class);
STRDUP(instance);
}
/*
* Check if a match data structure matches the given window.
*
@ -87,20 +106,3 @@ bool match_matches_window(Match *match, i3Window *window) {
return false;
}
/*
* Returns the first match in 'assignments' that matches the given window.
*
*/
Match *match_by_assignment(i3Window *window) {
Match *match;
TAILQ_FOREACH(match, &assignments, assignments) {
if (!match_matches_window(match, window))
continue;
DLOG("got a matching assignment (to %s)\n", match->target_ws);
return match;
}
return NULL;
}