[PATCH 7/9] shell: Use buffer_scale as output scale on fullscreen DRIVER

alexl at redhat.com alexl at redhat.com
Tue May 28 07:23:38 PDT 2013


From: Alexander Larsson <alexl at redhat.com>

It may happen that you e.g. fullscreen a 800x600 surface with
buffer_scale 1 (e.g. a 800x600 buffer) on an output that is
otherwise scale 2. In this case we want to temporarily set
the output scale to 1, as we're really scanning out of a
scale 1 buffer. This causes us to e.g. report the input
positions in the right place, etc.

When we restore the original mode we also restore the original
scale.

Note that the scale change is a purely compositor internal change,
to clients it still looks like the output is scale 2.
---
 src/compositor.c |  4 +++-
 src/compositor.h |  2 +-
 src/shell.c      | 12 +++++++-----
 3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index 8f82ba6..b5b5ab8 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -95,7 +95,7 @@ static void
 weston_output_transform_scale_init(struct weston_output *output, uint32_t transform, uint32_t scale);
 
 WL_EXPORT int
-weston_output_switch_mode(struct weston_output *output, struct weston_mode *mode)
+weston_output_switch_mode(struct weston_output *output, struct weston_mode *mode, int32_t scale)
 {
 	struct weston_seat *seat;
 	pixman_region32_t old_output_region;
@@ -108,6 +108,8 @@ weston_output_switch_mode(struct weston_output *output, struct weston_mode *mode
 	if (ret < 0)
 		return ret;
 
+        output->scale = scale;
+
 	pixman_region32_init(&old_output_region);
 	pixman_region32_copy(&old_output_region, &output->region);
 
diff --git a/src/compositor.h b/src/compositor.h
index b17d832..86793f5 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -1141,7 +1141,7 @@ void
 weston_surface_destroy(struct weston_surface *surface);
 
 int
-weston_output_switch_mode(struct weston_output *output, struct weston_mode *mode);
+weston_output_switch_mode(struct weston_output *output, struct weston_mode *mode, int32_t scale);
 
 int
 noop_renderer_init(struct weston_compositor *ec);
diff --git a/src/shell.c b/src/shell.c
index 07be564..1f2ad60 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -1503,7 +1503,8 @@ shell_unset_fullscreen(struct shell_surface *shsurf)
 	if (shsurf->fullscreen.type == WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER &&
 	    shell_surface_is_top_fullscreen(shsurf)) {
 		weston_output_switch_mode(shsurf->fullscreen_output,
-		                          shsurf->fullscreen_output->origin);
+		                          shsurf->fullscreen_output->origin,
+					  shsurf->fullscreen_output->origin_scale);
 	}
 	shsurf->fullscreen.type = WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT;
 	shsurf->fullscreen.framerate = 0;
@@ -1797,11 +1798,11 @@ shell_configure_fullscreen(struct shell_surface *shsurf)
 	case WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER:
 		if (shell_surface_is_top_fullscreen(shsurf)) {
 			struct weston_mode mode = {0,
-				surf_width,
-				surf_height,
+				surf_width * surface->buffer_scale,
+				surf_height * surface->buffer_scale,
 				shsurf->fullscreen.framerate};
 
-			if (weston_output_switch_mode(output, &mode) == 0) {
+			if (weston_output_switch_mode(output, &mode, surface->buffer_scale) == 0) {
 				weston_surface_set_position(surface,
 							    output->x - surf_x,
 							    output->y - surf_y);
@@ -2151,7 +2152,8 @@ destroy_shell_surface(struct shell_surface *shsurf)
 	if (shsurf->fullscreen.type == WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER &&
 	    shell_surface_is_top_fullscreen(shsurf)) {
 		weston_output_switch_mode(shsurf->fullscreen_output,
-					  shsurf->fullscreen_output->origin);
+					  shsurf->fullscreen_output->origin,
+					  shsurf->fullscreen_output->origin_scale);
 	}
 
 	if (shsurf->fullscreen.black_surface)
-- 
1.8.1.4



More information about the wayland-devel mailing list