-#undef I3__FILE__
-#define I3__FILE__ "fake_outputs.c"
/*
* vim:ts=4:sw=4:expandtab
*
* i3 - an improved dynamic tiling window manager
- * © 2009-2012 Michael Stapelberg and contributors (see also: LICENSE)
+ * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
*
* Faking outputs is useful in pathological situations (like network X servers
* which don’t support multi-monitor in a useful way) and for our testsuite.
*
*/
void fake_outputs_init(const char *output_spec) {
- char useless_buffer[1024];
const char *walk = output_spec;
unsigned int x, y, width, height;
- while (sscanf(walk, "%ux%u+%u+%u", &width, &height, &x, &y) == 4) {
+ int chars_consumed;
+ while (sscanf(walk, "%ux%u+%u+%u%n", &width, &height, &x, &y, &chars_consumed) == 4) {
DLOG("Parsed output as width = %u, height = %u at (%u, %u)\n",
width, height, x, y);
Output *new_output = get_screen_at(x, y);
new_output->rect.width = min(new_output->rect.width, width);
new_output->rect.height = min(new_output->rect.height, height);
} else {
- new_output = scalloc(sizeof(Output));
- sasprintf(&(new_output->name), "fake-%d", num_screens);
- DLOG("Created new fake output %s (%p)\n", new_output->name, new_output);
+ struct output_name *output_name = scalloc(1, sizeof(struct output_name));
+ new_output = scalloc(1, sizeof(Output));
+ 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);
new_output->active = true;
new_output->rect.x = x;
new_output->rect.y = y;
num_screens++;
}
- /* Figure out how long the input was to skip it */
- walk += sprintf(useless_buffer, "%ux%u+%u+%u", width, height, x, y) + 1;
+ walk += chars_consumed + 1;
}
if (num_screens == 0) {