Open new views on output where cursor is

This commit is contained in:
Johan Malm 2021-07-13 21:50:02 +01:00
parent eaed1a3cab
commit 69f0f68cc2
4 changed files with 16 additions and 1 deletions

View file

@ -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);

View file

@ -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);
}

View file

@ -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);

View file

@ -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;
}