diff --git a/include/desktop/view.h b/include/desktop/view.h index a830623..7b2d8e1 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 15e6579..20a73d1 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 a91ca7e..ddad277 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 c293905..5b48d39 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);