Skip to content

Commit

Permalink
Wire up minimization
Browse files Browse the repository at this point in the history
  • Loading branch information
serebit committed Oct 13, 2023
1 parent 28e352a commit 9727ba0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/foreign_toplevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<wlr_foreign_toplevel_handle_v1_maximized_event*>(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<wlr_foreign_toplevel_handle_v1_minimized_event*>(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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 13 additions & 1 deletion src/xdg_view.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "types.hpp"
#include "view.hpp"

#include "foreign_toplevel.hpp"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 9727ba0

Please sign in to comment.