]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Take into account deco on initial window positioning
authorJohan Malm <jgm323@gmail.com>
Tue, 12 May 2020 21:24:18 +0000 (22:24 +0100)
committerJohan Malm <jgm323@gmail.com>
Tue, 12 May 2020 21:24:18 +0000 (22:24 +0100)
dbg.c
deco.c
labwc.h
view.c
xwl.c

diff --git a/dbg.c b/dbg.c
index f99089b5df5f249c6a88b000a3a8d7228ee70a34..86a65cea1b75c214f52e4b531a3c46a35b52d50c 100644 (file)
--- a/dbg.c
+++ b/dbg.c
@@ -55,7 +55,7 @@ static void show_one_xwl_view(struct view *view)
         */
 }
 
-static void show_one_view(struct view *view)
+void dbg_show_one_view(struct view *view)
 {
        if (view->type == LAB_XDG_SHELL_VIEW)
                show_one_xdg_view(view);
@@ -70,7 +70,5 @@ void dbg_show_views(struct server *server)
        fprintf(stderr, "---\n");
        fprintf(stderr, "TYPE NR_PNT NR_CLD MAPPED VIEW-POINTER   NAME\n");
        wl_list_for_each_reverse (view, &server->views, link)
-               show_one_view(view);
+               dbg_show_one_view(view);
 }
-
-
diff --git a/deco.c b/deco.c
index e2175f98880569ae30985615f5a56a3c810fef12..5623df5a950ea51d0ac2e3300ebdc967b7a5263c 100644 (file)
--- a/deco.c
+++ b/deco.c
@@ -15,7 +15,7 @@ struct wlr_box deco_max_extents(struct view *view)
 struct wlr_box deco_box(struct view *view, enum deco_part deco_part)
 {
        struct wlr_box box = { .x = 0, .y = 0, .width = 0, .height = 0 };
-       if (!view)
+       if (!view || !view->surface)
                return box;
        switch (deco_part) {
        case LAB_DECO_PART_TOP:
@@ -25,6 +25,12 @@ struct wlr_box deco_box(struct view *view, enum deco_part deco_part)
                        view->surface->current.width + 2 * XWL_WINDOW_BORDER;
                box.height = XWL_TITLEBAR_HEIGHT + XWL_WINDOW_BORDER;
                break;
+       case LAB_DECO_PART_LEFT:
+               box.x = view->x - XWL_WINDOW_BORDER;
+               box.y = view->y;
+               box.width = XWL_WINDOW_BORDER;
+               box.height = view->surface->current.height;
+               break;
        default:
                break;
        }
diff --git a/labwc.h b/labwc.h
index fb1c3d7ef0fea380d2262ebf0bcfeab5553727f6..c493ff76ae937c8fd970407c3d0c1d95f21a7570 100644 (file)
--- a/labwc.h
+++ b/labwc.h
@@ -84,7 +84,7 @@ struct output {
 
 enum view_type { LAB_XDG_SHELL_VIEW, LAB_XWAYLAND_VIEW };
 
-enum deco_part { LAB_DECO_NONE, LAB_DECO_PART_TOP };
+enum deco_part { LAB_DECO_NONE, LAB_DECO_PART_TOP, LAB_DECO_PART_LEFT };
 
 struct view {
        enum view_type type;
@@ -159,6 +159,7 @@ void server_new_output(struct wl_listener *listener, void *data);
 
 void output_frame(struct wl_listener *listener, void *data);
 
+void dbg_show_one_view(struct view *view);
 void dbg_show_views(struct server *server);
 
 struct wlr_box deco_max_extents(struct view *view);
diff --git a/view.c b/view.c
index f67251f3b682c11cd063e2164e07ee299bd0ee81..9036e92af9dac2af61ea62dfb5b9216a831ebebf 100644 (file)
--- a/view.c
+++ b/view.c
@@ -2,8 +2,6 @@
 
 bool view_want_deco(struct view *view)
 {
-       if (!view->surface)
-               return false;
        if (view->type != LAB_XWAYLAND_VIEW)
                return false;
        if (!is_toplevel(view))
@@ -148,11 +146,11 @@ void begin_interactive(struct view *view, enum cursor_mode mode, uint32_t edges)
                server->grab_x = server->cursor->x - view->x;
                server->grab_y = server->cursor->y - view->y;
        } else {
-
                struct wlr_box geo_box;
                switch (view->type) {
                case LAB_XDG_SHELL_VIEW:
-                       wlr_xdg_surface_get_geometry(view->xdg_surface, &geo_box);
+                       wlr_xdg_surface_get_geometry(view->xdg_surface,
+                                                    &geo_box);
                        break;
                case LAB_XWAYLAND_VIEW:
                        geo_box.x = view->xwayland_surface->x;
@@ -162,8 +160,12 @@ void begin_interactive(struct view *view, enum cursor_mode mode, uint32_t edges)
                        break;
                }
 
-               double border_x = (view->x + geo_box.x) + ((edges & WLR_EDGE_RIGHT) ? geo_box.width : 0);
-               double border_y = (view->y + geo_box.y) + ((edges & WLR_EDGE_BOTTOM) ? geo_box.height : 0);
+               double border_x =
+                       (view->x + geo_box.x) +
+                       ((edges & WLR_EDGE_RIGHT) ? geo_box.width : 0);
+               double border_y =
+                       (view->y + geo_box.y) +
+                       ((edges & WLR_EDGE_BOTTOM) ? geo_box.height : 0);
                server->grab_x = server->cursor->x - border_x;
                server->grab_y = server->cursor->y - border_y;
                server->grab_box = geo_box;
@@ -261,4 +263,3 @@ struct view *desktop_view_at(struct server *server, double lx, double ly,
        }
        return NULL;
 }
-
diff --git a/xwl.c b/xwl.c
index 4f4afa8b554c8535b87209b22e08d234db88c1c6..03ee4858df486a4eb2600c12cd50c3373210b6ea 100644 (file)
--- a/xwl.c
+++ b/xwl.c
@@ -16,14 +16,32 @@ int xwl_nr_parents(struct view *view)
        return i;
 }
 
+static void position(struct view *view)
+{
+       struct wlr_box box;
+       if (!view_want_deco(view))
+               return;
+       if (view->x || view->y)
+               return;
+       box = deco_box(view, LAB_DECO_PART_TOP);
+       view->y = box.height;
+       box = deco_box(view, LAB_DECO_PART_LEFT);
+       view->x = box.width;
+       wlr_xwayland_surface_configure(view->xwayland_surface, view->x, view->y,
+                                      view->xwayland_surface->width,
+                                      view->xwayland_surface->height);
+}
+
 void xwl_surface_map(struct wl_listener *listener, void *data)
 {
        struct view *view = wl_container_of(listener, view, map);
        view->mapped = true;
-       view->been_mapped = true;
        view->x = view->xwayland_surface->x;
        view->y = view->xwayland_surface->y;
        view->surface = view->xwayland_surface->surface;
+       if (!view->been_mapped)
+               position(view);
+       view->been_mapped = true;
        focus_view(view, view->xwayland_surface->surface);
 }