aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/view.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-04-30 21:24:13 +1000
committerLibravatar Drew DeVault <sir@cmpwn.com>2018-05-01 07:46:57 -0400
commit630ba30e3c60cfe3f1018b4a1701f0c2a0f6da9a (patch)
treeda0aa984dd39f3501c4d9facd5c6a2f340ab2da4 /sway/tree/view.c
parentMerge pull request #1876 from RyanDwyer/view-unmap-segfault (diff)
downloadsway-630ba30e3c60cfe3f1018b4a1701f0c2a0f6da9a.tar.gz
sway-630ba30e3c60cfe3f1018b4a1701f0c2a0f6da9a.tar.zst
sway-630ba30e3c60cfe3f1018b4a1701f0c2a0f6da9a.zip
Implement borders
Implements rendering of borders. Title text is still to do. Implements the following configuration directives: * client.focused * client.focused_inactive * client.unfocused * client.urgent * border * default_border
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r--sway/tree/view.c60
1 files changed, 49 insertions, 11 deletions
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 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <wayland-server.h> 2#include <wayland-server.h>
3#include <wlr/render/wlr_renderer.h>
3#include <wlr/types/wlr_output_layout.h> 4#include <wlr/types/wlr_output_layout.h>
4#include "log.h" 5#include "log.h"
5#include "sway/criteria.h" 6#include "sway/criteria.h"
@@ -73,6 +74,51 @@ void view_configure(struct sway_view *view, double ox, double oy, int width,
73 } 74 }
74} 75}
75 76
77/**
78 * Configure the view's position and size based on the swayc's position and
79 * size, taking borders into consideration.
80 */
81void view_autoconfigure(struct sway_view *view) {
82 if (!sway_assert(view->swayc,
83 "Called view_autoconfigure() on a view without a swayc")) {
84 return;
85 }
86
87 if (view->is_fullscreen) {
88 struct sway_container *output = container_parent(view->swayc, C_OUTPUT);
89 view_configure(view, 0, 0, output->width, output->height);
90 view->x = view->y = 0;
91 return;
92 }
93
94 double x, y, width, height;
95 switch (view->border) {
96 case B_NONE:
97 x = view->swayc->x;
98 y = view->swayc->y;
99 width = view->swayc->width;
100 height = view->swayc->height;
101 break;
102 case B_PIXEL:
103 x = view->swayc->x + view->border_thickness;
104 y = view->swayc->y + view->border_thickness;
105 width = view->swayc->width - view->border_thickness * 2;
106 height = view->swayc->height - view->border_thickness * 2;
107 break;
108 case B_NORMAL:
109 // TODO: Size the title bar by checking the font
110 x = view->swayc->x + view->border_thickness;
111 y = view->swayc->y + 20;
112 width = view->swayc->width - view->border_thickness * 2;
113 height = view->swayc->height - view->border_thickness - 20;
114 break;
115 }
116
117 view->x = x;
118 view->y = y;
119 view_configure(view, x, y, width, height);
120}
121
76void view_set_activated(struct sway_view *view, bool activated) { 122void view_set_activated(struct sway_view *view, bool activated) {
77 if (view->impl->set_activated) { 123 if (view->impl->set_activated) {
78 view->impl->set_activated(view, activated); 124 view->impl->set_activated(view, activated);
@@ -262,6 +308,8 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) {
262 308
263 view->surface = wlr_surface; 309 view->surface = wlr_surface;
264 view->swayc = cont; 310 view->swayc = cont;
311 view->border = config->border;
312 view->border_thickness = config->border_thickness;
265 313
266 view_init_subsurfaces(view, wlr_surface); 314 view_init_subsurfaces(view, wlr_surface);
267 wl_signal_add(&wlr_surface->events.new_subsurface, 315 wl_signal_add(&wlr_surface->events.new_subsurface,
@@ -309,23 +357,13 @@ void view_unmap(struct sway_view *view) {
309 } 357 }
310} 358}
311 359
312void view_update_position(struct sway_view *view, double ox, double oy) {
313 if (view->swayc->x == ox && view->swayc->y == oy) {
314 return;
315 }
316
317 view_damage(view, true);
318 view->swayc->x = ox;
319 view->swayc->y = oy;
320 view_damage(view, true);
321}
322
323void view_update_size(struct sway_view *view, int width, int height) { 360void view_update_size(struct sway_view *view, int width, int height) {
324 if (view->width == width && view->height == height) { 361 if (view->width == width && view->height == height) {
325 return; 362 return;
326 } 363 }
327 364
328 view_damage(view, true); 365 view_damage(view, true);
366 // Should we update the swayc width/height here too?
329 view->width = width; 367 view->width = width;
330 view->height = height; 368 view->height = height;
331 view_damage(view, true); 369 view_damage(view, true);