Name outputs in x11 backend
Florian Scandella
flo at chilicode.com
Sun Jul 7 15:25:57 PDT 2013
small patch, will eventually be needed by output configuration.
>From f54e832fd453b9854378164aa35e15c816884147 Mon Sep 17 00:00:00 2001
From: Florian Scandella <flo at chilicode.com>
Date: Mon, 8 Jul 2013 00:18:51 +0200
Subject: [PATCH] [compositor-x11] Always generate a name for a x11
output and
store it in weston_output.
---
src/compositor-x11.c | 100
++++++++++++++++++++++-----------------------------
1 file changed, 42 insertions(+), 58 deletions(-)
diff --git a/src/compositor-x11.c b/src/compositor-x11.c
index 5a0bcf0..4e9a5f9 100644
--- a/src/compositor-x11.c
+++ b/src/compositor-x11.c
@@ -795,11 +795,7 @@ x11_compositor_create_output(struct x11_compositor
*c, int x, int y,
output_width = width * scale;
output_height = height * scale;
-
- if (configured_name)
- sprintf(title, "%s - %s", name, configured_name);
- else
- strcpy(title, name);
+ snprintf(title, 32, "%s - %s", name, configured_name);
if (!no_input)
values[0] |=
@@ -897,6 +893,8 @@ x11_compositor_create_output(struct x11_compositor
*c, int x, int y,
output->base.origin = output->base.current;
output->base.make = "xwayland";
output->base.model = "none";
+ output->base.name = strdup(configured_name);
+
weston_output_init(&output->base, &c->base,
x, y, width, height, transform, scale);
@@ -918,8 +916,8 @@ x11_compositor_create_output(struct x11_compositor
*c, int x, int y,
wl_list_insert(c->base.output_list.prev, &output->base.link);
- weston_log("x11 output %dx%d, window id %d\n",
- width, height, output->window);
+ weston_log("x11 output %dx%d, window id %d, window name %s\n",
+ width, height, output->window, output->base.name);
return output;
}
@@ -1511,10 +1509,9 @@ x11_compositor_create(struct wl_display *display,
struct x11_output *output;
struct weston_config_section *section;
xcb_screen_iterator_t s;
- int i, x = 0, output_count = 0;
+ int i, x = 0;
int width, height, count, scale;
- const char *section_name;
- char *name, *t, *mode;
+ char *t, *mode;
uint32_t transform;
weston_log("initializing x11 backend\n");
@@ -1574,55 +1571,42 @@ x11_compositor_create(struct wl_display *display,
height = option_height ? option_height : 640;
count = option_count ? option_count : 1;
- section = NULL;
- while (weston_config_next_section(c->base.config,
- §ion, §ion_name)) {
- if (strcmp(section_name, "output") != 0)
- continue;
- weston_config_section_get_string(section, "name", &name, NULL);
- if (name == NULL || name[0] != 'X')
- continue;
-
- weston_config_section_get_string(section,
- "mode", &mode, "1024x600");
- if (sscanf(mode, "%dx%d", &width, &height) != 2) {
- weston_log("Invalid mode \"%s\" for output %s\n",
- mode, name);
- width = 1024;
- height = 600;
+ for (i = 0; i < count; i++) {
+ char name[5];
+ snprintf(name, 5, "X%d", i + 1);
+ section = weston_config_get_section(c->base.config, "output",
"name", name);
+
+ if (section) {
+ weston_config_section_get_string(section,
+ "mode", &mode, "1024x600");
+ if (sscanf(mode, "%dx%d", &width, &height) != 2) {
+ weston_log("Invalid mode \"%s\" for output %s\n",
+ mode, name);
+ width = 1024;
+ height = 600;
+ }
+ free(mode);
+
+ if (option_width)
+ width = option_width;
+ if (option_height)
+ height = option_height;
+
+ weston_config_section_get_int(section, "scale", &scale, 1);
+ weston_config_section_get_string(section,
+ "transform", &t, "normal");
+ transform = parse_transform(t, name);
+ free(t);
+
+ output = x11_compositor_create_output(c, x, 0,
+ width, height,
+ fullscreen, no_input,
+ name, transform, scale);
+ } else {
+ output = x11_compositor_create_output(c, x, 0, width, height,
+ fullscreen, no_input, name,
+ WL_OUTPUT_TRANSFORM_NORMAL, 1);
}
- free(mode);
-
- if (option_width)
- width = option_width;
- if (option_height)
- height = option_height;
-
- weston_config_section_get_int(section, "scale", &scale, 1);
- weston_config_section_get_string(section,
- "transform", &t, "normal");
- transform = parse_transform(t, name);
- free(t);
-
- output = x11_compositor_create_output(c, x, 0,
- width, height,
- fullscreen, no_input,
- name, transform, scale);
- free(name);
- if (output == NULL)
- goto err_x11_input;
-
- x = pixman_region32_extents(&output->base.region)->x2;
-
- output_count++;
- if (option_count && output_count >= option_count)
- break;
- }
-
- for (i = output_count; i < count; i++) {
- output = x11_compositor_create_output(c, x, 0, width, height,
- fullscreen, no_input, NULL,
- WL_OUTPUT_TRANSFORM_NORMAL, 1);
if (output == NULL)
goto err_x11_input;
x = pixman_region32_extents(&output->base.region)->x2;
--
1.8.3.2
More information about the wayland-devel
mailing list