mirror of
https://github.com/labwc/labwc.git
synced 2026-02-26 01:40:22 -05:00
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.
This commit is contained in:
parent
4d1be7eada
commit
ef766d16f0
26 changed files with 294 additions and 320 deletions
11
src/action.c
11
src/action.c
|
|
@ -348,7 +348,7 @@ action_arg_from_xml_node(struct action *action, const char *nodename, const char
|
|||
bool tiled = (action->type == ACTION_TYPE_TOGGLE_SNAP_TO_EDGE
|
||||
|| action->type == ACTION_TYPE_SNAP_TO_EDGE);
|
||||
enum lab_edge edge = lab_edge_parse(content, tiled, /*any*/ false);
|
||||
if (edge == LAB_EDGE_INVALID) {
|
||||
if (edge == LAB_EDGE_NONE) {
|
||||
wlr_log(WLR_ERROR, "Invalid argument for action %s: '%s' (%s)",
|
||||
action_names[action->type], argument, content);
|
||||
} else {
|
||||
|
|
@ -462,7 +462,7 @@ action_arg_from_xml_node(struct action *action, const char *nodename, const char
|
|||
if (!strcmp(argument, "direction")) {
|
||||
enum lab_edge edge = lab_edge_parse(content,
|
||||
/*tiled*/ false, /*any*/ false);
|
||||
if (edge == LAB_EDGE_INVALID) {
|
||||
if (edge == LAB_EDGE_NONE) {
|
||||
wlr_log(WLR_ERROR, "Invalid argument for action %s: '%s' (%s)",
|
||||
action_names[action->type], argument, content);
|
||||
} else {
|
||||
|
|
@ -921,7 +921,7 @@ get_target_output(struct output *output, struct server *server,
|
|||
target = output_from_name(server, output_name);
|
||||
} else {
|
||||
enum lab_edge edge =
|
||||
action_get_int(action, "direction", LAB_EDGE_INVALID);
|
||||
action_get_int(action, "direction", LAB_EDGE_NONE);
|
||||
bool wrap = action_get_bool(action, "wrap", false);
|
||||
target = output_get_adjacent(output, edge, wrap);
|
||||
}
|
||||
|
|
@ -1144,7 +1144,8 @@ run_action(struct view *view, struct server *server, struct action *action,
|
|||
break;
|
||||
case ACTION_TYPE_MOVE:
|
||||
if (view) {
|
||||
interactive_begin(view, LAB_INPUT_STATE_MOVE, 0);
|
||||
interactive_begin(view, LAB_INPUT_STATE_MOVE,
|
||||
LAB_EDGE_NONE);
|
||||
}
|
||||
break;
|
||||
case ACTION_TYPE_RAISE:
|
||||
|
|
@ -1159,7 +1160,7 @@ run_action(struct view *view, struct server *server, struct action *action,
|
|||
break;
|
||||
case ACTION_TYPE_RESIZE:
|
||||
if (view) {
|
||||
uint32_t resize_edges = cursor_get_resize_edges(
|
||||
enum lab_edge resize_edges = cursor_get_resize_edges(
|
||||
server->seat.cursor, ctx);
|
||||
interactive_begin(view, LAB_INPUT_STATE_RESIZE,
|
||||
resize_edges);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue