struct wlr_box box = {
.x = view->x - BORDER_WIDTH,
.y = view->y - rc.title_height - BORDER_WIDTH,
- .width = view->surface->current.width + 2 * BORDER_WIDTH,
- .height = view->surface->current.height + rc.title_height +
- 2 * BORDER_WIDTH,
+ .width = view->w + 2 * BORDER_WIDTH,
+ .height = view->h + rc.title_height + 2 * BORDER_WIDTH,
};
return box;
}
return box;
BUG_ON(!view->been_mapped);
BUG_ON(!view->show_server_side_deco);
- if ((view->surface->current.width < 1) ||
- (view->surface->current.height < 1)) {
+ if ((view->w < 1) || (view->h < 1)) {
warn("view (%p) has no width/height", view);
return box;
}
wlr_texture_get_size(theme.xbm_close_active_unpressed,
&box.width, &box.height);
margin = (rc.title_height - box.height) / 2;
- box.x = view->x + view->surface->current.width + margin -
- rc.title_height;
+ box.x = view->x + view->w + margin - rc.title_height;
box.y = view->y - rc.title_height + margin;
break;
case LAB_DECO_BUTTON_MAXIMIZE:
wlr_texture_get_size(theme.xbm_maximize_active_unpressed,
&box.width, &box.height);
margin = (rc.title_height - box.height) / 2;
- box.x = view->x + view->surface->current.width + margin -
- rc.title_height * 2;
+ box.x = view->x + view->w + margin - rc.title_height * 2;
box.y = view->y - rc.title_height + margin;
break;
case LAB_DECO_BUTTON_ICONIFY:
wlr_texture_get_size(theme.xbm_iconify_active_unpressed,
&box.width, &box.height);
margin = (rc.title_height - box.height) / 2;
- box.x = view->x + view->surface->current.width + margin -
- rc.title_height * 3;
+ box.x = view->x + view->w + margin - rc.title_height * 3;
box.y = view->y - rc.title_height + margin;
break;
case LAB_DECO_PART_TITLE:
box.x = view->x;
box.y = view->y - rc.title_height;
- box.width = view->surface->current.width;
+ box.width = view->w;
box.height = rc.title_height;
break;
case LAB_DECO_PART_TOP:
box.x = view->x - BORDER_WIDTH;
box.y = view->y - rc.title_height - BORDER_WIDTH;
- box.width = view->surface->current.width + 2 * BORDER_WIDTH;
+ box.width = view->w + 2 * BORDER_WIDTH;
box.height = BORDER_WIDTH;
break;
case LAB_DECO_PART_RIGHT:
- box.x = view->x + view->surface->current.width;
+ box.x = view->x + view->w;
box.y = view->y - rc.title_height;
box.width = BORDER_WIDTH;
- box.height = view->surface->current.height + rc.title_height;
+ box.height = view->h + rc.title_height;
break;
case LAB_DECO_PART_BOTTOM:
box.x = view->x - BORDER_WIDTH;
- box.y = view->y + view->surface->current.height;
- box.width = view->surface->current.width + 2 * BORDER_WIDTH;
+ box.y = view->y + view->h;
+ box.width = view->w + 2 * BORDER_WIDTH;
box.height = +BORDER_WIDTH;
break;
case LAB_DECO_PART_LEFT:
box.x = view->x - BORDER_WIDTH;
box.y = view->y - rc.title_height;
box.width = BORDER_WIDTH;
- box.height = view->surface->current.height + rc.title_height;
+ box.height = view->h + rc.title_height;
break;
default:
break;
#include "labwc.h"
+#include "common/log.h"
+#include "common/bug-on.h"
struct xdg_deco {
struct wlr_xdg_toplevel_decoration_v1 *wlr_decoration;
return true;
}
+static void handle_commit(struct wl_listener *listener, void *data)
+{
+ struct view *view = wl_container_of(listener, view, commit);
+ BUG_ON(!view->surface);
+ view->w = view->surface->current.width;
+ view->h = view->surface->current.height;
+}
+
void xdg_surface_map(struct wl_listener *listener, void *data)
{
struct view *view = wl_container_of(listener, view, map);
view_init_position(view);
}
view->been_mapped = true;
+ wl_signal_add(&view->xdg_surface->surface->events.commit,
+ &view->commit);
+ view->commit.notify = handle_commit;
view_focus(view);
}
{
struct view *view = wl_container_of(listener, view, unmap);
view->mapped = false;
+ wl_list_remove(&view->commit.link);
view_focus(next_toplevel(view));
}
#include "labwc.h"
#include "common/log.h"
+#include "common/bug-on.h"
static bool has_ssd(struct view *view)
{
return true;
}
+static void handle_commit(struct wl_listener *listener, void *data)
+{
+ struct view *view = wl_container_of(listener, view, commit);
+ BUG_ON(!view->surface);
+
+ /* Must receive commit signal before accessing surface->current* */
+ view->w = view->surface->current.width;
+ view->h = view->surface->current.height;
+}
+
void xwl_surface_map(struct wl_listener *listener, void *data)
{
struct view *view = wl_container_of(listener, view, map);
view_init_position(view);
}
view->been_mapped = true;
+
+ /*
+ * Add commit listener here, because xwayland map/unmap can change
+ * the wlr_surface
+ */
+ wl_signal_add(&view->xwayland_surface->surface->events.commit,
+ &view->commit);
+ view->commit.notify = handle_commit;
+
view_focus(view);
}
{
struct view *view = wl_container_of(listener, view, unmap);
view->mapped = false;
+ wl_list_remove(&view->commit.link);
/*
* Note that if 'view' is not a toplevel view, the 'front' toplevel view
* will be focussed on; but if 'view' is a toplevel view, the 'next'