diff options
author | Tony Crisci <tony@dubstepdish.com> | 2016-07-31 20:32:40 -0400 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2016-07-31 20:32:40 -0400 |
commit | b39249508f458e302d843c440db8f992e1d545ca (patch) | |
tree | aff103964eb013f246674346fcb6685d593e98bd | |
parent | Implement focus handling for containers (diff) | |
download | sway-b39249508f458e302d843c440db8f992e1d545ca.tar.gz sway-b39249508f458e302d843c440db8f992e1d545ca.tar.zst sway-b39249508f458e302d843c440db8f992e1d545ca.zip |
Refactor functions to update container borders
Replace `update_view_border()` with `update_container_border()`. The latter
should handle both the case where the container is a view or if the container
has children.
-rw-r--r-- | include/border.h | 1 | ||||
-rw-r--r-- | sway/border.c | 14 | ||||
-rw-r--r-- | sway/commands.c | 2 | ||||
-rw-r--r-- | sway/handlers.c | 4 | ||||
-rw-r--r-- | sway/layout.c | 8 |
5 files changed, 14 insertions, 15 deletions
diff --git a/include/border.h b/include/border.h index b61b0f8a..b72dc5dc 100644 --- a/include/border.h +++ b/include/border.h | |||
@@ -22,7 +22,6 @@ void border_clear(struct border *border); | |||
22 | void update_container_border(swayc_t *container); | 22 | void update_container_border(swayc_t *container); |
23 | 23 | ||
24 | void render_view_borders(wlc_handle view); | 24 | void render_view_borders(wlc_handle view); |
25 | void update_view_border(swayc_t *view); | ||
26 | void map_update_view_border(swayc_t *view, void *data); | 25 | void map_update_view_border(swayc_t *view, void *data); |
27 | int get_font_text_height(const char *font); | 26 | int get_font_text_height(const char *font); |
28 | bool should_hide_top_border(swayc_t *con, double y); | 27 | bool should_hide_top_border(swayc_t *con, double y); |
diff --git a/sway/border.c b/sway/border.c index c3e1004a..f681e4f1 100644 --- a/sway/border.c +++ b/sway/border.c | |||
@@ -201,12 +201,6 @@ static void render_title_bar(swayc_t *view, cairo_t *cr, struct wlc_geometry *b, | |||
201 | } | 201 | } |
202 | } | 202 | } |
203 | 203 | ||
204 | void map_update_view_border(swayc_t *view, void *data) { | ||
205 | if (view->type == C_VIEW) { | ||
206 | update_view_border(view); | ||
207 | } | ||
208 | } | ||
209 | |||
210 | /** | 204 | /** |
211 | * Generate nested container title for tabbed/stacked layouts | 205 | * Generate nested container title for tabbed/stacked layouts |
212 | */ | 206 | */ |
@@ -293,7 +287,7 @@ void update_tabbed_stacked_titlebars(swayc_t *c, cairo_t *cr, struct wlc_geometr | |||
293 | } | 287 | } |
294 | } | 288 | } |
295 | 289 | ||
296 | void update_view_border(swayc_t *view) { | 290 | static void update_view_border(swayc_t *view) { |
297 | if (!view->visible) { | 291 | if (!view->visible) { |
298 | return; | 292 | return; |
299 | } | 293 | } |
@@ -417,6 +411,12 @@ void update_container_border(swayc_t *container) { | |||
417 | } | 411 | } |
418 | } | 412 | } |
419 | 413 | ||
414 | void map_update_view_border(swayc_t *view, void *data) { | ||
415 | if (view->type == C_VIEW) { | ||
416 | update_view_border(view); | ||
417 | } | ||
418 | } | ||
419 | |||
420 | void render_view_borders(wlc_handle view) { | 420 | void render_view_borders(wlc_handle view) { |
421 | swayc_t *c = swayc_by_handle(view); | 421 | swayc_t *c = swayc_by_handle(view); |
422 | 422 | ||
diff --git a/sway/commands.c b/sway/commands.c index 28dcc996..a65e0a01 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -2340,7 +2340,7 @@ static struct cmd_results *_do_split(int argc, char **argv, int layout) { | |||
2340 | 2340 | ||
2341 | // update container title if tabbed/stacked | 2341 | // update container title if tabbed/stacked |
2342 | if (swayc_tabbed_stacked_ancestor(focused)) { | 2342 | if (swayc_tabbed_stacked_ancestor(focused)) { |
2343 | update_view_border(focused); | 2343 | update_container_border(focused); |
2344 | swayc_t *output = swayc_parent_by_type(focused, C_OUTPUT); | 2344 | swayc_t *output = swayc_parent_by_type(focused, C_OUTPUT); |
2345 | // schedule render to make changes take effect right away, | 2345 | // schedule render to make changes take effect right away, |
2346 | // otherwise we would have to wait for the view to render, | 2346 | // otherwise we would have to wait for the view to render, |
diff --git a/sway/handlers.c b/sway/handlers.c index bdcdcaa4..87b7253b 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -553,9 +553,9 @@ static void handle_view_properties_updated(wlc_handle view, uint32_t mask) { | |||
553 | swayc_t *p = swayc_tabbed_stacked_ancestor(c); | 553 | swayc_t *p = swayc_tabbed_stacked_ancestor(c); |
554 | if (p) { | 554 | if (p) { |
555 | // TODO: we only got the topmost tabbed/stacked container, update borders of all containers on the path | 555 | // TODO: we only got the topmost tabbed/stacked container, update borders of all containers on the path |
556 | update_view_border(get_focused_view(p)); | 556 | update_container_border(get_focused_view(p)); |
557 | } else if (c->border_type == B_NORMAL) { | 557 | } else if (c->border_type == B_NORMAL) { |
558 | update_view_border(c); | 558 | update_container_border(c); |
559 | } | 559 | } |
560 | ipc_event_window(c, "title"); | 560 | ipc_event_window(c, "title"); |
561 | } | 561 | } |
diff --git a/sway/layout.c b/sway/layout.c index 6502d930..42954ebc 100644 --- a/sway/layout.c +++ b/sway/layout.c | |||
@@ -441,7 +441,7 @@ static void update_border_geometry_floating(swayc_t *c, struct wlc_geometry *geo | |||
441 | c->border_geometry = g; | 441 | c->border_geometry = g; |
442 | *geometry = c->actual_geometry; | 442 | *geometry = c->actual_geometry; |
443 | 443 | ||
444 | update_view_border(c); | 444 | update_container_border(c); |
445 | } | 445 | } |
446 | 446 | ||
447 | void update_layout_geometry(swayc_t *parent, enum swayc_layouts prev_layout) { | 447 | void update_layout_geometry(swayc_t *parent, enum swayc_layouts prev_layout) { |
@@ -688,7 +688,7 @@ void update_geometry(swayc_t *container) { | |||
688 | container->actual_geometry = geometry; | 688 | container->actual_geometry = geometry; |
689 | 689 | ||
690 | if (container->type == C_VIEW) { | 690 | if (container->type == C_VIEW) { |
691 | update_view_border(container); | 691 | update_container_border(container); |
692 | } | 692 | } |
693 | } | 693 | } |
694 | 694 | ||
@@ -867,7 +867,7 @@ static void arrange_windows_r(swayc_t *container, double width, double height) { | |||
867 | // update focused view border last because it may | 867 | // update focused view border last because it may |
868 | // depend on the title bar geometry of its siblings. | 868 | // depend on the title bar geometry of its siblings. |
869 | if (focused && container->children->length > 1) { | 869 | if (focused && container->children->length > 1) { |
870 | update_view_border(focused); | 870 | update_container_border(focused); |
871 | } | 871 | } |
872 | } | 872 | } |
873 | break; | 873 | break; |
@@ -911,7 +911,7 @@ static void arrange_windows_r(swayc_t *container, double width, double height) { | |||
911 | // update focused view border last because it may | 911 | // update focused view border last because it may |
912 | // depend on the title bar geometry of its siblings. | 912 | // depend on the title bar geometry of its siblings. |
913 | if (focused && container->children->length > 1) { | 913 | if (focused && container->children->length > 1) { |
914 | update_view_border(focused); | 914 | update_container_border(focused); |
915 | } | 915 | } |
916 | } | 916 | } |
917 | break; | 917 | break; |