Skip to content

Commit

Permalink
Wire up xdg-foreign-toplevel request_close
Browse files Browse the repository at this point in the history
  • Loading branch information
serebit committed Nov 12, 2023
1 parent f9a318c commit c7cf1b0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/foreign_toplevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions src/surface/view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/surface/xdg_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/surface/xwayland_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c7cf1b0

Please sign in to comment.