|
|
@ -132,66 +132,6 @@ static void ipc_json_describe_workspace(swayc_t *workspace, json_object *object)
|
|
|
|
json_object_object_add(object, "layout", (strcmp(layout, "null") == 0) ? NULL : json_object_new_string(layout));
|
|
|
|
json_object_object_add(object, "layout", (strcmp(layout, "null") == 0) ? NULL : json_object_new_string(layout));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void ipc_json_describe_view(swayc_t *view, json_object *object) {
|
|
|
|
|
|
|
|
float percent = ipc_json_child_percentage(view);
|
|
|
|
|
|
|
|
const char *layout = ipc_json_layout_description(view->layout);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
json_object_object_add(object, "border", json_object_new_string(ipc_json_border_description(view)));
|
|
|
|
|
|
|
|
json_object_object_add(object, "current_border_width", json_object_new_int(view->border_thickness));
|
|
|
|
|
|
|
|
json_object_object_add(object, "percent", (percent > 0) ? json_object_new_double(percent) : NULL);
|
|
|
|
|
|
|
|
// TODO: make urgency actually work once Sway supports it
|
|
|
|
|
|
|
|
json_object_object_add(object, "urgent", json_object_new_boolean(false));
|
|
|
|
|
|
|
|
json_object_object_add(object, "focused", json_object_new_boolean(view->is_focused));
|
|
|
|
|
|
|
|
json_object_object_add(object, "type", json_object_new_string((view->is_floating) ? "floating_con" : "con"));
|
|
|
|
|
|
|
|
json_object_object_add(object, "layout", (strcmp(layout, "null") == 0) ? NULL : json_object_new_string(layout));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (view->class) {
|
|
|
|
|
|
|
|
json_object_object_add(object, "class", json_object_new_string(view->class));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (view->app_id) {
|
|
|
|
|
|
|
|
json_object_object_add(object, "app_id", json_object_new_string(view->app_id));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
json_object *ipc_json_describe_container(swayc_t *c) {
|
|
|
|
|
|
|
|
if (!(sway_assert(c, "Container must not be null."))) {
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
json_object *object = json_object_new_object();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
json_object_object_add(object, "id", json_object_new_int((intptr_t)&c));
|
|
|
|
|
|
|
|
json_object_object_add(object, "name", (c->name) ? json_object_new_string(c->name) : NULL);
|
|
|
|
|
|
|
|
json_object_object_add(object, "rect", ipc_json_create_rect(c));
|
|
|
|
|
|
|
|
json_object_object_add(object, "visible", json_object_new_boolean(c->visible));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (c->type) {
|
|
|
|
|
|
|
|
case C_ROOT:
|
|
|
|
|
|
|
|
json_object_object_add(object, "type", json_object_new_string("root"));
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case C_OUTPUT:
|
|
|
|
|
|
|
|
ipc_json_describe_output(c, object);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case C_CONTAINER: // fallthrough
|
|
|
|
|
|
|
|
case C_VIEW:
|
|
|
|
|
|
|
|
ipc_json_describe_view(c, object);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case C_WORKSPACE:
|
|
|
|
|
|
|
|
ipc_json_describe_workspace(c, object);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case C_TYPES: // fallthrough; this should never happen, I'm just trying to silence compiler warnings
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return object;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// window is in the scratchpad ? changed : none
|
|
|
|
// window is in the scratchpad ? changed : none
|
|
|
|
static const char *ipc_json_get_scratchpad_state(swayc_t *c) {
|
|
|
|
static const char *ipc_json_get_scratchpad_state(swayc_t *c) {
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
@ -203,14 +143,8 @@ static const char *ipc_json_get_scratchpad_state(swayc_t *c) {
|
|
|
|
return "none"; // we ignore the fresh value
|
|
|
|
return "none"; // we ignore the fresh value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// simulate i3, it's probably not a good idea to use it anywhere except window events
|
|
|
|
static void ipc_json_describe_view(swayc_t *c, json_object *object) {
|
|
|
|
json_object *ipc_json_describe_window(swayc_t *c) {
|
|
|
|
|
|
|
|
if (!(sway_assert(c, "Container must not be null."))) {
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
json_object *object = json_object_new_object();
|
|
|
|
|
|
|
|
json_object *props = json_object_new_object();
|
|
|
|
json_object *props = json_object_new_object();
|
|
|
|
json_object *arr = json_object_new_array();
|
|
|
|
|
|
|
|
float percent = ipc_json_child_percentage(c);
|
|
|
|
float percent = ipc_json_child_percentage(c);
|
|
|
|
const char *layout = (c->parent->type == C_CONTAINER) ?
|
|
|
|
const char *layout = (c->parent->type == C_CONTAINER) ?
|
|
|
|
ipc_json_layout_description(c->parent->layout) : "none";
|
|
|
|
ipc_json_layout_description(c->parent->layout) : "none";
|
|
|
@ -245,22 +179,56 @@ json_object *ipc_json_describe_window(swayc_t *c) {
|
|
|
|
json_object_object_add(object, "name", (c->name) ? json_object_new_string(c->name) : NULL);
|
|
|
|
json_object_object_add(object, "name", (c->name) ? json_object_new_string(c->name) : NULL);
|
|
|
|
|
|
|
|
|
|
|
|
json_object_object_add(object, "window", json_object_new_int(c->handle)); // for the sake of i3 compat
|
|
|
|
json_object_object_add(object, "window", json_object_new_int(c->handle)); // for the sake of i3 compat
|
|
|
|
json_object_object_add(props, "class", json_object_new_string(
|
|
|
|
json_object_object_add(props, "class", c->class ? json_object_new_string(c->class) :
|
|
|
|
c->class ? c->class : c->app_id ? c->app_id : "null"));
|
|
|
|
c->app_id ? json_object_new_string(c->app_id) : NULL);
|
|
|
|
json_object_object_add(props, "title", json_object_new_string(c->name));
|
|
|
|
json_object_object_add(props, "title", (c->name) ? json_object_new_string(c->name) : NULL);
|
|
|
|
// json_object_object_add(props, "instance", json_object_new_string(c->name));
|
|
|
|
json_object_object_add(props, "transient_for", NULL); // unless sway keeps track of child views
|
|
|
|
json_object_object_add(props, "transient_for", NULL); // ditto
|
|
|
|
|
|
|
|
json_object_object_add(object, "window_properties", props);
|
|
|
|
json_object_object_add(object, "window_properties", props);
|
|
|
|
|
|
|
|
|
|
|
|
json_object_object_add(object, "fullscreen_mode",
|
|
|
|
json_object_object_add(object, "fullscreen_mode",
|
|
|
|
json_object_new_int(swayc_is_fullscreen(c) ? 1 : 0));
|
|
|
|
json_object_new_int(swayc_is_fullscreen(c) ? 1 : 0));
|
|
|
|
json_object_object_add(object, "sticky", json_object_new_boolean(c->sticky));
|
|
|
|
json_object_object_add(object, "sticky", json_object_new_boolean(c->sticky));
|
|
|
|
json_object_object_add(object, "floating", json_object_new_string(
|
|
|
|
json_object_object_add(object, "floating", json_object_new_string(
|
|
|
|
c->is_floating ? "auto_on" : "auto_off")); // not sure if all the info is saved
|
|
|
|
c->is_floating ? "auto_on" : "auto_off")); // unless relevant info is saved
|
|
|
|
if (c->app_id) {
|
|
|
|
|
|
|
|
json_object_object_add(object, "app_id", json_object_new_string(c->app_id));
|
|
|
|
json_object_object_add(object, "app_id", c->app_id ? json_object_new_string(c->app_id) : NULL);
|
|
|
|
|
|
|
|
// we do not include children, floating, unmanaged etc. as views seem to have none
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
json_object *ipc_json_describe_container(swayc_t *c) {
|
|
|
|
|
|
|
|
if (!(sway_assert(c, "Container must not be null."))) {
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
json_object *object = json_object_new_object();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
json_object_object_add(object, "id", json_object_new_int((intptr_t)&c));
|
|
|
|
|
|
|
|
json_object_object_add(object, "name", (c->name) ? json_object_new_string(c->name) : NULL);
|
|
|
|
|
|
|
|
json_object_object_add(object, "rect", ipc_json_create_rect(c));
|
|
|
|
|
|
|
|
json_object_object_add(object, "visible", json_object_new_boolean(c->visible));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (c->type) {
|
|
|
|
|
|
|
|
case C_ROOT:
|
|
|
|
|
|
|
|
json_object_object_add(object, "type", json_object_new_string("root"));
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case C_OUTPUT:
|
|
|
|
|
|
|
|
ipc_json_describe_output(c, object);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case C_CONTAINER: // fallthrough
|
|
|
|
|
|
|
|
case C_VIEW:
|
|
|
|
|
|
|
|
ipc_json_describe_view(c, object);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case C_WORKSPACE:
|
|
|
|
|
|
|
|
ipc_json_describe_workspace(c, object);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case C_TYPES: // fallthrough; this should never happen, I'm just trying to silence compiler warnings
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return object;
|
|
|
|
return object;
|
|
|
|
}
|
|
|
|
}
|
|
|
|