#define XCURSOR_MOVE "grabbing"
#define XWL_TITLEBAR_HEIGHT (10)
#define XWL_WINDOW_BORDER (3)
-#define LAB_DISABLE_CSD (1)
+#define LAB_DISABLE_CSD (0)
enum cursor_mode {
LAB_CURSOR_PASSTHROUGH,
int xwl_nr_parents(struct view *view);
void xwl_surface_new(struct wl_listener *listener, void *data);
+void view_init_position(struct view *view);
/**
* view_get_surface_geometry - geometry relative to view
* @view: toplevel containing the surface to process
box.y = view->y - XWL_TITLEBAR_HEIGHT - XWL_WINDOW_BORDER;
box.width =
view->surface->current.width + 2 * XWL_WINDOW_BORDER;
- box.height = + XWL_WINDOW_BORDER;
+ box.height = XWL_WINDOW_BORDER;
break;
case LAB_DECO_PART_RIGHT:
box.x = view->x + view->surface->current.width;
box.y = view->y - XWL_TITLEBAR_HEIGHT;
box.width = XWL_WINDOW_BORDER;
- box.height = view->surface->current.height + XWL_TITLEBAR_HEIGHT;
+ box.height =
+ view->surface->current.height + XWL_TITLEBAR_HEIGHT;
break;
case LAB_DECO_PART_BOTTOM:
box.x = view->x - XWL_WINDOW_BORDER;
box.y = view->y + view->surface->current.height;
box.width =
view->surface->current.width + 2 * XWL_WINDOW_BORDER;
- box.height = + XWL_WINDOW_BORDER;
+ box.height = +XWL_WINDOW_BORDER;
break;
case LAB_DECO_PART_LEFT:
box.x = view->x - XWL_WINDOW_BORDER;
box.y = view->y - XWL_TITLEBAR_HEIGHT;
box.width = XWL_WINDOW_BORDER;
- box.height = view->surface->current.height + XWL_TITLEBAR_HEIGHT;
+ box.height =
+ view->surface->current.height + XWL_TITLEBAR_HEIGHT;
break;
default:
break;
#include "labwc.h"
+static bool is_toplevel(struct view *view)
+{
+ switch (view->type) {
+ case LAB_XDG_SHELL_VIEW:
+ return view->xdg_surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL;
+ case LAB_XWAYLAND_VIEW:
+ return xwl_nr_parents(view) > 0 ? false : true;
+ }
+ return false;
+}
+
+void view_init_position(struct view *view)
+{
+ /* If surface already has a 'desired' position, don't touch it */
+ if (view->x || view->y)
+ return;
+ if (!is_toplevel(view))
+ return;
+ struct wlr_box box;
+ if (view->type == LAB_XDG_SHELL_VIEW && !LAB_DISABLE_CSD) {
+ /* CSD */
+ wlr_xdg_surface_get_geometry(view->xdg_surface, &box);
+ } else if (!view_want_deco(view)) {
+ return;
+ } else {
+ /* SSD */
+ box = deco_max_extents(view);
+ }
+ view->x -= box.x;
+ view->y -= box.y;
+ if (view->type != LAB_XWAYLAND_VIEW)
+ return;
+ wlr_xwayland_surface_configure(view->xwayland_surface, view->x, view->y,
+ view->xwayland_surface->width,
+ view->xwayland_surface->height);
+}
+
struct wlr_box view_get_surface_geometry(struct view *view)
{
struct wlr_box box = { 0 };
}
}
-static bool is_toplevel(struct view *view)
-{
- switch (view->type) {
- case LAB_XDG_SHELL_VIEW:
- return view->xdg_surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL;
- case LAB_XWAYLAND_VIEW:
- return xwl_nr_parents(view) > 0 ? false : true;
- }
- return false;
-}
-
+/* Do we want _server_ side decoration? */
bool view_want_deco(struct view *view)
{
if (!is_toplevel(view))
void xdg_surface_map(struct wl_listener *listener, void *data)
{
- /* Called when the surface is mapped, or ready to display on-screen. */
struct view *view = wl_container_of(listener, view, map);
view->mapped = true;
- view->been_mapped = true;
view->surface = view->xdg_surface->surface;
+ if (!view->been_mapped)
+ view_init_position(view);
+ view->been_mapped = true;
view_focus(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_TITLE);
- 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->y = view->xwayland_surface->y;
view->surface = view->xwayland_surface->surface;
if (!view->been_mapped)
- position(view);
+ view_init_position(view);
view->been_mapped = true;
view_focus(view);
}