ipc: add `floating` property to GET_TREE

i3 has had this property for over a decade but it wasn't documented
until a couple of years ago, so it was likely missed when developing
sway. Add the property to get us closer to ipc parity with i3.
This commit is contained in:
llyyr 2024-02-27 01:40:22 +05:30 committed by Simon Ser
parent fca8474e9b
commit 2867ef646b
2 changed files with 10 additions and 1 deletions

View File

@ -288,6 +288,7 @@ static json_object *ipc_json_create_node(int id, const char* type, char *name,
json_object_object_add(object, "focus", focus);
json_object_object_add(object, "fullscreen_mode", json_object_new_int(0));
json_object_object_add(object, "sticky", json_object_new_boolean(false));
json_object_object_add(object, "floating", NULL);
return object;
}
@ -675,7 +676,8 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object
static void ipc_json_describe_container(struct sway_container *c, json_object *object) {
json_object_object_add(object, "name",
c->title ? json_object_new_string(c->title) : NULL);
if (container_is_floating(c)) {
bool floating = container_is_floating(c);
if (floating) {
json_object_object_add(object, "type",
json_object_new_string("floating_con"));
}
@ -693,6 +695,10 @@ static void ipc_json_describe_container(struct sway_container *c, json_object *o
json_object_object_add(object, "urgent", json_object_new_boolean(urgent));
json_object_object_add(object, "sticky", json_object_new_boolean(c->is_sticky));
// sway doesn't track the floating reason, so we can't use "auto_on" or "user_off"
json_object_object_add(object, "floating",
json_object_new_string(floating ? "user_on" : "auto_off"));
json_object_object_add(object, "fullscreen_mode",
json_object_new_int(c->pending.fullscreen_mode));

View File

@ -376,6 +376,9 @@ node and will have the following properties:
: integer
: (Only containers and views) The fullscreen mode of the node. 0 means none, 1 means
full workspace, and 2 means global fullscreen
|- floating
: string
: Floating state of container. Can be either "auto_off" or "user_on"
|- app_id
: string
: (Only views) For an xdg-shell view, the name of the application, if set.