diff options
author | Nicolas Cornu <nicolac76@yahoo.fr> | 2016-12-18 02:03:31 +0100 |
---|---|---|
committer | Nicolas Cornu <nicolac76@yahoo.fr> | 2016-12-18 10:43:10 +0100 |
commit | 0f0bbbff4dae750a0e6f5770c67224bdf3b1bf46 (patch) | |
tree | 3c2a1d3c8c6f625d53ea4e9b65f4f4aa4bbe3c10 /sway/container.c | |
parent | 1172566d4e298aa6c3555a0d606af4ff31d0db48 (diff) |
Put floating views in center, fallback on top left
Sometimes views are created before we got its size
Diffstat (limited to 'sway/container.c')
-rw-r--r-- | sway/container.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/sway/container.c b/sway/container.c index d9677cdb..e557f450 100644 --- a/sway/container.c +++ b/sway/container.c @@ -340,9 +340,18 @@ swayc_t *new_floating_view(wlc_handle handle) { struct wlc_geometry geometry; wlc_view_get_visible_geometry(handle, &geometry); - // give it requested geometry, but place in center - view->x = (swayc_active_workspace()->width - geometry.size.w) / 2; - view->y = (swayc_active_workspace()->height- geometry.size.h) / 2; + // give it requested geometry, but place in center if possible + // in top left otherwise + if (geometry.size.w != 0) { + view->x = (swayc_active_workspace()->width - geometry.size.w) / 2; + } else { + view->x = 0; + } + if (geometry.size.h != 0) { + view->y = (swayc_active_workspace()->height - geometry.size.h) / 2; + } else { + view->y = 0; + } view->width = geometry.size.w; view->height = geometry.size.h; |