aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/view.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-08-26 10:16:49 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-08-28 23:50:41 +1000
commitf5b9815128b6c000bb5d47c339480fa481a5e99d (patch)
tree24b533a7579dde0f65392afbba5f3982fe5e79c6 /sway/tree/view.c
parentMerge pull request #2523 from RedSoxFan/fix-floating-drag-outputs (diff)
downloadsway-f5b9815128b6c000bb5d47c339480fa481a5e99d.tar.gz
sway-f5b9815128b6c000bb5d47c339480fa481a5e99d.tar.zst
sway-f5b9815128b6c000bb5d47c339480fa481a5e99d.zip
Prepare arrange code for type safe arguments
This commit changes the arrange code in a way that will support type safe arguments. The arrange_output et al functions are now public, however I opted not to use them directly yet. I've kept the generic arrange_windows there for convenience until type safety is fully implemented. This means this patch has much less risk of breaking things as it would otherwise. To be type safe, arrange_children_of cannot exist in its previous form because the thing passed to it could be either a workspace or a container. So it's now renamed to arrange_children and accepts a list_t, as well as the parent layout and parent's box. There was some code which checked the grandparent's layout to see if it was tabbed or stacked and adjusted the Y offset of the grandchild accordingly. Accessing the grandparent layout isn't easy when using type safe arguments, and it seemed odd to even need to do this. I determined that this was needed because a child of a tabbed container would have a swayc Y matching the top of the tab bar. I've changed this so a child of a tabbed container will have a swayc Y matching the bottom of the tab bar, which means we don't need to access the grandparent layout. Some tweaks to the rendering and autoconfigure code have been made to implement this, and the container_at code appears to work without needing any changes. arrange_children_of (now arrange_children) would check if the parent had gaps and would copy them to the child, effectively making the workspace's gaps recurse into all children. We can't do this any more without passing has_gaps, gaps_inner and gaps_outer as arguments to arrange_children, so I've changed the add_gaps function to retrieve it from the workspace directly. apply_tabbed_or_stacked_layout has been split into two functions, as it had different logic depending on the layout. Lastly, arrange.h had an unnecessary include of transaction.h. I've removed it, which means I've had to add it to several other files.
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r--sway/tree/view.c35
1 files changed, 14 insertions, 21 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 2870d4f5..1a98c5f2 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -13,6 +13,7 @@
13#include "log.h" 13#include "log.h"
14#include "sway/criteria.h" 14#include "sway/criteria.h"
15#include "sway/commands.h" 15#include "sway/commands.h"
16#include "sway/desktop/transaction.h"
16#include "sway/ipc-server.h" 17#include "sway/ipc-server.h"
17#include "sway/output.h" 18#include "sway/output.h"
18#include "sway/input/seat.h" 19#include "sway/input/seat.h"
@@ -224,15 +225,13 @@ void view_autoconfigure(struct sway_view *view) {
224 x = y = width = height = 0; 225 x = y = width = height = 0;
225 double y_offset = 0; 226 double y_offset = 0;
226 227
227 // In a tabbed or stacked container, the swayc's y is the top of the title 228 // In a tabbed or stacked container, the swayc's y is the bottom of the
228 // area. We have to offset the surface y by the height of the title bar, and 229 // title area. We have to disable any top border because the title bar is
229 // disable any top border because we'll always have the title bar. 230 // rendered by the parent.
230 if (con->parent->layout == L_TABBED) { 231 if (con->parent->layout == L_TABBED || con->parent->layout == L_STACKED) {
231 y_offset = container_titlebar_height();
232 view->border_top = false;
233 } else if (con->parent->layout == L_STACKED) {
234 y_offset = container_titlebar_height() * con->parent->children->length;
235 view->border_top = false; 232 view->border_top = false;
233 } else {
234 y_offset = container_titlebar_height();
236 } 235 }
237 236
238 enum sway_container_border border = view->border; 237 enum sway_container_border border = view->border;
@@ -243,17 +242,17 @@ void view_autoconfigure(struct sway_view *view) {
243 switch (border) { 242 switch (border) {
244 case B_NONE: 243 case B_NONE:
245 x = con->x; 244 x = con->x;
246 y = con->y + y_offset; 245 y = con->y;
247 width = con->width; 246 width = con->width;
248 height = con->height - y_offset; 247 height = con->height;
249 break; 248 break;
250 case B_PIXEL: 249 case B_PIXEL:
251 x = con->x + view->border_thickness * view->border_left; 250 x = con->x + view->border_thickness * view->border_left;
252 y = con->y + view->border_thickness * view->border_top + y_offset; 251 y = con->y + view->border_thickness * view->border_top;
253 width = con->width 252 width = con->width
254 - view->border_thickness * view->border_left 253 - view->border_thickness * view->border_left
255 - view->border_thickness * view->border_right; 254 - view->border_thickness * view->border_right;
256 height = con->height - y_offset 255 height = con->height
257 - view->border_thickness * view->border_top 256 - view->border_thickness * view->border_top
258 - view->border_thickness * view->border_bottom; 257 - view->border_thickness * view->border_bottom;
259 break; 258 break;
@@ -263,15 +262,9 @@ void view_autoconfigure(struct sway_view *view) {
263 width = con->width 262 width = con->width
264 - view->border_thickness * view->border_left 263 - view->border_thickness * view->border_left
265 - view->border_thickness * view->border_right; 264 - view->border_thickness * view->border_right;
266 if (y_offset) { 265 y = con->y + y_offset;
267 y = con->y + y_offset; 266 height = con->height - y_offset
268 height = con->height - y_offset 267 - view->border_thickness * view->border_bottom;
269 - view->border_thickness * view->border_bottom;
270 } else {
271 y = con->y + container_titlebar_height();
272 height = con->height - container_titlebar_height()
273 - view->border_thickness * view->border_bottom;
274 }
275 break; 268 break;
276 } 269 }
277 270