*/
}
-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);
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);
}
-
-
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:
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;
}
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;
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);
bool view_want_deco(struct view *view)
{
- if (!view->surface)
- return false;
if (view->type != LAB_XWAYLAND_VIEW)
return false;
if (!is_toplevel(view))
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;
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;
}
return NULL;
}
-
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);
}