diff options
Diffstat (limited to 'sway/ipc-json.c')
-rw-r--r-- | sway/ipc-json.c | 251 |
1 files changed, 194 insertions, 57 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 1b64f86e..81ca3483 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c | |||
@@ -3,7 +3,8 @@ | |||
3 | #include <json.h> | 3 | #include <json.h> |
4 | #include <libevdev/libevdev.h> | 4 | #include <libevdev/libevdev.h> |
5 | #include <stdio.h> | 5 | #include <stdio.h> |
6 | #include <wlr/backend/libinput.h> | 6 | #include <wlr/config.h> |
7 | #include <wlr/types/wlr_content_type_v1.h> | ||
7 | #include <wlr/types/wlr_output.h> | 8 | #include <wlr/types/wlr_output.h> |
8 | #include <xkbcommon/xkbcommon.h> | 9 | #include <xkbcommon/xkbcommon.h> |
9 | #include "config.h" | 10 | #include "config.h" |
@@ -20,6 +21,10 @@ | |||
20 | #include "wlr-layer-shell-unstable-v1-protocol.h" | 21 | #include "wlr-layer-shell-unstable-v1-protocol.h" |
21 | #include "sway/desktop/idle_inhibit_v1.h" | 22 | #include "sway/desktop/idle_inhibit_v1.h" |
22 | 23 | ||
24 | #if WLR_HAS_LIBINPUT_BACKEND | ||
25 | #include <wlr/backend/libinput.h> | ||
26 | #endif | ||
27 | |||
23 | static const int i3_output_id = INT32_MAX; | 28 | static const int i3_output_id = INT32_MAX; |
24 | static const int i3_scratch_id = INT32_MAX - 1; | 29 | static const int i3_scratch_id = INT32_MAX - 1; |
25 | 30 | ||
@@ -112,12 +117,43 @@ static const char *ipc_json_output_adaptive_sync_status_description( | |||
112 | return "disabled"; | 117 | return "disabled"; |
113 | case WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED: | 118 | case WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED: |
114 | return "enabled"; | 119 | return "enabled"; |
115 | case WLR_OUTPUT_ADAPTIVE_SYNC_UNKNOWN: | ||
116 | return "unknown"; | ||
117 | } | 120 | } |
118 | return NULL; | 121 | return NULL; |
119 | } | 122 | } |
120 | 123 | ||
124 | static const char *ipc_json_output_mode_aspect_ratio_description( | ||
125 | enum wlr_output_mode_aspect_ratio aspect_ratio) { | ||
126 | switch (aspect_ratio) { | ||
127 | case WLR_OUTPUT_MODE_ASPECT_RATIO_NONE: | ||
128 | return "none"; | ||
129 | case WLR_OUTPUT_MODE_ASPECT_RATIO_4_3: | ||
130 | return "4:3"; | ||
131 | case WLR_OUTPUT_MODE_ASPECT_RATIO_16_9: | ||
132 | return "16:9"; | ||
133 | case WLR_OUTPUT_MODE_ASPECT_RATIO_64_27: | ||
134 | return "64:27"; | ||
135 | case WLR_OUTPUT_MODE_ASPECT_RATIO_256_135: | ||
136 | return "256:135"; | ||
137 | } | ||
138 | return NULL; | ||
139 | } | ||
140 | |||
141 | static json_object *ipc_json_output_mode_description( | ||
142 | const struct wlr_output_mode *mode) { | ||
143 | const char *pic_ar = | ||
144 | ipc_json_output_mode_aspect_ratio_description(mode->picture_aspect_ratio); | ||
145 | json_object *mode_object = json_object_new_object(); | ||
146 | json_object_object_add(mode_object, "width", | ||
147 | json_object_new_int(mode->width)); | ||
148 | json_object_object_add(mode_object, "height", | ||
149 | json_object_new_int(mode->height)); | ||
150 | json_object_object_add(mode_object, "refresh", | ||
151 | json_object_new_int(mode->refresh)); | ||
152 | json_object_object_add(mode_object, "picture_aspect_ratio", | ||
153 | json_object_new_string(pic_ar)); | ||
154 | return mode_object; | ||
155 | } | ||
156 | |||
121 | #if HAVE_XWAYLAND | 157 | #if HAVE_XWAYLAND |
122 | static const char *ipc_json_xwindow_type_description(struct sway_view *view) { | 158 | static const char *ipc_json_xwindow_type_description(struct sway_view *view) { |
123 | struct wlr_xwayland_surface *surface = view->wlr_xwayland_surface; | 159 | struct wlr_xwayland_surface *surface = view->wlr_xwayland_surface; |
@@ -170,6 +206,20 @@ static const char *ipc_json_user_idle_inhibitor_description(enum sway_idle_inhib | |||
170 | return NULL; | 206 | return NULL; |
171 | } | 207 | } |
172 | 208 | ||
209 | static const char *ipc_json_content_type_description(enum wp_content_type_v1_type type) { | ||
210 | switch (type) { | ||
211 | case WP_CONTENT_TYPE_V1_TYPE_NONE: | ||
212 | return "none"; | ||
213 | case WP_CONTENT_TYPE_V1_TYPE_PHOTO: | ||
214 | return "photo"; | ||
215 | case WP_CONTENT_TYPE_V1_TYPE_VIDEO: | ||
216 | return "video"; | ||
217 | case WP_CONTENT_TYPE_V1_TYPE_GAME: | ||
218 | return "game"; | ||
219 | } | ||
220 | return NULL; | ||
221 | } | ||
222 | |||
173 | json_object *ipc_json_get_version(void) { | 223 | json_object *ipc_json_get_version(void) { |
174 | int major = 0, minor = 0, patch = 0; | 224 | int major = 0, minor = 0, patch = 0; |
175 | json_object *version = json_object_new_object(); | 225 | json_object *version = json_object_new_object(); |
@@ -238,27 +288,56 @@ static json_object *ipc_json_create_node(int id, const char* type, char *name, | |||
238 | json_object_object_add(object, "focus", focus); | 288 | json_object_object_add(object, "focus", focus); |
239 | json_object_object_add(object, "fullscreen_mode", json_object_new_int(0)); | 289 | json_object_object_add(object, "fullscreen_mode", json_object_new_int(0)); |
240 | json_object_object_add(object, "sticky", json_object_new_boolean(false)); | 290 | json_object_object_add(object, "sticky", json_object_new_boolean(false)); |
291 | json_object_object_add(object, "floating", NULL); | ||
292 | json_object_object_add(object, "scratchpad_state", NULL); | ||
241 | 293 | ||
242 | return object; | 294 | return object; |
243 | } | 295 | } |
244 | 296 | ||
297 | static void ipc_json_describe_wlr_output(struct wlr_output *wlr_output, json_object *object) { | ||
298 | json_object_object_add(object, "primary", json_object_new_boolean(false)); | ||
299 | json_object_object_add(object, "make", | ||
300 | json_object_new_string(wlr_output->make ? wlr_output->make : "Unknown")); | ||
301 | json_object_object_add(object, "model", | ||
302 | json_object_new_string(wlr_output->model ? wlr_output->model : "Unknown")); | ||
303 | json_object_object_add(object, "serial", | ||
304 | json_object_new_string(wlr_output->serial ? wlr_output->serial : "Unknown")); | ||
305 | |||
306 | json_object *modes_array = json_object_new_array(); | ||
307 | struct wlr_output_mode *mode; | ||
308 | wl_list_for_each(mode, &wlr_output->modes, link) { | ||
309 | json_object *mode_object = json_object_new_object(); | ||
310 | json_object_object_add(mode_object, "width", | ||
311 | json_object_new_int(mode->width)); | ||
312 | json_object_object_add(mode_object, "height", | ||
313 | json_object_new_int(mode->height)); | ||
314 | json_object_object_add(mode_object, "refresh", | ||
315 | json_object_new_int(mode->refresh)); | ||
316 | json_object_array_add(modes_array, mode_object); | ||
317 | } | ||
318 | json_object_object_add(object, "modes", modes_array); | ||
319 | } | ||
320 | |||
245 | static void ipc_json_describe_output(struct sway_output *output, | 321 | static void ipc_json_describe_output(struct sway_output *output, |
246 | json_object *object) { | 322 | json_object *object) { |
323 | ipc_json_describe_wlr_output(output->wlr_output, object); | ||
324 | } | ||
325 | |||
326 | static void ipc_json_describe_enabled_output(struct sway_output *output, | ||
327 | json_object *object) { | ||
328 | ipc_json_describe_output(output, object); | ||
329 | |||
247 | struct wlr_output *wlr_output = output->wlr_output; | 330 | struct wlr_output *wlr_output = output->wlr_output; |
331 | json_object_object_add(object, "non_desktop", json_object_new_boolean(false)); | ||
248 | json_object_object_add(object, "active", json_object_new_boolean(true)); | 332 | json_object_object_add(object, "active", json_object_new_boolean(true)); |
249 | json_object_object_add(object, "dpms", | 333 | json_object_object_add(object, "dpms", |
250 | json_object_new_boolean(wlr_output->enabled)); | 334 | json_object_new_boolean(wlr_output->enabled)); |
251 | json_object_object_add(object, "primary", json_object_new_boolean(false)); | 335 | json_object_object_add(object, "power", |
336 | json_object_new_boolean(wlr_output->enabled)); | ||
252 | json_object_object_add(object, "layout", json_object_new_string("output")); | 337 | json_object_object_add(object, "layout", json_object_new_string("output")); |
253 | json_object_object_add(object, "orientation", | 338 | json_object_object_add(object, "orientation", |
254 | json_object_new_string( | 339 | json_object_new_string( |
255 | ipc_json_orientation_description(L_NONE))); | 340 | ipc_json_orientation_description(L_NONE))); |
256 | json_object_object_add(object, "make", | ||
257 | json_object_new_string(wlr_output->make)); | ||
258 | json_object_object_add(object, "model", | ||
259 | json_object_new_string(wlr_output->model)); | ||
260 | json_object_object_add(object, "serial", | ||
261 | json_object_new_string(wlr_output->serial)); | ||
262 | json_object_object_add(object, "scale", | 341 | json_object_object_add(object, "scale", |
263 | json_object_new_double(wlr_output->scale)); | 342 | json_object_new_double(wlr_output->scale)); |
264 | json_object_object_add(object, "scale_filter", | 343 | json_object_object_add(object, "scale_filter", |
@@ -283,25 +362,26 @@ static void ipc_json_describe_output(struct sway_output *output, | |||
283 | json_object *modes_array = json_object_new_array(); | 362 | json_object *modes_array = json_object_new_array(); |
284 | struct wlr_output_mode *mode; | 363 | struct wlr_output_mode *mode; |
285 | wl_list_for_each(mode, &wlr_output->modes, link) { | 364 | wl_list_for_each(mode, &wlr_output->modes, link) { |
286 | json_object *mode_object = json_object_new_object(); | 365 | json_object *mode_object = |
287 | json_object_object_add(mode_object, "width", | 366 | ipc_json_output_mode_description(mode); |
288 | json_object_new_int(mode->width)); | ||
289 | json_object_object_add(mode_object, "height", | ||
290 | json_object_new_int(mode->height)); | ||
291 | json_object_object_add(mode_object, "refresh", | ||
292 | json_object_new_int(mode->refresh)); | ||
293 | json_object_array_add(modes_array, mode_object); | 367 | json_object_array_add(modes_array, mode_object); |
294 | } | 368 | } |
295 | 369 | ||
296 | json_object_object_add(object, "modes", modes_array); | 370 | json_object_object_add(object, "modes", modes_array); |
297 | 371 | ||
298 | json_object *current_mode_object = json_object_new_object(); | 372 | json_object *current_mode_object; |
299 | json_object_object_add(current_mode_object, "width", | 373 | if (wlr_output->current_mode != NULL) { |
300 | json_object_new_int(wlr_output->width)); | 374 | current_mode_object = |
301 | json_object_object_add(current_mode_object, "height", | 375 | ipc_json_output_mode_description(wlr_output->current_mode); |
302 | json_object_new_int(wlr_output->height)); | 376 | } else { |
303 | json_object_object_add(current_mode_object, "refresh", | 377 | current_mode_object = json_object_new_object(); |
304 | json_object_new_int(wlr_output->refresh)); | 378 | json_object_object_add(current_mode_object, "width", |
379 | json_object_new_int(wlr_output->width)); | ||
380 | json_object_object_add(current_mode_object, "height", | ||
381 | json_object_new_int(wlr_output->height)); | ||
382 | json_object_object_add(current_mode_object, "refresh", | ||
383 | json_object_new_int(wlr_output->refresh)); | ||
384 | } | ||
305 | json_object_object_add(object, "current_mode", current_mode_object); | 385 | json_object_object_add(object, "current_mode", current_mode_object); |
306 | 386 | ||
307 | struct sway_node *parent = node_get_parent(&output->node); | 387 | struct sway_node *parent = node_get_parent(&output->node); |
@@ -325,33 +405,15 @@ json_object *ipc_json_describe_disabled_output(struct sway_output *output) { | |||
325 | 405 | ||
326 | json_object *object = json_object_new_object(); | 406 | json_object *object = json_object_new_object(); |
327 | 407 | ||
408 | ipc_json_describe_output(output, object); | ||
409 | |||
410 | json_object_object_add(object, "non_desktop", json_object_new_boolean(false)); | ||
328 | json_object_object_add(object, "type", json_object_new_string("output")); | 411 | json_object_object_add(object, "type", json_object_new_string("output")); |
329 | json_object_object_add(object, "name", | 412 | json_object_object_add(object, "name", |
330 | json_object_new_string(wlr_output->name)); | 413 | json_object_new_string(wlr_output->name)); |
331 | json_object_object_add(object, "active", json_object_new_boolean(false)); | 414 | json_object_object_add(object, "active", json_object_new_boolean(false)); |
332 | json_object_object_add(object, "dpms", json_object_new_boolean(false)); | 415 | json_object_object_add(object, "dpms", json_object_new_boolean(false)); |
333 | json_object_object_add(object, "primary", json_object_new_boolean(false)); | 416 | json_object_object_add(object, "power", json_object_new_boolean(false)); |
334 | json_object_object_add(object, "make", | ||
335 | json_object_new_string(wlr_output->make)); | ||
336 | json_object_object_add(object, "model", | ||
337 | json_object_new_string(wlr_output->model)); | ||
338 | json_object_object_add(object, "serial", | ||
339 | json_object_new_string(wlr_output->serial)); | ||
340 | |||
341 | json_object *modes_array = json_object_new_array(); | ||
342 | struct wlr_output_mode *mode; | ||
343 | wl_list_for_each(mode, &wlr_output->modes, link) { | ||
344 | json_object *mode_object = json_object_new_object(); | ||
345 | json_object_object_add(mode_object, "width", | ||
346 | json_object_new_int(mode->width)); | ||
347 | json_object_object_add(mode_object, "height", | ||
348 | json_object_new_int(mode->height)); | ||
349 | json_object_object_add(mode_object, "refresh", | ||
350 | json_object_new_int(mode->refresh)); | ||
351 | json_object_array_add(modes_array, mode_object); | ||
352 | } | ||
353 | |||
354 | json_object_object_add(object, "modes", modes_array); | ||
355 | 417 | ||
356 | json_object_object_add(object, "current_workspace", NULL); | 418 | json_object_object_add(object, "current_workspace", NULL); |
357 | 419 | ||
@@ -367,6 +429,21 @@ json_object *ipc_json_describe_disabled_output(struct sway_output *output) { | |||
367 | return object; | 429 | return object; |
368 | } | 430 | } |
369 | 431 | ||
432 | json_object *ipc_json_describe_non_desktop_output(struct sway_output_non_desktop *output) { | ||
433 | struct wlr_output *wlr_output = output->wlr_output; | ||
434 | |||
435 | json_object *object = json_object_new_object(); | ||
436 | |||
437 | ipc_json_describe_wlr_output(wlr_output, object); | ||
438 | |||
439 | json_object_object_add(object, "non_desktop", json_object_new_boolean(true)); | ||
440 | json_object_object_add(object, "type", json_object_new_string("output")); | ||
441 | json_object_object_add(object, "name", | ||
442 | json_object_new_string(wlr_output->name)); | ||
443 | |||
444 | return object; | ||
445 | } | ||
446 | |||
370 | static json_object *ipc_json_describe_scratchpad_output(void) { | 447 | static json_object *ipc_json_describe_scratchpad_output(void) { |
371 | struct wlr_box box; | 448 | struct wlr_box box; |
372 | root_get_box(root, &box); | 449 | root_get_box(root, &box); |
@@ -453,7 +530,9 @@ static void ipc_json_describe_workspace(struct sway_workspace *workspace, | |||
453 | 530 | ||
454 | static void get_deco_rect(struct sway_container *c, struct wlr_box *deco_rect) { | 531 | static void get_deco_rect(struct sway_container *c, struct wlr_box *deco_rect) { |
455 | enum sway_container_layout parent_layout = container_parent_layout(c); | 532 | enum sway_container_layout parent_layout = container_parent_layout(c); |
456 | bool tab_or_stack = parent_layout == L_TABBED || parent_layout == L_STACKED; | 533 | list_t *siblings = container_get_siblings(c); |
534 | bool tab_or_stack = (parent_layout == L_TABBED || parent_layout == L_STACKED) | ||
535 | && ((siblings && siblings->length > 1) || !config->hide_lone_tab); | ||
457 | if (((!tab_or_stack || container_is_floating(c)) && | 536 | if (((!tab_or_stack || container_is_floating(c)) && |
458 | c->current.border != B_NORMAL) || | 537 | c->current.border != B_NORMAL) || |
459 | c->pending.fullscreen_mode != FULLSCREEN_NONE || | 538 | c->pending.fullscreen_mode != FULLSCREEN_NONE || |
@@ -500,7 +579,7 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object | |||
500 | 579 | ||
501 | struct wlr_box window_box = { | 580 | struct wlr_box window_box = { |
502 | c->pending.content_x - c->pending.x, | 581 | c->pending.content_x - c->pending.x, |
503 | (c->current.border == B_PIXEL) ? c->current.border_thickness : 0, | 582 | (c->current.border == B_PIXEL) ? c->pending.content_y - c->pending.y : 0, |
504 | c->pending.content_width, | 583 | c->pending.content_width, |
505 | c->pending.content_height | 584 | c->pending.content_height |
506 | }; | 585 | }; |
@@ -544,6 +623,16 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object | |||
544 | 623 | ||
545 | json_object_object_add(object, "idle_inhibitors", idle_inhibitors); | 624 | json_object_object_add(object, "idle_inhibitors", idle_inhibitors); |
546 | 625 | ||
626 | enum wp_content_type_v1_type content_type = WP_CONTENT_TYPE_V1_TYPE_NONE; | ||
627 | if (c->view->surface != NULL) { | ||
628 | content_type = wlr_surface_get_content_type_v1(server.content_type_manager_v1, | ||
629 | c->view->surface); | ||
630 | } | ||
631 | if (content_type != WP_CONTENT_TYPE_V1_TYPE_NONE) { | ||
632 | json_object_object_add(object, "content_type", | ||
633 | json_object_new_string(ipc_json_content_type_description(content_type))); | ||
634 | } | ||
635 | |||
547 | #if HAVE_XWAYLAND | 636 | #if HAVE_XWAYLAND |
548 | if (c->view->type == SWAY_VIEW_XWAYLAND) { | 637 | if (c->view->type == SWAY_VIEW_XWAYLAND) { |
549 | json_object_object_add(object, "window", | 638 | json_object_object_add(object, "window", |
@@ -588,7 +677,8 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object | |||
588 | static void ipc_json_describe_container(struct sway_container *c, json_object *object) { | 677 | static void ipc_json_describe_container(struct sway_container *c, json_object *object) { |
589 | json_object_object_add(object, "name", | 678 | json_object_object_add(object, "name", |
590 | c->title ? json_object_new_string(c->title) : NULL); | 679 | c->title ? json_object_new_string(c->title) : NULL); |
591 | if (container_is_floating(c)) { | 680 | bool floating = container_is_floating(c); |
681 | if (floating) { | ||
592 | json_object_object_add(object, "type", | 682 | json_object_object_add(object, "type", |
593 | json_object_new_string("floating_con")); | 683 | json_object_new_string("floating_con")); |
594 | } | 684 | } |
@@ -606,9 +696,17 @@ static void ipc_json_describe_container(struct sway_container *c, json_object *o | |||
606 | json_object_object_add(object, "urgent", json_object_new_boolean(urgent)); | 696 | json_object_object_add(object, "urgent", json_object_new_boolean(urgent)); |
607 | json_object_object_add(object, "sticky", json_object_new_boolean(c->is_sticky)); | 697 | json_object_object_add(object, "sticky", json_object_new_boolean(c->is_sticky)); |
608 | 698 | ||
699 | // sway doesn't track the floating reason, so we can't use "auto_on" or "user_off" | ||
700 | json_object_object_add(object, "floating", | ||
701 | json_object_new_string(floating ? "user_on" : "auto_off")); | ||
702 | |||
609 | json_object_object_add(object, "fullscreen_mode", | 703 | json_object_object_add(object, "fullscreen_mode", |
610 | json_object_new_int(c->pending.fullscreen_mode)); | 704 | json_object_new_int(c->pending.fullscreen_mode)); |
611 | 705 | ||
706 | // sway doesn't track if window was resized in scratchpad, so we can't use "changed" | ||
707 | json_object_object_add(object, "scratchpad_state", | ||
708 | json_object_new_string(!c->scratchpad ? "none" : "fresh")); | ||
709 | |||
612 | struct sway_node *parent = node_get_parent(&c->node); | 710 | struct sway_node *parent = node_get_parent(&c->node); |
613 | struct wlr_box parent_box = {0, 0, 0, 0}; | 711 | struct wlr_box parent_box = {0, 0, 0, 0}; |
614 | 712 | ||
@@ -706,7 +804,7 @@ json_object *ipc_json_describe_node(struct sway_node *node) { | |||
706 | case N_ROOT: | 804 | case N_ROOT: |
707 | break; | 805 | break; |
708 | case N_OUTPUT: | 806 | case N_OUTPUT: |
709 | ipc_json_describe_output(node->sway_output, object); | 807 | ipc_json_describe_enabled_output(node->sway_output, object); |
710 | break; | 808 | break; |
711 | case N_CONTAINER: | 809 | case N_CONTAINER: |
712 | ipc_json_describe_container(node->sway_container, object); | 810 | ipc_json_describe_container(node->sway_container, object); |
@@ -764,6 +862,7 @@ json_object *ipc_json_describe_node_recursive(struct sway_node *node) { | |||
764 | return object; | 862 | return object; |
765 | } | 863 | } |
766 | 864 | ||
865 | #if WLR_HAS_LIBINPUT_BACKEND | ||
767 | static json_object *describe_libinput_device(struct libinput_device *device) { | 866 | static json_object *describe_libinput_device(struct libinput_device *device) { |
768 | json_object *object = json_object_new_object(); | 867 | json_object *object = json_object_new_object(); |
769 | 868 | ||
@@ -847,6 +946,11 @@ static json_object *describe_libinput_device(struct libinput_device *device) { | |||
847 | case LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE: | 946 | case LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE: |
848 | accel_profile = "adaptive"; | 947 | accel_profile = "adaptive"; |
849 | break; | 948 | break; |
949 | #if HAVE_LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM | ||
950 | case LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM: | ||
951 | accel_profile = "custom"; | ||
952 | break; | ||
953 | #endif | ||
850 | } | 954 | } |
851 | json_object_object_add(object, "accel_profile", | 955 | json_object_object_add(object, "accel_profile", |
852 | json_object_new_string(accel_profile)); | 956 | json_object_new_string(accel_profile)); |
@@ -926,6 +1030,17 @@ static json_object *describe_libinput_device(struct libinput_device *device) { | |||
926 | uint32_t button = libinput_device_config_scroll_get_button(device); | 1030 | uint32_t button = libinput_device_config_scroll_get_button(device); |
927 | json_object_object_add(object, "scroll_button", | 1031 | json_object_object_add(object, "scroll_button", |
928 | json_object_new_int(button)); | 1032 | json_object_new_int(button)); |
1033 | const char *lock = "unknown"; | ||
1034 | switch (libinput_device_config_scroll_get_button_lock(device)) { | ||
1035 | case LIBINPUT_CONFIG_SCROLL_BUTTON_LOCK_ENABLED: | ||
1036 | lock = "enabled"; | ||
1037 | break; | ||
1038 | case LIBINPUT_CONFIG_SCROLL_BUTTON_LOCK_DISABLED: | ||
1039 | lock = "disabled"; | ||
1040 | break; | ||
1041 | } | ||
1042 | json_object_object_add(object, "scroll_button_lock", | ||
1043 | json_object_new_string(lock)); | ||
929 | } | 1044 | } |
930 | } | 1045 | } |
931 | 1046 | ||
@@ -942,6 +1057,19 @@ static json_object *describe_libinput_device(struct libinput_device *device) { | |||
942 | json_object_object_add(object, "dwt", json_object_new_string(dwt)); | 1057 | json_object_object_add(object, "dwt", json_object_new_string(dwt)); |
943 | } | 1058 | } |
944 | 1059 | ||
1060 | if (libinput_device_config_dwtp_is_available(device)) { | ||
1061 | const char *dwtp = "unknown"; | ||
1062 | switch (libinput_device_config_dwtp_get_enabled(device)) { | ||
1063 | case LIBINPUT_CONFIG_DWTP_ENABLED: | ||
1064 | dwtp = "enabled"; | ||
1065 | break; | ||
1066 | case LIBINPUT_CONFIG_DWTP_DISABLED: | ||
1067 | dwtp = "disabled"; | ||
1068 | break; | ||
1069 | } | ||
1070 | json_object_object_add(object, "dwtp", json_object_new_string(dwtp)); | ||
1071 | } | ||
1072 | |||
945 | if (libinput_device_config_calibration_has_matrix(device)) { | 1073 | if (libinput_device_config_calibration_has_matrix(device)) { |
946 | float matrix[6]; | 1074 | float matrix[6]; |
947 | libinput_device_config_calibration_get_matrix(device, matrix); | 1075 | libinput_device_config_calibration_get_matrix(device, matrix); |
@@ -956,6 +1084,7 @@ static json_object *describe_libinput_device(struct libinput_device *device) { | |||
956 | 1084 | ||
957 | return object; | 1085 | return object; |
958 | } | 1086 | } |
1087 | #endif | ||
959 | 1088 | ||
960 | json_object *ipc_json_describe_input(struct sway_input_device *device) { | 1089 | json_object *ipc_json_describe_input(struct sway_input_device *device) { |
961 | if (!(sway_assert(device, "Device must not be null"))) { | 1090 | if (!(sway_assert(device, "Device must not be null"))) { |
@@ -968,19 +1097,21 @@ json_object *ipc_json_describe_input(struct sway_input_device *device) { | |||
968 | json_object_new_string(device->identifier)); | 1097 | json_object_new_string(device->identifier)); |
969 | json_object_object_add(object, "name", | 1098 | json_object_object_add(object, "name", |
970 | json_object_new_string(device->wlr_device->name)); | 1099 | json_object_new_string(device->wlr_device->name)); |
971 | json_object_object_add(object, "vendor", | ||
972 | json_object_new_int(device->wlr_device->vendor)); | ||
973 | json_object_object_add(object, "product", | ||
974 | json_object_new_int(device->wlr_device->product)); | ||
975 | json_object_object_add(object, "type", | 1100 | json_object_object_add(object, "type", |
976 | json_object_new_string( | 1101 | json_object_new_string( |
977 | input_device_get_type(device))); | 1102 | input_device_get_type(device))); |
978 | 1103 | ||
979 | if (device->wlr_device->type == WLR_INPUT_DEVICE_KEYBOARD) { | 1104 | if (device->wlr_device->type == WLR_INPUT_DEVICE_KEYBOARD) { |
980 | struct wlr_keyboard *keyboard = device->wlr_device->keyboard; | 1105 | struct wlr_keyboard *keyboard = |
1106 | wlr_keyboard_from_input_device(device->wlr_device); | ||
981 | struct xkb_keymap *keymap = keyboard->keymap; | 1107 | struct xkb_keymap *keymap = keyboard->keymap; |
982 | struct xkb_state *state = keyboard->xkb_state; | 1108 | struct xkb_state *state = keyboard->xkb_state; |
983 | 1109 | ||
1110 | json_object_object_add(object, "repeat_delay", | ||
1111 | json_object_new_int(keyboard->repeat_info.delay)); | ||
1112 | json_object_object_add(object, "repeat_rate", | ||
1113 | json_object_new_int(keyboard->repeat_info.rate)); | ||
1114 | |||
984 | json_object *layouts_arr = json_object_new_array(); | 1115 | json_object *layouts_arr = json_object_new_array(); |
985 | json_object_object_add(object, "xkb_layout_names", layouts_arr); | 1116 | json_object_object_add(object, "xkb_layout_names", layouts_arr); |
986 | 1117 | ||
@@ -1005,20 +1136,26 @@ json_object *ipc_json_describe_input(struct sway_input_device *device) { | |||
1005 | if (device->wlr_device->type == WLR_INPUT_DEVICE_POINTER) { | 1136 | if (device->wlr_device->type == WLR_INPUT_DEVICE_POINTER) { |
1006 | struct input_config *ic = input_device_get_config(device); | 1137 | struct input_config *ic = input_device_get_config(device); |
1007 | float scroll_factor = 1.0f; | 1138 | float scroll_factor = 1.0f; |
1008 | if (ic != NULL && !isnan(ic->scroll_factor) && | 1139 | if (ic != NULL && !isnan(ic->scroll_factor) && |
1009 | ic->scroll_factor != FLT_MIN) { | 1140 | ic->scroll_factor != FLT_MIN) { |
1010 | scroll_factor = ic->scroll_factor; | 1141 | scroll_factor = ic->scroll_factor; |
1011 | } | 1142 | } |
1012 | json_object_object_add(object, "scroll_factor", | 1143 | json_object_object_add(object, "scroll_factor", |
1013 | json_object_new_double(scroll_factor)); | 1144 | json_object_new_double(scroll_factor)); |
1014 | } | 1145 | } |
1015 | 1146 | ||
1147 | #if WLR_HAS_LIBINPUT_BACKEND | ||
1016 | if (wlr_input_device_is_libinput(device->wlr_device)) { | 1148 | if (wlr_input_device_is_libinput(device->wlr_device)) { |
1017 | struct libinput_device *libinput_dev; | 1149 | struct libinput_device *libinput_dev; |
1018 | libinput_dev = wlr_libinput_get_device_handle(device->wlr_device); | 1150 | libinput_dev = wlr_libinput_get_device_handle(device->wlr_device); |
1019 | json_object_object_add(object, "libinput", | 1151 | json_object_object_add(object, "libinput", |
1020 | describe_libinput_device(libinput_dev)); | 1152 | describe_libinput_device(libinput_dev)); |
1153 | json_object_object_add(object, "vendor", | ||
1154 | json_object_new_int(libinput_device_get_id_vendor(libinput_dev))); | ||
1155 | json_object_object_add(object, "product", | ||
1156 | json_object_new_int(libinput_device_get_id_product(libinput_dev))); | ||
1021 | } | 1157 | } |
1158 | #endif | ||
1022 | 1159 | ||
1023 | return object; | 1160 | return object; |
1024 | } | 1161 | } |