get_first_output: prefer primary output

Used in two cases:
- When the pointer location can't be found but some initial container
needs to be focused
- When moving disabled outputs
This commit is contained in:
Orestis Floros 2019-08-13 16:44:45 +03:00
parent 0845d7b264
commit fd7e51927d
No known key found for this signature in database
GPG Key ID: A09DBD7D3222C1C3
1 changed files with 15 additions and 4 deletions

View File

@ -70,11 +70,22 @@ Output *get_output_by_name(const char *name, const bool require_active) {
*
*/
Output *get_first_output(void) {
Output *output;
Output *output, *result = NULL;
TAILQ_FOREACH(output, &outputs, outputs)
if (output->active)
return output;
TAILQ_FOREACH(output, &outputs, outputs) {
if (output->active) {
if (output->primary) {
return output;
}
if (!result) {
result = output;
}
}
}
if (result) {
return result;
}
die("No usable outputs available.\n");
}