summaryrefslogtreecommitdiff
path: root/sway/ipc-server.c
diff options
context:
space:
mode:
authoremersion <[email protected]>2018-04-05 22:54:26 -0400
committerGitHub <[email protected]>2018-04-05 22:54:26 -0400
commit254ca8103cfb633fe1392b51f5c80fd28e901479 (patch)
treeaa0bfd765d0c6562bed26acc753fe571e72a4110 /sway/ipc-server.c
parentf63d9417cd4d25121fa1fd309acad14a7562a55c (diff)
parent6b308dbeb7a1f2b26279481c001c15434d2468cb (diff)
Merge pull request #1747 from acrisci/ipc-layout
ipc layout
Diffstat (limited to 'sway/ipc-server.c')
-rw-r--r--sway/ipc-server.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/sway/ipc-server.c b/sway/ipc-server.c
index df5fb699..045802e1 100644
--- a/sway/ipc-server.c
+++ b/sway/ipc-server.c
@@ -241,10 +241,19 @@ int ipc_client_handle_readable(int client_fd, uint32_t mask, void *data) {
return 0;
}
+static bool ipc_has_event_listeners(enum ipc_command_type event) {
+ for (int i = 0; i < ipc_client_list->length; i++) {
+ struct ipc_client *client = ipc_client_list->items[i];
+ if ((client->subscribed_events & event_mask(event)) == 0) {
+ return true;
+ }
+ }
+ return false;
+}
+
static void ipc_send_event(const char *json_string, enum ipc_command_type event) {
- int i;
struct ipc_client *client;
- for (i = 0; i < ipc_client_list->length; i++) {
+ for (int i = 0; i < ipc_client_list->length; i++) {
client = ipc_client_list->items[i];
if ((client->subscribed_events & event_mask(event)) == 0) {
continue;
@@ -259,6 +268,9 @@ static void ipc_send_event(const char *json_string, enum ipc_command_type event)
void ipc_event_workspace(struct sway_container *old,
struct sway_container *new, const char *change) {
+ if (!ipc_has_event_listeners(IPC_EVENT_WORKSPACE)) {
+ return;
+ }
wlr_log(L_DEBUG, "Sending workspace::%s event", change);
json_object *obj = json_object_new_object();
json_object_object_add(obj, "change", json_object_new_string(change));
@@ -284,6 +296,9 @@ void ipc_event_workspace(struct sway_container *old,
}
void ipc_event_window(struct sway_container *window, const char *change) {
+ if (!ipc_has_event_listeners(IPC_EVENT_WINDOW)) {
+ return;
+ }
wlr_log(L_DEBUG, "Sending window::%s event", change);
json_object *obj = json_object_new_object();
json_object_object_add(obj, "change", json_object_new_string(change));
@@ -295,6 +310,9 @@ void ipc_event_window(struct sway_container *window, const char *change) {
}
void ipc_event_barconfig_update(struct bar_config *bar) {
+ if (!ipc_has_event_listeners(IPC_EVENT_BARCONFIG_UPDATE)) {
+ return;
+ }
wlr_log(L_DEBUG, "Sending barconfig_update event");
json_object *json = ipc_json_describe_bar_config(bar);
@@ -304,6 +322,9 @@ void ipc_event_barconfig_update(struct bar_config *bar) {
}
void ipc_event_mode(const char *mode) {
+ if (!ipc_has_event_listeners(IPC_EVENT_MODE)) {
+ return;
+ }
wlr_log(L_DEBUG, "Sending mode::%s event", mode);
json_object *obj = json_object_new_object();
json_object_object_add(obj, "change", json_object_new_string(mode));