aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop/transaction.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/transaction.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/transaction.c')
-rw-r--r--sway/desktop/transaction.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c
index 9155f0a1..e0c3a5d1 100644
--- a/sway/desktop/transaction.c
+++ b/sway/desktop/transaction.c
@@ -249,6 +249,26 @@ static void apply_container_state(struct sway_container *container,
249 desktop_damage_box(&box); 249 desktop_damage_box(&box);
250 } 250 }
251 251
252 // If the view hasn't responded to the configure, center it within
253 // the container. This is important for fullscreen views which
254 // refuse to resize to the size of the output.
255 if (view && view->surface) {
256 if (view->surface->current.width < container->width) {
257 container->surface_x = container->content_x +
258 (container->content_width - view->surface->current.width) / 2;
259 } else {
260 container->surface_x = container->content_x;
261 }
262 if (view->surface->current.height < container->height) {
263 container->surface_y = container->content_y +
264 (container->content_height - view->surface->current.height) / 2;
265 } else {
266 container->surface_y = container->content_y;
267 }
268 container->surface_width = view->surface->current.width;
269 container->surface_height = view->surface->current.height;
270 }
271
252 if (!container->node.destroying) { 272 if (!container->node.destroying) {
253 container_discover_outputs(container); 273 container_discover_outputs(container);
254 } 274 }