Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pr 06 unidirectional maximization support #2597

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

CarloWood
Copy link
Contributor

This works, together with changes already made to pixdecor. Aka, it is tested. But on its own it should do precisely nothing: have no effect at all (aka, still compile everything as before and still behave in the same way), short from UB as a result of plugins not following the correct meaning of TILED_EDGES_* - because now each bit is actually treated as how to treat that edge.

This member is not used anywhere.
wf::rectangle_t is another way to represent a geometry_t but
much easier and cleaner to manipulate when it comes to moving
edges. wf::rectangle_t and geometry_t seamless convert into
eachother and are as such interchangable.

wf::geometry_difference_t replaces decoration_margins_t, but
now represented as simply the mathematical difference between
two geometry_t/rectangle_t's without claiming to have anything
to do with decorations (hence that it goes into geometry.hpp).

Provided are functions to subtract two geometry_t's, as well
as add or subtract a geometry_difference_t to/from a geometry_t.

It is also possible to negate a geometry_difference_t.

Finally, there are several functions to conditionally act upon
a geometry_t/rectangle_t on a per-edge basis: expand_geometry_if,
geometry_switch_if and geometry_difference_t::subtract_if.
TILED_EDGES_* are now stored in src/api/wayfire/maximization.hpp
class maximization_t is a wrapper around a unsigned char, representing
two booleans (as bits): maximized vertically and/or horizontally.

toplevel_state_t, which stores tiled_edges that still had to
fully represent the maximization state, has been given operators
and accessors to seamlessly work with maximization_t types from
the outside, while only storing a uint32_t tiled_edges internally.

expand_geometry_by_margins and shrink_geometry_by_margins can now
be used conditionally - they are basically the same as
expand_geometry_if, but kept for legacy (API) reasons.

Then the hard part: everywhere where before `tiled_edges` was
used as a boolean, where zero meant not-maximized, and non-zero
meant fully-maximized, this commit either fixes that code to deal
properly with unidirectional maximization states, or adds a TODO
comment that this still has to be added. I don't think I missed
a place, despite the fact that the access to tiled_edges isn't
encapsulated.
Uses the requested tiled_edges as well as the pending tiled_edges
to know if we have to use, on a per edge basis, last_windowed (if
going from maximized to unmaximized), current (if going from
unmaximized to unmaximized) or workspace (if going from any to
maximized).
@CarloWood CarloWood force-pushed the PR_06_unidirectional_maximization_support branch from dd2adce to 2e91a85 Compare March 3, 2025 15:44
…ce `wf::decor`.

Because that's where they belong.
Also moved wayfire_decoration itself there.
…NTALLY}

Extend the enum for decoration actions to include
maximizing vertically and/or horizontally.
…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.
@CarloWood
Copy link
Contributor Author

CarloWood commented Mar 3, 2025

At this point the mouse button clicks on the maximize button are passed correctly to tile_request. It is almost surprising that after this the decoration plugin already seems to work; as nothing was changed to make it deal with unidirectional maximization internally (I had expected it to be completely confused and -say- draw the window fully maximized even if it is only partially maximized!).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant