aboutsummaryrefslogtreecommitdiffstats
path: root/sway/ipc-json.c
diff options
context:
space:
mode:
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 @@
18#include <wlr/types/wlr_output.h> 18#include <wlr/types/wlr_output.h>
19#include <xkbcommon/xkbcommon.h> 19#include <xkbcommon/xkbcommon.h>
20#include "wlr-layer-shell-unstable-v1-protocol.h" 20#include "wlr-layer-shell-unstable-v1-protocol.h"
21#include "sway/desktop/idle_inhibit_v1.h"
21 22
22static const int i3_output_id = INT32_MAX; 23static const int i3_output_id = INT32_MAX;
23static const int i3_scratch_id = INT32_MAX - 1; 24static const int i3_scratch_id = INT32_MAX - 1;
@@ -139,6 +140,22 @@ static const char *ipc_json_xwindow_type_description(struct sway_view *view) {
139} 140}
140#endif 141#endif
141 142
143static const char *ipc_json_user_idle_inhibitor_description(enum sway_idle_inhibit_mode mode) {
144 switch (mode) {
145 case INHIBIT_IDLE_FOCUS:
146 return "focus";
147 case INHIBIT_IDLE_FULLSCREEN:
148 return "fullscreen";
149 case INHIBIT_IDLE_OPEN:
150 return "open";
151 case INHIBIT_IDLE_VISIBLE:
152 return "visible";
153 case INHIBIT_IDLE_APPLICATION:
154 return NULL;
155 }
156 return NULL;
157}
158
142json_object *ipc_json_get_version(void) { 159json_object *ipc_json_get_version(void) {
143 int major = 0, minor = 0, patch = 0; 160 int major = 0, minor = 0, patch = 0;
144 json_object *version = json_object_new_object(); 161 json_object *version = json_object_new_object();
@@ -492,6 +509,36 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object
492 509
493 json_object_object_add(object, "shell", json_object_new_string(view_get_shell(c->view))); 510 json_object_object_add(object, "shell", json_object_new_string(view_get_shell(c->view)));
494 511
512 json_object_object_add(object, "inhibit_idle",
513 json_object_new_boolean(view_inhibit_idle(c->view)));
514
515 json_object *idle_inhibitors = json_object_new_object();
516
517 struct sway_idle_inhibitor_v1 *user_inhibitor =
518 sway_idle_inhibit_v1_user_inhibitor_for_view(c->view);
519
520 if (user_inhibitor) {
521 json_object_object_add(idle_inhibitors, "user",
522 json_object_new_string(
523 ipc_json_user_idle_inhibitor_description(user_inhibitor->mode)));
524 } else {
525 json_object_object_add(idle_inhibitors, "user",
526 json_object_new_string("none"));
527 }
528
529 struct sway_idle_inhibitor_v1 *application_inhibitor =
530 sway_idle_inhibit_v1_application_inhibitor_for_view(c->view);
531
532 if (application_inhibitor) {
533 json_object_object_add(idle_inhibitors, "application",
534 json_object_new_string("enabled"));
535 } else {
536 json_object_object_add(idle_inhibitors, "application",
537 json_object_new_string("none"));
538 }
539
540 json_object_object_add(object, "idle_inhibitors", idle_inhibitors);
541
495#if HAVE_XWAYLAND 542#if HAVE_XWAYLAND
496 if (c->view->type == SWAY_VIEW_XWAYLAND) { 543 if (c->view->type == SWAY_VIEW_XWAYLAND) {
497 json_object_object_add(object, "window", 544 json_object_object_add(object, "window",