diff --git a/src/foreign_toplevel.cpp b/src/foreign_toplevel.cpp index 69dc4c854..5b042e8ff 100644 --- a/src/foreign_toplevel.cpp +++ b/src/foreign_toplevel.cpp @@ -36,8 +36,10 @@ static void foreign_toplevel_handle_request_activate_notify(wl_listener* listene } static void foreign_toplevel_handle_request_close_notify(wl_listener* listener, void* data) { - (void) listener; + const ForeignToplevelHandle& handle = magpie_container_of(listener, handle, request_close); (void) data; + + handle.view.close(); } static void foreign_toplevel_handle_set_rectangle_notify(wl_listener* listener, void* data) { diff --git a/src/surface/view.hpp b/src/surface/view.hpp index 366fccff9..64c7ef298 100644 --- a/src/surface/view.hpp +++ b/src/surface/view.hpp @@ -28,6 +28,7 @@ struct View : Surface { [[nodiscard]] virtual wlr_box get_geometry() const = 0; virtual void map() = 0; virtual void unmap() = 0; + virtual void close() = 0; [[nodiscard]] constexpr bool is_view() const override { return true; @@ -91,6 +92,7 @@ class XdgView final : public View { [[nodiscard]] wlr_box get_geometry() const override; void map() override; void unmap() override; + void close() override; protected: void impl_set_position(int new_x, int new_y) override; @@ -136,6 +138,7 @@ class XWaylandView final : public View { [[nodiscard]] constexpr wlr_box get_geometry() const override; void map() override; void unmap() override; + void close() override; protected: void impl_set_position(int new_x, int new_y) override; diff --git a/src/surface/xdg_view.cpp b/src/surface/xdg_view.cpp index 297b5e726..715b8748f 100644 --- a/src/surface/xdg_view.cpp +++ b/src/surface/xdg_view.cpp @@ -236,6 +236,10 @@ void XdgView::unmap() { } } +void XdgView::close() { + wlr_xdg_toplevel_send_close(&xdg_toplevel); +} + void XdgView::impl_set_position(const int new_x, const int new_y) { (void) new_x; (void) new_y; diff --git a/src/surface/xwayland_view.cpp b/src/surface/xwayland_view.cpp index 97bc52b41..14a638fa8 100644 --- a/src/surface/xwayland_view.cpp +++ b/src/surface/xwayland_view.cpp @@ -254,6 +254,10 @@ void XWaylandView::unmap() { toplevel_handle.reset(); } +void XWaylandView::close() { + wlr_xwayland_surface_close(&xwayland_surface); +} + static constexpr int16_t trunc(const int32_t int32) { if (int32 > INT16_MAX) { return INT16_MAX;