aboutsummaryrefslogtreecommitdiff
path: root/sway/tree
diff options
context:
space:
mode:
authorRyan Dwyer <RyanDwyer@users.noreply.github.com>2018-08-02 08:17:25 +1000
committerGitHub <noreply@github.com>2018-08-02 08:17:25 +1000
commit4cc0855f21a2704314aa7b8973ceae7a8b463a1a (patch)
tree92d5b04c01c2da2bce20819ade8ed834bf2e420c /sway/tree
parentf078f7fdfa8c1b2549178b8137c6731c2fff6d3f (diff)
parent46cfa8ff56acff0139b2e24300cbc3ea19da723f (diff)
Merge pull request #2264 from ianyfan/ipc
IPC Events (1.0)
Diffstat (limited to 'sway/tree')
-rw-r--r--sway/tree/container.c14
-rw-r--r--sway/tree/layout.c14
-rw-r--r--sway/tree/output.c2
-rw-r--r--sway/tree/view.c15
4 files changed, 33 insertions, 12 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 4e85021d..b6ff4d30 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -62,8 +62,10 @@ void container_create_notify(struct sway_container *container) {
// TODO send ipc event type based on the container type
wl_signal_emit(&root_container.sway_root->events.new_container, container);
- if (container->type == C_VIEW || container->type == C_CONTAINER) {
+ if (container->type == C_VIEW) {
ipc_event_window(container, "new");
+ } else if (container->type == C_WORKSPACE) {
+ ipc_event_workspace(NULL, container, "init");
}
}
@@ -281,7 +283,7 @@ static struct sway_container *container_output_destroy(
container_remove_child(workspace);
if (!workspace_is_empty(workspace)) {
container_add_child(new_output, workspace);
- ipc_event_workspace(workspace, NULL, "move");
+ ipc_event_workspace(NULL, workspace, "move");
} else {
container_destroy(workspace);
}
@@ -319,7 +321,13 @@ static struct sway_container *container_destroy_noreaping(
}
wl_signal_emit(&con->events.destroy, con);
- ipc_event_window(con, "close");
+
+ // emit IPC event
+ if (con->type == C_VIEW) {
+ ipc_event_window(con, "close");
+ } else if (con->type == C_WORKSPACE) {
+ ipc_event_workspace(NULL, con, "empty");
+ }
// The below functions move their children to somewhere else.
if (con->type == C_OUTPUT) {
diff --git a/sway/tree/layout.c b/sway/tree/layout.c
index a0764a54..1f82e534 100644
--- a/sway/tree/layout.c
+++ b/sway/tree/layout.c
@@ -217,7 +217,9 @@ void container_move_to(struct sway_container *container,
container_sort_workspaces(new_parent);
seat_set_focus(seat, new_parent);
workspace_output_raise_priority(container, old_parent, new_parent);
- ipc_event_workspace(container, NULL, "move");
+ ipc_event_workspace(NULL, container, "move");
+ } else if (container->type == C_VIEW) {
+ ipc_event_window(container, "move");
}
container_notify_subtree_changed(old_parent);
container_notify_subtree_changed(new_parent);
@@ -578,6 +580,10 @@ void container_move(struct sway_container *container,
container_notify_subtree_changed(old_parent);
container_notify_subtree_changed(container->parent);
+ if (container->type == C_VIEW) {
+ ipc_event_window(container, "move");
+ }
+
if (old_parent) {
seat_set_focus(config->handler_context.seat, old_parent);
seat_set_focus(config->handler_context.seat, container);
@@ -592,7 +598,7 @@ void container_move(struct sway_container *container,
next_ws = container_parent(next_ws, C_WORKSPACE);
}
if (last_ws && next_ws && last_ws != next_ws) {
- ipc_event_workspace(last_ws, container, "focus");
+ ipc_event_workspace(last_ws, next_ws, "focus");
workspace_detect_urgent(last_ws);
workspace_detect_urgent(next_ws);
}
@@ -995,13 +1001,13 @@ static void swap_focus(struct sway_container *con1,
if (focus == con1 && (con2->parent->layout == L_TABBED
|| con2->parent->layout == L_STACKED)) {
if (workspace_is_visible(ws2)) {
- seat_set_focus_warp(seat, con2, false);
+ seat_set_focus_warp(seat, con2, false, true);
}
seat_set_focus(seat, ws1 != ws2 ? con2 : con1);
} else if (focus == con2 && (con1->parent->layout == L_TABBED
|| con1->parent->layout == L_STACKED)) {
if (workspace_is_visible(ws1)) {
- seat_set_focus_warp(seat, con1, false);
+ seat_set_focus_warp(seat, con1, false, true);
}
seat_set_focus(seat, ws1 != ws2 ? con1 : con2);
} else if (ws1 != ws2) {
diff --git a/sway/tree/output.c b/sway/tree/output.c
index da535c18..31e3bf9b 100644
--- a/sway/tree/output.c
+++ b/sway/tree/output.c
@@ -22,7 +22,7 @@ static void restore_workspaces(struct sway_container *output) {
if (highest == output) {
container_remove_child(ws);
container_add_child(output, ws);
- ipc_event_workspace(ws, NULL, "move");
+ ipc_event_workspace(NULL, ws, "move");
j--;
}
}
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 8f54cc11..48b39e80 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -864,6 +864,8 @@ void view_update_title(struct sway_view *view, bool force) {
// Update title after the global font height is updated
container_update_title_textures(view->swayc);
+
+ ipc_event_window(view->swayc, "title");
}
static bool find_by_mark_iterator(struct sway_container *con,
@@ -886,6 +888,7 @@ bool view_find_and_unmark(char *mark) {
free(view_mark);
list_del(view->marks, i);
view_update_marks_textures(view);
+ ipc_event_window(container, "mark");
return true;
}
}
@@ -893,11 +896,10 @@ bool view_find_and_unmark(char *mark) {
}
void view_clear_marks(struct sway_view *view) {
- for (int i = 0; i < view->marks->length; ++i) {
- free(view->marks->items[i]);
+ while (view->marks->length) {
+ list_del(view->marks, 0);
+ ipc_event_window(view->swayc, "mark");
}
- list_free(view->marks);
- view->marks = create_list();
}
bool view_has_mark(struct sway_view *view, char *mark) {
@@ -910,6 +912,11 @@ bool view_has_mark(struct sway_view *view, char *mark) {
return false;
}
+void view_add_mark(struct sway_view *view, char *mark) {
+ list_add(view->marks, strdup(mark));
+ ipc_event_window(view->swayc, "mark");
+}
+
static void update_marks_texture(struct sway_view *view,
struct wlr_texture **texture, struct border_colors *class) {
struct sway_container *output = container_parent(view->swayc, C_OUTPUT);