Skip to content

Commit

Permalink
hrt: partially hook up output layout change listener
Browse files Browse the repository at this point in the history
  • Loading branch information
sdilts committed Oct 19, 2024
1 parent 0178186 commit 88ab22d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions heart/include/hrt/hrt_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions heart/include/hrt/hrt_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions heart/src/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -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);
}
4 changes: 3 additions & 1 deletion lisp/bindings/hrt-bindings.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 88ab22d

Please sign in to comment.