view_restore_to() (which is just set_maximized() + view_move_resize())
hasn't aged well and doesn't line up with typical usage anymore:
- it's missing view_set_untiled(), which has to be called separately
- it always forces view_move_resize() even when that's not needed
- it doesn't allow un-maximizing only one axis (see next commit)
- the fullscreen check is unnecessary (already checked in callers)
Eliminate it and just expose view_set_maximized() instead.
No functional change intended in this commit.
Now it's not very reasonable to determine the default window width based
on the titlebar geometry, as the titlebar can be shrunk to 1px.
Let's use the fixed value of 100px for simplification.
- Use a single `lab_scene_rect` for both overlay background and outlines,
like I described in the TODO comment in ffd4005.
- Simplify the resource management by destroying the overlay tree when
it's hidden. I think its overhead is pretty minimal.
- Share a single `lab_scene_rect` for both region/edge overlays.
Our codebase for ssd scenes has grown with a lot of technical debts:
- We needed to call `ssd_get_part()` everywhere to get the scene node of a
ssd part. We then needed to cast it to `wlr_scene_rect` and
`wlr_scene_buffer`. This bloated our codebase and even blocked
duplicated button types in `<titlebar><layout>`.
- `ssd_get_part_type()` was a dirty hack. It compared parent, grandparent
and grandgrandparent of a node with each subtree in the ssd to get the
part type of the node.
To resolve this issues, this commit changes how ssd scenes are managed:
- Access scene rects and scene buffers just as a member of `struct ssd`.
- `ssd_part` is now a attachment to a scene node that can be accessed via
node_descriptor->data, with a new node-descriptor type
`LAB_NODE_DESC_SSD_PART`. `LAB_NODE_DESC_SSD_BUTTON` is unified into it.
Now the scene graph under ssd->tree looks like below. The parentheses
indicate the type of ssd_part attached to the node:
ssd->tree (LAB_SSD_NONE)
+--titlebar (LAB_SSD_PART_TITLEBAR)
| +--inactive
| | +--background bar
| | +--left corner
| | +--right corner
| | +--title (LAB_SSD_PART_TITLE)
| | +--iconify button (LAB_SSD_BUTTON_ICONIFY)
| | | +--normal close icon image
| | | +--hovered close icon image
| | | +--...
| | +--window icon (LAB_SSD_BUTTON_WINDOW_ICON)
| | | +--window icon image
| | +--...
| +--active
| +--...
+--border
| +--inactive
| | +--top
| | +--...
| +--active
| +--top
| +--...
+--shadow
| +--inactive
| | +--top
| | +--...
| +--active
| +--top
| +--...
+--extents
+--top
+--...
When hovering on SSD, `get_cursor_context()` traverses this scene node
from the leaf. If it finds a `ssd_part` attached to the node, it returns
`ssd_part_type` that represents the resizing direction, button types or
`Title`/`Titlebar`.
I needed to debug an input configuration issue and found the debug
output not-super-helpful, so I made some improvements:
- Print the name and "sysname" (e.g. event11) of the device being
configured. Note that the name alone isn't enough since there can
be multiple identically-named devices.
- Print the config category matched for each device.
- Print the config values (if any) being applied. For enums, only the
numeric value is printed since I'm lazy.
- Don't print "pointer acceleration configured" if neither a pointer
speed nor acceleration profile is configured (it's confusing).
- add LAB_WINDOW_TYPE_INVALID in place of literal -1
- document more clearly that enum lab_view_criteria is a bitset
- other one-off replacements of integer values/types for consistency
Note: variables of type enum lab_view_criteria are already used
extensively throughout the code to contain combinations of the declared
enum values. I am not introducing any new usage here, just changing the
single uint32_t to be consistent with all the other usages.
I like the new common/edge.h. I don't like how inconsistently we use it.
Current situation:
- enum wlr_edges and wlr_direction are designed to be used as bitset,
and are defined compatibly
- enum lab_edge is *also* designed to be used as bitset, but
incompatible with the others (LEFT/RIGHT come before UP/DOWN)
- we use an inconsistent mix of all three *AND* uint32_t (usually with
the WLR_EDGE constants rather than the LAB_EDGE constants), and
convert between them on an ad-hoc basis, sometimes implicitly
Let's clean this up:
- reorder enum lab_edge to be compatible with the two wlr enums
(check this by static_assert)
- use TOP/BOTTOM naming rather than UP/DOWN (matches wlr_edges)
- add constants for the remaining possible combinations of the 4 edges
- use lab_edge for all internal edge/direction fields, consistently
- add lab_edge_is_cardinal() as a sanity check before casting to
enum wlr_direction, and then eliminate all of direction.c/h
Instead of "enum wlr_edges direction", we now have
"enum lab_edge direction" which is not that much better. At least we
are now clear that we're overloading one enum with two meanings.
update_keycodes_iter() currently has 4(!) levels of nested loops, which
makes the logic (especially the break/continue statements) difficult to
understand. The logic also appears to continue looping uselessly after
a given keycode has already been added to a keybind.
Refactor by adding some small utility functions:
- keybind_contains_keycode()
- keybind_contains_keysym()
- keybind_contains_any_keysym()
No functional change intended.
...and allow If Action without activator view.
For example:
<action name="If">
<prompt message="Toggle maximize?"/>
<then>
<action name="ToggleMaximize" />
</then>
</action>
Also revert the change in b9c84f9 that <else> branch is always taken when
no window is focused.
Co-Authored-by: johanmalm
Co-Authored-by: tokyo4j
Currently, the dependencies between foreign-toplevel[-internal],
ext-foreign, and wlr-foreign are cyclical and a bit complex.
I suggest we reorganize it into a simpler hierarchy:
foreign-toplevel/
-> foreign.c/h
-> (depends on) ext-foreign.c/h
-> (depends on) wlr-foreign.c/h
The refactored code is smaller and (IMO) easier to follow.
In detail:
- Add include/foreign-toplevel folder mirroring src/foreign-toplevel
- Split foreign-toplevel-internal.h to ext-foreign.h and wlr-foreign.h
- Eliminate ext-/wlr-foreign.c -> foreign.c reverse dependencies
(including internal signals and foreign_request* functions)
- Make struct foreign_toplevel private to foreign.c
Lightly tested with qmpanel (which uses wlr-foreign-toplevel).
v2: reorder foreign-toplevel internal API funcs
In addition to <snapping><range>, <snapping><cornerRange> configures the
distance from the screen corner to trigger quater window snapping.
Also, new values "up-left", "up-right", "down-left" and "down-right" are
allowed for <action name="(Toggle)SnapToEdge" direction="[value]"> and
<query tiled="[value]">.
For example, the following node:
<keybind name.action="ShowMenu" menu.action="root-menu"
x.position.action="1" y.position.action="2" />
is converted to:
<keybind>
<action>
<name>ShowMenu</name>
<menu>root-menu</menu>
<position>
<x>1</x>
<y>2</y>
</position>
</action>
</keybind>
...before processing the entire xml tree. This is a preparation to prevent
breaking changes when we refactor rcxml.c to use recursion instead of
encoding nodes into dotted strings.
Hi-res mice produces mulitple scroll events with `delta_discrete` != 0
during a single "click". This patch makes them trigger `Scroll` actions
only when the accumulated `delta_discrete` exceeds 120 (= 1 click).
See https://lists.freedesktop.org/archives/wayland-devel/2019-April/040377.html
for how hi-res scroll events are reported.
'restrict' is harmful as it encourages the compiler to make dangerous
assumptions while increasing cognitive load on the human programmer.
The extra 1% (or whatever) of performance here is not worth the cost.
Wlroots now destroys the wlr_output when granting a lease.
So we can't iterate through the outputs in the request after
granting the lease. This is also not necessary anymore because
they are already destroyed and thus removed from the layout.
Alternative to 7bf08af which was reverted in the previous commit.
7bf08af fixed the problem that layer-shell clients are terminated when
it's unmapped, by sending configure events in node-destroy handler
rather than in unmap handler. But it caused a UAF bug when an output
with layer-shell clients is destroyed.
So this patch fixes the original issue by simply skipping the surface in
arrange_one_layer() if it's being unmapped.