]> git.mdlowis.com Git - proto/labwc.git/commit
common: flesh out enum lab_edge and prefer over wlr_edges/wlr_direction
authorJohn Lindgren <john@jlindgren.net>
Wed, 27 Aug 2025 00:27:34 +0000 (20:27 -0400)
committerJohn Lindgren <john@jlindgren.net>
Wed, 27 Aug 2025 00:36:43 +0000 (20:36 -0400)
commitef766d16f03132777b730732ab9a78fe8be9d827
tree2d4d837c2ead8cc9e31cf5f42cfdb2ba156a2a43
parent4d1be7eada7a72f67051b4b6c4339dd8664bd7fa
common: flesh out enum lab_edge and prefer over wlr_edges/wlr_direction

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.
26 files changed:
include/common/direction.h [deleted file]
include/common/edge.h
include/edges.h
include/input/cursor.h
include/labwc.h
include/snap-constraints.h
include/ssd.h
include/view.h
src/action.c
src/common/direction.c [deleted file]
src/common/edge.c
src/common/meson.build
src/edges.c
src/input/cursor.c
src/interactive.c
src/output.c
src/overlay.c
src/resistance.c
src/snap-constraints.c
src/snap.c
src/ssd/ssd.c
src/theme.c
src/view-impl-common.c
src/view.c
src/xdg.c
src/xwayland.c