summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Mykyta Holubakha <hilobakho@gmail.com>2016-07-12 13:58:24 +0000
committerLibravatar Mykyta Holubakha <hilobakho@gmail.com>2016-07-21 21:51:20 +0300
commit976e48d79f46fbab02d7af0ae1b6804018774a63 (patch)
treef230178d62aff86bd83181b588e055aa7963d2a6
parentRemove arrange_windows from post-render (diff)
downloadsway-976e48d79f46fbab02d7af0ae1b6804018774a63.tar.gz
sway-976e48d79f46fbab02d7af0ae1b6804018774a63.tar.zst
sway-976e48d79f46fbab02d7af0ae1b6804018774a63.zip
Initial work on window events
-rw-r--r--include/ipc-server.h4
-rw-r--r--sway/commands.c2
-rw-r--r--sway/extensions.c2
-rw-r--r--sway/focus.c4
-rw-r--r--sway/handlers.c3
-rw-r--r--sway/ipc-server.c17
-rw-r--r--sway/layout.c2
7 files changed, 34 insertions, 0 deletions
diff --git a/include/ipc-server.h b/include/ipc-server.h
index aef3aa07..1d199134 100644
--- a/include/ipc-server.h
+++ b/include/ipc-server.h
@@ -18,6 +18,10 @@ void ipc_event_barconfig_update(struct bar_config *bar);
18 */ 18 */
19void ipc_event_mode(const char *mode); 19void ipc_event_mode(const char *mode);
20/** 20/**
21 * Send IPC window change event
22 */
23void ipc_event_window(swayc_t *window, const char *change);
24/**
21 * Sends an IPC modifier event to all listening clients. The modifier event 25 * Sends an IPC modifier event to all listening clients. The modifier event
22 * includes a key 'change' with the value of state and a key 'modifier' with 26 * includes a key 'change' with the value of state and a key 'modifier' with
23 * the name of that modifier. 27 * the name of that modifier.
diff --git a/sway/commands.c b/sway/commands.c
index aaacf0fc..5cf93c53 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -679,6 +679,7 @@ static struct cmd_results *cmd_floating(int argc, char **argv) {
679 view->width = view->height = 0; 679 view->width = view->height = 0;
680 arrange_windows(swayc_active_workspace(), -1, -1); 680 arrange_windows(swayc_active_workspace(), -1, -1);
681 remove_view_from_scratchpad(view); 681 remove_view_from_scratchpad(view);
682 ipc_event_window(view, "floating");
682 } 683 }
683 set_focused_container(view); 684 set_focused_container(view);
684 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 685 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
@@ -2495,6 +2496,7 @@ static struct cmd_results *cmd_fullscreen(int argc, char **argv) {
2495 arrange_windows(container, -1, -1); 2496 arrange_windows(container, -1, -1);
2496 workspace->fullscreen = NULL; 2497 workspace->fullscreen = NULL;
2497 } 2498 }
2499 ipc_event_window(container, "fullscreen_mode");
2498 2500
2499 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 2501 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
2500} 2502}
diff --git a/sway/extensions.c b/sway/extensions.c
index 1fe15ac5..4611f33e 100644
--- a/sway/extensions.c
+++ b/sway/extensions.c
@@ -8,6 +8,7 @@
8#include "log.h" 8#include "log.h"
9#include "input_state.h" 9#include "input_state.h"
10#include "extensions.h" 10#include "extensions.h"
11#include "ipc-server.h"
11 12
12struct desktop_shell_state desktop_shell; 13struct desktop_shell_state desktop_shell;
13 14
@@ -128,6 +129,7 @@ static void set_lock_surface(struct wl_client *client, struct wl_resource *resou
128 } 129 }
129 wlc_view_set_state(view->handle, WLC_BIT_FULLSCREEN, true); 130 wlc_view_set_state(view->handle, WLC_BIT_FULLSCREEN, true);
130 workspace->fullscreen = view; 131 workspace->fullscreen = view;
132 ipc_event_window(view, "fullscreen_mode");
131 desktop_shell.is_locked = true; 133 desktop_shell.is_locked = true;
132 // reset input state 134 // reset input state
133 input_init(); 135 input_init();
diff --git a/sway/focus.c b/sway/focus.c
index ff064b72..97fa4b98 100644
--- a/sway/focus.c
+++ b/sway/focus.c
@@ -118,6 +118,10 @@ bool set_focused_container(swayc_t *c) {
118 c = focused; 118 c = focused;
119 } 119 }
120 120
121 if (c->type == C_VIEW) {
122 // dispatch a window event
123 ipc_event_window(c, "focus");
124 }
121 // update container focus from here to root, making necessary changes along 125 // update container focus from here to root, making necessary changes along
122 // the way 126 // the way
123 swayc_t *p = c; 127 swayc_t *p = c;
diff --git a/sway/handlers.c b/sway/handlers.c
index b95a6e65..abed8cd7 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -369,6 +369,7 @@ static bool handle_view_created(wlc_handle handle) {
369 suspend_workspace_cleanup = true; 369 suspend_workspace_cleanup = true;
370 370
371 if (newview) { 371 if (newview) {
372 ipc_event_window(newview, "new");
372 set_focused_container(newview); 373 set_focused_container(newview);
373 swayc_t *output = swayc_parent_by_type(newview, C_OUTPUT); 374 swayc_t *output = swayc_parent_by_type(newview, C_OUTPUT);
374 arrange_windows(output, -1, -1); 375 arrange_windows(output, -1, -1);
@@ -461,6 +462,7 @@ static void handle_view_destroyed(wlc_handle handle) {
461 } 462 }
462 463
463 arrange_windows(parent, -1, -1); 464 arrange_windows(parent, -1, -1);
465 ipc_event_window(parent, "close");
464 } else { 466 } else {
465 // Is it unmanaged? 467 // Is it unmanaged?
466 int i; 468 int i;
@@ -555,6 +557,7 @@ static void handle_view_properties_updated(wlc_handle view, uint32_t mask) {
555 } else if (c->border_type == B_NORMAL) { 557 } else if (c->border_type == B_NORMAL) {
556 update_view_border(c); 558 update_view_border(c);
557 } 559 }
560 ipc_event_window(c, "title");
558 } 561 }
559 } 562 }
560 } 563 }
diff --git a/sway/ipc-server.c b/sway/ipc-server.c
index 0729bfd5..1dc3ab79 100644
--- a/sway/ipc-server.c
+++ b/sway/ipc-server.c
@@ -339,6 +339,8 @@ void ipc_client_handle_command(struct ipc_client *client) {
339 client->subscribed_events |= IPC_EVENT_BARCONFIG_UPDATE; 339 client->subscribed_events |= IPC_EVENT_BARCONFIG_UPDATE;
340 } else if (strcmp(event_type, "mode") == 0) { 340 } else if (strcmp(event_type, "mode") == 0) {
341 client->subscribed_events |= IPC_EVENT_MODE; 341 client->subscribed_events |= IPC_EVENT_MODE;
342 } else if (strcmp(event_type, "window") == 0) {
343 client->subscribed_events |= IPC_EVENT_WINDOW;
342 } else if (strcmp(event_type, "modifier") == 0) { 344 } else if (strcmp(event_type, "modifier") == 0) {
343 client->subscribed_events |= IPC_EVENT_MODIFIER; 345 client->subscribed_events |= IPC_EVENT_MODIFIER;
344#if SWAY_BINDING_EVENT 346#if SWAY_BINDING_EVENT
@@ -556,6 +558,21 @@ void ipc_event_workspace(swayc_t *old, swayc_t *new, const char *change) {
556 json_object_put(obj); // free 558 json_object_put(obj); // free
557} 559}
558 560
561void ipc_event_window(swayc_t *window, const char *change) {
562 json_object *obj = json_object_new_object();
563 json_object_object_add(obj, "change", json_object_new_string(change));
564 if (strcmp(change, "close") == 0 || !window) {
565 json_object_object_add(obj, "container", NULL);
566 } else {
567 json_object_object_add(obj, "container", ipc_json_describe_container(window));
568 }
569
570 const char *json_string = json_object_to_json_string(obj);
571 ipc_send_event(json_string, IPC_EVENT_WINDOW);
572
573 json_object_put(obj); // free
574}
575
559void ipc_event_barconfig_update(struct bar_config *bar) { 576void ipc_event_barconfig_update(struct bar_config *bar) {
560 json_object *json = ipc_json_describe_bar_config(bar); 577 json_object *json = ipc_json_describe_bar_config(bar);
561 const char *json_string = json_object_to_json_string(json); 578 const char *json_string = json_object_to_json_string(json);
diff --git a/sway/layout.c b/sway/layout.c
index 2e0bf0bb..d32b4139 100644
--- a/sway/layout.c
+++ b/sway/layout.c
@@ -91,6 +91,7 @@ void add_floating(swayc_t *ws, swayc_t *child) {
91 if (!ws->focused) { 91 if (!ws->focused) {
92 ws->focused = child; 92 ws->focused = child;
93 } 93 }
94 ipc_event_window(child, "floating");
94} 95}
95 96
96swayc_t *add_sibling(swayc_t *fixed, swayc_t *active) { 97swayc_t *add_sibling(swayc_t *fixed, swayc_t *active) {
@@ -305,6 +306,7 @@ void move_container(swayc_t *container, enum movement_direction dir) {
305 parent = child->parent; 306 parent = child->parent;
306 } 307 }
307 arrange_windows(parent->parent, -1, -1); 308 arrange_windows(parent->parent, -1, -1);
309 ipc_event_window(container, "move");
308 set_focused_container_for(parent->parent, container); 310 set_focused_container_for(parent->parent, container);
309} 311}
310 312