From: Johan Malm Date: Tue, 13 Jul 2021 20:50:02 +0000 (+0100) Subject: Open new views on output where cursor is X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=69f0f68cc2f3fb732cf51f6bff97ed82b9b30d07;p=proto%2Flabwc.git Open new views on output where cursor is --- diff --git a/include/labwc.h b/include/labwc.h index 08905473..af8fe82b 100644 --- a/include/labwc.h +++ b/include/labwc.h @@ -334,9 +334,9 @@ void output_init(struct server *server); void output_damage_surface(struct output *output, struct wlr_surface *surface, double lx, double ly, bool whole); void scale_box(struct wlr_box *box, float scale); - void output_manager_init(struct server *server); struct output *output_from_wlr_output(struct server *server, struct wlr_output *wlr_output); +struct wlr_box *output_box_from_cursor_coords(struct server *server); void damage_all_outputs(struct server *server); void damage_view_whole(struct view *view); diff --git a/src/output.c b/src/output.c index f56873dc..9db24e35 100644 --- a/src/output.c +++ b/src/output.c @@ -998,3 +998,12 @@ output_from_wlr_output(struct server *server, struct wlr_output *wlr_output) } return NULL; } + +struct wlr_box * +output_box_from_cursor_coords(struct server *server) +{ + struct wlr_output *wlr_output; + wlr_output = wlr_output_layout_output_at(server->output_layout, + server->seat.cursor->x, server->seat.cursor->y); + return wlr_output_layout_get_box(server->output_layout, wlr_output); +} diff --git a/src/xdg.c b/src/xdg.c index 1860b05f..18ff8b2e 100644 --- a/src/xdg.c +++ b/src/xdg.c @@ -224,6 +224,9 @@ static void position_xdg_toplevel_view(struct view *view) { if (istopmost(view)) { + struct wlr_box *box = output_box_from_cursor_coords(view->server); + view->x = box->x; + view->y = box->y; view->w = view->xdg_surface->geometry.width; view->h = view->xdg_surface->geometry.height; view_center(view); diff --git a/src/xwayland.c b/src/xwayland.c index 0daf4c8d..36b7e935 100644 --- a/src/xwayland.c +++ b/src/xwayland.c @@ -159,6 +159,9 @@ map(struct view *view) if (!view->been_mapped) { view_maximize(view, false); + struct wlr_box *box = output_box_from_cursor_coords(view->server); + view->x = box->x; + view->y = box->y; view_center(view); view->been_mapped = true; }