summaryrefslogtreecommitdiffstats
path: root/sway/tree
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-07-16 13:15:35 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-07-16 13:15:35 +1000
commit5f0a4bb6a46cf359dd270e3c448ca1e112331f9d (patch)
treeb6f9df379c05b5a1bda6010c9e3bab5ef8f9dfb0 /sway/tree
parentMake container_for_each_descendant_dfs descend into floating views (diff)
downloadsway-5f0a4bb6a46cf359dd270e3c448ca1e112331f9d.tar.gz
sway-5f0a4bb6a46cf359dd270e3c448ca1e112331f9d.tar.zst
sway-5f0a4bb6a46cf359dd270e3c448ca1e112331f9d.zip
Update workspace urgent state when views close or move workspaces
Diffstat (limited to 'sway/tree')
-rw-r--r--sway/tree/container.c2
-rw-r--r--sway/tree/layout.c11
-rw-r--r--sway/tree/view.c11
-rw-r--r--sway/tree/workspace.c9
4 files changed, 28 insertions, 5 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 99d57218..c1de46b5 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -1070,6 +1070,8 @@ void container_floating_move_to(struct sway_container *con,
1070 container_add_child(new_workspace->sway_workspace->floating, con); 1070 container_add_child(new_workspace->sway_workspace->floating, con);
1071 arrange_windows(old_workspace); 1071 arrange_windows(old_workspace);
1072 arrange_windows(new_workspace); 1072 arrange_windows(new_workspace);
1073 workspace_detect_urgent(old_workspace);
1074 workspace_detect_urgent(new_workspace);
1073 } 1075 }
1074} 1076}
1075 1077
diff --git a/sway/tree/layout.c b/sway/tree/layout.c
index 54ddb3f9..197a2fc8 100644
--- a/sway/tree/layout.c
+++ b/sway/tree/layout.c
@@ -225,6 +225,15 @@ void container_move_to(struct sway_container *container,
225 } 225 }
226 } 226 }
227 } 227 }
228 // Update workspace urgent state
229 struct sway_container *old_workspace = old_parent;
230 if (old_workspace->type != C_WORKSPACE) {
231 old_workspace = container_parent(old_workspace, C_WORKSPACE);
232 }
233 if (new_workspace != old_workspace) {
234 workspace_detect_urgent(new_workspace);
235 workspace_detect_urgent(old_workspace);
236 }
228} 237}
229 238
230static bool sway_dir_to_wlr(enum movement_direction dir, 239static bool sway_dir_to_wlr(enum movement_direction dir,
@@ -548,6 +557,8 @@ void container_move(struct sway_container *container,
548 } 557 }
549 if (last_ws && next_ws && last_ws != next_ws) { 558 if (last_ws && next_ws && last_ws != next_ws) {
550 ipc_event_workspace(last_ws, container, "focus"); 559 ipc_event_workspace(last_ws, container, "focus");
560 workspace_detect_urgent(last_ws);
561 workspace_detect_urgent(next_ws);
551 } 562 }
552} 563}
553 564
diff --git a/sway/tree/view.c b/sway/tree/view.c
index ae520b07..b5b73408 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -595,16 +595,21 @@ void view_unmap(struct sway_view *view) {
595 view->urgent_timer = NULL; 595 view->urgent_timer = NULL;
596 } 596 }
597 597
598 struct sway_container *parent;
599 struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE);
600
598 if (view->is_fullscreen) { 601 if (view->is_fullscreen) {
599 struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE);
600 ws->sway_workspace->fullscreen = NULL; 602 ws->sway_workspace->fullscreen = NULL;
601 container_destroy(view->swayc); 603 parent = container_destroy(view->swayc);
602 604
603 arrange_windows(ws->parent); 605 arrange_windows(ws->parent);
604 } else { 606 } else {
605 struct sway_container *parent = container_destroy(view->swayc); 607 struct sway_container *parent = container_destroy(view->swayc);
606 arrange_windows(parent); 608 arrange_windows(parent);
607 } 609 }
610 if (parent->type >= C_WORKSPACE) { // if the workspace still exists
611 workspace_detect_urgent(ws);
612 }
608 transaction_commit_dirty(); 613 transaction_commit_dirty();
609 view->surface = NULL; 614 view->surface = NULL;
610} 615}
@@ -1073,7 +1078,7 @@ void view_set_urgent(struct sway_view *view, bool enable) {
1073 ipc_event_window(view->swayc, "urgent"); 1078 ipc_event_window(view->swayc, "urgent");
1074 1079
1075 struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE); 1080 struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE);
1076 ipc_event_workspace(NULL, ws, "urgent"); 1081 workspace_detect_urgent(ws);
1077} 1082}
1078 1083
1079bool view_is_urgent(struct sway_view *view) { 1084bool view_is_urgent(struct sway_view *view) {
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c
index d71b0a53..d14f01eb 100644
--- a/sway/tree/workspace.c
+++ b/sway/tree/workspace.c
@@ -525,6 +525,11 @@ static bool find_urgent_iterator(struct sway_container *con,
525 return con->type == C_VIEW && view_is_urgent(con->sway_view); 525 return con->type == C_VIEW && view_is_urgent(con->sway_view);
526} 526}
527 527
528bool workspace_is_urgent(struct sway_container *workspace) { 528void workspace_detect_urgent(struct sway_container *workspace) {
529 return container_find(workspace, find_urgent_iterator, NULL); 529 bool new_urgent = container_find(workspace, find_urgent_iterator, NULL);
530
531 if (workspace->sway_workspace->urgent != new_urgent) {
532 workspace->sway_workspace->urgent = new_urgent;
533 ipc_event_workspace(NULL, workspace, "urgent");
534 }
530} 535}