Store output names as a linked list
Currently, only one name is ever added, and only the first name is ever accessed; actually using the capability to store and access multiple names comes in the following commits.
This commit is contained in:
parent
1b419431cd
commit
6c0e715877
|
@ -349,6 +349,13 @@ struct Autostart {
|
||||||
autostarts_always;
|
autostarts_always;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct output_name {
|
||||||
|
char *name;
|
||||||
|
|
||||||
|
SLIST_ENTRY(output_name)
|
||||||
|
names;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An Output is a physical output on your graphics driver. Outputs which
|
* An Output is a physical output on your graphics driver. Outputs which
|
||||||
* are currently in use have (output->active == true). Each output has a
|
* are currently in use have (output->active == true). Each output has a
|
||||||
|
@ -370,8 +377,11 @@ struct xoutput {
|
||||||
bool to_be_disabled;
|
bool to_be_disabled;
|
||||||
bool primary;
|
bool primary;
|
||||||
|
|
||||||
/** Name of the output */
|
/** List of names for the output.
|
||||||
char *name;
|
* An output always has at least one name; the first name is
|
||||||
|
* considered the primary one. */
|
||||||
|
SLIST_HEAD(names_head, output_name)
|
||||||
|
names_head;
|
||||||
|
|
||||||
/** Pointer to the Con which represents this output */
|
/** Pointer to the Con which represents this output */
|
||||||
Con *con;
|
Con *con;
|
||||||
|
|
|
@ -47,8 +47,11 @@ void fake_outputs_init(const char *output_spec) {
|
||||||
new_output->rect.width = min(new_output->rect.width, width);
|
new_output->rect.width = min(new_output->rect.width, width);
|
||||||
new_output->rect.height = min(new_output->rect.height, height);
|
new_output->rect.height = min(new_output->rect.height, height);
|
||||||
} else {
|
} else {
|
||||||
|
struct output_name *output_name = scalloc(1, sizeof(struct output_name));
|
||||||
new_output = scalloc(1, sizeof(Output));
|
new_output = scalloc(1, sizeof(Output));
|
||||||
sasprintf(&(new_output->name), "fake-%d", num_screens);
|
sasprintf(&(output_name->name), "fake-%d", num_screens);
|
||||||
|
SLIST_INIT(&(new_output->names_head));
|
||||||
|
SLIST_INSERT_HEAD(&(new_output->names_head), output_name, names);
|
||||||
DLOG("Created new fake output %s (%p)\n", output_primary_name(new_output), new_output);
|
DLOG("Created new fake output %s (%p)\n", output_primary_name(new_output), new_output);
|
||||||
new_output->active = true;
|
new_output->active = true;
|
||||||
new_output->rect.x = x;
|
new_output->rect.x = x;
|
||||||
|
|
|
@ -49,7 +49,7 @@ Output *get_output_from_string(Output *current_output, const char *output_str) {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
char *output_primary_name(Output *output) {
|
char *output_primary_name(Output *output) {
|
||||||
return output->name;
|
return SLIST_FIRST(&output->names_head)->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
Output *get_output_for_con(Con *con) {
|
Output *get_output_for_con(Con *con) {
|
||||||
|
|
28
src/randr.c
28
src/randr.c
|
@ -266,7 +266,11 @@ Output *create_root_output(xcb_connection_t *conn) {
|
||||||
s->rect.y = 0;
|
s->rect.y = 0;
|
||||||
s->rect.width = root_screen->width_in_pixels;
|
s->rect.width = root_screen->width_in_pixels;
|
||||||
s->rect.height = root_screen->height_in_pixels;
|
s->rect.height = root_screen->height_in_pixels;
|
||||||
s->name = "xroot-0";
|
|
||||||
|
struct output_name *output_name = scalloc(1, sizeof(struct output_name));
|
||||||
|
output_name->name = "xroot-0";
|
||||||
|
SLIST_INIT(&s->names_head);
|
||||||
|
SLIST_INSERT_HEAD(&s->names_head, output_name, names);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
@ -594,7 +598,12 @@ static bool randr_query_outputs_15(void) {
|
||||||
Output *new = get_output_by_name(name, false);
|
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);
|
|
||||||
|
struct output_name *output_name = scalloc(1, sizeof(struct output_name));
|
||||||
|
output_name->name = sstrdup(name);
|
||||||
|
SLIST_INIT(&new->names_head);
|
||||||
|
SLIST_INSERT_HEAD(&new->names_head, output_name, names);
|
||||||
|
|
||||||
if (monitor_info->primary) {
|
if (monitor_info->primary) {
|
||||||
TAILQ_INSERT_HEAD(&outputs, new, outputs);
|
TAILQ_INSERT_HEAD(&outputs, new, outputs);
|
||||||
} else {
|
} else {
|
||||||
|
@ -643,14 +652,23 @@ static void handle_output(xcb_connection_t *conn, xcb_randr_output_t id,
|
||||||
|
|
||||||
Output *new = get_output_by_id(id);
|
Output *new = get_output_by_id(id);
|
||||||
bool existing = (new != NULL);
|
bool existing = (new != NULL);
|
||||||
if (!existing)
|
if (!existing) {
|
||||||
new = scalloc(1, sizeof(Output));
|
new = scalloc(1, sizeof(Output));
|
||||||
|
SLIST_INIT(&new->names_head);
|
||||||
|
}
|
||||||
new->id = id;
|
new->id = id;
|
||||||
new->primary = (primary && primary->output == id);
|
new->primary = (primary && primary->output == id);
|
||||||
FREE(new->name);
|
while (!SLIST_EMPTY(&new->names_head)) {
|
||||||
sasprintf(&new->name, "%.*s",
|
FREE(SLIST_FIRST(&new->names_head)->name);
|
||||||
|
struct output_name *old_head = SLIST_FIRST(&new->names_head);
|
||||||
|
SLIST_REMOVE_HEAD(&new->names_head, names);
|
||||||
|
FREE(old_head);
|
||||||
|
}
|
||||||
|
struct output_name *output_name = scalloc(1, sizeof(struct output_name));
|
||||||
|
sasprintf(&output_name->name, "%.*s",
|
||||||
xcb_randr_get_output_info_name_length(output),
|
xcb_randr_get_output_info_name_length(output),
|
||||||
xcb_randr_get_output_info_name(output));
|
xcb_randr_get_output_info_name(output));
|
||||||
|
SLIST_INSERT_HEAD(&new->names_head, output_name, names);
|
||||||
|
|
||||||
DLOG("found output with name %s\n", output_primary_name(new));
|
DLOG("found output with name %s\n", output_primary_name(new));
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,10 @@ static void query_screens(xcb_connection_t *conn) {
|
||||||
s->rect.height = min(s->rect.height, screen_info[screen].height);
|
s->rect.height = min(s->rect.height, screen_info[screen].height);
|
||||||
} else {
|
} else {
|
||||||
s = scalloc(1, sizeof(Output));
|
s = scalloc(1, sizeof(Output));
|
||||||
sasprintf(&(s->name), "xinerama-%d", num_screens);
|
struct output_name *output_name = scalloc(1, sizeof(struct output_name));
|
||||||
|
sasprintf(&output_name->name, "xinerama-%d", num_screens);
|
||||||
|
SLIST_INIT(&s->names_head);
|
||||||
|
SLIST_INSERT_HEAD(&s->names_head, output_name, names);
|
||||||
DLOG("Created new Xinerama screen %s (%p)\n", output_primary_name(s), s);
|
DLOG("Created new Xinerama screen %s (%p)\n", output_primary_name(s), s);
|
||||||
s->active = true;
|
s->active = true;
|
||||||
s->rect.x = screen_info[screen].x_org;
|
s->rect.x = screen_info[screen].x_org;
|
||||||
|
|
Loading…
Reference in New Issue