]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Open new views on output where cursor is
authorJohan Malm <jgm323@gmail.com>
Tue, 13 Jul 2021 20:50:02 +0000 (21:50 +0100)
committerJohan Malm <jgm323@gmail.com>
Tue, 13 Jul 2021 20:50:02 +0000 (21:50 +0100)
include/labwc.h
src/output.c
src/xdg.c
src/xwayland.c

index 0890547318980fc996df8c0fd1586c8f682380f5..af8fe82b4fa9377993e967e90cc05c56dd5355ce 100644 (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);
index f56873dc30c8f9a0c910c70c1ef8f47349513962..9db24e3532ac7522861d4e3b78d83d1140557e15 100644 (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);
+}
index 1860b05f994b4372da73bd86a5abdde9963e9802..18ff8b2ec65d29ee6f739a21923d2e9c5683b21b 100644 (file)
--- 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);
index 0daf4c8d4811685ccb79976c5a03cda5b0e530d9..36b7e93559fe60b4f7dcb6686cd23cb0e7edae58 100644 (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;
        }