From 7a5ebbe4022d1a025d2e75a5b3b1c0a80587cb05 Mon Sep 17 00:00:00 2001 From: Johan Malm Date: Tue, 12 May 2020 22:24:18 +0100 Subject: [PATCH] Take into account deco on initial window positioning --- dbg.c | 6 ++---- deco.c | 8 +++++++- labwc.h | 3 ++- view.c | 15 ++++++++------- xwl.c | 20 +++++++++++++++++++- 5 files changed, 38 insertions(+), 14 deletions(-) diff --git a/dbg.c b/dbg.c index f99089b5..86a65cea 100644 --- 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 e2175f98..5623df5a 100644 --- 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 fb1c3d7e..c493ff76 100644 --- 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 f67251f3..9036e92a 100644 --- 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 4f4afa8b..03ee4858 100644 --- 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); }