fake_outputs: Allow designating a fake output as primary
Allow appending 'P' to the fake output specification to set the created output's "primary" flag, to allow writing test cases that depend on the presence of a primary output.
This commit is contained in:
parent
c932c88ea9
commit
e4bfb4dae3
|
@ -28,8 +28,9 @@ static Output *get_screen_at(unsigned int x, unsigned int y) {
|
||||||
/*
|
/*
|
||||||
* Creates outputs according to the given specification.
|
* Creates outputs according to the given specification.
|
||||||
* The specification must be in the format wxh+x+y, for example 1024x768+0+0,
|
* The specification must be in the format wxh+x+y, for example 1024x768+0+0,
|
||||||
|
* optionally followed by 'P' to indicate a primary output,
|
||||||
* with multiple outputs separated by commas:
|
* with multiple outputs separated by commas:
|
||||||
* 1900x1200+0+0,1280x1024+1900+0
|
* 1900x1200+0+0P,1280x1024+1900+0
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void fake_outputs_init(const char *output_spec) {
|
void fake_outputs_init(const char *output_spec) {
|
||||||
|
@ -37,8 +38,17 @@ void fake_outputs_init(const char *output_spec) {
|
||||||
unsigned int x, y, width, height;
|
unsigned int x, y, width, height;
|
||||||
int chars_consumed;
|
int chars_consumed;
|
||||||
while (sscanf(walk, "%ux%u+%u+%u%n", &width, &height, &x, &y, &chars_consumed) == 4) {
|
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",
|
walk += chars_consumed;
|
||||||
width, height, x, y);
|
bool primary = false;
|
||||||
|
if (*walk == 'P') {
|
||||||
|
primary = true;
|
||||||
|
walk++;
|
||||||
|
}
|
||||||
|
if (*walk == ',')
|
||||||
|
walk++; /* Skip delimiter */
|
||||||
|
DLOG("Parsed output as width = %u, height = %u at (%u, %u)%s\n",
|
||||||
|
width, height, x, y, primary ? " (primary)" : "");
|
||||||
|
|
||||||
Output *new_output = get_screen_at(x, y);
|
Output *new_output = get_screen_at(x, y);
|
||||||
if (new_output != NULL) {
|
if (new_output != NULL) {
|
||||||
DLOG("Re-used old output %p\n", new_output);
|
DLOG("Re-used old output %p\n", new_output);
|
||||||
|
@ -67,10 +77,7 @@ void fake_outputs_init(const char *output_spec) {
|
||||||
init_ws_for_output(new_output, output_get_content(new_output->con));
|
init_ws_for_output(new_output, output_get_content(new_output->con));
|
||||||
num_screens++;
|
num_screens++;
|
||||||
}
|
}
|
||||||
|
new_output->primary = primary;
|
||||||
walk += chars_consumed;
|
|
||||||
if (*walk == ',')
|
|
||||||
walk++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num_screens == 0) {
|
if (num_screens == 0) {
|
||||||
|
|
Loading…
Reference in New Issue