diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-04-30 21:24:13 +1000 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2018-05-01 07:46:57 -0400 |
commit | 630ba30e3c60cfe3f1018b4a1701f0c2a0f6da9a (patch) | |
tree | da0aa984dd39f3501c4d9facd5c6a2f340ab2da4 /sway/tree | |
parent | Merge pull request #1876 from RyanDwyer/view-unmap-segfault (diff) | |
download | sway-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')
-rw-r--r-- | sway/tree/arrange.c | 10 | ||||
-rw-r--r-- | sway/tree/view.c | 60 |
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) { | |||
174 | } | 174 | } |
175 | if (workspace->sway_workspace->fullscreen) { | 175 | if (workspace->sway_workspace->fullscreen) { |
176 | // Just arrange the fullscreen view and jump out | 176 | // Just arrange the fullscreen view and jump out |
177 | struct sway_container *view = | 177 | view_autoconfigure(workspace->sway_workspace->fullscreen); |
178 | workspace->sway_workspace->fullscreen->swayc; | ||
179 | view_configure(view->sway_view, 0, 0, | ||
180 | workspace->parent->width, workspace->parent->height); | ||
181 | view->width = workspace->parent->width; | ||
182 | view->height = workspace->parent->height; | ||
183 | return; | 178 | return; |
184 | } | 179 | } |
185 | 180 | ||
@@ -204,8 +199,7 @@ void arrange_children_of(struct sway_container *parent) { | |||
204 | for (int i = 0; i < parent->children->length; ++i) { | 199 | for (int i = 0; i < parent->children->length; ++i) { |
205 | struct sway_container *child = parent->children->items[i]; | 200 | struct sway_container *child = parent->children->items[i]; |
206 | if (child->type == C_VIEW) { | 201 | if (child->type == C_VIEW) { |
207 | view_configure(child->sway_view, child->x, child->y, | 202 | view_autoconfigure(child->sway_view); |
208 | child->width, child->height); | ||
209 | } else { | 203 | } else { |
210 | arrange_children_of(child); | 204 | arrange_children_of(child); |
211 | } | 205 | } |
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 | */ | ||
81 | void 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 | |||
76 | void view_set_activated(struct sway_view *view, bool activated) { | 122 | void 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 | ||
312 | void 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 | |||
323 | void view_update_size(struct sway_view *view, int width, int height) { | 360 | void 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); |