summaryrefslogtreecommitdiff
path: root/sway/ipc-json.c
diff options
context:
space:
mode:
authorDamien Tardy-Panis <[email protected]>2020-05-05 18:35:03 +0200
committerBrian Ashworth <[email protected]>2020-05-29 17:29:41 -0400
commit0cbd26f0dae32db38160a82d557017edab8bb632 (patch)
tree33d51bd6d990ca9606d0306e211e3d0e5f464494 /sway/ipc-json.c
parent8cdcb77e12bf9c52fb51ce9a7da7e6a850fa5a37 (diff)
Add views idle inhibition status in get_tree output
Fixes #5286
Diffstat (limited to 'sway/ipc-json.c')
-rw-r--r--sway/ipc-json.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c
index c2e43f6e..066fd8db 100644
--- a/sway/ipc-json.c
+++ b/sway/ipc-json.c
@@ -18,6 +18,7 @@
#include <wlr/types/wlr_output.h>
#include <xkbcommon/xkbcommon.h>
#include "wlr-layer-shell-unstable-v1-protocol.h"
+#include "sway/desktop/idle_inhibit_v1.h"
static const int i3_output_id = INT32_MAX;
static const int i3_scratch_id = INT32_MAX - 1;
@@ -139,6 +140,22 @@ static const char *ipc_json_xwindow_type_description(struct sway_view *view) {
}
#endif
+static const char *ipc_json_user_idle_inhibitor_description(enum sway_idle_inhibit_mode mode) {
+ switch (mode) {
+ case INHIBIT_IDLE_FOCUS:
+ return "focus";
+ case INHIBIT_IDLE_FULLSCREEN:
+ return "fullscreen";
+ case INHIBIT_IDLE_OPEN:
+ return "open";
+ case INHIBIT_IDLE_VISIBLE:
+ return "visible";
+ case INHIBIT_IDLE_APPLICATION:
+ return NULL;
+ }
+ return NULL;
+}
+
json_object *ipc_json_get_version(void) {
int major = 0, minor = 0, patch = 0;
json_object *version = json_object_new_object();
@@ -492,6 +509,36 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object
json_object_object_add(object, "shell", json_object_new_string(view_get_shell(c->view)));
+ json_object_object_add(object, "inhibit_idle",
+ json_object_new_boolean(view_inhibit_idle(c->view)));
+
+ json_object *idle_inhibitors = json_object_new_object();
+
+ struct sway_idle_inhibitor_v1 *user_inhibitor =
+ sway_idle_inhibit_v1_user_inhibitor_for_view(c->view);
+
+ if (user_inhibitor) {
+ json_object_object_add(idle_inhibitors, "user",
+ json_object_new_string(
+ ipc_json_user_idle_inhibitor_description(user_inhibitor->mode)));
+ } else {
+ json_object_object_add(idle_inhibitors, "user",
+ json_object_new_string("none"));
+ }
+
+ struct sway_idle_inhibitor_v1 *application_inhibitor =
+ sway_idle_inhibit_v1_application_inhibitor_for_view(c->view);
+
+ if (application_inhibitor) {
+ json_object_object_add(idle_inhibitors, "application",
+ json_object_new_string("enabled"));
+ } else {
+ json_object_object_add(idle_inhibitors, "application",
+ json_object_new_string("none"));
+ }
+
+ json_object_object_add(object, "idle_inhibitors", idle_inhibitors);
+
#if HAVE_XWAYLAND
if (c->view->type == SWAY_VIEW_XWAYLAND) {
json_object_object_add(object, "window",