compositor-wayland: split wayland_output_create_for_config
The splitting intend to separate configuration parsing from output setup. Introduces struct weston_wayland_backend_output_config. Signed-off-by: Benoit Gschwind <gschwind@gnu-log.net> [Pekka: squashed "wayland-backend: define output configuration structure" into this.] [Pekka: fix fullscreen output scale back to 1.] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This commit is contained in:
committed by
Pekka Paalanen
parent
244ff799fb
commit
830b7882f1
+68
-36
@@ -52,6 +52,14 @@
|
|||||||
|
|
||||||
#define WINDOW_TITLE "Weston Compositor"
|
#define WINDOW_TITLE "Weston Compositor"
|
||||||
|
|
||||||
|
struct weston_wayland_backend_output_config {
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
char *name;
|
||||||
|
uint32_t transform;
|
||||||
|
int32_t scale;
|
||||||
|
};
|
||||||
|
|
||||||
struct weston_wayland_backend_config {
|
struct weston_wayland_backend_config {
|
||||||
int use_pixman;
|
int use_pixman;
|
||||||
int sprawl;
|
int sprawl;
|
||||||
@@ -1099,61 +1107,68 @@ err_name:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct wayland_output *
|
static void
|
||||||
wayland_output_create_for_config(struct wayland_backend *b,
|
wayland_output_init_from_config(struct weston_wayland_backend_output_config *output,
|
||||||
struct weston_config_section *config_section,
|
struct weston_config_section *config_section,
|
||||||
int option_width, int option_height,
|
int option_width, int option_height,
|
||||||
int option_scale, int32_t x, int32_t y)
|
int option_scale)
|
||||||
{
|
{
|
||||||
struct wayland_output *output;
|
char *mode, *t, *str;
|
||||||
char *mode, *t, *name, *str;
|
|
||||||
int width, height, scale;
|
|
||||||
uint32_t transform;
|
|
||||||
unsigned int slen;
|
unsigned int slen;
|
||||||
|
|
||||||
weston_config_section_get_string(config_section, "name", &name, NULL);
|
weston_config_section_get_string(config_section, "name", &output->name,
|
||||||
if (name) {
|
NULL);
|
||||||
slen = strlen(name);
|
if (output->name) {
|
||||||
|
slen = strlen(output->name);
|
||||||
slen += strlen(WINDOW_TITLE " - ");
|
slen += strlen(WINDOW_TITLE " - ");
|
||||||
str = malloc(slen + 1);
|
str = malloc(slen + 1);
|
||||||
if (str)
|
if (str)
|
||||||
snprintf(str, slen + 1, WINDOW_TITLE " - %s", name);
|
snprintf(str, slen + 1, WINDOW_TITLE " - %s",
|
||||||
free(name);
|
output->name);
|
||||||
name = str;
|
free(output->name);
|
||||||
|
output->name = str;
|
||||||
}
|
}
|
||||||
if (!name)
|
if (!output->name)
|
||||||
name = strdup(WINDOW_TITLE);
|
output->name = strdup(WINDOW_TITLE);
|
||||||
|
|
||||||
weston_config_section_get_string(config_section,
|
weston_config_section_get_string(config_section,
|
||||||
"mode", &mode, "1024x600");
|
"mode", &mode, "1024x600");
|
||||||
if (sscanf(mode, "%dx%d", &width, &height) != 2) {
|
if (sscanf(mode, "%dx%d", &output->width, &output->height) != 2) {
|
||||||
weston_log("Invalid mode \"%s\" for output %s\n",
|
weston_log("Invalid mode \"%s\" for output %s\n",
|
||||||
mode, name);
|
mode, output->name);
|
||||||
width = 1024;
|
output->width = 1024;
|
||||||
height = 640;
|
output->height = 640;
|
||||||
}
|
}
|
||||||
free(mode);
|
free(mode);
|
||||||
|
|
||||||
if (option_width)
|
if (option_width)
|
||||||
width = option_width;
|
output->width = option_width;
|
||||||
if (option_height)
|
if (option_height)
|
||||||
height = option_height;
|
output->height = option_height;
|
||||||
|
|
||||||
weston_config_section_get_int(config_section, "scale", &scale, 1);
|
weston_config_section_get_int(config_section, "scale", &output->scale, 1);
|
||||||
|
|
||||||
if (option_scale)
|
if (option_scale)
|
||||||
scale = option_scale;
|
output->scale = option_scale;
|
||||||
|
|
||||||
weston_config_section_get_string(config_section,
|
weston_config_section_get_string(config_section,
|
||||||
"transform", &t, "normal");
|
"transform", &t, "normal");
|
||||||
if (weston_parse_transform(t, &transform) < 0)
|
if (weston_parse_transform(t, &output->transform) < 0)
|
||||||
weston_log("Invalid transform \"%s\" for output %s\n",
|
weston_log("Invalid transform \"%s\" for output %s\n",
|
||||||
t, name);
|
t, output->name);
|
||||||
free(t);
|
free(t);
|
||||||
|
|
||||||
output = wayland_output_create(b, x, y, width, height, name, 0,
|
}
|
||||||
transform, scale);
|
|
||||||
free(name);
|
static struct wayland_output *
|
||||||
|
wayland_output_create_for_config(struct wayland_backend *b,
|
||||||
|
struct weston_wayland_backend_output_config *oc,
|
||||||
|
int fullscreen, int32_t x, int32_t y)
|
||||||
|
{
|
||||||
|
struct wayland_output *output;
|
||||||
|
|
||||||
|
output = wayland_output_create(b, x, y, oc->width, oc->height, oc->name,
|
||||||
|
fullscreen, oc->transform, oc->scale);
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
@@ -2336,6 +2351,7 @@ backend_init(struct weston_compositor *compositor, int *argc, char *argv[],
|
|||||||
struct wayland_parent_output *poutput;
|
struct wayland_parent_output *poutput;
|
||||||
struct weston_config_section *section;
|
struct weston_config_section *section;
|
||||||
struct weston_wayland_backend_config new_config;
|
struct weston_wayland_backend_config new_config;
|
||||||
|
struct weston_wayland_backend_output_config output_config;
|
||||||
int x, count, width, height, scale;
|
int x, count, width, height, scale;
|
||||||
const char *section_name;
|
const char *section_name;
|
||||||
char *name;
|
char *name;
|
||||||
@@ -2387,8 +2403,14 @@ backend_init(struct weston_compositor *compositor, int *argc, char *argv[],
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (new_config.fullscreen) {
|
if (new_config.fullscreen) {
|
||||||
output = wayland_output_create(b, 0, 0, width, height,
|
output_config.width = width;
|
||||||
NULL, 1, 0, 1);
|
output_config.height = height;
|
||||||
|
output_config.name = NULL;
|
||||||
|
output_config.transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
||||||
|
output_config.scale = 1;
|
||||||
|
|
||||||
|
output = wayland_output_create_for_config(b, &output_config,
|
||||||
|
1, 0, 0);
|
||||||
if (!output)
|
if (!output)
|
||||||
goto err_outputs;
|
goto err_outputs;
|
||||||
|
|
||||||
@@ -2411,8 +2433,12 @@ backend_init(struct weston_compositor *compositor, int *argc, char *argv[],
|
|||||||
}
|
}
|
||||||
free(name);
|
free(name);
|
||||||
|
|
||||||
output = wayland_output_create_for_config(b, section, width,
|
wayland_output_init_from_config(&output_config, section, width,
|
||||||
height, scale, x, 0);
|
height, scale);
|
||||||
|
output = wayland_output_create_for_config(b, &output_config, 0,
|
||||||
|
x, 0);
|
||||||
|
free(output_config.name);
|
||||||
|
|
||||||
if (!output)
|
if (!output)
|
||||||
goto err_outputs;
|
goto err_outputs;
|
||||||
if (wayland_output_set_windowed(output))
|
if (wayland_output_set_windowed(output))
|
||||||
@@ -2429,8 +2455,14 @@ backend_init(struct weston_compositor *compositor, int *argc, char *argv[],
|
|||||||
if (!scale)
|
if (!scale)
|
||||||
scale = 1;
|
scale = 1;
|
||||||
while (count > 0) {
|
while (count > 0) {
|
||||||
output = wayland_output_create(b, x, 0, width, height,
|
output_config.width = width;
|
||||||
NULL, 0, 0, scale);
|
output_config.height = height;
|
||||||
|
output_config.name = NULL;
|
||||||
|
output_config.transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
||||||
|
output_config.scale = scale;
|
||||||
|
|
||||||
|
output = wayland_output_create_for_config(b, &output_config,
|
||||||
|
0, x, 0);
|
||||||
if (!output)
|
if (!output)
|
||||||
goto err_outputs;
|
goto err_outputs;
|
||||||
if (wayland_output_set_windowed(output))
|
if (wayland_output_set_windowed(output))
|
||||||
|
|||||||
Reference in New Issue
Block a user