diff --git a/src/client/client.h b/src/client/client.h index a6247bb..2c5e638 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -475,6 +475,18 @@ static inline bool client_request_minimize(Client *c, void *data) { return c->surface.xdg->toplevel->requested.minimized; } +static inline bool client_request_maximize(Client *c, void *data) { + +#ifdef XWAYLAND + if (client_is_x11(c)) { + struct wlr_xwayland_surface *surface = c->surface.xwayland; + return surface->maximized_vert || surface->maximized_horz; + } +#endif + + return c->surface.xdg->toplevel->requested.maximized; +} + static inline void client_set_size_bound(Client *c) { struct wlr_xdg_toplevel *toplevel; struct wlr_xdg_toplevel_state state; diff --git a/src/mango.c b/src/mango.c index 93c70eb..3e33db8 100644 --- a/src/mango.c +++ b/src/mango.c @@ -3568,31 +3568,22 @@ mapnotify(struct wl_listener *listener, void *data) { printstatus(); } -void // 0.5 custom -maximizenotify(struct wl_listener *listener, void *data) { - /* This event is raised when a client would like to maximize itself, - * typically because the user clicked on the maximize button on - * client-side decorations. dwl doesn't support maximization, but - * to conform to xdg-shell protocol we still must send a configure. - * Since xdg-shell protocol v5 we should ignore request of unsupported - * capabilities, just schedule a empty configure when the client uses <5 - * protocol version - * wlr_xdg_surface_schedule_configure() is used to send an empty reply. - */ - // Client *c = wl_container_of(listener, c, maximize); - // if (wl_resource_get_version(c->surface.xdg->toplevel->resource) - // < XDG_TOPLEVEL_WM_CAPABILITIES_SINCE_VERSION) - // wlr_xdg_surface_schedule_configure(c->surface.xdg); - // togglemaximizescreen(&(Arg){0}); +void maximizenotify(struct wl_listener *listener, void *data) { + Client *c = wl_container_of(listener, c, maximize); if (!c || !c->mon || c->iskilling || c->ignore_maximize) return; - if (c->ismaximizescreen || c->isfullscreen) - setmaximizescreen(c, 0); - else + if (!client_is_x11(c) && !c->surface.xdg->initialized) { + return; + } + + if (client_request_maximize(c, data)) { setmaximizescreen(c, 1); + } else { + setmaximizescreen(c, 0); + } } void unminimize(Client *c) { @@ -3636,22 +3627,7 @@ void set_minimized(Client *c) { wl_list_insert(clients.prev, &c->link); // 插入尾部 } -void // 0.5 custom -minimizenotify(struct wl_listener *listener, void *data) { - /* This event is raised when a client would like to maximize itself, - * typically because the user clicked on the maximize button on - * client-side decorations. dwl doesn't support maximization, but - * to conform to xdg-shell protocol we still must send a configure. - * Since xdg-shell protocol v5 we should ignore request of unsupported - * capabilities, just schedule a empty configure when the client uses <5 - * protocol version - * wlr_xdg_surface_schedule_configure() is used to send an empty reply. - */ - // Client *c = wl_container_of(listener, c, maximize); - // if (wl_resource_get_version(c->surface.xdg->toplevel->resource) - // < XDG_TOPLEVEL_WM_CAPABILITIES_SINCE_VERSION) - // wlr_xdg_surface_schedule_configure(c->surface.xdg); - // togglemaximizescreen(&(Arg){0}); +void minimizenotify(struct wl_listener *listener, void *data) { Client *c = wl_container_of(listener, c, minimize);