aboutsummaryrefslogtreecommitdiff
path: root/sway/tree/container.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r--sway/tree/container.c37
1 files changed, 31 insertions, 6 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 9b671c1d..a069b177 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -593,7 +593,7 @@ void container_update_representation(struct sway_container *con) {
}
}
-size_t container_titlebar_height() {
+size_t container_titlebar_height(void) {
return config->font_height + TITLEBAR_V_PADDING * 2;
}
@@ -829,9 +829,16 @@ void container_floating_move_to_center(struct sway_container *con) {
return;
}
struct sway_workspace *ws = con->workspace;
+ bool full = con->is_fullscreen;
+ if (full) {
+ container_set_fullscreen(con, false);
+ }
double new_lx = ws->x + (ws->width - con->width) / 2;
double new_ly = ws->y + (ws->height - con->height) / 2;
container_floating_translate(con, new_lx - con->x, new_ly - con->y);
+ if (full) {
+ container_set_fullscreen(con, true);
+ }
}
static bool find_urgent_iterator(struct sway_container *con, void *data) {
@@ -1020,15 +1027,33 @@ void container_add_gaps(struct sway_container *c) {
if (!c->view && c->layout != L_TABBED && c->layout != L_STACKED) {
return;
}
- // Children of tabbed/stacked containers re-use the gaps of the container
- enum sway_container_layout layout = container_parent_layout(c);
- if (layout == L_TABBED || layout == L_STACKED) {
- return;
+ // Descendants of tabbed/stacked containers re-use the gaps of the container
+ struct sway_container *temp = c;
+ while (temp) {
+ enum sway_container_layout layout = container_parent_layout(temp);
+ if (layout == L_TABBED || layout == L_STACKED) {
+ return;
+ }
+ temp = temp->parent;
+ }
+ // If smart gaps is on, don't add gaps if there is only one view visible
+ if (config->smart_gaps) {
+ struct sway_view *view = c->view;
+ if (!view) {
+ struct sway_seat *seat =
+ input_manager_get_default_seat(input_manager);
+ struct sway_container *focus =
+ seat_get_focus_inactive_view(seat, &c->node);
+ view = focus ? focus->view : NULL;
+ }
+ if (view && view_is_only_visible(view)) {
+ return;
+ }
}
struct sway_workspace *ws = c->workspace;
- c->current_gaps = ws->has_gaps ? ws->gaps_inner : config->gaps_inner;
+ c->current_gaps = ws->gaps_inner;
c->x += c->current_gaps;
c->y += c->current_gaps;
c->width -= 2 * c->current_gaps;