diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-03-30 00:02:29 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2018-03-30 00:04:04 -0400 |
commit | f26ecd9f58bb672fe107660ce9b37f4bf0777a8c (patch) | |
tree | 997658454de40db3f8b76b68d658efaf2b686188 /sway/ipc-server.c | |
parent | Early return from render functions if necessary (diff) | |
parent | Merge pull request #1654 from acrisci/refactor-2-electric-boogaloo (diff) | |
download | sway-f26ecd9f58bb672fe107660ce9b37f4bf0777a8c.tar.gz sway-f26ecd9f58bb672fe107660ce9b37f4bf0777a8c.tar.zst sway-f26ecd9f58bb672fe107660ce9b37f4bf0777a8c.zip |
Merge remote-tracking branch 'origin/wlroots' into swaybar-layers
Diffstat (limited to 'sway/ipc-server.c')
-rw-r--r-- | sway/ipc-server.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/sway/ipc-server.c b/sway/ipc-server.c index 9d23607b..394161af 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c | |||
@@ -257,7 +257,8 @@ static void ipc_send_event(const char *json_string, enum ipc_command_type event) | |||
257 | } | 257 | } |
258 | } | 258 | } |
259 | 259 | ||
260 | void ipc_event_workspace(swayc_t *old, swayc_t *new, const char *change) { | 260 | void ipc_event_workspace(struct sway_container *old, |
261 | struct sway_container *new, const char *change) { | ||
261 | wlr_log(L_DEBUG, "Sending workspace::%s event", change); | 262 | wlr_log(L_DEBUG, "Sending workspace::%s event", change); |
262 | json_object *obj = json_object_new_object(); | 263 | json_object *obj = json_object_new_object(); |
263 | json_object_object_add(obj, "change", json_object_new_string(change)); | 264 | json_object_object_add(obj, "change", json_object_new_string(change)); |
@@ -282,7 +283,7 @@ void ipc_event_workspace(swayc_t *old, swayc_t *new, const char *change) { | |||
282 | json_object_put(obj); | 283 | json_object_put(obj); |
283 | } | 284 | } |
284 | 285 | ||
285 | void ipc_event_window(swayc_t *window, const char *change) { | 286 | void ipc_event_window(struct sway_container *window, const char *change) { |
286 | wlr_log(L_DEBUG, "Sending window::%s event", change); | 287 | wlr_log(L_DEBUG, "Sending window::%s event", change); |
287 | json_object *obj = json_object_new_object(); | 288 | json_object *obj = json_object_new_object(); |
288 | json_object_object_add(obj, "change", json_object_new_string(change)); | 289 | json_object_object_add(obj, "change", json_object_new_string(change)); |
@@ -378,7 +379,8 @@ void ipc_client_disconnect(struct ipc_client *client) { | |||
378 | free(client); | 379 | free(client); |
379 | } | 380 | } |
380 | 381 | ||
381 | static void ipc_get_workspaces_callback(swayc_t *workspace, void *data) { | 382 | static void ipc_get_workspaces_callback(struct sway_container *workspace, |
383 | void *data) { | ||
382 | if (workspace->type != C_WORKSPACE) { | 384 | if (workspace->type != C_WORKSPACE) { |
383 | return; | 385 | return; |
384 | } | 386 | } |
@@ -387,9 +389,9 @@ static void ipc_get_workspaces_callback(swayc_t *workspace, void *data) { | |||
387 | // it's set differently for the get_workspaces reply | 389 | // it's set differently for the get_workspaces reply |
388 | struct sway_seat *seat = | 390 | struct sway_seat *seat = |
389 | sway_input_manager_get_default_seat(input_manager); | 391 | sway_input_manager_get_default_seat(input_manager); |
390 | swayc_t *focused_ws = sway_seat_get_focus(seat); | 392 | struct sway_container *focused_ws = sway_seat_get_focus(seat); |
391 | if (focused_ws->type != C_WORKSPACE) { | 393 | if (focused_ws->type != C_WORKSPACE) { |
392 | focused_ws = swayc_parent_by_type(focused_ws, C_WORKSPACE); | 394 | focused_ws = container_parent(focused_ws, C_WORKSPACE); |
393 | } | 395 | } |
394 | bool focused = workspace == focused_ws; | 396 | bool focused = workspace == focused_ws; |
395 | json_object_object_del(workspace_json, "focused"); | 397 | json_object_object_del(workspace_json, "focused"); |
@@ -441,7 +443,7 @@ void ipc_client_handle_command(struct ipc_client *client) { | |||
441 | { | 443 | { |
442 | json_object *outputs = json_object_new_array(); | 444 | json_object *outputs = json_object_new_array(); |
443 | for (int i = 0; i < root_container.children->length; ++i) { | 445 | for (int i = 0; i < root_container.children->length; ++i) { |
444 | swayc_t *container = root_container.children->items[i]; | 446 | struct sway_container *container = root_container.children->items[i]; |
445 | if (container->type == C_OUTPUT) { | 447 | if (container->type == C_OUTPUT) { |
446 | json_object_array_add(outputs, | 448 | json_object_array_add(outputs, |
447 | ipc_json_describe_container(container)); | 449 | ipc_json_describe_container(container)); |
@@ -456,7 +458,8 @@ void ipc_client_handle_command(struct ipc_client *client) { | |||
456 | case IPC_GET_WORKSPACES: | 458 | case IPC_GET_WORKSPACES: |
457 | { | 459 | { |
458 | json_object *workspaces = json_object_new_array(); | 460 | json_object *workspaces = json_object_new_array(); |
459 | container_map(&root_container, ipc_get_workspaces_callback, workspaces); | 461 | container_for_each_descendant_dfs(&root_container, |
462 | ipc_get_workspaces_callback, workspaces); | ||
460 | const char *json_string = json_object_to_json_string(workspaces); | 463 | const char *json_string = json_object_to_json_string(workspaces); |
461 | ipc_send_reply(client, json_string, (uint32_t) strlen(json_string)); | 464 | ipc_send_reply(client, json_string, (uint32_t) strlen(json_string)); |
462 | json_object_put(workspaces); // free | 465 | json_object_put(workspaces); // free |