aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop/xdg_shell_v6.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/xdg_shell_v6.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/xdg_shell_v6.c')
-rw-r--r--sway/desktop/xdg_shell_v6.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c
index 386e350e..a7ea163f 100644
--- a/sway/desktop/xdg_shell_v6.c
+++ b/sway/desktop/xdg_shell_v6.c
@@ -284,10 +284,9 @@ static void handle_commit(struct wl_listener *listener, void *data) {
284 wlr_xdg_surface_v6_get_geometry(xdg_surface_v6, &new_geo); 284 wlr_xdg_surface_v6_get_geometry(xdg_surface_v6, &new_geo);
285 struct sway_container *con = view->container; 285 struct sway_container *con = view->container;
286 286
287 if ((new_geo.width != con->content_width || 287 if ((new_geo.width != con->surface_width ||
288 new_geo.height != con->content_height) && 288 new_geo.height != con->surface_height)) {
289 container_is_floating(con)) { 289 // The view has unexpectedly sent a new size
290 // A floating view has unexpectedly sent a new size
291 desktop_damage_view(view); 290 desktop_damage_view(view);
292 view_update_size(view, new_geo.width, new_geo.height); 291 view_update_size(view, new_geo.width, new_geo.height);
293 memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box)); 292 memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));