[PATCH] Bug fix client apps because of output change

Wang, Quanxian quanxian.wang at intel.com
Thu Mar 6 19:41:59 PST 2014


I have double checked the patch and retesting it.

The bug is caused by not setting background window size after output change.

This fix has been included in previous patch. Pq's comment is right. We should set background min allocation before resize. 

Why did I get this? Because I just use another patch which only comment min_allocation of background for testing. This caused the bug I mentioned.

Just use previous patch is fine.

Thanks

Regards

Quanxian Wang


>-----Original Message-----
>From: Wang, Quanxian
>Sent: Friday, March 07, 2014 10:44 AM
>To: wayland-devel at lists.freedesktop.org
>Cc: ppaalanen at gmail.com
>Subject: RE: [PATCH] Bug fix client apps because of output change
>
>Ignore this, I have found a bug. After bug fixing, I will resend the patch. Sorry
>about that.
>
>I have two monitors.
>VGA1(left) + HDMI3(right)
>
>The bug is shown when you set the mode of HDMI3 to 800x600, and then move
>layout as HDMI3(left) + VGA1(right), and then change to mode 1920x1200.
>It will have some issue.
>
>Sorry about that.
>
>Regards
>
>Quanxian Wang
>
>>-----Original Message-----
>>From: Wang, Quanxian
>>Sent: Thursday, March 06, 2014 6:31 PM
>>To: wayland-devel at lists.freedesktop.org
>>Cc: ppaalanen at gmail.com; Wang, Quanxian
>>Subject: [PATCH] Bug fix client apps because of output change
>>
>>1)
>>Width and height of Panel and Background depend on output's, therefore
>>they should be bound with output changes including mode, transform and scale.
>>
>>2)
>>Update the min_allocation before resize the panel and background
>>window. Add window_set_min_allocation function because it is invisible outside
>window.c.
>>
>>Signed-off-by: Quanxian Wang <quanxian.wang at intel.com>
>>---
>> clients/desktop-shell.c | 80
>>+++++++++++++++++++++++++++++++++++++++++++++++--
>> clients/window.c        |  7 +++++
>> clients/window.h        |  2 ++
>> 3 files changed, 87 insertions(+), 2 deletions(-)
>>
>>diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c index
>>a0c6b6d..4373448 100644
>>--- a/clients/desktop-shell.c
>>+++ b/clients/desktop-shell.c
>>@@ -103,6 +103,15 @@ struct output {
>>
>> 	struct panel *panel;
>> 	struct background *background;
>>+	struct {
>>+		int height;
>>+		int width;
>>+		uint32_t refresh;
>>+	} mode;
>>+
>>+	uint32_t interface_version;
>>+	uint32_t transform;
>>+	uint32_t scale;
>> };
>>
>> struct panel_launcher {
>>@@ -1145,6 +1154,45 @@ desktop_destroy_outputs(struct desktop *desktop)
>>}
>>
>> static void
>>+update_output(struct output *output)
>>+{
>>+	struct panel *panel = output->panel;
>>+	struct background *background = output->background;
>>+	int width, height;
>>+
>>+	if (!output)
>>+		return;
>>+
>>+	width = output->mode.width;
>>+	height = output->mode.height;
>>+
>>+	switch (output->transform) {
>>+	case WL_OUTPUT_TRANSFORM_90:
>>+	case WL_OUTPUT_TRANSFORM_270:
>>+	case WL_OUTPUT_TRANSFORM_FLIPPED_90:
>>+	case WL_OUTPUT_TRANSFORM_FLIPPED_270:
>>+		/* Swap width and height */
>>+		width = output->mode.height;
>>+		height = output->mode.width;
>>+		break;
>>+	default:
>>+		break;
>>+	}
>>+
>>+	if (output->scale != 0) {
>>+		width /= output->scale;
>>+		height /= output->scale;
>>+	}
>>+
>>+	/* Set min_allocation of panel */
>>+	window_set_min_allocation(panel->window, width, 32);
>>+	window_set_min_allocation(background->window, width, height);
>>+
>>+	window_schedule_resize(background->window, width, height);
>>+	window_schedule_resize(panel->window, width, 32); }
>>+
>>+static void
>> output_handle_geometry(void *data,
>>                        struct wl_output *wl_output,
>>                        int x, int y,
>>@@ -1157,6 +1205,11 @@ output_handle_geometry(void *data,  {
>> 	struct output *output = data;
>>
>>+	output->transform = transform;
>>+
>>+	if (output->interface_version < 2)
>>+		update_output(output);
>>+
>> 	window_set_buffer_transform(output->panel->window, transform);
>> 	window_set_buffer_transform(output->background->window,
>>transform);  } @@ -1169,12 +1222,29 @@ output_handle_mode(void *data,
>> 		   int height,
>> 		   int refresh)
>> {
>>+	struct output *output = data;
>>+
>>+	if (flags & WL_OUTPUT_MODE_CURRENT) {
>>+		if (!output)
>>+			return;
>>+
>>+		output->mode.width = width;
>>+		output->mode.height = height;
>>+		output->mode.refresh = refresh;
>>+
>>+		if (output->interface_version < 2)
>>+			update_output(output);
>>+	}
>> }
>>
>> static void
>> output_handle_done(void *data,
>>                    struct wl_output *wl_output)  {
>>+	struct output *output = data;
>>+
>>+	if (output->interface_version >= 2)
>>+		update_output(output);
>> }
>>
>> static void
>>@@ -1184,6 +1254,11 @@ output_handle_scale(void *data,  {
>> 	struct output *output = data;
>>
>>+	output->scale  = scale;
>>+
>>+	if (output->interface_version < 2)
>>+		update_output(output);
>>+
>> 	window_set_buffer_scale(output->panel->window, scale);
>> 	window_set_buffer_scale(output->background->window, scale);  } @@
>>-1212,7 +1287,7 @@ output_init(struct output *output, struct desktop
>>*desktop)  }
>>
>> static void
>>-create_output(struct desktop *desktop, uint32_t id)
>>+create_output(struct desktop *desktop, uint32_t id, uint32_t version)
>> {
>> 	struct output *output;
>>
>>@@ -1223,6 +1298,7 @@ create_output(struct desktop *desktop, uint32_t id)
>> 	output->output =
>> 		display_bind(desktop->display, id, &wl_output_interface, 2);
>> 	output->server_output_id = id;
>>+	output->interface_version = version;
>>
>> 	wl_output_add_listener(output->output, &output_listener, output);
>>
>>@@ -1247,7 +1323,7 @@ global_handler(struct display *display, uint32_t id,
>> 					      desktop->interface_version);
>> 		desktop_shell_add_listener(desktop->shell, &listener, desktop);
>> 	} else if (!strcmp(interface, "wl_output")) {
>>-		create_output(desktop, id);
>>+		create_output(desktop, id, version);
>> 	}
>> }
>>
>>diff --git a/clients/window.c b/clients/window.c index c8287e2..6c01222
>>100644
>>--- a/clients/window.c
>>+++ b/clients/window.c
>>@@ -3839,6 +3839,13 @@ undo_resize(struct window *window)  }
>>
>> void
>>+window_set_min_allocation(struct window *window, int width, int
>>+height) {
>>+	window->min_allocation.width = width;
>>+	window->min_allocation.height = height; }
>>+
>>+void
>> window_schedule_resize(struct window *window, int width, int height)  {
>> 	/* We should probably get these numbers from the theme. */ diff --git
>>a/clients/window.h b/clients/window.h index 54b848b..b221b76 100644
>>--- a/clients/window.h
>>+++ b/clients/window.h
>>@@ -336,6 +336,8 @@ void
>> window_schedule_redraw(struct window *window);  void
>>window_schedule_resize(struct window *window, int width, int height);
>>+void
>>+window_set_min_allocation(struct window *window, int width, int
>>+height);
>>
>> void
>> window_damage(struct window *window, int32_t x, int32_t y,
>>--
>>1.8.1.2



More information about the wayland-devel mailing list