From 0a839c39094cc49be107c593617cc229c9005961 Mon Sep 17 00:00:00 2001 From: Carlo Wood Date: Mon, 3 Mar 2025 17:44:28 +0100 Subject: [PATCH] maxhorvert - Change simple_decoration_node_t::handle_pointer_button et al handle_pointer_button: Pass all mouse buttons to layout.handle_press_event, not just BTN_LEFT. If the returned action is DECORATION_ACTION_TOGGLE_MAXIMIZE, the user clicked on the maximize button. Then change the action to DECORATION_ACTION_TOGGLE_MAXIMIZE_VERTICALLY or DECORATION_ACTION_TOGGLE_MAXIMIZE_HORIZONTALLY if the button used was BTN_MIDDLE or BTN_RIGHT respectively, before passing it on to handle_action. In all other cases just return if the pressed button wasn't BTN_LEFT, just like before. handle_action: Now also handle DECORATION_ACTION_TOGGLE_MAXIMIZE_VERTICALLY and DECORATION_ACTION_TOGGLE_MAXIMIZE_HORIZONTALLY and set the bits of tiled_edges accordingly, before calling default_wm->tile_request. --- plugins/decor/deco-subsurface.cpp | 42 +++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/plugins/decor/deco-subsurface.cpp b/plugins/decor/deco-subsurface.cpp index 22b20a8ce..ec1cf2f23 100644 --- a/plugins/decor/deco-subsurface.cpp +++ b/plugins/decor/deco-subsurface.cpp @@ -241,12 +241,26 @@ class simple_decoration_node_t : public wf::scene::node_t, public wf::pointer_in void handle_pointer_button(const wlr_pointer_button_event& ev) override { - if (ev.button != BTN_LEFT) + auto action = layout.handle_press_event(ev.state == WL_POINTER_BUTTON_STATE_PRESSED); + if (action.action == DECORATION_ACTION_TOGGLE_MAXIMIZE) + { + // Fixup the maximize action. + if (ev.button == BTN_MIDDLE) + { + action.action = DECORATION_ACTION_TOGGLE_MAXIMIZE_VERTICALLY; + } else if (ev.button == BTN_RIGHT) + { + action.action = DECORATION_ACTION_TOGGLE_MAXIMIZE_HORIZONTALLY; + } else if (ev.button != BTN_LEFT) + { + return; + } + } else if (ev.button != BTN_LEFT) { return; } - handle_action(layout.handle_press_event(ev.state == WL_POINTER_BUTTON_STATE_PRESSED)); + handle_action(action); } void handle_action(decoration_layout_t::action_response_t action) @@ -265,15 +279,29 @@ class simple_decoration_node_t : public wf::scene::node_t, public wf::pointer_in return view->close(); case DECORATION_ACTION_TOGGLE_MAXIMIZE: - if (view->pending_tiled_edges()) + case DECORATION_ACTION_TOGGLE_MAXIMIZE_VERTICALLY: + case DECORATION_ACTION_TOGGLE_MAXIMIZE_HORIZONTALLY: + { + // Get the last maximization state that was requested; + // it is this value that needs to be toggled. + maximization_t maximization = view->pending_maximization(); + + // Toggle the state if appropriate. + if (((action.action == DECORATION_ACTION_TOGGLE_MAXIMIZE) || + (action.action == DECORATION_ACTION_TOGGLE_MAXIMIZE_VERTICALLY))) { - return wf::get_core().default_wm->tile_request(view, 0); - } else + maximization ^= maximization_t::vertical; + } + + if (((action.action == DECORATION_ACTION_TOGGLE_MAXIMIZE) || + (action.action == DECORATION_ACTION_TOGGLE_MAXIMIZE_HORIZONTALLY))) { - return wf::get_core().default_wm->tile_request(view, wf::TILED_EDGES_ALL); + maximization ^= maximization_t::horizontal; } - break; + // Request the new maximize state. + return wf::get_core().default_wm->tile_request(view, maximization.as_tiled_edges()); + } case DECORATION_ACTION_MINIMIZE: return wf::get_core().default_wm->minimize_request(view, true);