diff options
author | Simon Ser <contact@emersion.fr> | 2023-02-01 16:19:41 +0100 |
---|---|---|
committer | Simon Zeni <simon@bl4ckb0ne.ca> | 2023-02-01 11:32:57 -0500 |
commit | 40eb29e7c56b67c2112ead7f048e45220a1c2887 (patch) | |
tree | d29b0d25eafeb8e93ad3f067658d3930d0020665 | |
parent | Added reference for event types to swaymsg manpage (diff) | |
download | sway-40eb29e7c56b67c2112ead7f048e45220a1c2887.tar.gz sway-40eb29e7c56b67c2112ead7f048e45220a1c2887.tar.zst sway-40eb29e7c56b67c2112ead7f048e45220a1c2887.zip |
ipc: add support for output event
For compatibility with i3 [1].
[1]: https://i3wm.org/docs/ipc.html#_output_event
-rw-r--r-- | include/sway/ipc-server.h | 1 | ||||
-rw-r--r-- | sway/desktop/output.c | 3 | ||||
-rw-r--r-- | sway/ipc-server.c | 14 | ||||
-rw-r--r-- | sway/sway-ipc.7.scd | 17 |
4 files changed, 35 insertions, 0 deletions
diff --git a/include/sway/ipc-server.h b/include/sway/ipc-server.h index bc4f781a..d4c00942 100644 --- a/include/sway/ipc-server.h +++ b/include/sway/ipc-server.h | |||
@@ -21,5 +21,6 @@ void ipc_event_mode(const char *mode, bool pango); | |||
21 | void ipc_event_shutdown(const char *reason); | 21 | void ipc_event_shutdown(const char *reason); |
22 | void ipc_event_binding(struct sway_binding *binding); | 22 | void ipc_event_binding(struct sway_binding *binding); |
23 | void ipc_event_input(const char *change, struct sway_input_device *device); | 23 | void ipc_event_input(const char *change, struct sway_input_device *device); |
24 | void ipc_event_output(void); | ||
24 | 25 | ||
25 | #endif | 26 | #endif |
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 1c209a39..141edb49 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include "sway/desktop/transaction.h" | 20 | #include "sway/desktop/transaction.h" |
21 | #include "sway/input/input-manager.h" | 21 | #include "sway/input/input-manager.h" |
22 | #include "sway/input/seat.h" | 22 | #include "sway/input/seat.h" |
23 | #include "sway/ipc-server.h" | ||
23 | #include "sway/layers.h" | 24 | #include "sway/layers.h" |
24 | #include "sway/output.h" | 25 | #include "sway/output.h" |
25 | #include "sway/server.h" | 26 | #include "sway/server.h" |
@@ -789,6 +790,8 @@ static void update_output_manager_config(struct sway_server *server) { | |||
789 | } | 790 | } |
790 | 791 | ||
791 | wlr_output_manager_v1_set_configuration(server->output_manager_v1, config); | 792 | wlr_output_manager_v1_set_configuration(server->output_manager_v1, config); |
793 | |||
794 | ipc_event_output(); | ||
792 | } | 795 | } |
793 | 796 | ||
794 | static void handle_destroy(struct wl_listener *listener, void *data) { | 797 | static void handle_destroy(struct wl_listener *listener, void *data) { |
diff --git a/sway/ipc-server.c b/sway/ipc-server.c index 51244436..2941ee76 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c | |||
@@ -508,6 +508,20 @@ void ipc_event_input(const char *change, struct sway_input_device *device) { | |||
508 | json_object_put(json); | 508 | json_object_put(json); |
509 | } | 509 | } |
510 | 510 | ||
511 | void ipc_event_output(void) { | ||
512 | if (!ipc_has_event_listeners(IPC_EVENT_OUTPUT)) { | ||
513 | return; | ||
514 | } | ||
515 | sway_log(SWAY_DEBUG, "Sending output event"); | ||
516 | |||
517 | json_object *json = json_object_new_object(); | ||
518 | json_object_object_add(json, "change", json_object_new_string("unspecified")); | ||
519 | |||
520 | const char *json_string = json_object_to_json_string(json); | ||
521 | ipc_send_event(json_string, IPC_EVENT_OUTPUT); | ||
522 | json_object_put(json); | ||
523 | } | ||
524 | |||
511 | int ipc_client_handle_writable(int client_fd, uint32_t mask, void *data) { | 525 | int ipc_client_handle_writable(int client_fd, uint32_t mask, void *data) { |
512 | struct ipc_client *client = data; | 526 | struct ipc_client *client = data; |
513 | 527 | ||
diff --git a/sway/sway-ipc.7.scd b/sway/sway-ipc.7.scd index 9121f679..2e903988 100644 --- a/sway/sway-ipc.7.scd +++ b/sway/sway-ipc.7.scd | |||
@@ -1445,6 +1445,9 @@ available: | |||
1445 | : workspace | 1445 | : workspace |
1446 | :[ Sent whenever an event involving a workspace occurs such as initialization | 1446 | :[ Sent whenever an event involving a workspace occurs such as initialization |
1447 | of a new workspace or a different workspace gains focus | 1447 | of a new workspace or a different workspace gains focus |
1448 | |- 0x80000001 | ||
1449 | : output | ||
1450 | : Sent when outputs are updated | ||
1448 | |- 0x80000002 | 1451 | |- 0x80000002 |
1449 | : mode | 1452 | : mode |
1450 | : Sent whenever the binding mode changes | 1453 | : Sent whenever the binding mode changes |
@@ -1565,6 +1568,20 @@ The following change types are currently available: | |||
1565 | } | 1568 | } |
1566 | ``` | 1569 | ``` |
1567 | 1570 | ||
1571 | ## 0x80000001. OUTPUT | ||
1572 | |||
1573 | Sent whenever an output is added, removed, or its configuration is changed. | ||
1574 | The event is a single object with the property _change_, which is a string | ||
1575 | containing the reason for the change. Currently, the only value for _change_ is | ||
1576 | _unspecified_. | ||
1577 | |||
1578 | *Example Event:* | ||
1579 | ``` | ||
1580 | { | ||
1581 | "change": "unspecified" | ||
1582 | } | ||
1583 | ``` | ||
1584 | |||
1568 | ## 0x80000002. MODE | 1585 | ## 0x80000002. MODE |
1569 | 1586 | ||
1570 | Sent whenever the binding mode changes. The event consists of a single object | 1587 | Sent whenever the binding mode changes. The event consists of a single object |