diff --git a/src/input/cursor.cpp b/src/input/cursor.cpp index 860bb15af..ead7a43a5 100644 --- a/src/input/cursor.cpp +++ b/src/input/cursor.cpp @@ -5,6 +5,8 @@ #include "surface.hpp" #include "view.hpp" +#include + #include "wlr-wrap-start.hpp" #include #include @@ -134,7 +136,8 @@ static void cursor_button_notify(wl_listener* listener, void* data) { /* Notify the client with pointer focus that a button press has occurred */ wlr_seat_pointer_notify_button(server.seat->seat, event->time_msec, event->button, event->state); double sx, sy; - wlr_surface* surface = NULL; + + wlr_surface* surface = nullptr; Surface* magpie_surface = server.surface_at(cursor.cursor->x, cursor.cursor->y, &surface, &sx, &sy); if (event->state == WLR_BUTTON_RELEASED) { diff --git a/src/view.cpp b/src/view.cpp index bf7a8c212..e0c744f22 100644 --- a/src/view.cpp +++ b/src/view.cpp @@ -104,7 +104,7 @@ void View::set_activated(const bool activated) { void View::set_maximized(const bool maximized) { Server& server = get_server(); - if (this->maximized == maximized) { + if (this->is_maximized == maximized) { /* Don't honor request if already maximized. */ return; } @@ -115,7 +115,7 @@ void View::set_maximized(const bool maximized) { return; } - if (this->maximized) { + if (this->is_maximized) { set_size(previous.width, previous.height); impl_set_maximized(false); current.x = previous.x; @@ -140,6 +140,23 @@ void View::set_maximized(const bool maximized) { wlr_scene_node_set_position(scene_node, current.x, current.y); } - this->maximized = maximized; + this->is_maximized = maximized; toplevel_handle->set_maximized(maximized); } + +void View::set_minimized(const bool minimized) { + if (minimized == is_minimized) { + return; + } + + toplevel_handle->set_minimized(minimized); + impl_set_minimized(minimized); + this->is_minimized = minimized; + + if (minimized) { + unmap(); + set_activated(false); + } else { + map(); + } +} diff --git a/src/view.hpp b/src/view.hpp index ee6cbc34c..94fc2ffc1 100644 --- a/src/view.hpp +++ b/src/view.hpp @@ -15,7 +15,8 @@ #include "wlr-wrap-end.hpp" struct View : public Surface { - bool maximized; + bool is_maximized; + bool is_minimized; wlr_box current; wlr_box pending; wlr_box previous; @@ -32,6 +33,7 @@ struct View : public Surface { void set_size(const int new_width, const int new_height); void set_activated(const bool activated); void set_maximized(const bool maximized); + void set_minimized(const bool minimized); private: const std::optional find_output_for_maximize(); @@ -40,6 +42,7 @@ struct View : public Surface { virtual void impl_set_size(const int new_width, const int new_height) = 0; virtual void impl_set_activated(const bool activated) = 0; virtual void impl_set_maximized(const bool maximized) = 0; + virtual void impl_set_minimized(bool minimized) = 0; }; class XdgView : public View { @@ -71,15 +74,16 @@ class XdgView : public View { XdgView(Server& server, wlr_xdg_toplevel& toplevel) noexcept; ~XdgView() noexcept; - inline Server& get_server() const; - const wlr_box get_geometry() const; - void map(); - void unmap(); + inline Server& get_server() const override; + const wlr_box get_geometry() const override; + void map() override; + void unmap() override; protected: - void impl_set_size(int new_width, int new_height); - void impl_set_activated(bool activated); - void impl_set_maximized(bool maximized); + void impl_set_size(int new_width, int new_height) override; + void impl_set_activated(bool activated) override; + void impl_set_maximized(bool maximized) override; + void impl_set_minimized(bool minimized) override; }; class XWaylandView : public View { @@ -110,15 +114,16 @@ class XWaylandView : public View { XWaylandView(Server& server, wlr_xwayland_surface& surface) noexcept; ~XWaylandView() noexcept; - inline Server& get_server() const; - const wlr_box get_geometry() const; - void map(); - void unmap(); + inline Server& get_server() const override; + const wlr_box get_geometry() const override; + void map() override; + void unmap() override; protected: - void impl_set_size(int new_width, int new_height); - void impl_set_activated(bool activated); - void impl_set_maximized(bool maximized); + void impl_set_size(int new_width, int new_height) override; + void impl_set_activated(bool activated) override; + void impl_set_maximized(bool maximized) override; + void impl_set_minimized(bool minimized) override; }; #endif diff --git a/src/xdg_view.cpp b/src/xdg_view.cpp index c6a34b823..97620291c 100644 --- a/src/xdg_view.cpp +++ b/src/xdg_view.cpp @@ -70,7 +70,7 @@ static void xdg_toplevel_request_maximize_notify(wl_listener* listener, void* da XdgView& view = magpie_container_of(listener, view, request_maximize); (void) data; - view.set_maximized(!view.maximized); + view.set_maximized(!view.is_maximized); wlr_xdg_surface_schedule_configure(view.xdg_toplevel.base); } @@ -183,7 +183,7 @@ const wlr_box XdgView::get_geometry() const { void XdgView::map() { wlr_scene_node_set_enabled(scene_node, true); - maximized = xdg_toplevel.current.maximized; + is_maximized = xdg_toplevel.current.maximized; server.focus_view(*this, xdg_toplevel.base->surface); } @@ -207,3 +207,7 @@ void XdgView::impl_set_activated(const bool activated) { void XdgView::impl_set_maximized(const bool maximized) { wlr_xdg_toplevel_set_maximized(&xdg_toplevel, maximized); } + +void XdgView::impl_set_minimized(const bool minimized) { + (void) minimized; +} diff --git a/src/xwayland_view.cpp b/src/xwayland_view.cpp index 30ec73c97..4d6ca12c2 100644 --- a/src/xwayland_view.cpp +++ b/src/xwayland_view.cpp @@ -245,3 +245,7 @@ void XWaylandView::impl_set_activated(bool activated) { void XWaylandView::impl_set_maximized(const bool maximized) { wlr_xwayland_surface_set_maximized(&xwayland_surface, maximized); } + +void XWaylandView::impl_set_minimized(const bool minimized) { + wlr_xwayland_surface_set_minimized(&xwayland_surface, minimized); +}