71 | 71 |
|
72 | 72 |
/*
|
73 | 73 |
* Returns the first output that is assigned to a workspace specified by the
|
74 | |
* given name or number or NULL if no such output exists. If there is a
|
75 | |
* workspace with a matching name and another workspace with a matching number,
|
76 | |
* the output assigned to the first one is returned.
|
77 | |
* The order of the 'ws_assignments' queue is respected: if multiple assignments
|
78 | |
* match the specified workspace, the first one is returned.
|
79 | |
* If 'name' is NULL it will be ignored.
|
80 | |
* If 'parsed_num' is -1 it will be ignored.
|
81 | |
*
|
82 | |
*/
|
83 | |
static Con *get_assigned_output(const char *name, long parsed_num) {
|
|
74 |
* given name or number. Returns NULL if no such output exists.
|
|
75 |
*
|
|
76 |
* If an assignment matches by number but there is an assignment later that
|
|
77 |
* matches by name, the second one is preferred.
|
|
78 |
* The order of the 'ws_assignments' queue is respected: if multiple
|
|
79 |
* assignments match the criteria, the first one is returned.
|
|
80 |
* 'name' is ignored when NULL, 'parsed_num' is ignored when it is -1.
|
|
81 |
*
|
|
82 |
*/
|
|
83 |
Con *get_assigned_output(const char *name, long parsed_num) {
|
84 | 84 |
Con *output = NULL;
|
85 | 85 |
struct Workspace_Assignment *assignment;
|
86 | 86 |
TAILQ_FOREACH (assignment, &ws_assignments, ws_assignments) {
|
87 | 87 |
if (name && strcmp(assignment->name, name) == 0) {
|
88 | |
DLOG("Found workspace name assignment to output \"%s\"\n", assignment->output);
|
|
88 |
DLOG("Found workspace name=\"%s\" assignment to output \"%s\"\n",
|
|
89 |
name, assignment->output);
|
89 | 90 |
Output *assigned_by_name = get_output_by_name(assignment->output, true);
|
90 | 91 |
if (assigned_by_name) {
|
91 | 92 |
/* When the name matches exactly, skip numbered assignments. */
|
|
95 | 96 |
parsed_num != -1 &&
|
96 | 97 |
name_is_digits(assignment->name) &&
|
97 | 98 |
ws_name_to_number(assignment->name) == parsed_num) {
|
98 | |
DLOG("Found workspace number assignment to output \"%s\"\n", assignment->output);
|
|
99 |
DLOG("Found workspace number=%ld assignment to output \"%s\"\n",
|
|
100 |
parsed_num, assignment->output);
|
99 | 101 |
Output *assigned_by_num = get_output_by_name(assignment->output, true);
|
100 | 102 |
if (assigned_by_num) {
|
101 | 103 |
output = assigned_by_num->con;
|