aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop/render.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2019-01-28 16:00:34 +1000
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-01-28 01:17:21 -0500
commit0a9ff774ad77d5c650c03c0ac3501983f3cb0d19 (patch)
tree08cb652bb05cc7003b30f93f78d62f84e965fe8f /sway/desktop/render.c
parentMerge pull request #3423 from RyanDwyer/fullscreen-global (diff)
downloadsway-0a9ff774ad77d5c650c03c0ac3501983f3cb0d19.tar.gz
sway-0a9ff774ad77d5c650c03c0ac3501983f3cb0d19.tar.zst
sway-0a9ff774ad77d5c650c03c0ac3501983f3cb0d19.zip
Center surface inside container when it's too small
The goal here is to center fullscreen views when they are both too small for the output and refuse to resize to the output's dimensions. It has the side effect of also centering the view when it's too small for its container. Example clients that have this behaviour are emersion's hello-wayland and weston. It works by introducing surface_{x,y,width,height} properties to the container struct. The x and y represent layout-local coordinates where the surface will be rendered. The width and height are only used to track the surface's previous dimensions so we can detect when the client has resized it and recenter and apply damage accordingly. The new surface properties are calculated when a transaction is applied, as well as when a view resizes itself unexpectedly. The latter is done in view_update_size. This function was previously restricted to views which are floating, but can now be called for any views. For views which refuse to resize *smaller* than a particular size, such as gnome-calculator, the surface is still anchored to the top left as per the current behaviour.
Diffstat (limited to 'sway/desktop/render.c')
-rw-r--r--sway/desktop/render.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/sway/desktop/render.c b/sway/desktop/render.c
index fa27500e..9102dc34 100644
--- a/sway/desktop/render.c
+++ b/sway/desktop/render.c
@@ -204,9 +204,9 @@ static void render_view_toplevels(struct sway_view *view,
204 .alpha = alpha, 204 .alpha = alpha,
205 }; 205 };
206 // Render all toplevels without descending into popups 206 // Render all toplevels without descending into popups
207 double ox = view->container->current.content_x - 207 double ox = view->container->surface_x -
208 output->wlr_output->lx - view->geometry.x; 208 output->wlr_output->lx - view->geometry.x;
209 double oy = view->container->current.content_y - 209 double oy = view->container->surface_y -
210 output->wlr_output->ly - view->geometry.y; 210 output->wlr_output->ly - view->geometry.y;
211 output_surface_for_each_surface(output, view->surface, ox, oy, 211 output_surface_for_each_surface(output, view->surface, ox, oy,
212 render_surface_iterator, &data); 212 render_surface_iterator, &data);
@@ -240,9 +240,9 @@ static void render_saved_view(struct sway_view *view,
240 return; 240 return;
241 } 241 }
242 struct wlr_box box = { 242 struct wlr_box box = {
243 .x = view->container->current.content_x - output->wlr_output->lx - 243 .x = view->container->surface_x - output->wlr_output->lx -
244 view->saved_geometry.x, 244 view->saved_geometry.x,
245 .y = view->container->current.content_y - output->wlr_output->ly - 245 .y = view->container->surface_y - output->wlr_output->ly -
246 view->saved_geometry.y, 246 view->saved_geometry.y,
247 .width = view->saved_buffer_width, 247 .width = view->saved_buffer_width,
248 .height = view->saved_buffer_height, 248 .height = view->saved_buffer_height,
@@ -1004,7 +1004,6 @@ void output_render(struct sway_output *output, struct timespec *when,
1004 wlr_renderer_clear(renderer, clear_color); 1004 wlr_renderer_clear(renderer, clear_color);
1005 } 1005 }
1006 1006
1007 // TODO: handle views smaller than the output
1008 if (fullscreen_con->view) { 1007 if (fullscreen_con->view) {
1009 if (fullscreen_con->view->saved_buffer) { 1008 if (fullscreen_con->view->saved_buffer) {
1010 render_saved_view(fullscreen_con->view, output, damage, 1.0f); 1009 render_saved_view(fullscreen_con->view, output, damage, 1.0f);