From 9727ba0621f0e1b19054c7bf58f3dd1ccbba6d3d Mon Sep 17 00:00:00 2001 From: Campbell Jones Date: Fri, 13 Oct 2023 16:41:51 -0400 Subject: [PATCH] Wire up minimization --- src/foreign_toplevel.cpp | 8 ++++++-- src/view.hpp | 2 +- src/xdg_view.cpp | 14 +++++++++++++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/foreign_toplevel.cpp b/src/foreign_toplevel.cpp index c91c0e4ba..571bc4836 100644 --- a/src/foreign_toplevel.cpp +++ b/src/foreign_toplevel.cpp @@ -8,18 +8,22 @@ static void foreign_toplevel_handle_request_maximize_notify(wl_listener* listene const ForeignToplevelHandle& handle = magpie_container_of(listener, handle, request_activate); auto& event = *static_cast(data); + handle.view.set_minimized(false); handle.view.set_maximized(event.maximized); } static void foreign_toplevel_handle_request_minimize_notify(wl_listener* listener, void* data) { - (void) listener; - (void) data; + const ForeignToplevelHandle& handle = magpie_container_of(listener, handle, request_activate); + auto& event = *static_cast(data); + + handle.view.set_minimized(event.minimized); } static void foreign_toplevel_handle_request_activate_notify(wl_listener* listener, void* data) { const ForeignToplevelHandle& handle = magpie_container_of(listener, handle, request_activate); (void) data; + handle.view.set_minimized(false); handle.view.get_server().focus_view(handle.view, handle.view.surface); } diff --git a/src/view.hpp b/src/view.hpp index c206c4bc7..dbc2bd843 100644 --- a/src/view.hpp +++ b/src/view.hpp @@ -57,7 +57,7 @@ class XdgView : public View { wl_listener request_move; wl_listener request_resize; wl_listener request_maximize; - wl_listener request_unmaximize; + wl_listener request_minimize; wl_listener request_fullscreen; wl_listener set_title; wl_listener set_app_id; diff --git a/src/xdg_view.cpp b/src/xdg_view.cpp index c84df382f..01e055acb 100644 --- a/src/xdg_view.cpp +++ b/src/xdg_view.cpp @@ -1,3 +1,4 @@ +#include "types.hpp" #include "view.hpp" #include "foreign_toplevel.hpp" @@ -74,6 +75,14 @@ static void xdg_toplevel_request_maximize_notify(wl_listener* listener, void* da wlr_xdg_surface_schedule_configure(view.xdg_toplevel.base); } +static void xdg_toplevel_request_minimize_notify(wl_listener* listener, void* data) { + XdgView& view = magpie_container_of(listener, view, request_minimize); + (void) data; + + view.set_minimized(!view.is_minimized); + wlr_xdg_surface_schedule_configure(view.xdg_toplevel.base); +} + static void xdg_toplevel_request_fullscreen_notify(wl_listener* listener, void* data) { XdgView& view = magpie_container_of(listener, view, request_fullscreen); (void) data; @@ -147,6 +156,8 @@ XdgView::XdgView(Server& server, wlr_xdg_toplevel& toplevel) noexcept wl_signal_add(&xdg_toplevel.events.request_resize, &listeners.request_resize); listeners.request_maximize.notify = xdg_toplevel_request_maximize_notify; wl_signal_add(&xdg_toplevel.events.request_maximize, &listeners.request_maximize); + listeners.request_minimize.notify = xdg_toplevel_request_minimize_notify; + wl_signal_add(&xdg_toplevel.events.request_minimize, &listeners.request_minimize); listeners.request_fullscreen.notify = xdg_toplevel_request_fullscreen_notify; wl_signal_add(&xdg_toplevel.events.request_fullscreen, &listeners.request_fullscreen); listeners.set_title.notify = xdg_toplevel_set_title_notify; @@ -166,6 +177,7 @@ XdgView::~XdgView() noexcept { wl_list_remove(&listeners.request_move.link); wl_list_remove(&listeners.request_resize.link); wl_list_remove(&listeners.request_maximize.link); + wl_list_remove(&listeners.request_minimize.link); wl_list_remove(&listeners.set_title.link); wl_list_remove(&listeners.set_app_id.link); wl_list_remove(&listeners.set_parent.link); @@ -182,7 +194,7 @@ const wlr_box XdgView::get_geometry() const { } void XdgView::map() { - current = {0, 0, surface->current.width, surface->current.height}; + current = {scene_node->x, scene_node->y, surface->current.width, surface->current.height}; wlr_scene_node_set_enabled(scene_node, true); is_maximized = xdg_toplevel.current.maximized; server.focus_view(*this, xdg_toplevel.base->surface);