From 678b4ce549bf1644a424e8873fbc9f6f81a2a6cd Mon Sep 17 00:00:00 2001 From: Charlotte Meyer Date: Sun, 19 Jan 2020 17:28:19 +0000 Subject: [PATCH] Fix geometry --- include/desktop/view.h | 3 +++ kiwmi/desktop/output.c | 4 ++-- kiwmi/desktop/view.c | 4 ++-- kiwmi/desktop/xdg_shell.c | 12 ++++++++++++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/include/desktop/view.h b/include/desktop/view.h index 5ba362f..0c6975e 100644 --- a/include/desktop/view.h +++ b/include/desktop/view.h @@ -33,8 +33,11 @@ struct kiwmi_view { struct wlr_surface *wlr_surface; + struct wlr_box geom; + struct wl_listener map; struct wl_listener unmap; + struct wl_listener commit; struct wl_listener destroy; struct wl_listener request_move; struct wl_listener request_resize; diff --git a/kiwmi/desktop/output.c b/kiwmi/desktop/output.c index b6a5106..2b1c574 100644 --- a/kiwmi/desktop/output.c +++ b/kiwmi/desktop/output.c @@ -103,8 +103,8 @@ render_surface(struct wlr_surface *surface, int sx, int sy, void *data) wlr_output_layout_output_coords( view->desktop->output_layout, output, &ox, &oy); - ox += view->x + sx; - oy += view->y + sy; + ox += view->x + sx - view->geom.x; + oy += view->y + sy - view->geom.y; struct wlr_box box = { .x = ox * output->scale, diff --git a/kiwmi/desktop/view.c b/kiwmi/desktop/view.c index 8c6f1eb..6f9ada3 100644 --- a/kiwmi/desktop/view.c +++ b/kiwmi/desktop/view.c @@ -90,8 +90,8 @@ surface_at( double *sx, double *sy) { - double view_sx = lx - view->x; - double view_sy = ly - view->y; + double view_sx = lx - view->x + view->geom.x; + double view_sy = ly - view->y + view->geom.y; double _sx, _sy; struct wlr_surface *_surface = NULL; diff --git a/kiwmi/desktop/xdg_shell.c b/kiwmi/desktop/xdg_shell.c index a6b6225..e2dccc7 100644 --- a/kiwmi/desktop/xdg_shell.c +++ b/kiwmi/desktop/xdg_shell.c @@ -35,6 +35,14 @@ xdg_surface_unmap_notify(struct wl_listener *listener, void *UNUSED(data)) wl_signal_emit(&view->events.unmap, view); } +static void +xdg_surface_commit_notify(struct wl_listener *listener, void *UNUSED(data)) +{ + struct kiwmi_view *view = wl_container_of(listener, view, commit); + + wlr_xdg_surface_get_geometry(view->xdg_surface, &view->geom); +} + static void xdg_surface_destroy_notify(struct wl_listener *listener, void *UNUSED(data)) { @@ -50,6 +58,7 @@ xdg_surface_destroy_notify(struct wl_listener *listener, void *UNUSED(data)) wl_list_remove(&view->link); wl_list_remove(&view->map.link); wl_list_remove(&view->unmap.link); + wl_list_remove(&view->commit.link); wl_list_remove(&view->destroy.link); wl_list_remove(&view->request_move.link); wl_list_remove(&view->request_resize.link); @@ -184,6 +193,9 @@ xdg_shell_new_surface_notify(struct wl_listener *listener, void *data) view->unmap.notify = xdg_surface_unmap_notify; wl_signal_add(&xdg_surface->events.unmap, &view->unmap); + view->commit.notify = xdg_surface_commit_notify; + wl_signal_add(&xdg_surface->surface->events.commit, &view->commit); + view->destroy.notify = xdg_surface_destroy_notify; wl_signal_add(&xdg_surface->events.destroy, &view->destroy);