aboutsummaryrefslogtreecommitdiff
path: root/sway/tree
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2018-05-01 15:31:02 +0100
committerGitHub <noreply@github.com>2018-05-01 15:31:02 +0100
commit0e51c7be449dd68025d5acd8c634f8dcacb10a16 (patch)
treec2c7e713a150c7f9a947b100e0fa4c56efb5c3b2 /sway/tree
parentbf0603cd2d905554cc57d121b56b6708bb1d382b (diff)
parentcb07434913b89580a4025824cb181733b2db1eb7 (diff)
downloadsway-0e51c7be449dd68025d5acd8c634f8dcacb10a16.tar.xz
Merge pull request #1874 from RyanDwyer/borders
Implement borders
Diffstat (limited to 'sway/tree')
-rw-r--r--sway/tree/arrange.c10
-rw-r--r--sway/tree/container.c14
-rw-r--r--sway/tree/view.c47
3 files changed, 61 insertions, 10 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/container.c b/sway/tree/container.c
index 03d7e49c..995da5ce 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -423,8 +423,8 @@ struct sway_container *container_at(struct sway_container *parent,
soutput->sway_output->wlr_output);
double ox = lx - output_box->x;
double oy = ly - output_box->y;
- double view_sx = ox - swayc->x;
- double view_sy = oy - swayc->y;
+ double view_sx = ox - sview->x;
+ double view_sy = oy - sview->y;
double _sx, _sy;
struct wlr_surface *_surface;
@@ -455,6 +455,16 @@ struct sway_container *container_at(struct sway_container *parent,
*surface = _surface;
return swayc;
}
+ // Check the view's decorations
+ struct wlr_box swayc_box = {
+ .x = swayc->x,
+ .y = swayc->y,
+ .width = swayc->width,
+ .height = swayc->height,
+ };
+ if (wlr_box_contains_point(&swayc_box, ox, oy)) {
+ return swayc;
+ }
} else {
list_cat(queue, swayc->children);
}
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 519c3c78..05a9b277 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,47 @@ void view_configure(struct sway_view *view, double ox, double oy, int width,
}
}
+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 +304,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,
@@ -314,6 +358,8 @@ void view_update_position(struct sway_view *view, double ox, double oy) {
return;
}
+ // TODO: Only allow this if the view is floating (this function will only be
+ // called in response to wayland clients wanting to reposition themselves).
view_damage(view, true);
view->swayc->x = ox;
view->swayc->y = oy;
@@ -326,6 +372,7 @@ void view_update_size(struct sway_view *view, int width, int height) {
}
view_damage(view, true);
+ // Should we update the swayc width/height here too?
view->width = width;
view->height = height;
view_damage(view, true);