diff --git a/heart/include/hrt/hrt_server.h b/heart/include/hrt/hrt_server.h index 54259e2..58d4746 100644 --- a/heart/include/hrt/hrt_server.h +++ b/heart/include/hrt/hrt_server.h @@ -29,6 +29,9 @@ struct hrt_server { struct hrt_seat seat; + struct wlr_xdg_shell *xdg_shell; + struct wl_listener new_xdg_surface; + const struct hrt_output_callbacks *output_callback; }; diff --git a/heart/include/hrt/hrt_view.h b/heart/include/hrt/hrt_view.h new file mode 100644 index 0000000..b19d24c --- /dev/null +++ b/heart/include/hrt/hrt_view.h @@ -0,0 +1,9 @@ +#include +#include "hrt/hrt_server.h" + +struct hrt_view { + struct wlr_xdg_toplevel *xdg_toplevel; + struct wl_listener map; + struct wl_listener unmap; + struct wl_listener destroy; +}; diff --git a/heart/include/xdg_impl.h b/heart/include/xdg_impl.h new file mode 100644 index 0000000..454a894 --- /dev/null +++ b/heart/include/xdg_impl.h @@ -0,0 +1,5 @@ +#pragma once + +#include + +void handle_new_xdg_surface(struct wl_listener *listener, void *data); diff --git a/heart/src/meson.build b/heart/src/meson.build index 4cc09ad..eca78b3 100644 --- a/heart/src/meson.build +++ b/heart/src/meson.build @@ -5,4 +5,5 @@ hrt_source_files += files( 'seat.c', 'keyboard.c', 'cursor.c', + 'xdg_shell.c', ) diff --git a/heart/src/server.c b/heart/src/server.c index 1da728b..458a81e 100644 --- a/heart/src/server.c +++ b/heart/src/server.c @@ -1,4 +1,5 @@ #include "wlr/util/log.h" +#include "xdg_impl.h" #include #include #include @@ -8,6 +9,7 @@ #include #include #include +#include #include #include @@ -43,6 +45,13 @@ bool hrt_server_init(struct hrt_server *server, const struct hrt_output_callback wlr_data_control_manager_v1_create(server->wl_display); wlr_gamma_control_manager_v1_create(server->wl_display); + server->output_layout = wlr_output_layout_create(); + + server->xdg_shell = wlr_xdg_shell_create(server->wl_display, 3); + server->new_xdg_surface.notify = handle_new_xdg_surface; + wl_signal_add(&server->xdg_shell->events.new_surface, &server->new_xdg_surface); + + if(!hrt_output_init(server, output_callbacks)) { return false; } diff --git a/heart/src/xdg_shell.c b/heart/src/xdg_shell.c new file mode 100644 index 0000000..eb8ebe7 --- /dev/null +++ b/heart/src/xdg_shell.c @@ -0,0 +1,51 @@ +#include + +#include +#include +#include + +#include "hrt/hrt_input.h" +#include "xdg_impl.h" +#include "hrt/hrt_view.h" + +#include + +static void handle_xdg_toplevel_map(struct wl_listener *listener, void *data) { + wlr_log(WLR_DEBUG, "XDG Toplevel Mapped!"); +} + +static void handle_xdg_toplevel_unmap(struct wl_listener *listener, + void *data) { + wlr_log(WLR_DEBUG, "XDG Toplevel unmapped!"); +} + +static void handle_xdg_toplevel_destroy(struct wl_listener *listener, + void *data) { + wlr_log(WLR_DEBUG, "XDG Toplevel Destroyed!"); + struct hrt_view *view = wl_container_of(listener, view, destroy); + + wl_list_remove(&view->map.link); + wl_list_remove(&view->unmap.link); + wl_list_remove(&view->destroy.link); + + free(view); +} + +void handle_new_xdg_surface(struct wl_listener *listener, void *data) { + wlr_log(WLR_DEBUG, "New XDG Surface recieved"); + struct hrt_server *server = wl_container_of(listener, server, new_xdg_surface); + struct wlr_xdg_surface *xdg_surface = data; + + if(xdg_surface->role == WLR_XDG_SURFACE_ROLE_POPUP) { + return; + } + + struct hrt_view *view = calloc(1, sizeof(struct hrt_view)); + + view->map.notify = handle_xdg_toplevel_map; + wl_signal_add(&xdg_surface->events.map, &view->map); + view->unmap.notify = handle_xdg_toplevel_unmap; + wl_signal_add(&xdg_surface->events.unmap, &view->unmap); + view->destroy.notify = handle_xdg_toplevel_destroy; + wl_signal_add(&xdg_surface->events.destroy, &view->destroy); +} diff --git a/lisp/bindings/hrt-bindings.lisp b/lisp/bindings/hrt-bindings.lisp index 9d39e24..baa884d 100644 --- a/lisp/bindings/hrt-bindings.lisp +++ b/lisp/bindings/hrt-bindings.lisp @@ -97,7 +97,6 @@ See themes section of man xcursor(3) to find where to find valid cursor names." (output-manager-apply (:struct wl-listener)) (output-manager-test (:struct wl-listener)) (seat (:struct hrt-seat)) - (scene :pointer #| (:struct wlr-scene) |# ) (xdg-shell :pointer #| (:struct wlr-xdg-shell) |# ) (new-xdg-surface (:struct wl-listener)) (output-callback (:pointer (:struct hrt-output-callbacks))))