Merge pull request #3768 from orestisfl/get_first_output

get_first_output changes
next
Ingo Bürk 2019-08-15 17:23:41 +02:00 committed by GitHub
commit ac9e55caa5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 8 deletions

View File

@ -813,12 +813,13 @@ int main(int argc, char *argv[]) {
if (!output) {
ELOG("ERROR: No screen at (%d, %d), starting on the first screen\n",
pointerreply->root_x, pointerreply->root_y);
output = get_first_output();
}
con_activate(con_descend_focused(output_get_content(output->con)));
free(pointerreply);
}
if (!output) {
output = get_first_output();
}
con_activate(con_descend_focused(output_get_content(output->con)));
free(pointerreply);
tree_render();

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");
}