aboutsummaryrefslogtreecommitdiff
path: root/rootston/xdg_shell.c
diff options
context:
space:
mode:
authorGenki Sky <sky@genki.is>2018-05-30 20:11:58 -0400
committerDrew DeVault <sir@cmpwn.com>2018-05-30 20:21:19 -0400
commit32013abae63f1c31598ac716acd7e73c24fadae1 (patch)
treec39f15182eeae7a5d0808f05d5f095d2049fe7de /rootston/xdg_shell.c
parentd1cf9acbd5ab6735952d013e5eb685e7139094a7 (diff)
rootston: xdg-shell*: Fix get_size() for newly-mapped views
The user-visible issue is that newly-mapped xdg-shell* windows would sometimes start with their top-left-corner, rather than their center, in the center of the screen. This is because get_size() would conservatively fall back on (width, height) == (0, 0) if both set_window_geometry() had not been called, and it found view->wlr_surface to be NULL. But, view->wlr_surface is only set to non-NULL in view_map(). We call get_size() before this. Fortunately, the wlr_surface in question is accessible via view->xdg_shell{,_v6}->surface, so always fall back on that. We can assert its presence instead of further falling back on (width, height) == (0, 0). Signed-off-by: Genki Sky <sky@genki.is>
Diffstat (limited to 'rootston/xdg_shell.c')
-rw-r--r--rootston/xdg_shell.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/rootston/xdg_shell.c b/rootston/xdg_shell.c
index 83a1caf0..03ae1dc6 100644
--- a/rootston/xdg_shell.c
+++ b/rootston/xdg_shell.c
@@ -135,11 +135,10 @@ static void get_size(const struct roots_view *view, struct wlr_box *box) {
if (surface->geometry.width > 0 && surface->geometry.height > 0) {
box->width = surface->geometry.width;
box->height = surface->geometry.height;
- } else if (view->wlr_surface != NULL) {
- box->width = view->wlr_surface->current->width;
- box->height = view->wlr_surface->current->height;
} else {
- box->width = box->height = 0;
+ assert(surface->surface);
+ box->width = surface->surface->current->width;
+ box->height = surface->surface->current->height;
}
}