mirror of
https://github.com/swaywm/sway.git
synced 2024-11-11 13:04:11 +01:00
address feedback
This commit is contained in:
parent
235798ff8e
commit
6b308dbeb7
@ -12,37 +12,22 @@
|
|||||||
#include "wlr-layer-shell-unstable-v1-protocol.h"
|
#include "wlr-layer-shell-unstable-v1-protocol.h"
|
||||||
|
|
||||||
static const char *ipc_json_layout_description(enum sway_container_layout l) {
|
static const char *ipc_json_layout_description(enum sway_container_layout l) {
|
||||||
const char *layout;
|
|
||||||
|
|
||||||
switch (l) {
|
switch (l) {
|
||||||
case L_VERT:
|
case L_VERT:
|
||||||
layout = "splitv";
|
return "splitv";
|
||||||
break;
|
|
||||||
|
|
||||||
case L_HORIZ:
|
case L_HORIZ:
|
||||||
layout = "splith";
|
return "splith";
|
||||||
break;
|
|
||||||
|
|
||||||
case L_TABBED:
|
case L_TABBED:
|
||||||
layout = "tabbed";
|
return "tabbed";
|
||||||
break;
|
|
||||||
|
|
||||||
case L_STACKED:
|
case L_STACKED:
|
||||||
layout = "stacked";
|
return "stacked";
|
||||||
break;
|
|
||||||
|
|
||||||
case L_FLOATING:
|
case L_FLOATING:
|
||||||
layout = "floating";
|
return "floating";
|
||||||
break;
|
case L_NONE:
|
||||||
|
case L_LAYOUTS:
|
||||||
case L_NONE: // fallthrough
|
|
||||||
case L_LAYOUTS: // fallthrough; this should never happen, I'm just trying to silence compiler warnings
|
|
||||||
default:
|
|
||||||
layout = "null";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
return "none";
|
||||||
return layout;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
json_object *ipc_json_get_version() {
|
json_object *ipc_json_get_version() {
|
||||||
@ -149,9 +134,8 @@ static void ipc_json_describe_output(struct sway_container *container, json_obje
|
|||||||
json_object_new_int(mode->refresh));
|
json_object_new_int(mode->refresh));
|
||||||
json_object_array_add(modes_array, mode_object);
|
json_object_array_add(modes_array, mode_object);
|
||||||
}
|
}
|
||||||
|
|
||||||
json_object_object_add(object, "modes", modes_array);
|
json_object_object_add(object, "modes", modes_array);
|
||||||
|
|
||||||
|
|
||||||
json_object_object_add(object, "layout", json_object_new_string("output"));
|
json_object_object_add(object, "layout", json_object_new_string("output"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,8 +150,7 @@ static void ipc_json_describe_workspace(struct sway_container *workspace,
|
|||||||
json_object_object_add(object, "urgent", json_object_new_boolean(false));
|
json_object_object_add(object, "urgent", json_object_new_boolean(false));
|
||||||
|
|
||||||
const char *layout = ipc_json_layout_description(workspace->workspace_layout);
|
const char *layout = ipc_json_layout_description(workspace->workspace_layout);
|
||||||
json_object_object_add(object, "layout", (strcmp(layout, "null") == 0) ?
|
json_object_object_add(object, "layout", json_object_new_string(layout));
|
||||||
NULL : json_object_new_string(layout));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ipc_json_describe_view(struct sway_container *c, json_object *object) {
|
static void ipc_json_describe_view(struct sway_container *c, json_object *object) {
|
||||||
@ -176,10 +159,11 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object
|
|||||||
json_object_object_add(object, "type", json_object_new_string("con"));
|
json_object_object_add(object, "type", json_object_new_string("con"));
|
||||||
|
|
||||||
if (c->parent) {
|
if (c->parent) {
|
||||||
const char *layout = (c->parent->type == C_CONTAINER) ?
|
enum sway_container_layout layout = (c->parent->type == C_CONTAINER) ?
|
||||||
ipc_json_layout_description(c->parent->layout) : "none";
|
c->parent->layout : c->layout;
|
||||||
|
|
||||||
json_object_object_add(object, "layout",
|
json_object_object_add(object, "layout",
|
||||||
(strcmp(layout, "null") == 0) ? NULL : json_object_new_string(layout));
|
json_object_new_string(ipc_json_layout_description(layout)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,19 +242,13 @@ int ipc_client_handle_readable(int client_fd, uint32_t mask, void *data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool ipc_has_event_listeners(enum ipc_command_type event) {
|
static bool ipc_has_event_listeners(enum ipc_command_type event) {
|
||||||
bool has_listeners = false;
|
|
||||||
|
|
||||||
struct ipc_client *client;
|
|
||||||
for (int i = 0; i < ipc_client_list->length; i++) {
|
for (int i = 0; i < ipc_client_list->length; i++) {
|
||||||
client = ipc_client_list->items[i];
|
struct ipc_client *client = ipc_client_list->items[i];
|
||||||
if ((client->subscribed_events & event_mask(event)) == 0) {
|
if ((client->subscribed_events & event_mask(event)) == 0) {
|
||||||
continue;
|
return true;
|
||||||
}
|
}
|
||||||
has_listeners = true;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
return has_listeners;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ipc_send_event(const char *json_string, enum ipc_command_type event) {
|
static void ipc_send_event(const char *json_string, enum ipc_command_type event) {
|
||||||
|
Loading…
Reference in New Issue
Block a user