Skip to content

Commit

Permalink
maxhorvert - Change simple_decoration_node_t::handle_pointer_button e…
Browse files Browse the repository at this point in the history
…t 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.
  • Loading branch information
CarloWood committed Mar 3, 2025
1 parent 665a78d commit 0a839c3
Showing 1 changed file with 35 additions and 7 deletions.
42 changes: 35 additions & 7 deletions plugins/decor/deco-subsurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
Expand Down

0 comments on commit 0a839c3

Please sign in to comment.