Bugfix: consider inactive monitors when querying (#2862)
fixes #2815 fixes #2594
This commit is contained in:
parent
e6682f862b
commit
4d93d26484
|
@ -75,10 +75,11 @@ void randr_disable_output(Output *output);
|
||||||
Output *get_first_output(void);
|
Output *get_first_output(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the output with the given name if it is active (!) or NULL.
|
* Returns the output with the given name or NULL.
|
||||||
|
* If require_active is true, only active outputs are considered.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Output *get_output_by_name(const char *name);
|
Output *get_output_by_name(const char *name, const bool require_active);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the active (!) output which contains the coordinates x, y or NULL
|
* Returns the active (!) output which contains the coordinates x, y or NULL
|
||||||
|
|
|
@ -41,7 +41,7 @@ Output *get_output_from_string(Output *current_output, const char *output_str) {
|
||||||
return get_output_next_wrap(D_DOWN, current_output);
|
return get_output_next_wrap(D_DOWN, current_output);
|
||||||
}
|
}
|
||||||
|
|
||||||
return get_output_by_name(output_str);
|
return get_output_by_name(output_str, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Output *get_output_for_con(Con *con) {
|
Output *get_output_for_con(Con *con) {
|
||||||
|
@ -51,7 +51,7 @@ Output *get_output_for_con(Con *con) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Output *output = get_output_by_name(output_con->name);
|
Output *output = get_output_by_name(output_con->name, true);
|
||||||
if (output == NULL) {
|
if (output == NULL) {
|
||||||
ELOG("Could not get output from name \"%s\".\n", output_con->name);
|
ELOG("Could not get output from name \"%s\".\n", output_con->name);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
11
src/randr.c
11
src/randr.c
|
@ -40,15 +40,16 @@ static Output *get_output_by_id(xcb_randr_output_t id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns the output with the given name if it is active (!) or NULL.
|
* Returns the output with the given name or NULL.
|
||||||
|
* If require_active is true, only active outputs are considered.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Output *get_output_by_name(const char *name) {
|
Output *get_output_by_name(const char *name, const bool require_active) {
|
||||||
Output *output;
|
Output *output;
|
||||||
bool get_primary = (strcasecmp("primary", name) == 0);
|
bool get_primary = (strcasecmp("primary", name) == 0);
|
||||||
TAILQ_FOREACH(output, &outputs, outputs) {
|
TAILQ_FOREACH(output, &outputs, outputs) {
|
||||||
if ((output->primary && get_primary) ||
|
if ((output->primary && get_primary) ||
|
||||||
(output->active && strcasecmp(output->name, name) == 0)) {
|
((!require_active || output->active) && strcasecmp(output->name, name) == 0)) {
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -442,7 +443,7 @@ void init_ws_for_output(Output *output, Con *content) {
|
||||||
if (visible && previous == NULL) {
|
if (visible && previous == NULL) {
|
||||||
LOG("There is no workspace left on \"%s\", re-initializing\n",
|
LOG("There is no workspace left on \"%s\", re-initializing\n",
|
||||||
workspace_out->name);
|
workspace_out->name);
|
||||||
init_ws_for_output(get_output_by_name(workspace_out->name),
|
init_ws_for_output(get_output_by_name(workspace_out->name, true),
|
||||||
output_get_content(workspace_out));
|
output_get_content(workspace_out));
|
||||||
DLOG("Done re-initializing, continuing with \"%s\"\n", output->name);
|
DLOG("Done re-initializing, continuing with \"%s\"\n", output->name);
|
||||||
}
|
}
|
||||||
|
@ -590,7 +591,7 @@ static bool randr_query_outputs_15(void) {
|
||||||
xcb_get_atom_name_name(atom_reply));
|
xcb_get_atom_name_name(atom_reply));
|
||||||
free(atom_reply);
|
free(atom_reply);
|
||||||
|
|
||||||
Output *new = get_output_by_name(name);
|
Output *new = get_output_by_name(name, false);
|
||||||
if (new == NULL) {
|
if (new == NULL) {
|
||||||
new = scalloc(1, sizeof(Output));
|
new = scalloc(1, sizeof(Output));
|
||||||
new->name = sstrdup(name);
|
new->name = sstrdup(name);
|
||||||
|
|
Loading…
Reference in New Issue