diff --git a/include/ssd.h b/include/ssd.h index d26df066..111c9934 100644 --- a/include/ssd.h +++ b/include/ssd.h @@ -2,8 +2,7 @@ #ifndef __LABWC_SSD_H #define __LABWC_SSD_H -#include "buffer.h" -#include +#include #define BUTTON_COUNT 4 #define BUTTON_WIDTH 26 @@ -50,10 +49,10 @@ enum ssd_part_type { /* Forward declare arguments */ struct view; -struct wl_list; -struct wlr_box; +struct wlr_buffer; +struct wlr_scene; +struct wlr_scene_node; struct wlr_scene_tree; -struct scaled_font_buffer; struct border { int top; @@ -155,9 +154,10 @@ void ssd_update_button_hover(struct wlr_scene_node *node, struct ssd_hover_state *hover_state); /* Public SSD helpers */ -enum ssd_part_type ssd_at(struct view *view, double lx, double ly); -enum ssd_part_type ssd_get_part_type( - struct view *view, struct wlr_scene_node *node); +enum ssd_part_type ssd_at(const struct ssd *ssd, + struct wlr_scene *scene, double lx, double ly); +enum ssd_part_type ssd_get_part_type(const struct ssd *ssd, + struct wlr_scene_node *node); uint32_t ssd_resize_edges(enum ssd_part_type type); bool ssd_is_button(enum ssd_part_type type); bool ssd_part_contains(enum ssd_part_type whole, enum ssd_part_type candidate); @@ -189,17 +189,17 @@ struct ssd_part *ssd_get_part( void ssd_destroy_parts(struct wl_list *list); /* SSD internal */ -void ssd_titlebar_create(struct view *view); -void ssd_titlebar_update(struct view *view); -void ssd_titlebar_destroy(struct view *view); +void ssd_titlebar_create(struct ssd *ssd); +void ssd_titlebar_update(struct ssd *ssd); +void ssd_titlebar_destroy(struct ssd *ssd); -void ssd_border_create(struct view *view); -void ssd_border_update(struct view *view); -void ssd_border_destroy(struct view *view); +void ssd_border_create(struct ssd *ssd); +void ssd_border_update(struct ssd *ssd); +void ssd_border_destroy(struct ssd *ssd); -void ssd_extents_create(struct view *view); -void ssd_extents_update(struct view *view); -void ssd_extents_destroy(struct view *view); +void ssd_extents_create(struct ssd *ssd); +void ssd_extents_update(struct ssd *ssd); +void ssd_extents_destroy(struct ssd *ssd); /* TODO: clean up / update */ struct border ssd_thickness(struct view *view); diff --git a/src/action.c b/src/action.c index 4f3171e1..879f3e9b 100644 --- a/src/action.c +++ b/src/action.c @@ -161,8 +161,8 @@ show_menu(struct server *server, struct view *view, const char *menu_name) if (!view) { return; } - enum ssd_part_type type = ssd_at(view, server->seat.cursor->x, - server->seat.cursor->y); + enum ssd_part_type type = ssd_at(&view->ssd, server->scene, + server->seat.cursor->x, server->seat.cursor->y); if (type == LAB_SSD_BUTTON_WINDOW_MENU) { force_menu_top_left = true; } else if (ssd_part_contains(LAB_SSD_PART_TITLEBAR, type)) { diff --git a/src/desktop.c b/src/desktop.c index 5fca85b6..895c9011 100644 --- a/src/desktop.c +++ b/src/desktop.c @@ -339,7 +339,7 @@ get_cursor_context(struct server *server) case LAB_NODE_DESC_VIEW: case LAB_NODE_DESC_XDG_POPUP: ret.view = desc->data; - ret.type = ssd_get_part_type(ret.view, ret.node); + ret.type = ssd_get_part_type(&ret.view->ssd, ret.node); if (ret.type == LAB_SSD_CLIENT) { ret.surface = lab_wlr_surface_from_node(ret.node); } diff --git a/src/ssd/ssd.c b/src/ssd/ssd.c index adf86c07..7b87248f 100644 --- a/src/ssd/ssd.c +++ b/src/ssd/ssd.c @@ -54,50 +54,50 @@ ssd_is_button(enum ssd_part_type type) } enum ssd_part_type -ssd_get_part_type(struct view *view, struct wlr_scene_node *node) +ssd_get_part_type(const struct ssd *ssd, struct wlr_scene_node *node) { if (!node) { return LAB_SSD_NONE; } else if (node->type == WLR_SCENE_NODE_BUFFER && lab_wlr_surface_from_node(node)) { return LAB_SSD_CLIENT; - } else if (!view->ssd.tree) { + } else if (!ssd->tree) { return LAB_SSD_NONE; } - struct wl_list *part_list = NULL; + const struct wl_list *part_list = NULL; struct wlr_scene_tree *grandparent = node->parent ? node->parent->node.parent : NULL; struct wlr_scene_tree *greatgrandparent = grandparent ? grandparent->node.parent : NULL; /* active titlebar */ - if (node->parent == view->ssd.titlebar.active.tree) { - part_list = &view->ssd.titlebar.active.parts; - } else if (grandparent == view->ssd.titlebar.active.tree) { - part_list = &view->ssd.titlebar.active.parts; - } else if (greatgrandparent == view->ssd.titlebar.active.tree) { - part_list = &view->ssd.titlebar.active.parts; + if (node->parent == ssd->titlebar.active.tree) { + part_list = &ssd->titlebar.active.parts; + } else if (grandparent == ssd->titlebar.active.tree) { + part_list = &ssd->titlebar.active.parts; + } else if (greatgrandparent == ssd->titlebar.active.tree) { + part_list = &ssd->titlebar.active.parts; /* extents */ - } else if (node->parent == view->ssd.extents.tree) { - part_list = &view->ssd.extents.parts; + } else if (node->parent == ssd->extents.tree) { + part_list = &ssd->extents.parts; /* active border */ - } else if (node->parent == view->ssd.border.active.tree) { - part_list = &view->ssd.border.active.parts; + } else if (node->parent == ssd->border.active.tree) { + part_list = &ssd->border.active.parts; /* inactive titlebar */ - } else if (node->parent == view->ssd.titlebar.inactive.tree) { - part_list = &view->ssd.titlebar.inactive.parts; - } else if (grandparent == view->ssd.titlebar.inactive.tree) { - part_list = &view->ssd.titlebar.inactive.parts; - } else if (greatgrandparent == view->ssd.titlebar.inactive.tree) { - part_list = &view->ssd.titlebar.inactive.parts; + } else if (node->parent == ssd->titlebar.inactive.tree) { + part_list = &ssd->titlebar.inactive.parts; + } else if (grandparent == ssd->titlebar.inactive.tree) { + part_list = &ssd->titlebar.inactive.parts; + } else if (greatgrandparent == ssd->titlebar.inactive.tree) { + part_list = &ssd->titlebar.inactive.parts; /* inactive border */ - } else if (node->parent == view->ssd.border.inactive.tree) { - part_list = &view->ssd.border.inactive.parts; + } else if (node->parent == ssd->border.inactive.tree) { + part_list = &ssd->border.inactive.parts; } if (part_list) { @@ -112,12 +112,12 @@ ssd_get_part_type(struct view *view, struct wlr_scene_node *node) } enum ssd_part_type -ssd_at(struct view *view, double lx, double ly) +ssd_at(const struct ssd *ssd, struct wlr_scene *scene, double lx, double ly) { double sx, sy; struct wlr_scene_node *node = wlr_scene_node_at( - &view->server->scene->tree.node, lx, ly, &sx, &sy); - return ssd_get_part_type(view, node); + &scene->tree.node, lx, ly, &sx, &sy); + return ssd_get_part_type(ssd, node); } uint32_t @@ -148,52 +148,55 @@ ssd_resize_edges(enum ssd_part_type type) void ssd_create(struct view *view, bool active) { - assert(!view->ssd.tree); + struct ssd *ssd = &view->ssd; + assert(!ssd->tree); - view->ssd.tree = wlr_scene_tree_create(view->scene_tree); - wlr_scene_node_lower_to_bottom(&view->ssd.tree->node); - ssd_extents_create(view); - ssd_border_create(view); - ssd_titlebar_create(view); - view->ssd.margin = ssd_thickness(view); + ssd->tree = wlr_scene_tree_create(view->scene_tree); + wlr_scene_node_lower_to_bottom(&ssd->tree->node); + ssd_extents_create(ssd); + ssd_border_create(ssd); + ssd_titlebar_create(ssd); + ssd->margin = ssd_thickness(view); ssd_set_active(view, active); - view->ssd.state.width = view->w; - view->ssd.state.height = view->h; - view->ssd.state.x = view->x; - view->ssd.state.y = view->y; + ssd->state.width = view->w; + ssd->state.height = view->h; + ssd->state.x = view->x; + ssd->state.y = view->y; } void ssd_update_geometry(struct view *view) { - if (!view->ssd.tree) { + struct ssd *ssd = &view->ssd; + if (!ssd->tree) { return; } - if (view->w == view->ssd.state.width && view->h == view->ssd.state.height) { - if (view->x != view->ssd.state.x || view->y != view->ssd.state.y) { + if (view->w == ssd->state.width && view->h == ssd->state.height) { + if (view->x != ssd->state.x || view->y != ssd->state.y) { /* Dynamically resize extents based on position and usable_area */ - ssd_extents_update(view); - view->ssd.state.x = view->x; - view->ssd.state.y = view->y; + ssd_extents_update(ssd); + ssd->state.x = view->x; + ssd->state.y = view->y; } return; } - ssd_extents_update(view); - ssd_border_update(view); - ssd_titlebar_update(view); + ssd_extents_update(ssd); + ssd_border_update(ssd); + ssd_titlebar_update(ssd); - view->ssd.state.width = view->w; - view->ssd.state.height = view->h; - view->ssd.state.x = view->x; - view->ssd.state.y = view->y; + ssd->state.width = view->w; + ssd->state.height = view->h; + ssd->state.x = view->x; + ssd->state.y = view->y; } void ssd_destroy(struct view *view) { - if (!view->ssd.tree) { + struct ssd *ssd = &view->ssd; + if (!ssd->tree) { return; } @@ -206,12 +209,12 @@ ssd_destroy(struct view *view) } /* Destroy subcomponents */ - ssd_titlebar_destroy(view); - ssd_border_destroy(view); - ssd_extents_destroy(view); - wlr_scene_node_destroy(&view->ssd.tree->node); - view->ssd.tree = NULL; - view->ssd.margin = (struct border){ 0 }; + ssd_titlebar_destroy(ssd); + ssd_border_destroy(ssd); + ssd_extents_destroy(ssd); + wlr_scene_node_destroy(&ssd->tree->node); + ssd->tree = NULL; + ssd->margin = (struct border){ 0 }; } bool @@ -255,11 +258,12 @@ ssd_part_contains(enum ssd_part_type whole, enum ssd_part_type candidate) void ssd_set_active(struct view *view, bool active) { - if (!view->ssd.tree) { + struct ssd *ssd = &view->ssd; + if (!ssd->tree) { return; } - wlr_scene_node_set_enabled(&view->ssd.border.active.tree->node, active); - wlr_scene_node_set_enabled(&view->ssd.titlebar.active.tree->node, active); - wlr_scene_node_set_enabled(&view->ssd.border.inactive.tree->node, !active); - wlr_scene_node_set_enabled(&view->ssd.titlebar.inactive.tree->node, !active); + wlr_scene_node_set_enabled(&ssd->border.active.tree->node, active); + wlr_scene_node_set_enabled(&ssd->titlebar.active.tree->node, active); + wlr_scene_node_set_enabled(&ssd->border.inactive.tree->node, !active); + wlr_scene_node_set_enabled(&ssd->titlebar.inactive.tree->node, !active); } diff --git a/src/ssd/ssd_border.c b/src/ssd/ssd_border.c index e39f3e5f..b1ef3e85 100644 --- a/src/ssd/ssd_border.c +++ b/src/ssd/ssd_border.c @@ -6,13 +6,14 @@ #include "theme.h" #include "view.h" -#define FOR_EACH_STATE(view, tmp) FOR_EACH(tmp, \ - &(view)->ssd.border.active, \ - &(view)->ssd.border.inactive) +#define FOR_EACH_STATE(ssd, tmp) FOR_EACH(tmp, \ + &(ssd)->border.active, \ + &(ssd)->border.inactive) void -ssd_border_create(struct view *view) +ssd_border_create(struct ssd *ssd) { + struct view *view = wl_container_of(ssd, view, ssd); struct theme *theme = view->server->theme; int width = view->w; int height = view->h; @@ -22,11 +23,11 @@ ssd_border_create(struct view *view) struct wlr_scene_tree *parent; struct ssd_sub_tree *subtree; - FOR_EACH_STATE(view, subtree) { - subtree->tree = wlr_scene_tree_create(view->ssd.tree); + FOR_EACH_STATE(ssd, subtree) { + subtree->tree = wlr_scene_tree_create(ssd->tree); parent = subtree->tree; wlr_scene_node_set_position(&parent->node, -theme->border_width, 0); - if (subtree == &view->ssd.border.active) { + if (subtree == &ssd->border.active) { color = theme->window_active_border_color; } else { color = theme->window_inactive_border_color; @@ -48,8 +49,9 @@ ssd_border_create(struct view *view) } void -ssd_border_update(struct view *view) +ssd_border_update(struct ssd *ssd) { + struct view *view = wl_container_of(ssd, view, ssd); struct theme *theme = view->server->theme; int width = view->w; @@ -59,7 +61,7 @@ ssd_border_update(struct view *view) struct ssd_part *part; struct wlr_scene_rect *rect; struct ssd_sub_tree *subtree; - FOR_EACH_STATE(view, subtree) { + FOR_EACH_STATE(ssd, subtree) { wl_list_for_each(part, &subtree->parts, link) { rect = lab_wlr_scene_get_rect(part->node); switch (part->type) { @@ -92,14 +94,14 @@ ssd_border_update(struct view *view) } void -ssd_border_destroy(struct view *view) +ssd_border_destroy(struct ssd *ssd) { - if (!view->ssd.border.active.tree) { + if (!ssd->border.active.tree) { return; } struct ssd_sub_tree *subtree; - FOR_EACH_STATE(view, subtree) { + FOR_EACH_STATE(ssd, subtree) { ssd_destroy_parts(&subtree->parts); wlr_scene_node_destroy(&subtree->tree->node); subtree->tree = NULL; diff --git a/src/ssd/ssd_extents.c b/src/ssd/ssd_extents.c index 027086de..2d203609 100644 --- a/src/ssd/ssd_extents.c +++ b/src/ssd/ssd_extents.c @@ -35,19 +35,20 @@ lab_wlr_output_layout_layout_coords(struct wlr_output_layout *layout, } void -ssd_extents_create(struct view *view) +ssd_extents_create(struct ssd *ssd) { + struct view *view = wl_container_of(ssd, view, ssd); struct theme *theme = view->server->theme; - struct wl_list *part_list = &view->ssd.extents.parts; + struct wl_list *part_list = &ssd->extents.parts; int extended_area = EXTENDED_AREA; int corner_size = extended_area + theme->border_width + BUTTON_WIDTH / 2; - view->ssd.extents.tree = wlr_scene_tree_create(view->ssd.tree); - struct wlr_scene_tree *parent = view->ssd.extents.tree; + ssd->extents.tree = wlr_scene_tree_create(ssd->tree); + struct wlr_scene_tree *parent = ssd->extents.tree; if (view->maximized || view->fullscreen) { wlr_scene_node_set_enabled(&parent->node, false); } - wl_list_init(&view->ssd.extents.parts); + wl_list_init(&ssd->extents.parts); wlr_scene_node_set_position(&parent->node, -(theme->border_width + extended_area), -(theme->title_height + theme->border_width + extended_area)); @@ -91,18 +92,19 @@ ssd_extents_create(struct view *view) p->geometry->height = corner_size; /* Initial manual update to keep X11 applications happy */ - ssd_extents_update(view); + ssd_extents_update(ssd); } void -ssd_extents_update(struct view *view) +ssd_extents_update(struct ssd *ssd) { + struct view *view = wl_container_of(ssd, view, ssd); if (view->maximized || view->fullscreen) { - wlr_scene_node_set_enabled(&view->ssd.extents.tree->node, false); + wlr_scene_node_set_enabled(&ssd->extents.tree->node, false); return; } - if (!view->ssd.extents.tree->node.enabled) { - wlr_scene_node_set_enabled(&view->ssd.extents.tree->node, true); + if (!ssd->extents.tree->node.enabled) { + wlr_scene_node_set_enabled(&ssd->extents.tree->node, true); } if (!view->output) { @@ -133,10 +135,10 @@ ssd_extents_update(struct view *view) /* Remember base layout coordinates */ int base_x, base_y; - wlr_scene_node_coords(&view->ssd.extents.tree->node, &base_x, &base_y); + wlr_scene_node_coords(&ssd->extents.tree->node, &base_x, &base_y); struct wlr_box *target; - wl_list_for_each(part, &view->ssd.extents.parts, link) { + wl_list_for_each(part, &ssd->extents.parts, link) { rect = lab_wlr_scene_get_rect(part->node); target = part->geometry; switch (part->type) { @@ -206,13 +208,13 @@ ssd_extents_update(struct view *view) } void -ssd_extents_destroy(struct view *view) +ssd_extents_destroy(struct ssd *ssd) { - if (!view->ssd.extents.tree) { + if (!ssd->extents.tree) { return; } - ssd_destroy_parts(&view->ssd.extents.parts); - wlr_scene_node_destroy(&view->ssd.extents.tree->node); - view->ssd.extents.tree = NULL; + ssd_destroy_parts(&ssd->extents.parts); + wlr_scene_node_destroy(&ssd->extents.tree->node); + ssd->extents.tree = NULL; } diff --git a/src/ssd/ssd_titlebar.c b/src/ssd/ssd_titlebar.c index 983a3718..15bb2c07 100644 --- a/src/ssd/ssd_titlebar.c +++ b/src/ssd/ssd_titlebar.c @@ -3,6 +3,7 @@ #define _POSIX_C_SOURCE 200809L #include #include +#include "buffer.h" #include "common/mem.h" #include "common/scaled_font_buffer.h" #include "common/scene-helpers.h" @@ -12,13 +13,14 @@ #include "theme.h" #include "view.h" -#define FOR_EACH_STATE(view, tmp) FOR_EACH(tmp, \ - &(view)->ssd.titlebar.active, \ - &(view)->ssd.titlebar.inactive) +#define FOR_EACH_STATE(ssd, tmp) FOR_EACH(tmp, \ + &(ssd)->titlebar.active, \ + &(ssd)->titlebar.inactive) void -ssd_titlebar_create(struct view *view) +ssd_titlebar_create(struct ssd *ssd) { + struct view *view = wl_container_of(ssd, view, ssd); struct theme *theme = view->server->theme; int width = view->w; @@ -33,11 +35,11 @@ ssd_titlebar_create(struct view *view) struct wlr_buffer *close_button_unpressed; struct ssd_sub_tree *subtree; - FOR_EACH_STATE(view, subtree) { - subtree->tree = wlr_scene_tree_create(view->ssd.tree); + FOR_EACH_STATE(ssd, subtree) { + subtree->tree = wlr_scene_tree_create(ssd->tree); parent = subtree->tree; wlr_scene_node_set_position(&parent->node, 0, -theme->title_height); - if (subtree == &view->ssd.titlebar.active) { + if (subtree == &ssd->titlebar.active) { color = theme->window_active_title_bg_color; corner_top_left = &theme->corner_top_left_active_normal->base; corner_top_right = &theme->corner_top_right_active_normal->base; @@ -86,17 +88,18 @@ is_direct_child(struct wlr_scene_node *node, struct ssd_sub_tree *subtree) } void -ssd_titlebar_update(struct view *view) +ssd_titlebar_update(struct ssd *ssd) { + struct view *view = wl_container_of(ssd, view, ssd); int width = view->w; - if (width == view->ssd.state.width) { + if (width == ssd->state.width) { return; } struct theme *theme = view->server->theme; struct ssd_part *part; struct ssd_sub_tree *subtree; - FOR_EACH_STATE(view, subtree) { + FOR_EACH_STATE(ssd, subtree) { wl_list_for_each(part, &subtree->parts, link) { switch (part->type) { case LAB_SSD_PART_TITLEBAR: @@ -132,22 +135,22 @@ ssd_titlebar_update(struct view *view) } void -ssd_titlebar_destroy(struct view *view) +ssd_titlebar_destroy(struct ssd *ssd) { - if (!view->ssd.titlebar.active.tree) { + if (!ssd->titlebar.active.tree) { return; } struct ssd_sub_tree *subtree; - FOR_EACH_STATE(view, subtree) { + FOR_EACH_STATE(ssd, subtree) { ssd_destroy_parts(&subtree->parts); wlr_scene_node_destroy(&subtree->tree->node); subtree->tree = NULL; } FOR_EACH_END - if (view->ssd.state.title.text) { - free(view->ssd.state.title.text); - view->ssd.state.title.text = NULL; + if (ssd->state.title.text) { + free(ssd->state.title.text); + ssd->state.title.text = NULL; } } @@ -164,8 +167,9 @@ ssd_titlebar_destroy(struct view *view) */ static void -ssd_update_title_positions(struct view *view) +ssd_update_title_positions(struct ssd *ssd) { + struct view *view = wl_container_of(ssd, view, ssd); struct theme *theme = view->server->theme; int width = view->w; int title_bg_width = width - BUTTON_WIDTH * BUTTON_COUNT; @@ -174,7 +178,7 @@ ssd_update_title_positions(struct view *view) int buffer_height, buffer_width; struct ssd_part *part; struct ssd_sub_tree *subtree; - FOR_EACH_STATE(view, subtree) { + FOR_EACH_STATE(ssd, subtree) { part = ssd_get_part(&subtree->parts, LAB_SSD_PART_TITLE); if (!part || !part->node) { /* view->surface never been mapped */ @@ -217,7 +221,8 @@ ssd_update_title_positions(struct view *view) void ssd_update_title(struct view *view) { - if (!view->ssd.tree) { + struct ssd *ssd = &view->ssd; + if (!ssd->tree) { return; } @@ -227,7 +232,7 @@ ssd_update_title(struct view *view) } struct theme *theme = view->server->theme; - struct ssd_state_title *state = &view->ssd.state.title; + struct ssd_state_title *state = &ssd->state.title; bool title_unchanged = state->text && !strcmp(title, state->text); float *text_color; @@ -236,8 +241,8 @@ ssd_update_title(struct view *view) struct ssd_state_title_width *dstate; int title_bg_width = view->w - BUTTON_WIDTH * BUTTON_COUNT; - FOR_EACH_STATE(view, subtree) { - if (subtree == &view->ssd.titlebar.active) { + FOR_EACH_STATE(ssd, subtree) { + if (subtree == &ssd->titlebar.active) { dstate = &state->active; text_color = theme->window_active_label_text_color; } else { @@ -287,7 +292,7 @@ ssd_update_title(struct view *view) } state->text = xstrdup(title); } - ssd_update_title_positions(view); + ssd_update_title_positions(ssd); } void diff --git a/src/view.c b/src/view.c index d5d4834e..97064508 100644 --- a/src/view.c +++ b/src/view.c @@ -87,11 +87,13 @@ view_get_edge_snap_box(struct view *view, struct output *output, base_height = usable.height - 2 * rc.gap; break; } + + struct border margin = view->ssd.margin; struct wlr_box dst = { - .x = x_offset + usable.x + view->ssd.margin.left, - .y = y_offset + usable.y + view->ssd.margin.top, - .width = base_width - view->ssd.margin.left - view->ssd.margin.right, - .height = base_height - view->ssd.margin.top - view->ssd.margin.bottom, + .x = x_offset + usable.x + margin.left, + .y = y_offset + usable.y + margin.top, + .width = base_width - margin.left - margin.right, + .height = base_height - margin.top - margin.bottom, }; return dst; @@ -276,9 +278,10 @@ view_compute_centered_position(struct view *view, int w, int h, int *x, int *y) return false; } + struct border margin = view->ssd.margin; struct wlr_box usable = output_usable_area_in_layout_coords(output); - int width = w + view->ssd.margin.left + view->ssd.margin.right; - int height = h + view->ssd.margin.top + view->ssd.margin.bottom; + int width = w + margin.left + margin.right; + int height = h + margin.top + margin.bottom; *x = usable.x + (usable.width - width) / 2; *y = usable.y + (usable.height - height) / 2; @@ -293,8 +296,8 @@ view_compute_centered_position(struct view *view, int w, int h, int *x, int *y) #if HAVE_XWAYLAND /* TODO: refactor xwayland.c functions to get rid of this */ if (view->type == LAB_XWAYLAND_VIEW) { - *x += view->ssd.margin.left; - *y += view->ssd.margin.top; + *x += margin.left; + *y += margin.top; } #endif @@ -726,6 +729,8 @@ view_move_to_edge(struct view *view, const char *direction) wlr_log(WLR_ERROR, "invalid edge"); return; } + + struct border margin = view->ssd.margin; struct wlr_box usable = output_usable_area_in_layout_coords(output); if (usable.height == output->wlr_output->height && output->wlr_output->scale != 1) { @@ -738,18 +743,18 @@ view_move_to_edge(struct view *view, const char *direction) int x = 0, y = 0; if (!strcasecmp(direction, "left")) { - x = usable.x + view->ssd.margin.left + rc.gap; + x = usable.x + margin.left + rc.gap; y = view->y; } else if (!strcasecmp(direction, "up")) { x = view->x; - y = usable.y + view->ssd.margin.top + rc.gap; + y = usable.y + margin.top + rc.gap; } else if (!strcasecmp(direction, "right")) { - x = usable.x + usable.width - view->w - view->ssd.margin.right + x = usable.x + usable.width - view->w - margin.right - rc.gap; y = view->y; } else if (!strcasecmp(direction, "down")) { x = view->x; - y = usable.y + usable.height - view->h - view->ssd.margin.bottom + y = usable.y + usable.height - view->h - margin.bottom - rc.gap; } else { wlr_log(WLR_ERROR, "invalid edge"); diff --git a/src/workspaces.c b/src/workspaces.c index 20abf011..d7036b8d 100644 --- a/src/workspaces.c +++ b/src/workspaces.c @@ -7,12 +7,12 @@ #include #include #include +#include "buffer.h" #include "common/font.h" #include "common/graphic-helpers.h" #include "common/list.h" #include "common/mem.h" #include "labwc.h" -#include "view.h" #include "workspaces.h" /* Internal helpers */