aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Dwyer <ryandwyer1@gmail.com>2018-07-16 13:15:35 +1000
committerRyan Dwyer <ryandwyer1@gmail.com>2018-07-16 13:15:35 +1000
commit5f0a4bb6a46cf359dd270e3c448ca1e112331f9d (patch)
treeb6f9df379c05b5a1bda6010c9e3bab5ef8f9dfb0
parent560627437b536db490d7e4a3c6fb4282757a7327 (diff)
downloadsway-5f0a4bb6a46cf359dd270e3c448ca1e112331f9d.tar.xz
Update workspace urgent state when views close or move workspaces
-rw-r--r--include/sway/tree/workspace.h3
-rw-r--r--sway/ipc-json.c2
-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
6 files changed, 31 insertions, 7 deletions
diff --git a/include/sway/tree/workspace.h b/include/sway/tree/workspace.h
index 8c2f4cd5..bc95317a 100644
--- a/include/sway/tree/workspace.h
+++ b/include/sway/tree/workspace.h
@@ -10,6 +10,7 @@ struct sway_workspace {
struct sway_view *fullscreen;
struct sway_container *floating;
list_t *output_priority;
+ bool urgent;
};
extern char *prev_workspace_name;
@@ -43,6 +44,6 @@ void workspace_output_add_priority(struct sway_container *workspace,
struct sway_container *workspace_output_get_highest_available(
struct sway_container *ws, struct sway_container *exclude);
-bool workspace_is_urgent(struct sway_container *workspace);
+void workspace_detect_urgent(struct sway_container *workspace);
#endif
diff --git a/sway/ipc-json.c b/sway/ipc-json.c
index f8de51ed..dbab8e68 100644
--- a/sway/ipc-json.c
+++ b/sway/ipc-json.c
@@ -171,7 +171,7 @@ static void ipc_json_describe_workspace(struct sway_container *workspace,
json_object_new_string(workspace->parent->name) : NULL);
json_object_object_add(object, "type", json_object_new_string("workspace"));
json_object_object_add(object, "urgent",
- json_object_new_boolean(workspace_is_urgent(workspace)));
+ json_object_new_boolean(workspace->sway_workspace->urgent));
json_object_object_add(object, "representation", workspace->formatted_title ?
json_object_new_string(workspace->formatted_title) : NULL);
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,
container_add_child(new_workspace->sway_workspace->floating, con);
arrange_windows(old_workspace);
arrange_windows(new_workspace);
+ workspace_detect_urgent(old_workspace);
+ workspace_detect_urgent(new_workspace);
}
}
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,
}
}
}
+ // Update workspace urgent state
+ struct sway_container *old_workspace = old_parent;
+ if (old_workspace->type != C_WORKSPACE) {
+ old_workspace = container_parent(old_workspace, C_WORKSPACE);
+ }
+ if (new_workspace != old_workspace) {
+ workspace_detect_urgent(new_workspace);
+ workspace_detect_urgent(old_workspace);
+ }
}
static bool sway_dir_to_wlr(enum movement_direction dir,
@@ -548,6 +557,8 @@ void container_move(struct sway_container *container,
}
if (last_ws && next_ws && last_ws != next_ws) {
ipc_event_workspace(last_ws, container, "focus");
+ workspace_detect_urgent(last_ws);
+ workspace_detect_urgent(next_ws);
}
}
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) {
view->urgent_timer = NULL;
}
+ struct sway_container *parent;
+ struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE);
+
if (view->is_fullscreen) {
- struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE);
ws->sway_workspace->fullscreen = NULL;
- container_destroy(view->swayc);
+ parent = container_destroy(view->swayc);
arrange_windows(ws->parent);
} else {
struct sway_container *parent = container_destroy(view->swayc);
arrange_windows(parent);
}
+ if (parent->type >= C_WORKSPACE) { // if the workspace still exists
+ workspace_detect_urgent(ws);
+ }
transaction_commit_dirty();
view->surface = NULL;
}
@@ -1073,7 +1078,7 @@ void view_set_urgent(struct sway_view *view, bool enable) {
ipc_event_window(view->swayc, "urgent");
struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE);
- ipc_event_workspace(NULL, ws, "urgent");
+ workspace_detect_urgent(ws);
}
bool 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,
return con->type == C_VIEW && view_is_urgent(con->sway_view);
}
-bool workspace_is_urgent(struct sway_container *workspace) {
- return container_find(workspace, find_urgent_iterator, NULL);
+void workspace_detect_urgent(struct sway_container *workspace) {
+ bool new_urgent = container_find(workspace, find_urgent_iterator, NULL);
+
+ if (workspace->sway_workspace->urgent != new_urgent) {
+ workspace->sway_workspace->urgent = new_urgent;
+ ipc_event_workspace(NULL, workspace, "urgent");
+ }
}