From 46c44e19a0109330505c3032bd4fe65fff975eec Mon Sep 17 00:00:00 2001 From: Stuart Dilts Date: Sun, 7 Apr 2024 16:49:52 -0600 Subject: [PATCH] hrt: partially hook up output layout change listener --- heart/include/hrt/hrt_output.h | 1 + heart/include/hrt/hrt_server.h | 1 + heart/src/output.c | 8 ++++++++ lisp/bindings/hrt-bindings.lisp | 4 +++- 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/heart/include/hrt/hrt_output.h b/heart/include/hrt/hrt_output.h index 19ff78a..4928d32 100644 --- a/heart/include/hrt/hrt_output.h +++ b/heart/include/hrt/hrt_output.h @@ -22,6 +22,7 @@ struct hrt_output { struct hrt_output_callbacks { void (*output_added)(struct hrt_output *output); void (*output_removed)(struct hrt_output *output); + void (*output_layout_changed)(struct hrt_output *output); }; bool hrt_output_init(struct hrt_server *server, const struct hrt_output_callbacks *callbacks); diff --git a/heart/include/hrt/hrt_server.h b/heart/include/hrt/hrt_server.h index 9878cc2..6ea9be8 100644 --- a/heart/include/hrt/hrt_server.h +++ b/heart/include/hrt/hrt_server.h @@ -30,6 +30,7 @@ struct hrt_server { struct wl_listener new_output; struct wlr_output_manager_v1 *output_manager; struct wlr_output_layout *output_layout; + struct wl_listener output_layout_changed; struct wl_listener output_manager_apply; struct wl_listener output_manager_test; struct wl_listener output_manager_destroy; diff --git a/heart/src/output.c b/heart/src/output.c index 5e1f0fa..dc69f9f 100644 --- a/heart/src/output.c +++ b/heart/src/output.c @@ -127,6 +127,10 @@ static void handle_output_manager_test(struct wl_listener *listener, void *data) } +static void handle_output_layout_changed(struct wl_listener *listener, void *data) { + wlr_log(WLR_DEBUG, "Output Layout changed"); +} + bool hrt_output_init(struct hrt_server *server, const struct hrt_output_callbacks *callbacks) { server->output_callback = callbacks; server->new_output.notify = handle_new_output; @@ -136,6 +140,9 @@ bool hrt_output_init(struct hrt_server *server, const struct hrt_output_callback server->scene = wlr_scene_create(); server->scene_layout = wlr_scene_attach_output_layout(server->scene, server->output_layout); + server->output_layout_changed.notify = handle_output_layout_changed; + wl_signal_add(&server->output_layout->events.change, &server->output_layout_changed); + server->output_manager = wlr_output_manager_v1_create(server->wl_display); if(!server->output_manager) { @@ -156,6 +163,7 @@ bool hrt_output_init(struct hrt_server *server, const struct hrt_output_callback void hrt_output_destroy(struct hrt_server *server) { wlr_scene_node_destroy(&server->scene->tree.node); + wl_list_remove(&server->output_layout_changed.link); // The output layout gets destroyed when the display does: // wlr_output_layout_destroy(server->output_layout); } diff --git a/lisp/bindings/hrt-bindings.lisp b/lisp/bindings/hrt-bindings.lisp index fd48dc7..385ff3b 100644 --- a/lisp/bindings/hrt-bindings.lisp +++ b/lisp/bindings/hrt-bindings.lisp @@ -122,7 +122,8 @@ See themes section of man xcursor(3) to find where to find valid cursor names." (cffi:defcstruct hrt-output-callbacks (output-added :pointer #| function ptr void (struct hrt_output *) |#) - (output-removed :pointer #| function ptr void (struct hrt_output *) |#)) + (output-removed :pointer #| function ptr void (struct hrt_output *) |#) + (output-layout-changed :pointer #| function ptr void (struct hrt_output *) |#)) (cffi:defcfun ("hrt_output_init" hrt-output-init) :bool (server (:pointer (:struct hrt-server))) @@ -170,6 +171,7 @@ set the width and height of views." (new-output (:struct wl-listener)) (output-manager :pointer #| (:struct wlr-output-manager-v1) |# ) (output-layout :pointer #| (:struct wlr-output-layout) |# ) + (output-layout-changed (:struct wl-listener)) (output-manager-apply (:struct wl-listener)) (output-manager-test (:struct wl-listener)) (output-manager-destroy (:struct wl-listener))