summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/border.h6
-rw-r--r--sway/border.c34
-rw-r--r--sway/commands.c2
-rw-r--r--sway/focus.c30
-rw-r--r--sway/handlers.c6
-rw-r--r--sway/layout.c8
6 files changed, 52 insertions, 34 deletions
diff --git a/include/border.h b/include/border.h
index b629ba46..b72dc5dc 100644
--- a/include/border.h
+++ b/include/border.h
@@ -16,8 +16,12 @@ struct border {
16 */ 16 */
17void border_clear(struct border *border); 17void border_clear(struct border *border);
18 18
19/**
20 * Recursively update all of the borders within a container.
21 */
22void update_container_border(swayc_t *container);
23
19void render_view_borders(wlc_handle view); 24void render_view_borders(wlc_handle view);
20void update_view_border(swayc_t *view);
21void map_update_view_border(swayc_t *view, void *data); 25void map_update_view_border(swayc_t *view, void *data);
22int get_font_text_height(const char *font); 26int get_font_text_height(const char *font);
23bool should_hide_top_border(swayc_t *con, double y); 27bool should_hide_top_border(swayc_t *con, double y);
diff --git a/sway/border.c b/sway/border.c
index c1a62bc6..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
204void 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
296void update_view_border(swayc_t *view) { 290static void update_view_border(swayc_t *view) {
297 if (!view->visible) { 291 if (!view->visible) {
298 return; 292 return;
299 } 293 }
@@ -308,6 +302,9 @@ void update_view_border(swayc_t *view) {
308 swayc_t *focused = get_focused_view(&root_container); 302 swayc_t *focused = get_focused_view(&root_container);
309 swayc_t *container = swayc_parent_by_type(view, C_CONTAINER); 303 swayc_t *container = swayc_parent_by_type(view, C_CONTAINER);
310 swayc_t *focused_inactive = NULL; 304 swayc_t *focused_inactive = NULL;
305
306 bool is_child_of_focused = swayc_is_parent_of(get_focused_container(&root_container), view);
307
311 if (container) { 308 if (container) {
312 focused_inactive = swayc_focus_by_type(container, C_VIEW); 309 focused_inactive = swayc_focus_by_type(container, C_VIEW);
313 } else { 310 } else {
@@ -334,7 +331,7 @@ void update_view_border(swayc_t *view) {
334 cr = create_border_buffer(view, g, &surface); 331 cr = create_border_buffer(view, g, &surface);
335 332
336 bool render_top = !should_hide_top_border(view, view->y); 333 bool render_top = !should_hide_top_border(view, view->y);
337 if (view == focused) { 334 if (view == focused || is_child_of_focused) {
338 render_borders(view, cr, &config->border_colors.focused, render_top); 335 render_borders(view, cr, &config->border_colors.focused, render_top);
339 } else { 336 } else {
340 render_borders(view, cr, &config->border_colors.focused_inactive, render_top); 337 render_borders(view, cr, &config->border_colors.focused_inactive, render_top);
@@ -360,7 +357,7 @@ void update_view_border(swayc_t *view) {
360 break; 357 break;
361 } 358 }
362 359
363 if (focused == view) { 360 if (focused == view || is_child_of_focused) {
364 render_borders(view, cr, &config->border_colors.focused, true); 361 render_borders(view, cr, &config->border_colors.focused, true);
365 } else if (focused_inactive == view) { 362 } else if (focused_inactive == view) {
366 render_borders(view, cr, &config->border_colors.focused_inactive, true); 363 render_borders(view, cr, &config->border_colors.focused_inactive, true);
@@ -375,7 +372,7 @@ void update_view_border(swayc_t *view) {
375 break; 372 break;
376 } 373 }
377 374
378 if (focused == view) { 375 if (focused == view || is_child_of_focused) {
379 render_borders(view, cr, &config->border_colors.focused, false); 376 render_borders(view, cr, &config->border_colors.focused, false);
380 render_title_bar(view, cr, &view->border_geometry, 377 render_title_bar(view, cr, &view->border_geometry,
381 &config->border_colors.focused); 378 &config->border_colors.focused);
@@ -403,6 +400,23 @@ void update_view_border(swayc_t *view) {
403 } 400 }
404} 401}
405 402
403void update_container_border(swayc_t *container) {
404 if (container->type == C_VIEW) {
405 update_view_border(container);
406 return;
407 } else {
408 for (int i = 0; i < container->children->length; ++i) {
409 update_container_border(container->children->items[i]);
410 }
411 }
412}
413
414void map_update_view_border(swayc_t *view, void *data) {
415 if (view->type == C_VIEW) {
416 update_view_border(view);
417 }
418}
419
406void render_view_borders(wlc_handle view) { 420void render_view_borders(wlc_handle view) {
407 swayc_t *c = swayc_by_handle(view); 421 swayc_t *c = swayc_by_handle(view);
408 422
diff --git a/sway/commands.c b/sway/commands.c
index f0c9cc52..f73bd21c 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/focus.c b/sway/focus.c
index 0f629e1e..45ec43e9 100644
--- a/sway/focus.c
+++ b/sway/focus.c
@@ -115,7 +115,7 @@ bool set_focused_container(swayc_t *c) {
115 115
116 // Get workspace for c, get that workspaces current focused container. 116 // Get workspace for c, get that workspaces current focused container.
117 swayc_t *workspace = swayc_active_workspace_for(c); 117 swayc_t *workspace = swayc_active_workspace_for(c);
118 swayc_t *focused = get_focused_view(workspace); 118 swayc_t *focused = get_focused_container(workspace);
119 119
120 if (swayc_is_fullscreen(focused) && focused != c) { 120 if (swayc_is_fullscreen(focused) && focused != c) {
121 // if switching to a workspace with a fullscreen view, 121 // if switching to a workspace with a fullscreen view,
@@ -140,35 +140,35 @@ bool set_focused_container(swayc_t *c) {
140 } 140 }
141 141
142 // get new focused view and set focus to it. 142 // get new focused view and set focus to it.
143 p = get_focused_view(c); 143 if (c->type == C_CONTAINER || (c->type == C_VIEW && !(wlc_view_get_type(p->handle) & WLC_BIT_POPUP))) {
144 if (p->type == C_VIEW && !(wlc_view_get_type(p->handle) & WLC_BIT_POPUP)) {
145 // unactivate previous focus 144 // unactivate previous focus
146 if (focused->type == C_VIEW) { 145 if (focused->type == C_VIEW) {
147 wlc_view_set_state(focused->handle, WLC_BIT_ACTIVATED, false); 146 wlc_view_set_state(focused->handle, WLC_BIT_ACTIVATED, false);
148 update_view_border(focused);
149 } 147 }
148 update_container_border(focused);
150 // activate current focus 149 // activate current focus
151 if (p->type == C_VIEW) { 150 if (c->type == C_VIEW) {
152 wlc_view_set_state(p->handle, WLC_BIT_ACTIVATED, true); 151 wlc_view_set_state(c->handle, WLC_BIT_ACTIVATED, true);
153 // set focus if view_focus is unlocked 152 }
154 if (!locked_view_focus) { 153 // set focus if view_focus is unlocked
155 wlc_view_focus(p->handle); 154 if (!locked_view_focus) {
156 if (p->parent->layout != L_TABBED 155 wlc_view_focus(c->handle);
157 && p->parent->layout != L_STACKED) { 156 if (c->parent->layout != L_TABBED
158 update_view_border(p); 157 && c->parent->layout != L_STACKED) {
159 } 158 update_container_border(c);
160 } 159 }
161 } 160 }
162 161
163 // rearrange if parent container is tabbed/stacked 162 // rearrange if parent container is tabbed/stacked
164 swayc_t *parent = swayc_tabbed_stacked_ancestor(p); 163 swayc_t *parent = swayc_tabbed_stacked_ancestor(c);
165 if (parent != NULL) { 164 if (parent != NULL) {
166 arrange_backgrounds(); 165 arrange_backgrounds();
167 arrange_windows(parent, -1, -1); 166 arrange_windows(parent, -1, -1);
168 } 167 }
169 } else if (p->type == C_WORKSPACE) { 168 } else if (c->type == C_WORKSPACE) {
170 // remove previous focus if view_focus is unlocked 169 // remove previous focus if view_focus is unlocked
171 if (!locked_view_focus) { 170 if (!locked_view_focus) {
171 update_container_border(c);
172 wlc_view_focus(0); 172 wlc_view_focus(0);
173 } 173 }
174 } 174 }
diff --git a/sway/handlers.c b/sway/handlers.c
index bdcdcaa4..684e45ba 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -415,7 +415,7 @@ static bool handle_view_created(wlc_handle handle) {
415 // we were on one workspace, switched to another to add this view, 415 // we were on one workspace, switched to another to add this view,
416 // now let's return to where we were 416 // now let's return to where we were
417 workspace_switch(current_ws); 417 workspace_switch(current_ws);
418 set_focused_container(current_ws->focused); 418 set_focused_container(get_focused_container(current_ws));
419 } 419 }
420 420
421 suspend_workspace_cleanup = false; 421 suspend_workspace_cleanup = false;
@@ -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
447void update_layout_geometry(swayc_t *parent, enum swayc_layouts prev_layout) { 447void 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;