diff options
author | 2018-07-16 15:39:08 -0700 | |
---|---|---|
committer | 2018-07-16 15:39:08 -0700 | |
commit | d6bd314dffb7385eec73de40f0fdd5775cd5941b (patch) | |
tree | 1cec389e971cda3e42766c07789d0f51c2d39715 /sway/tree | |
parent | Merge pull request #2265 from RedSoxFan/implement-1962 (diff) | |
parent | swaybar: Read urgent colors from IPC (diff) | |
download | sway-d6bd314dffb7385eec73de40f0fdd5775cd5941b.tar.gz sway-d6bd314dffb7385eec73de40f0fdd5775cd5941b.tar.zst sway-d6bd314dffb7385eec73de40f0fdd5775cd5941b.zip |
Merge pull request #2276 from RyanDwyer/urgency
Implement urgency base functionality
Diffstat (limited to 'sway/tree')
-rw-r--r-- | sway/tree/container.c | 34 | ||||
-rw-r--r-- | sway/tree/layout.c | 11 | ||||
-rw-r--r-- | sway/tree/view.c | 41 | ||||
-rw-r--r-- | sway/tree/workspace.c | 11 |
4 files changed, 87 insertions, 10 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c index 35f67cce..6d52c38c 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -674,16 +674,23 @@ struct sway_container *floating_container_at(double lx, double ly, | |||
674 | void container_for_each_descendant_dfs(struct sway_container *container, | 674 | void container_for_each_descendant_dfs(struct sway_container *container, |
675 | void (*f)(struct sway_container *container, void *data), | 675 | void (*f)(struct sway_container *container, void *data), |
676 | void *data) { | 676 | void *data) { |
677 | if (container) { | 677 | if (!container) { |
678 | if (container->children) { | 678 | return; |
679 | for (int i = 0; i < container->children->length; ++i) { | 679 | } |
680 | struct sway_container *child = | 680 | if (container->children) { |
681 | container->children->items[i]; | 681 | for (int i = 0; i < container->children->length; ++i) { |
682 | container_for_each_descendant_dfs(child, f, data); | 682 | struct sway_container *child = container->children->items[i]; |
683 | } | 683 | container_for_each_descendant_dfs(child, f, data); |
684 | } | ||
685 | } | ||
686 | if (container->type == C_WORKSPACE) { | ||
687 | struct sway_container *floating = container->sway_workspace->floating; | ||
688 | for (int i = 0; i < floating->children->length; ++i) { | ||
689 | struct sway_container *child = floating->children->items[i]; | ||
690 | container_for_each_descendant_dfs(child, f, data); | ||
684 | } | 691 | } |
685 | f(container, data); | ||
686 | } | 692 | } |
693 | f(container, data); | ||
687 | } | 694 | } |
688 | 695 | ||
689 | void container_for_each_descendant_bfs(struct sway_container *con, | 696 | void container_for_each_descendant_bfs(struct sway_container *con, |
@@ -1063,6 +1070,8 @@ void container_floating_move_to(struct sway_container *con, | |||
1063 | container_add_child(new_workspace->sway_workspace->floating, con); | 1070 | container_add_child(new_workspace->sway_workspace->floating, con); |
1064 | arrange_windows(old_workspace); | 1071 | arrange_windows(old_workspace); |
1065 | arrange_windows(new_workspace); | 1072 | arrange_windows(new_workspace); |
1073 | workspace_detect_urgent(old_workspace); | ||
1074 | workspace_detect_urgent(new_workspace); | ||
1066 | } | 1075 | } |
1067 | } | 1076 | } |
1068 | 1077 | ||
@@ -1073,3 +1082,12 @@ void container_set_dirty(struct sway_container *container) { | |||
1073 | container->dirty = true; | 1082 | container->dirty = true; |
1074 | list_add(server.dirty_containers, container); | 1083 | list_add(server.dirty_containers, container); |
1075 | } | 1084 | } |
1085 | |||
1086 | static bool find_urgent_iterator(struct sway_container *con, | ||
1087 | void *data) { | ||
1088 | return con->type == C_VIEW && view_is_urgent(con->sway_view); | ||
1089 | } | ||
1090 | |||
1091 | bool container_has_urgent_child(struct sway_container *container) { | ||
1092 | return container_find(container, find_urgent_iterator, NULL); | ||
1093 | } | ||
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 | ||
230 | static bool sway_dir_to_wlr(enum movement_direction dir, | 239 | static 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 10c97518..76e0f42c 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -25,6 +25,7 @@ void view_init(struct sway_view *view, enum sway_view_type type, | |||
25 | view->impl = impl; | 25 | view->impl = impl; |
26 | view->executed_criteria = create_list(); | 26 | view->executed_criteria = create_list(); |
27 | view->marks = create_list(); | 27 | view->marks = create_list(); |
28 | view->allow_request_urgent = true; | ||
28 | wl_signal_init(&view->events.unmap); | 29 | wl_signal_init(&view->events.unmap); |
29 | } | 30 | } |
30 | 31 | ||
@@ -609,16 +610,26 @@ void view_unmap(struct sway_view *view) { | |||
609 | wl_list_remove(&view->surface_new_subsurface.link); | 610 | wl_list_remove(&view->surface_new_subsurface.link); |
610 | wl_list_remove(&view->container_reparent.link); | 611 | wl_list_remove(&view->container_reparent.link); |
611 | 612 | ||
613 | if (view->urgent_timer) { | ||
614 | wl_event_source_remove(view->urgent_timer); | ||
615 | view->urgent_timer = NULL; | ||
616 | } | ||
617 | |||
618 | struct sway_container *parent; | ||
619 | struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE); | ||
620 | |||
612 | if (view->is_fullscreen) { | 621 | if (view->is_fullscreen) { |
613 | struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE); | ||
614 | ws->sway_workspace->fullscreen = NULL; | 622 | ws->sway_workspace->fullscreen = NULL; |
615 | container_destroy(view->swayc); | 623 | parent = container_destroy(view->swayc); |
616 | 624 | ||
617 | arrange_windows(ws->parent); | 625 | arrange_windows(ws->parent); |
618 | } else { | 626 | } else { |
619 | struct sway_container *parent = container_destroy(view->swayc); | 627 | struct sway_container *parent = container_destroy(view->swayc); |
620 | arrange_windows(parent); | 628 | arrange_windows(parent); |
621 | } | 629 | } |
630 | if (parent->type >= C_WORKSPACE) { // if the workspace still exists | ||
631 | workspace_detect_urgent(ws); | ||
632 | } | ||
622 | transaction_commit_dirty(); | 633 | transaction_commit_dirty(); |
623 | view->surface = NULL; | 634 | view->surface = NULL; |
624 | } | 635 | } |
@@ -1067,3 +1078,29 @@ bool view_is_visible(struct sway_view *view) { | |||
1067 | } | 1078 | } |
1068 | return true; | 1079 | return true; |
1069 | } | 1080 | } |
1081 | |||
1082 | void view_set_urgent(struct sway_view *view, bool enable) { | ||
1083 | if (enable) { | ||
1084 | struct sway_seat *seat = input_manager_current_seat(input_manager); | ||
1085 | if (seat_get_focus(seat) == view->swayc) { | ||
1086 | return; | ||
1087 | } | ||
1088 | clock_gettime(CLOCK_MONOTONIC, &view->urgent); | ||
1089 | } else { | ||
1090 | view->urgent = (struct timespec){ 0 }; | ||
1091 | if (view->urgent_timer) { | ||
1092 | wl_event_source_remove(view->urgent_timer); | ||
1093 | view->urgent_timer = NULL; | ||
1094 | } | ||
1095 | } | ||
1096 | container_damage_whole(view->swayc); | ||
1097 | |||
1098 | ipc_event_window(view->swayc, "urgent"); | ||
1099 | |||
1100 | struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE); | ||
1101 | workspace_detect_urgent(ws); | ||
1102 | } | ||
1103 | |||
1104 | bool view_is_urgent(struct sway_view *view) { | ||
1105 | return view->urgent.tv_sec || view->urgent.tv_nsec; | ||
1106 | } | ||
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 2a2d834a..622f01ec 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include "sway/ipc-server.h" | 11 | #include "sway/ipc-server.h" |
12 | #include "sway/tree/arrange.h" | 12 | #include "sway/tree/arrange.h" |
13 | #include "sway/tree/container.h" | 13 | #include "sway/tree/container.h" |
14 | #include "sway/tree/view.h" | ||
14 | #include "sway/tree/workspace.h" | 15 | #include "sway/tree/workspace.h" |
15 | #include "list.h" | 16 | #include "list.h" |
16 | #include "log.h" | 17 | #include "log.h" |
@@ -518,3 +519,13 @@ struct sway_container *workspace_output_get_highest_available( | |||
518 | 519 | ||
519 | return NULL; | 520 | return NULL; |
520 | } | 521 | } |
522 | |||
523 | void workspace_detect_urgent(struct sway_container *workspace) { | ||
524 | bool new_urgent = container_has_urgent_child(workspace); | ||
525 | |||
526 | if (workspace->sway_workspace->urgent != new_urgent) { | ||
527 | workspace->sway_workspace->urgent = new_urgent; | ||
528 | ipc_event_workspace(NULL, workspace, "urgent"); | ||
529 | container_damage_whole(workspace); | ||
530 | } | ||
531 | } | ||