Update workspace urgent state when views close or move workspaces

master
Ryan Dwyer 7 years ago
parent 560627437b
commit 5f0a4bb6a4

@ -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

@ -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);

@ -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);
}
}

@ -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);
}
}

@ -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) {

@ -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");
}
}

Loading…
Cancel
Save