ssd_update_geometry(struct view *view)
{
/* TODO: verify we are not called without reason. like in commit handlers */
- if (!view->ssd.tree || !view->surface) {
+ if (!view->ssd.tree || !view->scene_node) {
return;
}
wlr_scene_node_set_enabled(&view->ssd.tree->node, false);
}
- int width = view->surface->current.width;
- int height = view->surface->current.height;
+ int width = view->w;
+ int height = view->h;
if (width == view->ssd.state.width && height == view->ssd.state.height) {
return;
}
ssd_border_create(struct view *view)
{
struct theme *theme = view->server->theme;
- int width = view->surface->current.width;
- int height = view->surface->current.height;
+ int width = view->w;
+ int height = view->h;
int full_width = width + 2 * theme->border_width;
float *color;
{
struct theme *theme = view->server->theme;
- int width = view->surface->current.width;
- int height = view->surface->current.height;
+ int width = view->w;
+ int height = view->h;
int full_width = width + 2 * theme->border_width;
struct ssd_part *part;
struct theme *theme = view->server->theme;
float invisible[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
struct wl_list *part_list = &view->ssd.extents.parts;
- int width = view->surface->current.width;
- int height = view->surface->current.height;
+ int width = view->w;
+ int height = view->h;
int full_height = height + theme->border_width + SSD_HEIGHT;
int full_width = width + 2 * theme->border_width;
int extended_area = EXTENDED_AREA;
{
struct theme *theme = view->server->theme;
- int width = view->surface->current.width;
- int height = view->surface->current.height;
+ int width = view->w;
+ int height = view->h;
int full_height = height + theme->border_width + SSD_HEIGHT;
int full_width = width + 2 * theme->border_width;
int extended_area = EXTENDED_AREA;
struct wlr_scene_node *parent, int width, int height,
int x, int y, float color[4])
{
+ /*
+ * When initialized without surface being mapped,
+ * size may be negative. Just set to 0, next call
+ * to ssd_*_update() will update the rect to use
+ * its correct size.
+ */
+ width = width >= 0 ? width : 0;
+ height = height >= 0 ? height : 0;
+
struct ssd_part *part = add_scene_part(list, type);
part->node = &wlr_scene_rect_create(
parent, width, height, color)->node;
ssd_titlebar_create(struct view *view)
{
struct theme *theme = view->server->theme;
- int width = view->surface->current.width;
+ int width = view->w;
int full_width = width + 2 * theme->border_width;
float *color;
void
ssd_titlebar_update(struct view *view)
{
- int width = view->surface->current.width;
+ int width = view->w;
if (width == view->ssd.state.width) {
return;
}
ssd_update_title_positions(struct view *view)
{
struct theme *theme = view->server->theme;
- int width = view->surface->current.width;
+ int width = view->w;
int full_width = width + 2 * view->server->theme->border_width;
int x, y;
FOR_EACH_STATE(view, subtree) {
part = ssd_get_part(&subtree->parts, LAB_SSD_PART_TITLE);
if (!part) {
- wlr_log(WLR_ERROR,
- "Failed to position SSD title: title node not found");
+ /* view->surface never been mapped */
continue;
}
y = (SSD_HEIGHT - part->buffer->base.height) / 2;
rect = lab_wlr_scene_get_rect(part->node->parent);
if (rect->width <= 0) {
- wlr_log(WLR_ERROR,
- "Failed to position SSD title: not enough screen space");
wlr_scene_node_set_position(part->node, x, y);
continue;
}
struct ssd_state_title_width *dstate;
FOR_EACH_STATE(view, subtree) {
parent_part = ssd_get_part(&subtree->parts, LAB_SSD_PART_TITLEBAR);
- if (!parent_part) {
- wlr_log(WLR_ERROR,
- "Failed to update SSD title: parent node not found");
- continue;
- }
- rect = lab_wlr_scene_get_rect(parent_part->node);
- if (rect->width <= 0) {
- wlr_log(WLR_ERROR,
- "Failed to update SSD title: not enough screen space");
- continue;
- }
+ assert(parent_part);
+
if (subtree == &view->ssd.titlebar.active) {
dstate = &state->active;
text_color = theme->window_active_label_text_color;
dstate = &state->inactive;
text_color = theme->window_inactive_label_text_color;
}
+
+ rect = lab_wlr_scene_get_rect(parent_part->node);
+ if (rect->width <= 0) {
+ dstate->truncated = true;
+ continue;
+ }
+
if (title_unchanged
&& !dstate->truncated && dstate->width < rect->width) {
/* title the same + we don't need to resize title */
continue;
}
+
part = ssd_get_part(&subtree->parts, LAB_SSD_PART_TITLE);
if (!part) {
part = add_scene_part(&subtree->parts, LAB_SSD_PART_TITLE);