summaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar D.B <thejan.2009@gmail.com>2016-07-16 15:11:08 +0200
committerLibravatar D.B <thejan.2009@gmail.com>2016-07-16 15:34:43 +0200
commitad7605675ef5d1fc99653e80c3c846429abfda25 (patch)
tree001033de86cb34fca09837a643a0818f299cdf3e /sway
parentFix warning in window.c (diff)
downloadsway-ad7605675ef5d1fc99653e80c3c846429abfda25.tar.gz
sway-ad7605675ef5d1fc99653e80c3c846429abfda25.tar.zst
sway-ad7605675ef5d1fc99653e80c3c846429abfda25.zip
refactor swayc_tabbed_stacked_parent into _ancestor and _parent and use where needed
Diffstat (limited to 'sway')
-rw-r--r--sway/border.c2
-rw-r--r--sway/commands.c2
-rw-r--r--sway/container.c12
-rw-r--r--sway/focus.c2
-rw-r--r--sway/handlers.c3
-rw-r--r--sway/layout.c4
6 files changed, 18 insertions, 7 deletions
diff --git a/sway/border.c b/sway/border.c
index 7600351a..9bc25816 100644
--- a/sway/border.c
+++ b/sway/border.c
@@ -318,7 +318,7 @@ void update_view_border(swayc_t *view) {
318 // for tabbed/stacked layouts the focused view has to draw all the 318 // for tabbed/stacked layouts the focused view has to draw all the
319 // titlebars of the hidden views. 319 // titlebars of the hidden views.
320 swayc_t *p = NULL; 320 swayc_t *p = NULL;
321 if (view->parent->focused == view && (p = swayc_tabbed_stacked_parent(view))) { 321 if (view->parent->focused == view && (p = swayc_tabbed_stacked_ancestor(view))) {
322 struct wlc_geometry g = { 322 struct wlc_geometry g = {
323 .origin = { 323 .origin = {
324 .x = p->x, 324 .x = p->x,
diff --git a/sway/commands.c b/sway/commands.c
index 871b3078..b9399dec 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -2315,7 +2315,7 @@ static struct cmd_results *_do_split(int argc, char **argv, int layout) {
2315 } 2315 }
2316 2316
2317 // update container title if tabbed/stacked 2317 // update container title if tabbed/stacked
2318 if (swayc_tabbed_stacked_parent(focused)) { 2318 if (swayc_tabbed_stacked_ancestor(focused)) {
2319 update_view_border(focused); 2319 update_view_border(focused);
2320 swayc_t *output = swayc_parent_by_type(focused, C_OUTPUT); 2320 swayc_t *output = swayc_parent_by_type(focused, C_OUTPUT);
2321 // schedule render to make changes take effect right away, 2321 // schedule render to make changes take effect right away,
diff --git a/sway/container.c b/sway/container.c
index ae70a8ee..bffbe620 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -878,7 +878,7 @@ void close_views(swayc_t *container) {
878 container_map(container, close_view, NULL); 878 container_map(container, close_view, NULL);
879} 879}
880 880
881swayc_t *swayc_tabbed_stacked_parent(swayc_t *view) { 881swayc_t *swayc_tabbed_stacked_ancestor(swayc_t *view) {
882 swayc_t *parent = NULL; 882 swayc_t *parent = NULL;
883 if (!ASSERT_NONNULL(view)) { 883 if (!ASSERT_NONNULL(view)) {
884 return NULL; 884 return NULL;
@@ -892,3 +892,13 @@ swayc_t *swayc_tabbed_stacked_parent(swayc_t *view) {
892 892
893 return parent; 893 return parent;
894} 894}
895
896swayc_t *swayc_tabbed_stacked_parent(swayc_t *con) {
897 if (!ASSERT_NONNULL(con)) {
898 return NULL;
899 }
900 if (con->parent && (con->parent->layout == L_TABBED || con->parent->layout == L_STACKED)) {
901 return con->parent;
902 }
903 return NULL;
904}
diff --git a/sway/focus.c b/sway/focus.c
index 0d9ee7e3..ff064b72 100644
--- a/sway/focus.c
+++ b/sway/focus.c
@@ -152,7 +152,7 @@ bool set_focused_container(swayc_t *c) {
152 } 152 }
153 153
154 // rearrange if parent container is tabbed/stacked 154 // rearrange if parent container is tabbed/stacked
155 swayc_t *parent = swayc_tabbed_stacked_parent(p); 155 swayc_t *parent = swayc_tabbed_stacked_ancestor(p);
156 if (parent != NULL) { 156 if (parent != NULL) {
157 arrange_windows(parent, -1, -1); 157 arrange_windows(parent, -1, -1);
158 } 158 }
diff --git a/sway/handlers.c b/sway/handlers.c
index a7a87564..1b96be0a 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -523,8 +523,9 @@ static void handle_view_properties_updated(wlc_handle view, uint32_t mask) {
523 if (!c->name || strcmp(c->name, new_name) != 0) { 523 if (!c->name || strcmp(c->name, new_name) != 0) {
524 free(c->name); 524 free(c->name);
525 c->name = strdup(new_name); 525 c->name = strdup(new_name);
526 swayc_t *p = swayc_tabbed_stacked_parent(c); 526 swayc_t *p = swayc_tabbed_stacked_ancestor(c);
527 if (p) { 527 if (p) {
528 // TODO: we only got the topmost tabbed/stacked container, update borders of all containers on the path
528 update_view_border(get_focused_view(p)); 529 update_view_border(get_focused_view(p));
529 } else if (c->border_type == B_NORMAL) { 530 } else if (c->border_type == B_NORMAL) {
530 update_view_border(c); 531 update_view_border(c);
diff --git a/sway/layout.c b/sway/layout.c
index 27760f35..3d746ebe 100644
--- a/sway/layout.c
+++ b/sway/layout.c
@@ -538,7 +538,7 @@ void update_geometry(swayc_t *container) {
538 int gap = 0; 538 int gap = 0;
539 539
540 // apply inner gaps to non-tabbed/stacked containers 540 // apply inner gaps to non-tabbed/stacked containers
541 swayc_t *p = swayc_tabbed_stacked_parent(container); 541 swayc_t *p = swayc_tabbed_stacked_ancestor(container);
542 if (p == NULL) { 542 if (p == NULL) {
543 gap = update_gap_geometry(container, &geometry); 543 gap = update_gap_geometry(container, &geometry);
544 } 544 }
@@ -803,7 +803,7 @@ static void arrange_windows_r(swayc_t *container, double width, double height) {
803 y = container->border_geometry.origin.y; 803 y = container->border_geometry.origin.y;
804 } 804 }
805 805
806 // update container size if it's a child in a tabbed/stacked layout 806 // update container size if it's a direct child in a tabbed/stacked layout
807 if (swayc_tabbed_stacked_parent(container) != NULL) { 807 if (swayc_tabbed_stacked_parent(container) != NULL) {
808 // Use parent actual_geometry as a base for calculating 808 // Use parent actual_geometry as a base for calculating
809 // container geometry 809 // container geometry