Fix geometry

This commit is contained in:
buffet 2020-01-19 17:28:19 +00:00
parent dd46523b3c
commit 678b4ce549
4 changed files with 19 additions and 4 deletions

View file

@ -33,8 +33,11 @@ struct kiwmi_view {
struct wlr_surface *wlr_surface; struct wlr_surface *wlr_surface;
struct wlr_box geom;
struct wl_listener map; struct wl_listener map;
struct wl_listener unmap; struct wl_listener unmap;
struct wl_listener commit;
struct wl_listener destroy; struct wl_listener destroy;
struct wl_listener request_move; struct wl_listener request_move;
struct wl_listener request_resize; struct wl_listener request_resize;

View file

@ -103,8 +103,8 @@ render_surface(struct wlr_surface *surface, int sx, int sy, void *data)
wlr_output_layout_output_coords( wlr_output_layout_output_coords(
view->desktop->output_layout, output, &ox, &oy); view->desktop->output_layout, output, &ox, &oy);
ox += view->x + sx; ox += view->x + sx - view->geom.x;
oy += view->y + sy; oy += view->y + sy - view->geom.y;
struct wlr_box box = { struct wlr_box box = {
.x = ox * output->scale, .x = ox * output->scale,

View file

@ -90,8 +90,8 @@ surface_at(
double *sx, double *sx,
double *sy) double *sy)
{ {
double view_sx = lx - view->x; double view_sx = lx - view->x + view->geom.x;
double view_sy = ly - view->y; double view_sy = ly - view->y + view->geom.y;
double _sx, _sy; double _sx, _sy;
struct wlr_surface *_surface = NULL; struct wlr_surface *_surface = NULL;

View file

@ -35,6 +35,14 @@ xdg_surface_unmap_notify(struct wl_listener *listener, void *UNUSED(data))
wl_signal_emit(&view->events.unmap, view); 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 static void
xdg_surface_destroy_notify(struct wl_listener *listener, void *UNUSED(data)) 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->link);
wl_list_remove(&view->map.link); wl_list_remove(&view->map.link);
wl_list_remove(&view->unmap.link); wl_list_remove(&view->unmap.link);
wl_list_remove(&view->commit.link);
wl_list_remove(&view->destroy.link); wl_list_remove(&view->destroy.link);
wl_list_remove(&view->request_move.link); wl_list_remove(&view->request_move.link);
wl_list_remove(&view->request_resize.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; view->unmap.notify = xdg_surface_unmap_notify;
wl_signal_add(&xdg_surface->events.unmap, &view->unmap); 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; view->destroy.notify = xdg_surface_destroy_notify;
wl_signal_add(&xdg_surface->events.destroy, &view->destroy); wl_signal_add(&xdg_surface->events.destroy, &view->destroy);