mirror of
https://github.com/labwc/labwc.git
synced 2025-10-29 05:40:24 -04: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
|
|
@ -3,7 +3,7 @@
|
|||
#define LABWC_CURSOR_H
|
||||
|
||||
#include <wlr/types/wlr_cursor.h>
|
||||
#include <wlr/util/edges.h>
|
||||
#include "common/edge.h"
|
||||
#include "ssd.h"
|
||||
|
||||
struct view;
|
||||
|
|
@ -11,7 +11,6 @@ struct seat;
|
|||
struct server;
|
||||
struct wlr_surface;
|
||||
struct wlr_scene_node;
|
||||
enum wl_pointer_button_state;
|
||||
|
||||
/* Cursors used internally by labwc */
|
||||
enum lab_cursors {
|
||||
|
|
@ -85,20 +84,19 @@ void cursor_set_visible(struct seat *seat, bool visible);
|
|||
* This is mostly important when either resizing a window using a
|
||||
* keyboard modifier or when using the Resize action from a keybind.
|
||||
*/
|
||||
uint32_t cursor_get_resize_edges(struct wlr_cursor *cursor,
|
||||
enum lab_edge cursor_get_resize_edges(struct wlr_cursor *cursor,
|
||||
struct cursor_context *ctx);
|
||||
|
||||
/**
|
||||
* cursor_get_from_edge - translate wlroots edge enum to lab_cursor enum
|
||||
* @resize_edges - WLR_EDGE_ combination like WLR_EDGE_TOP | WLR_EDGE_RIGHT
|
||||
* cursor_get_from_edge - translate lab_edge enum to lab_cursor enum
|
||||
* @resize_edges - edge(s) being resized
|
||||
*
|
||||
* Returns LAB_CURSOR_DEFAULT on WLR_EDGE_NONE
|
||||
* Returns the appropriate lab_cursors enum if @resize_edges
|
||||
* is one of the 4 corners or one of the 4 edges.
|
||||
*
|
||||
* Asserts on invalid edge combinations like WLR_EDGE_LEFT | WLR_EDGE_RIGHT
|
||||
* Returns LAB_CURSOR_DEFAULT on any other value.
|
||||
*/
|
||||
enum lab_cursors cursor_get_from_edge(uint32_t resize_edges);
|
||||
enum lab_cursors cursor_get_from_edge(enum lab_edge resize_edges);
|
||||
|
||||
/**
|
||||
* cursor_update_focus - update cursor focus, may update the cursor icon
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue