aboutsummaryrefslogtreecommitdiff
path: root/sway/tree
diff options
context:
space:
mode:
Diffstat (limited to 'sway/tree')
-rw-r--r--sway/tree/arrange.c10
-rw-r--r--sway/tree/view.c60
2 files changed, 51 insertions, 19 deletions
diff --git a/sway/tree/arrange.c b/sway/tree/arrange.c
index e1f3ad13..83bb20fb 100644
--- a/sway/tree/arrange.c
+++ b/sway/tree/arrange.c
@@ -174,12 +174,7 @@ void arrange_children_of(struct sway_container *parent) {
}
if (workspace->sway_workspace->fullscreen) {
// Just arrange the fullscreen view and jump out
- struct sway_container *view =
- workspace->sway_workspace->fullscreen->swayc;
- view_configure(view->sway_view, 0, 0,
- workspace->parent->width, workspace->parent->height);
- view->width = workspace->parent->width;
- view->height = workspace->parent->height;
+ view_autoconfigure(workspace->sway_workspace->fullscreen);
return;
}
@@ -204,8 +199,7 @@ void arrange_children_of(struct sway_container *parent) {
for (int i = 0; i < parent->children->length; ++i) {
struct sway_container *child = parent->children->items[i];
if (child->type == C_VIEW) {
- view_configure(child->sway_view, child->x, child->y,
- child->width, child->height);
+ view_autoconfigure(child->sway_view);
} else {
arrange_children_of(child);
}
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 519c3c78..26902c23 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <wayland-server.h>
+#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_output_layout.h>
#include "log.h"
#include "sway/criteria.h"
@@ -73,6 +74,51 @@ void view_configure(struct sway_view *view, double ox, double oy, int width,
}
}
+/**
+ * Configure the view's position and size based on the swayc's position and
+ * size, taking borders into consideration.
+ */
+void view_autoconfigure(struct sway_view *view) {
+ if (!sway_assert(view->swayc,
+ "Called view_autoconfigure() on a view without a swayc")) {
+ return;
+ }
+
+ if (view->is_fullscreen) {
+ struct sway_container *output = container_parent(view->swayc, C_OUTPUT);
+ view_configure(view, 0, 0, output->width, output->height);
+ view->x = view->y = 0;
+ return;
+ }
+
+ double x, y, width, height;
+ switch (view->border) {
+ case B_NONE:
+ x = view->swayc->x;
+ y = view->swayc->y;
+ width = view->swayc->width;
+ height = view->swayc->height;
+ break;
+ case B_PIXEL:
+ x = view->swayc->x + view->border_thickness;
+ y = view->swayc->y + view->border_thickness;
+ width = view->swayc->width - view->border_thickness * 2;
+ height = view->swayc->height - view->border_thickness * 2;
+ break;
+ case B_NORMAL:
+ // TODO: Size the title bar by checking the font
+ x = view->swayc->x + view->border_thickness;
+ y = view->swayc->y + 20;
+ width = view->swayc->width - view->border_thickness * 2;
+ height = view->swayc->height - view->border_thickness - 20;
+ break;
+ }
+
+ view->x = x;
+ view->y = y;
+ view_configure(view, x, y, width, height);
+}
+
void view_set_activated(struct sway_view *view, bool activated) {
if (view->impl->set_activated) {
view->impl->set_activated(view, activated);
@@ -262,6 +308,8 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) {
view->surface = wlr_surface;
view->swayc = cont;
+ view->border = config->border;
+ view->border_thickness = config->border_thickness;
view_init_subsurfaces(view, wlr_surface);
wl_signal_add(&wlr_surface->events.new_subsurface,
@@ -309,23 +357,13 @@ void view_unmap(struct sway_view *view) {
}
}
-void view_update_position(struct sway_view *view, double ox, double oy) {
- if (view->swayc->x == ox && view->swayc->y == oy) {
- return;
- }
-
- view_damage(view, true);
- view->swayc->x = ox;
- view->swayc->y = oy;
- view_damage(view, true);
-}
-
void view_update_size(struct sway_view *view, int width, int height) {
if (view->width == width && view->height == height) {
return;
}
view_damage(view, true);
+ // Should we update the swayc width/height here too?
view->width = width;
view->height = height;
view_damage(view, true);