summaryrefslogtreecommitdiff
path: root/sway/tree/view.c
diff options
context:
space:
mode:
authorRyan Dwyer <[email protected]>2018-07-15 22:43:33 +1000
committerRyan Dwyer <[email protected]>2018-07-16 08:19:25 +1000
commit315d5311b2004b9e148e7b52a7de161b6dfe3878 (patch)
tree1a70d1d73cbffb26bf432c1c7b395ee996651ad3 /sway/tree/view.c
parentb314a8f2cc792aa59d8f12e5adb9aed2967af646 (diff)
Implement urgency base functionality
Introduces a command to manually set urgency, as well as rendering of urgent views, sending the IPC event, removing urgency after focused for one second, and matching urgent views via criteria.
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r--sway/tree/view.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c
index bf380d98..a2dbe92c 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,
view->impl = impl;
view->executed_criteria = create_list();
view->marks = create_list();
+ view->allow_request_urgent = true;
wl_signal_init(&view->events.unmap);
}
@@ -589,6 +590,11 @@ void view_unmap(struct sway_view *view) {
wl_list_remove(&view->surface_new_subsurface.link);
wl_list_remove(&view->container_reparent.link);
+ if (view->urgent_timer) {
+ wl_event_source_remove(view->urgent_timer);
+ view->urgent_timer = NULL;
+ }
+
if (view->is_fullscreen) {
struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE);
ws->sway_workspace->fullscreen = NULL;
@@ -1047,3 +1053,27 @@ bool view_is_visible(struct sway_view *view) {
}
return true;
}
+
+void view_set_urgent(struct sway_view *view, bool enable) {
+ if (enable) {
+ struct sway_seat *seat = input_manager_current_seat(input_manager);
+ if (seat_get_focus(seat) == view->swayc) {
+ return;
+ }
+ clock_gettime(CLOCK_MONOTONIC, &view->urgent);
+ } else {
+ view->urgent = (struct timespec){ 0 };
+ if (view->urgent_timer) {
+ wl_event_source_remove(view->urgent_timer);
+ view->urgent_timer = NULL;
+ }
+ }
+ container_damage_whole(view->swayc);
+
+ struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE);
+ ipc_event_workspace(ws, NULL, "urgent");
+}
+
+bool view_is_urgent(struct sway_view *view) {
+ return view->urgent.tv_sec || view->urgent.tv_nsec;
+}