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.
+++ /dev/null
-/* SPDX-License-Identifier: GPL-2.0-only */
-#ifndef LABWC_DIRECTION_H
-#define LABWC_DIRECTION_H
-
-#include <wlr/types/wlr_output_layout.h>
-#include "common/edge.h"
-
-bool direction_from_edge(enum lab_edge edge, enum wlr_direction *direction);
-enum wlr_direction direction_get_opposite(enum wlr_direction direction);
-
-#endif /* LABWC_DIRECTION_H */
#ifndef LABWC_EDGE_H
#define LABWC_EDGE_H
-#include <wayland-server-core.h>
+#include <stdbool.h>
/**
- * Represents an edge or direction (e.g. window tiling, window motion)
+ * Unified/overloaded enum representing edges, corners, and directions.
+ * Used in many different contexts (moving, resizing, tiling) and with
+ * somewhat different semantics depending on context.
+ *
+ * Examples:
+ * - LAB_EDGE_TOP can also mean "up" or "north".
+ * - LAB_EDGES_TOP_LEFT can mean "top left corner" or "northwest".
+ *
+ * The enum is designed to be used as a bitset, and combinations of
+ * edges typically mean what you'd expect from the context. For example,
+ * LAB_EDGES_TOP_LEFT is used when resizing a view from its top-left
+ * corner, or when tiling a view in the top-left corner of an output.
+ *
+ * All 16 possible combinations of TOP/BOTTOM/LEFT/RIGHT are listed for
+ * completeness. Not all combinations make sense in all contexts.
+ *
+ * LAB_EDGE_NONE is sometimes used to mean "invalid".
+ *
+ * LAB_EDGE_ANY means "any edge or combination of edges (except NONE)"
+ * and is distinct from LAB_EDGE_ALL (which means all 4 edges).
+ *
+ * LAB_EDGE_TOP/BOTTOM/LEFT/RIGHT match the corresponding values of
+ * enum wlr_edges and enum wlr_direction, so that conversion between
+ * enums can be done with a simple cast.
*/
enum lab_edge {
- LAB_EDGE_INVALID = 0,
+ LAB_EDGE_NONE = 0,
- LAB_EDGE_LEFT = (1 << 0),
- LAB_EDGE_RIGHT = (1 << 1),
- LAB_EDGE_UP = (1 << 2),
- LAB_EDGE_DOWN = (1 << 3),
+ LAB_EDGE_TOP = (1 << 0), /* or UP */
+ LAB_EDGE_BOTTOM = (1 << 1), /* or DOWN */
+ LAB_EDGE_LEFT = (1 << 2),
+ LAB_EDGE_RIGHT = (1 << 3),
LAB_EDGE_CENTER = (1 << 4), /* for window tiling */
LAB_EDGE_ANY = (1 << 5), /* for window rules */
- /* for window tiling */
- LAB_EDGE_UPLEFT = (LAB_EDGE_UP | LAB_EDGE_LEFT),
- LAB_EDGE_UPRIGHT = (LAB_EDGE_UP | LAB_EDGE_RIGHT),
- LAB_EDGE_DOWNLEFT = (LAB_EDGE_DOWN | LAB_EDGE_LEFT),
- LAB_EDGE_DOWNRIGHT = (LAB_EDGE_DOWN | LAB_EDGE_RIGHT),
+ /* corners or ordinal directions (NW/NE/SW/SE) */
+ LAB_EDGES_TOP_LEFT = (LAB_EDGE_TOP | LAB_EDGE_LEFT),
+ LAB_EDGES_TOP_RIGHT = (LAB_EDGE_TOP | LAB_EDGE_RIGHT),
+ LAB_EDGES_BOTTOM_LEFT = (LAB_EDGE_BOTTOM | LAB_EDGE_LEFT),
+ LAB_EDGES_BOTTOM_RIGHT = (LAB_EDGE_BOTTOM | LAB_EDGE_RIGHT),
+
+ /* opposite edges */
+ LAB_EDGES_TOP_BOTTOM = (LAB_EDGE_TOP | LAB_EDGE_BOTTOM),
+ LAB_EDGES_LEFT_RIGHT = (LAB_EDGE_LEFT | LAB_EDGE_RIGHT),
+
+ /* all 4 edges */
+ LAB_EDGES_ALL = (LAB_EDGE_TOP | LAB_EDGE_BOTTOM |
+ LAB_EDGE_LEFT | LAB_EDGE_RIGHT),
+
+ /* 3-edge combinations (for completeness) */
+ LAB_EDGES_EXCEPT_TOP = (LAB_EDGES_ALL ^ LAB_EDGE_TOP),
+ LAB_EDGES_EXCEPT_BOTTOM = (LAB_EDGES_ALL ^ LAB_EDGE_BOTTOM),
+ LAB_EDGES_EXCEPT_LEFT = (LAB_EDGES_ALL ^ LAB_EDGE_LEFT),
+ LAB_EDGES_EXCEPT_RIGHT = (LAB_EDGES_ALL ^ LAB_EDGE_RIGHT),
};
enum lab_edge lab_edge_parse(const char *direction, bool tiled, bool any);
+/**
+ * Returns true if edge is TOP, BOTTOM, LEFT, or RIGHT
+ * (i.e. one of the four cardinal directions N/S/W/E)
+ */
+bool lab_edge_is_cardinal(enum lab_edge edge);
+
/**
* lab_edge_invert() - select the opposite of a provided edge
*
- * Returns LAB_EDGE_INVALID for edges other than UP/DOWN/LEFT/RIGHT.
+ * Returns LAB_EDGE_NONE for edges other than TOP/BOTTOM/LEFT/RIGHT.
*
* @edge: edge to be inverted
*/
#include <limits.h>
#include <stdbool.h>
-#include <stdint.h>
+#include "common/edge.h"
#include "common/macros.h"
struct border;
int *x, int *y, bool use_pending);
void edges_adjust_resize_geom(struct view *view, struct border edges,
- uint32_t resize_edges, struct wlr_box *geom, bool use_pending);
+ enum lab_edge resize_edges, struct wlr_box *geom, bool use_pending);
bool edges_traverse_edge(struct edge current, struct edge target, struct edge edge);
void edges_calculate_visibility(struct server *server, struct view *ignored_view);
+
#endif /* LABWC_EDGES_H */
#define LABWC_CURSOR_H
#include <wlr/types/wlr_cursor.h>
-#include <wlr/util/edges.h>
+#include "common/edge.h"
#include "ssd.h"
struct view;
struct server;
struct wlr_surface;
struct wlr_scene_node;
-enum wl_pointer_button_state;
/* Cursors used internally by labwc */
enum lab_cursors {
* 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
double grab_x, grab_y;
/* View geometry when interactive move/resize is requested */
struct wlr_box grab_box;
- uint32_t resize_edges;
+ enum lab_edge resize_edges;
/*
* 'active_view' is generally the view with keyboard-focus, updated with
*/
void interactive_anchor_to_cursor(struct server *server, struct wlr_box *geo);
-void interactive_begin(struct view *view, enum input_mode mode, uint32_t edges);
+void interactive_begin(struct view *view, enum input_mode mode,
+ enum lab_edge edges);
void interactive_finish(struct view *view);
void interactive_cancel(struct view *view);
* Returns the edge to snap a window to.
* For example, if the output-relative cursor position (x,y) fulfills
* x <= (<snapping><cornerRange>) and y <= (<snapping><range>),
- * then edge1=LAB_EDGE_UP and edge2=LAB_EDGE_LEFT.
+ * then edge1=LAB_EDGE_TOP and edge2=LAB_EDGE_LEFT.
* The value of (edge1|edge2) can be passed to view_snap_to_edge().
*/
bool edge_from_cursor(struct seat *seat, struct output **dest_output,
#ifndef LABWC_SNAP_CONSTRAINTS_H
#define LABWC_SNAP_CONSTRAINTS_H
-#include <wlr/util/edges.h>
-
-#include "common/border.h"
-#include "view.h"
+#include "common/edge.h"
+struct view;
struct wlr_box;
-void snap_constraints_set(struct view *view,
- enum wlr_edges direction, struct wlr_box geom);
+void snap_constraints_set(struct view *view, enum lab_edge direction,
+ struct wlr_box geom);
void snap_constraints_invalidate(struct view *view);
void snap_constraints_update(struct view *view);
struct wlr_box snap_constraints_effective(struct view *view,
- enum wlr_edges direction, bool use_pending);
+ enum lab_edge direction, bool use_pending);
#endif /* LABWC_SNAP_CONSTRAINTS_H */
#ifndef LABWC_SSD_H
#define LABWC_SSD_H
-#include <wayland-server-core.h>
#include "common/border.h"
+#include "common/edge.h"
+#include "config/types.h"
struct wlr_cursor;
/* Public SSD helpers */
enum ssd_part_type ssd_get_part_type(const struct ssd *ssd,
struct wlr_scene_node *node, struct wlr_cursor *cursor);
-uint32_t ssd_resize_edges(enum ssd_part_type type);
+enum lab_edge ssd_resize_edges(enum ssd_part_type type);
bool ssd_part_contains(enum ssd_part_type whole, enum ssd_part_type candidate);
enum lab_ssd_mode ssd_mode_parse(const char *mode);
enum lab_tristate force_tearing;
bool visible_on_all_workspaces;
enum lab_edge tiled;
- uint32_t edges_visible; /* enum wlr_edges bitset */
+ enum lab_edge edges_visible;
bool inhibits_keybinds; /* also inhibits mousebinds */
xkb_layout_index_t keyboard_layout;
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 {
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 {
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);
}
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:
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);
+++ /dev/null
-// SPDX-License-Identifier: GPL-2.0-only
-#include "common/direction.h"
-#include <assert.h>
-#include <wlr/types/wlr_output_layout.h>
-#include "view.h"
-
-bool
-direction_from_edge(enum lab_edge edge, enum wlr_direction *direction)
-{
- switch (edge) {
- case LAB_EDGE_LEFT:
- *direction = WLR_DIRECTION_LEFT;
- return true;
- case LAB_EDGE_RIGHT:
- *direction = WLR_DIRECTION_RIGHT;
- return true;
- case LAB_EDGE_UP:
- *direction = WLR_DIRECTION_UP;
- return true;
- case LAB_EDGE_DOWN:
- *direction = WLR_DIRECTION_DOWN;
- return true;
- default:
- return false;
- }
-}
-
-enum wlr_direction
-direction_get_opposite(enum wlr_direction direction)
-{
- switch (direction) {
- case WLR_DIRECTION_RIGHT:
- return WLR_DIRECTION_LEFT;
- case WLR_DIRECTION_LEFT:
- return WLR_DIRECTION_RIGHT;
- case WLR_DIRECTION_DOWN:
- return WLR_DIRECTION_UP;
- case WLR_DIRECTION_UP:
- return WLR_DIRECTION_DOWN;
- default:
- assert(0); /* Unreachable */
- return WLR_DIRECTION_UP;
- }
-}
// SPDX-License-Identifier: GPL-2.0-only
#include "common/edge.h"
+#include <assert.h>
#include <strings.h>
+#include <wlr/util/edges.h>
+#include <wlr/types/wlr_output_layout.h>
+
+static_assert((int)LAB_EDGE_TOP == (int)WLR_EDGE_TOP
+ && (int)LAB_EDGE_BOTTOM == (int)WLR_EDGE_BOTTOM
+ && (int)LAB_EDGE_LEFT == (int)WLR_EDGE_LEFT
+ && (int)LAB_EDGE_RIGHT == (int)WLR_EDGE_RIGHT,
+ "enum lab_edge does not match enum wlr_edges");
+
+static_assert((int)LAB_EDGE_TOP == (int)WLR_DIRECTION_UP
+ && (int)LAB_EDGE_BOTTOM == (int)WLR_DIRECTION_DOWN
+ && (int)LAB_EDGE_LEFT == (int)WLR_DIRECTION_LEFT
+ && (int)LAB_EDGE_RIGHT == (int)WLR_DIRECTION_RIGHT,
+ "enum lab_edge does not match enum wlr_direction");
enum lab_edge
lab_edge_parse(const char *direction, bool tiled, bool any)
{
if (!direction) {
- return LAB_EDGE_INVALID;
+ return LAB_EDGE_NONE;
}
if (!strcasecmp(direction, "left")) {
return LAB_EDGE_LEFT;
} else if (!strcasecmp(direction, "up")) {
- return LAB_EDGE_UP;
+ return LAB_EDGE_TOP;
} else if (!strcasecmp(direction, "right")) {
return LAB_EDGE_RIGHT;
} else if (!strcasecmp(direction, "down")) {
- return LAB_EDGE_DOWN;
+ return LAB_EDGE_BOTTOM;
}
if (any) {
if (!strcasecmp(direction, "center")) {
return LAB_EDGE_CENTER;
} else if (!strcasecmp(direction, "up-left")) {
- return LAB_EDGE_UPLEFT;
+ return LAB_EDGES_TOP_LEFT;
} else if (!strcasecmp(direction, "up-right")) {
- return LAB_EDGE_UPRIGHT;
+ return LAB_EDGES_TOP_RIGHT;
} else if (!strcasecmp(direction, "down-left")) {
- return LAB_EDGE_DOWNLEFT;
+ return LAB_EDGES_BOTTOM_LEFT;
} else if (!strcasecmp(direction, "down-right")) {
- return LAB_EDGE_DOWNRIGHT;
+ return LAB_EDGES_BOTTOM_RIGHT;
}
}
- return LAB_EDGE_INVALID;
+ return LAB_EDGE_NONE;
+}
+
+bool
+lab_edge_is_cardinal(enum lab_edge edge)
+{
+ switch (edge) {
+ case LAB_EDGE_TOP:
+ case LAB_EDGE_BOTTOM:
+ case LAB_EDGE_LEFT:
+ case LAB_EDGE_RIGHT:
+ return true;
+ default:
+ return false;
+ }
}
enum lab_edge
return LAB_EDGE_RIGHT;
case LAB_EDGE_RIGHT:
return LAB_EDGE_LEFT;
- case LAB_EDGE_UP:
- return LAB_EDGE_DOWN;
- case LAB_EDGE_DOWN:
- return LAB_EDGE_UP;
+ case LAB_EDGE_TOP:
+ return LAB_EDGE_BOTTOM;
+ case LAB_EDGE_BOTTOM:
+ return LAB_EDGE_TOP;
default:
- return LAB_EDGE_INVALID;
+ return LAB_EDGE_NONE;
}
}
labwc_sources += files(
- 'direction.c',
'box.c',
'buf.c',
'dir.c',
}
static inline struct edge
-build_edge(struct border region, enum wlr_edges direction, int pad)
+build_edge(struct border region, enum lab_edge direction, int pad)
{
struct edge edge = { 0 };
switch (direction) {
- case WLR_EDGE_LEFT:
+ case LAB_EDGE_LEFT:
edge.offset = clipped_sub(region.left, pad);
edge.min = region.top;
edge.max = region.bottom;
break;
- case WLR_EDGE_RIGHT:
+ case LAB_EDGE_RIGHT:
edge.offset = clipped_add(region.right, pad);
edge.min = region.top;
edge.max = region.bottom;
break;
- case WLR_EDGE_TOP:
+ case LAB_EDGE_TOP:
edge.offset = clipped_sub(region.top, pad);
edge.min = region.left;
edge.max = region.right;
break;
- case WLR_EDGE_BOTTOM:
+ case LAB_EDGE_BOTTOM:
edge.offset = clipped_add(region.bottom, pad);
edge.min = region.left;
edge.max = region.right;
break;
- case WLR_EDGE_NONE:
+ default:
/* Should never be reached */
wlr_log(WLR_ERROR, "invalid direction");
abort();
}
static inline bool
-is_lesser(enum wlr_edges direction)
+is_lesser(enum lab_edge direction)
{
- return direction == WLR_EDGE_LEFT || direction == WLR_EDGE_TOP;
+ return direction == LAB_EDGE_LEFT || direction == LAB_EDGE_TOP;
}
static inline struct edge
-build_visible_edge(struct border region, enum wlr_edges direction,
- int pad, uint32_t edges_visible)
+build_visible_edge(struct border region, enum lab_edge direction,
+ int pad, enum lab_edge edges_visible)
{
struct edge edge = build_edge(region, direction, pad);
validate_single_region_edge(int *valid_edge,
struct border view, struct border target,
struct border region, edge_validator_t validator,
- enum wlr_edges direction, uint32_t edges_visible)
+ enum lab_edge direction, enum lab_edge edges_visible)
{
/*
* When a view snaps to another while moving to its target, it can do
* the region borders for aligned edges only.
*/
- enum wlr_edges opposing = WLR_EDGE_NONE;
-
- switch (direction) {
- case WLR_EDGE_TOP:
- opposing = WLR_EDGE_BOTTOM;
- break;
- case WLR_EDGE_BOTTOM:
- opposing = WLR_EDGE_TOP;
- break;
- case WLR_EDGE_LEFT:
- opposing = WLR_EDGE_RIGHT;
- break;
- case WLR_EDGE_RIGHT:
- opposing = WLR_EDGE_LEFT;
- break;
- case WLR_EDGE_NONE:
- /* Should never be reached */
- assert(false);
- return;
- }
+ enum lab_edge opposing = lab_edge_invert(direction);
+ assert(opposing != LAB_EDGE_NONE);
validator(valid_edge,
build_edge(view, direction, 0),
static void
validate_edges(struct border *valid_edges,
struct border view, struct border target,
- struct border region, uint32_t edges_visible,
+ struct border region, enum lab_edge edges_visible,
edge_validator_t validator)
{
/* Check for edges encountered during movement of left edge */
validate_single_region_edge(&valid_edges->left,
- view, target, region, validator, WLR_EDGE_LEFT, edges_visible);
+ view, target, region, validator, LAB_EDGE_LEFT, edges_visible);
/* Check for edges encountered during movement of right edge */
validate_single_region_edge(&valid_edges->right,
- view, target, region, validator, WLR_EDGE_RIGHT, edges_visible);
+ view, target, region, validator, LAB_EDGE_RIGHT, edges_visible);
/* Check for edges encountered during movement of top edge */
validate_single_region_edge(&valid_edges->top,
- view, target, region, validator, WLR_EDGE_TOP, edges_visible);
+ view, target, region, validator, LAB_EDGE_TOP, edges_visible);
/* Check for edges encountered during movement of bottom edge */
validate_single_region_edge(&valid_edges->bottom,
- view, target, region, validator, WLR_EDGE_BOTTOM, edges_visible);
+ view, target, region, validator, LAB_EDGE_BOTTOM, edges_visible);
}
static void
validate_single_output_edge(int *valid_edge,
struct border view, struct border target,
struct border region, edge_validator_t validator,
- enum wlr_edges direction)
+ enum lab_edge direction)
{
static struct border unbounded = {
.top = INT_MIN,
/* Left edge encounters a half-infinite region to the left of the output */
validate_single_output_edge(&valid_edges->left,
- view, target, output, validator, WLR_EDGE_LEFT);
+ view, target, output, validator, LAB_EDGE_LEFT);
/* Right edge encounters a half-infinite region to the right of the output */
validate_single_output_edge(&valid_edges->right,
- view, target, output, validator, WLR_EDGE_RIGHT);
+ view, target, output, validator, LAB_EDGE_RIGHT);
/* Top edge encounters a half-infinite region above the output */
validate_single_output_edge(&valid_edges->top,
- view, target, output, validator, WLR_EDGE_TOP);
+ view, target, output, validator, LAB_EDGE_TOP);
/* Bottom edge encounters a half-infinite region below the output */
validate_single_output_edge(&valid_edges->bottom,
- view, target, output, validator, WLR_EDGE_BOTTOM);
+ view, target, output, validator, LAB_EDGE_BOTTOM);
}
-static uint32_t
+static enum lab_edge
compute_edges_visible(const struct wlr_box *view_size,
const pixman_box32_t *view_rect,
const pixman_region32_t *available)
const pixman_box32_t *rects =
pixman_region32_rectangles(&intersection, &nrects);
- uint32_t edges_visible = 0;
+ enum lab_edge edges_visible = LAB_EDGE_NONE;
for (int i = 0; i < nrects; i++) {
if (rects[i].x1 == view_rect->x1) {
- edges_visible |= WLR_EDGE_LEFT;
+ edges_visible |= LAB_EDGE_LEFT;
}
if (rects[i].y1 == view_rect->y1) {
- edges_visible |= WLR_EDGE_TOP;
+ edges_visible |= LAB_EDGE_TOP;
}
if (rects[i].x2 == view_rect->x2) {
- edges_visible |= WLR_EDGE_RIGHT;
+ edges_visible |= LAB_EDGE_RIGHT;
}
if (rects[i].y2 == view_rect->y2) {
- edges_visible |= WLR_EDGE_BOTTOM;
+ edges_visible |= LAB_EDGE_BOTTOM;
}
}
pixman_region32_fini(&intersection);
switch (overlap) {
case PIXMAN_REGION_IN:
- view->edges_visible = WLR_EDGE_TOP | WLR_EDGE_RIGHT
- | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT;
+ view->edges_visible = LAB_EDGES_ALL;
break;
case PIXMAN_REGION_OUT:
- view->edges_visible = 0;
+ view->edges_visible = LAB_EDGE_NONE;
return;
case PIXMAN_REGION_PART:
view->edges_visible = compute_edges_visible(
continue;
}
- uint32_t edges_visible = ignore_hidden ? v->edges_visible :
- WLR_EDGE_TOP | WLR_EDGE_LEFT
- | WLR_EDGE_BOTTOM | WLR_EDGE_RIGHT;
+ enum lab_edge edges_visible =
+ ignore_hidden ? v->edges_visible : LAB_EDGES_ALL;
- if (edges_visible == 0) {
+ if (edges_visible == LAB_EDGE_NONE) {
continue;
}
void
edges_adjust_resize_geom(struct view *view, struct border edges,
- uint32_t resize_edges, struct wlr_box *geom, bool use_pending)
+ enum lab_edge resize_edges, struct wlr_box *geom,
+ bool use_pending)
{
assert(view);
* any valid nearest edge in the corresponding direction.
*/
- if (resize_edges & WLR_EDGE_LEFT) {
+ if (resize_edges & LAB_EDGE_LEFT) {
if (BOUNDED_INT(edges.left)) {
geom->x = edges.left + border.left + rc.gap;
geom->width = view_geom->width + view_geom->x - geom->x;
}
- } else if (resize_edges & WLR_EDGE_RIGHT) {
+ } else if (resize_edges & LAB_EDGE_RIGHT) {
if (BOUNDED_INT(edges.right)) {
geom->width = edges.right
- view_geom->x - border.right - rc.gap;
}
}
- if (resize_edges & WLR_EDGE_TOP) {
+ if (resize_edges & LAB_EDGE_TOP) {
if (BOUNDED_INT(edges.top)) {
geom->y = edges.top + border.top + rc.gap;
geom->height = view_geom->height + view_geom->y - geom->y;
}
- } else if (resize_edges & WLR_EDGE_BOTTOM) {
+ } else if (resize_edges & LAB_EDGE_BOTTOM) {
if (BOUNDED_INT(edges.bottom)) {
geom->height = edges.bottom
- view_geom->y - border.bottom - rc.gap;
"X11 cursor names are out of sync");
enum lab_cursors
-cursor_get_from_edge(uint32_t resize_edges)
+cursor_get_from_edge(enum lab_edge resize_edges)
{
switch (resize_edges) {
- case WLR_EDGE_NONE:
- return LAB_CURSOR_DEFAULT;
- case WLR_EDGE_TOP | WLR_EDGE_LEFT:
+ case LAB_EDGES_TOP_LEFT:
return LAB_CURSOR_RESIZE_NW;
- case WLR_EDGE_TOP:
+ case LAB_EDGE_TOP:
return LAB_CURSOR_RESIZE_N;
- case WLR_EDGE_TOP | WLR_EDGE_RIGHT:
+ case LAB_EDGES_TOP_RIGHT:
return LAB_CURSOR_RESIZE_NE;
- case WLR_EDGE_RIGHT:
+ case LAB_EDGE_RIGHT:
return LAB_CURSOR_RESIZE_E;
- case WLR_EDGE_BOTTOM | WLR_EDGE_RIGHT:
+ case LAB_EDGES_BOTTOM_RIGHT:
return LAB_CURSOR_RESIZE_SE;
- case WLR_EDGE_BOTTOM:
+ case LAB_EDGE_BOTTOM:
return LAB_CURSOR_RESIZE_S;
- case WLR_EDGE_BOTTOM | WLR_EDGE_LEFT:
+ case LAB_EDGES_BOTTOM_LEFT:
return LAB_CURSOR_RESIZE_SW;
- case WLR_EDGE_LEFT:
+ case LAB_EDGE_LEFT:
return LAB_CURSOR_RESIZE_W;
default:
- wlr_log(WLR_ERROR,
- "Failed to resolve wlroots edge %u to cursor name", resize_edges);
- assert(false);
+ return LAB_CURSOR_DEFAULT;
}
-
- return LAB_CURSOR_DEFAULT;
}
static enum lab_cursors
cursor_get_from_ssd(enum ssd_part_type view_area)
{
- uint32_t resize_edges = ssd_resize_edges(view_area);
+ enum lab_edge resize_edges = ssd_resize_edges(view_area);
return cursor_get_from_edge(resize_edges);
}
struct view *view = server->grabbed_view;
struct wlr_box new_view_geo = view->current;
- if (server->resize_edges & WLR_EDGE_TOP) {
+ if (server->resize_edges & LAB_EDGE_TOP) {
/* Shift y to anchor bottom edge when resizing top */
new_view_geo.y = server->grab_box.y + dy;
new_view_geo.height = server->grab_box.height - dy;
- } else if (server->resize_edges & WLR_EDGE_BOTTOM) {
+ } else if (server->resize_edges & LAB_EDGE_BOTTOM) {
new_view_geo.height = server->grab_box.height + dy;
}
- if (server->resize_edges & WLR_EDGE_LEFT) {
+ if (server->resize_edges & LAB_EDGE_LEFT) {
/* Shift x to anchor right edge when resizing left */
new_view_geo.x = server->grab_box.x + dx;
new_view_geo.width = server->grab_box.width - dx;
- } else if (server->resize_edges & WLR_EDGE_RIGHT) {
+ } else if (server->resize_edges & LAB_EDGE_RIGHT) {
new_view_geo.width = server->grab_box.width + dx;
}
resistance_resize_apply(view, &new_view_geo);
view_adjust_size(view, &new_view_geo.width, &new_view_geo.height);
- if (server->resize_edges & WLR_EDGE_TOP) {
+ if (server->resize_edges & LAB_EDGE_TOP) {
/* After size adjustments, make sure to anchor bottom edge */
new_view_geo.y = server->grab_box.y +
server->grab_box.height - new_view_geo.height;
}
- if (server->resize_edges & WLR_EDGE_LEFT) {
+ if (server->resize_edges & LAB_EDGE_LEFT) {
/* After size adjustments, make sure to anchor bottom right */
new_view_geo.x = server->grab_box.x +
server->grab_box.width - new_view_geo.width;
return false;
}
-uint32_t
+enum lab_edge
cursor_get_resize_edges(struct wlr_cursor *cursor, struct cursor_context *ctx)
{
- uint32_t resize_edges = ssd_resize_edges(ctx->type);
+ enum lab_edge resize_edges = ssd_resize_edges(ctx->type);
if (ctx->view && !resize_edges) {
struct wlr_box box = ctx->view->current;
resize_edges |=
(int)cursor->x < box.x + box.width / 2 ?
- WLR_EDGE_LEFT : WLR_EDGE_RIGHT;
+ LAB_EDGE_LEFT : LAB_EDGE_RIGHT;
resize_edges |=
(int)cursor->y < box.y + box.height / 2 ?
- WLR_EDGE_TOP : WLR_EDGE_BOTTOM;
+ LAB_EDGE_TOP : LAB_EDGE_BOTTOM;
}
return resize_edges;
}
}
void
-interactive_begin(struct view *view, enum input_mode mode, uint32_t edges)
+interactive_begin(struct view *view, enum input_mode mode, enum lab_edge edges)
{
/*
* This function sets up an interactive move or resize operation, where
enum lab_edge *edge1, enum lab_edge *edge2)
{
*dest_output = NULL;
- *edge1 = LAB_EDGE_INVALID;
- *edge2 = LAB_EDGE_INVALID;
+ *edge1 = LAB_EDGE_NONE;
+ *edge2 = LAB_EDGE_NONE;
if (!view_is_floating(seat->server->grabbed_view)) {
return false;
int right = area->x + area->width - cursor_x;
if (top < rc.snap_edge_range) {
- *edge1 = LAB_EDGE_UP;
+ *edge1 = LAB_EDGE_TOP;
} else if (bottom < rc.snap_edge_range) {
- *edge1 = LAB_EDGE_DOWN;
+ *edge1 = LAB_EDGE_BOTTOM;
} else if (left < rc.snap_edge_range) {
*edge1 = LAB_EDGE_LEFT;
} else if (right < rc.snap_edge_range) {
return false;
}
- if (*edge1 == LAB_EDGE_UP || *edge1 == LAB_EDGE_DOWN) {
+ if (*edge1 == LAB_EDGE_TOP || *edge1 == LAB_EDGE_BOTTOM) {
if (left < rc.snap_edge_corner_range) {
*edge2 = LAB_EDGE_LEFT;
} else if (right < rc.snap_edge_corner_range) {
}
} else if (*edge1 == LAB_EDGE_LEFT || *edge1 == LAB_EDGE_RIGHT) {
if (top < rc.snap_edge_corner_range) {
- *edge2 = LAB_EDGE_UP;
+ *edge2 = LAB_EDGE_TOP;
} else if (bottom < rc.snap_edge_corner_range) {
- *edge2 = LAB_EDGE_DOWN;
+ *edge2 = LAB_EDGE_BOTTOM;
}
}
* Don't store natural geometry here (it was
* stored already in interactive_begin())
*/
- if (edge == LAB_EDGE_UP && rc.snap_top_maximize) {
+ if (edge == LAB_EDGE_TOP && rc.snap_top_maximize) {
/* <topMaximize> */
view_maximize(view, VIEW_AXIS_BOTH,
/*store_natural_geometry*/ false);
#include <wlr/types/wlr_scene.h>
#include <wlr/util/region.h>
#include <wlr/util/log.h>
-#include "common/direction.h"
#include "common/macros.h"
#include "common/mem.h"
#include "common/scene-helpers.h"
return NULL;
}
- enum wlr_direction direction;
- if (!direction_from_edge(edge, &direction)) {
+ /* Allow only up/down/left/right */
+ if (!lab_edge_is_cardinal(edge)) {
return NULL;
}
struct wlr_output *new_output = NULL;
struct wlr_output *current_output = output->wlr_output;
struct wlr_output_layout *layout = output->server->output_layout;
- new_output = wlr_output_layout_adjacent_output(layout, direction,
- current_output, lx, ly);
+ /* Cast from enum lab_edge to enum wlr_direction is safe */
+ new_output = wlr_output_layout_adjacent_output(layout,
+ (enum wlr_direction)edge, current_output, lx, ly);
/*
* Optionally wrap around from top-to-bottom or left-to-right, and vice
* versa.
*/
if (wrap && !new_output) {
+ enum lab_edge opposite = lab_edge_invert(edge);
new_output = wlr_output_layout_farthest_output(layout,
- direction_get_opposite(direction), current_output, lx, ly);
+ (enum wlr_direction)opposite, current_output, lx, ly);
}
/*
#include "overlay.h"
#include <assert.h>
#include <wlr/types/wlr_scene.h>
-#include "common/direction.h"
#include "common/lab-scene-rect.h"
#include "config/rcxml.h"
#include "labwc.h"
&overlay->edge_rect.tree->node, false);
}
overlay->active.region = NULL;
- overlay->active.edge = LAB_EDGE_INVALID;
+ overlay->active.edge = LAB_EDGE_NONE;
overlay->active.output = NULL;
if (overlay->timer) {
wl_event_source_timer_update(overlay->timer, 0);
static struct wlr_box
get_edge_snap_box(enum lab_edge edge, struct output *output)
{
- if (edge == LAB_EDGE_UP && rc.snap_top_maximize) {
+ if (edge == LAB_EDGE_TOP && rc.snap_top_maximize) {
return output_usable_area_in_layout_coords(output);
} else {
return view_get_edge_snap_box(NULL, output, edge);
handle_edge_overlay_timeout(void *data)
{
struct seat *seat = data;
- assert(seat->overlay.active.edge != LAB_EDGE_INVALID
+ assert(seat->overlay.active.edge != LAB_EDGE_NONE
&& seat->overlay.active.output);
struct wlr_box box = get_edge_snap_box(seat->overlay.active.edge,
seat->overlay.active.output);
edge_has_adjacent_output_from_cursor(struct seat *seat, struct output *output,
enum lab_edge edge)
{
- enum wlr_direction dir;
- if (!direction_from_edge(edge, &dir)) {
+ /* Allow only up/down/left/right */
+ if (!lab_edge_is_cardinal(edge)) {
return false;
}
+ /* Cast from enum lab_edge to enum wlr_direction is safe */
return wlr_output_layout_adjacent_output(
- seat->server->output_layout, dir,
+ seat->server->output_layout, (enum wlr_direction)edge,
output->wlr_output, seat->cursor->x, seat->cursor->y);
}
if (!rc.snap_overlay_enabled) {
return;
}
- uint32_t edge = edge1 | edge2;
+ enum lab_edge edge = edge1 | edge2;
if (seat->overlay.active.edge == edge
&& seat->overlay.active.output == output) {
return;
edges_initialize(&next_edges);
/* Use a constrained, effective geometry for snapping if appropriate */
- enum wlr_edges resize_edges = view->server->resize_edges;
+ enum lab_edge resize_edges = view->server->resize_edges;
struct wlr_box origin =
snap_constraints_effective(view, resize_edges, /* use_pending */ false);
bool pending;
int vertical_offset;
int horizontal_offset;
- enum wlr_edges resize_edges;
+ enum lab_edge resize_edges;
struct wlr_box geom;
} last_snap_hit;
last_snap_hit.pending = false;
last_snap_hit.horizontal_offset = INT_MIN;
last_snap_hit.vertical_offset = INT_MIN;
- last_snap_hit.resize_edges = WLR_EDGE_NONE;
+ last_snap_hit.resize_edges = LAB_EDGE_NONE;
memset(&last_snap_hit.geom, 0, sizeof(last_snap_hit.geom));
}
static bool
-snap_constraints_are_valid(struct view *view, enum wlr_edges resize_edges)
+snap_constraints_are_valid(struct view *view, enum lab_edge resize_edges)
{
assert(view);
}
/* Cache is not valid if edge offsets are invalid */
- if (resize_edges & (WLR_EDGE_LEFT | WLR_EDGE_RIGHT)) {
+ if (resize_edges & LAB_EDGES_LEFT_RIGHT) {
if (!BOUNDED_INT(last_snap_hit.horizontal_offset)) {
return false;
}
- if ((resize_edges & WLR_EDGE_LEFT) && (resize_edges & WLR_EDGE_RIGHT)) {
+ if ((resize_edges & LAB_EDGE_LEFT) && (resize_edges & LAB_EDGE_RIGHT)) {
return false;
}
- } else if (resize_edges & (WLR_EDGE_TOP | WLR_EDGE_BOTTOM)) {
+ } else if (resize_edges & LAB_EDGES_TOP_BOTTOM) {
if (!BOUNDED_INT(last_snap_hit.vertical_offset)) {
return false;
}
- if ((resize_edges & WLR_EDGE_TOP) && (resize_edges & WLR_EDGE_BOTTOM)) {
+ if ((resize_edges & LAB_EDGE_TOP) && (resize_edges & LAB_EDGE_BOTTOM)) {
return false;
}
} else {
}
void
-snap_constraints_set(struct view *view,
- enum wlr_edges resize_edges, struct wlr_box geom)
+snap_constraints_set(struct view *view, enum lab_edge resize_edges,
+ struct wlr_box geom)
{
assert(view);
/* Set horizontal offset when resizing horizontal edges */
last_snap_hit.horizontal_offset = INT_MIN;
- if (resize_edges & WLR_EDGE_LEFT) {
+ if (resize_edges & LAB_EDGE_LEFT) {
last_snap_hit.horizontal_offset = geom.x;
- } else if (resize_edges & WLR_EDGE_RIGHT) {
+ } else if (resize_edges & LAB_EDGE_RIGHT) {
last_snap_hit.horizontal_offset = geom.x + geom.width;
}
/* Set vertical offset when resizing vertical edges */
last_snap_hit.vertical_offset = INT_MIN;
- if (resize_edges & WLR_EDGE_TOP) {
+ if (resize_edges & LAB_EDGE_TOP) {
last_snap_hit.vertical_offset = geom.y;
- } else if (resize_edges & WLR_EDGE_BOTTOM) {
+ } else if (resize_edges & LAB_EDGE_BOTTOM) {
last_snap_hit.vertical_offset = geom.y + geom.height;
}
}
struct wlr_box
-snap_constraints_effective(struct view *view,
- enum wlr_edges resize_edges, bool use_pending)
+snap_constraints_effective(struct view *view, enum lab_edge resize_edges,
+ bool use_pending)
{
assert(view);
/* Override changing edge with constrained value */
struct wlr_box geom = real_geom;
- if (resize_edges & WLR_EDGE_LEFT) {
+ if (resize_edges & LAB_EDGE_LEFT) {
geom.x = last_snap_hit.horizontal_offset;
- } else if (resize_edges & WLR_EDGE_RIGHT) {
+ } else if (resize_edges & LAB_EDGE_RIGHT) {
geom.width = last_snap_hit.horizontal_offset - geom.x;
}
- if (resize_edges & WLR_EDGE_TOP) {
+ if (resize_edges & LAB_EDGE_TOP) {
geom.y = last_snap_hit.vertical_offset;
- } else if (resize_edges & WLR_EDGE_BOTTOM) {
+ } else if (resize_edges & LAB_EDGE_BOTTOM) {
geom.height = last_snap_hit.vertical_offset - geom.y;
}
return;
}
break;
- case LAB_EDGE_UP:
+ case LAB_EDGE_TOP:
target.y = usable.y + ssd.top + rc.gap;
if (target.y >= view->pending.y) {
return;
}
break;
- case LAB_EDGE_DOWN:
+ case LAB_EDGE_BOTTOM:
target.y = usable.y + usable.height - rc.gap - ssd.bottom
- view_effective_height(view, /* use_pending */ true);
if (target.y <= view->pending.y) {
struct border ssd = ssd_thickness(view);
struct wlr_box usable = output_usable_area_in_layout_coords(output);
- uint32_t resize_edges;
+ enum lab_edge resize_edges;
/* First try to grow the view to the relevant edge of its output. */
switch (direction) {
case LAB_EDGE_LEFT:
geo->x = usable.x + ssd.left + rc.gap;
geo->width = view->pending.x + view->pending.width - geo->x;
- resize_edges = WLR_EDGE_LEFT;
+ resize_edges = LAB_EDGE_LEFT;
break;
case LAB_EDGE_RIGHT:
geo->width = usable.x + usable.width
- rc.gap - ssd.right - view->pending.x;
- resize_edges = WLR_EDGE_RIGHT;
+ resize_edges = LAB_EDGE_RIGHT;
break;
- case LAB_EDGE_UP:
+ case LAB_EDGE_TOP:
geo->y = usable.y + ssd.top + rc.gap;
geo->height = view->pending.y + view->pending.height - geo->y;
- resize_edges = WLR_EDGE_TOP;
+ resize_edges = LAB_EDGE_TOP;
break;
- case LAB_EDGE_DOWN:
+ case LAB_EDGE_BOTTOM:
geo->height = usable.y + usable.height
- rc.gap - ssd.bottom - view->pending.y;
- resize_edges = WLR_EDGE_BOTTOM;
+ resize_edges = LAB_EDGE_BOTTOM;
break;
default:
return;
assert(!view->shaded);
*geo = view->pending;
- uint32_t resize_edges;
+ enum lab_edge resize_edges;
int min_width = view_get_min_width();
/*
case LAB_EDGE_RIGHT:
geo->width = MAX(geo->width / 2, min_width);
geo->x = view->pending.x + view->pending.width - geo->width;
- resize_edges = WLR_EDGE_LEFT;
+ resize_edges = LAB_EDGE_LEFT;
break;
case LAB_EDGE_LEFT:
geo->width = MAX(geo->width / 2, min_width);
- resize_edges = WLR_EDGE_RIGHT;
+ resize_edges = LAB_EDGE_RIGHT;
break;
- case LAB_EDGE_DOWN:
+ case LAB_EDGE_BOTTOM:
geo->height = MAX(geo->height / 2, LAB_MIN_VIEW_HEIGHT);
geo->y = view->pending.y + view->pending.height - geo->height;
- resize_edges = WLR_EDGE_TOP;
+ resize_edges = LAB_EDGE_TOP;
break;
- case LAB_EDGE_UP:
+ case LAB_EDGE_TOP:
geo->height = MAX(geo->height / 2, LAB_MIN_VIEW_HEIGHT);
- resize_edges = WLR_EDGE_BOTTOM;
+ resize_edges = LAB_EDGE_BOTTOM;
break;
default:
return;
return resizing_type != LAB_SSD_NONE ? resizing_type : part_type;
}
-uint32_t
+enum lab_edge
ssd_resize_edges(enum ssd_part_type type)
{
switch (type) {
case LAB_SSD_PART_TOP:
- return WLR_EDGE_TOP;
+ return LAB_EDGE_TOP;
case LAB_SSD_PART_RIGHT:
- return WLR_EDGE_RIGHT;
+ return LAB_EDGE_RIGHT;
case LAB_SSD_PART_BOTTOM:
- return WLR_EDGE_BOTTOM;
+ return LAB_EDGE_BOTTOM;
case LAB_SSD_PART_LEFT:
- return WLR_EDGE_LEFT;
+ return LAB_EDGE_LEFT;
case LAB_SSD_PART_CORNER_TOP_LEFT:
- return WLR_EDGE_TOP | WLR_EDGE_LEFT;
+ return LAB_EDGES_TOP_LEFT;
case LAB_SSD_PART_CORNER_TOP_RIGHT:
- return WLR_EDGE_RIGHT | WLR_EDGE_TOP;
+ return LAB_EDGES_TOP_RIGHT;
case LAB_SSD_PART_CORNER_BOTTOM_RIGHT:
- return WLR_EDGE_BOTTOM | WLR_EDGE_RIGHT;
+ return LAB_EDGES_BOTTOM_RIGHT;
case LAB_SSD_PART_CORNER_BOTTOM_LEFT:
- return WLR_EDGE_BOTTOM | WLR_EDGE_LEFT;
+ return LAB_EDGES_BOTTOM_LEFT;
default:
- return WLR_EDGE_NONE;
+ return LAB_EDGE_NONE;
}
}
uint8_t state_set;
};
-enum corner {
- LAB_CORNER_UNKNOWN = 0,
- LAB_CORNER_TOP_LEFT,
- LAB_CORNER_TOP_RIGHT,
+enum rounded_corner {
+ ROUNDED_CORNER_TOP_LEFT,
+ ROUNDED_CORNER_TOP_RIGHT
};
struct rounded_corner_ctx {
double line_width;
cairo_pattern_t *fill_pattern;
float *border_color;
- enum corner corner;
+ enum rounded_corner corner;
};
#define zero_array(arr) memset(arr, 0, sizeof(arr))
static struct lab_data_buffer *
rounded_rect(struct rounded_corner_ctx *ctx)
{
- if (ctx->corner == LAB_CORNER_UNKNOWN) {
- return NULL;
- }
-
double w = ctx->box->width;
double h = ctx->box->height;
double r = ctx->radius;
cairo_set_line_width(cairo, 0.0);
cairo_new_sub_path(cairo);
switch (ctx->corner) {
- case LAB_CORNER_TOP_LEFT:
+ case ROUNDED_CORNER_TOP_LEFT:
cairo_arc(cairo, r, r, r, 180 * deg, 270 * deg);
cairo_line_to(cairo, w, 0);
cairo_line_to(cairo, w, h);
cairo_line_to(cairo, 0, h);
break;
- case LAB_CORNER_TOP_RIGHT:
+ case ROUNDED_CORNER_TOP_RIGHT:
cairo_arc(cairo, w - r, r, r, -90 * deg, 0 * deg);
cairo_line_to(cairo, w, h);
cairo_line_to(cairo, 0, h);
cairo_line_to(cairo, 0, 0);
break;
- default:
- wlr_log(WLR_ERROR, "unknown corner type");
}
cairo_close_path(cairo);
cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE);
cairo_set_line_width(cairo, ctx->line_width);
double half_line_width = ctx->line_width / 2.0;
switch (ctx->corner) {
- case LAB_CORNER_TOP_LEFT:
+ case ROUNDED_CORNER_TOP_LEFT:
cairo_move_to(cairo, half_line_width, h);
cairo_line_to(cairo, half_line_width, r);
cairo_move_to(cairo, r, half_line_width);
cairo_line_to(cairo, w, half_line_width);
break;
- case LAB_CORNER_TOP_RIGHT:
+ case ROUNDED_CORNER_TOP_RIGHT:
cairo_move_to(cairo, 0, half_line_width);
cairo_line_to(cairo, w - r, half_line_width);
cairo_move_to(cairo, w - half_line_width, r);
cairo_line_to(cairo, w - half_line_width, h);
break;
- default:
- wlr_log(WLR_ERROR, "unknown corner type");
}
cairo_stroke(cairo);
cairo_set_line_width(cairo, line_width);
half_line_width = line_width / 2.0;
switch (ctx->corner) {
- case LAB_CORNER_TOP_LEFT:
+ case ROUNDED_CORNER_TOP_LEFT:
cairo_move_to(cairo, half_line_width, r);
cairo_arc(cairo, r, r, r - half_line_width, 180 * deg, 270 * deg);
break;
- case LAB_CORNER_TOP_RIGHT:
+ case ROUNDED_CORNER_TOP_RIGHT:
cairo_move_to(cairo, w - r, half_line_width);
cairo_arc(cairo, w - r, r, r - half_line_width, -90 * deg, 0 * deg);
break;
- default:
- break;
}
cairo_stroke(cairo);
.line_width = theme->border_width,
.fill_pattern = theme->window[active].titlebar_pattern,
.border_color = theme->window[active].border_color,
- .corner = LAB_CORNER_TOP_LEFT,
+ .corner = ROUNDED_CORNER_TOP_LEFT,
};
theme->window[active].corner_top_left_normal = rounded_rect(&ctx);
- ctx.corner = LAB_CORNER_TOP_RIGHT;
+ ctx.corner = ROUNDED_CORNER_TOP_RIGHT;
theme->window[active].corner_top_right_normal = rounded_rect(&ctx);
}
}
}
static bool
-resizing_edge(struct view *view, uint32_t edge)
+resizing_edge(struct view *view, enum lab_edge edge)
{
struct server *server = view->server;
return server->input_mode == LAB_INPUT_STATE_RESIZE
* reliable on its own. The combination of the two methods
* should catch 99% of resize cases that we care about.
*/
- bool resizing_left_edge = resizing_edge(view, WLR_EDGE_LEFT);
+ bool resizing_left_edge = resizing_edge(view, LAB_EDGE_LEFT);
if (resizing_left_edge || (current->x != pending->x
&& current->x + current->width ==
pending->x + pending->width)) {
}
/* Anchor bottom edge if resizing via top edge */
- bool resizing_top_edge = resizing_edge(view, WLR_EDGE_TOP);
+ bool resizing_top_edge = resizing_edge(view, LAB_EDGE_TOP);
if (resizing_top_edge || (current->y != pending->y
&& current->y + current->height ==
pending->y + pending->height)) {
if (!view->tiled) {
return false;
}
- } else if (query->tiled != LAB_EDGE_INVALID) {
+ } else if (query->tiled != LAB_EDGE_NONE) {
if (query->tiled != view->tiled) {
return false;
}
if (edge & LAB_EDGE_LEFT) {
x2 = (usable.width - rc.gap) / 2;
}
- if (edge & LAB_EDGE_DOWN) {
+ if (edge & LAB_EDGE_BOTTOM) {
y1 = (usable.height + rc.gap) / 2;
}
- if (edge & LAB_EDGE_UP) {
+ if (edge & LAB_EDGE_TOP) {
y2 = (usable.height - rc.gap) / 2;
}
view_set_untiled(struct view *view)
{
assert(view);
- view->tiled = LAB_EDGE_INVALID;
+ view->tiled = LAB_EDGE_NONE;
view->tiled_region = NULL;
zfree(view->tiled_region_evacuate);
view_notify_tiled(view);
case LAB_EDGE_RIGHT:
destination_x = right - view->pending.width;
break;
- case LAB_EDGE_UP:
+ case LAB_EDGE_TOP:
destination_y = top;
break;
- case LAB_EDGE_DOWN:
+ case LAB_EDGE_BOTTOM:
destination_y = bottom
- view_effective_height(view, /* use_pending */ true);
break;
*/
struct view *view = wl_container_of(listener, view, request_move);
if (view == view->server->seat.pressed.view) {
- interactive_begin(view, LAB_INPUT_STATE_MOVE, 0);
+ interactive_begin(view, LAB_INPUT_STATE_MOVE, LAB_EDGE_NONE);
}
}
return;
}
- enum wlr_edges edge = WLR_EDGE_NONE;
+ enum lab_edge edge = LAB_EDGE_NONE;
bool want_edge = rc.snap_tiling_events_mode & LAB_TILING_EVENTS_EDGE;
bool want_region = rc.snap_tiling_events_mode & LAB_TILING_EVENTS_REGION;
if (want_edge) {
switch (view->tiled) {
case LAB_EDGE_LEFT:
- edge = WLR_EDGE_LEFT | WLR_EDGE_TOP | WLR_EDGE_BOTTOM;
+ edge = LAB_EDGES_EXCEPT_RIGHT;
break;
case LAB_EDGE_RIGHT:
- edge = WLR_EDGE_RIGHT | WLR_EDGE_TOP | WLR_EDGE_BOTTOM;
+ edge = LAB_EDGES_EXCEPT_LEFT;
break;
- case LAB_EDGE_UP:
- edge = WLR_EDGE_TOP | WLR_EDGE_LEFT | WLR_EDGE_RIGHT;
+ case LAB_EDGE_TOP:
+ edge = LAB_EDGES_EXCEPT_BOTTOM;
break;
- case LAB_EDGE_DOWN:
- edge = WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | WLR_EDGE_RIGHT;
+ case LAB_EDGE_BOTTOM:
+ edge = LAB_EDGES_EXCEPT_TOP;
break;
- case LAB_EDGE_UPLEFT:
- edge = WLR_EDGE_TOP | WLR_EDGE_LEFT;
- break;
- case LAB_EDGE_UPRIGHT:
- edge = WLR_EDGE_TOP | WLR_EDGE_RIGHT;
- break;
- case LAB_EDGE_DOWNLEFT:
- edge = WLR_EDGE_BOTTOM | WLR_EDGE_LEFT;
- break;
- case LAB_EDGE_DOWNRIGHT:
- edge = WLR_EDGE_BOTTOM | WLR_EDGE_RIGHT;
+ case LAB_EDGES_TOP_LEFT:
+ case LAB_EDGES_TOP_RIGHT:
+ case LAB_EDGES_BOTTOM_LEFT:
+ case LAB_EDGES_BOTTOM_RIGHT:
+ edge = view->tiled;
break;
/* TODO: LAB_EDGE_CENTER? */
default:
- edge = WLR_EDGE_NONE;
+ edge = LAB_EDGE_NONE;
}
}
if (want_region && view->tiled_region) {
/* Region-snapped views are considered tiled on all edges */
- edge = WLR_EDGE_LEFT | WLR_EDGE_RIGHT |
- WLR_EDGE_TOP | WLR_EDGE_BOTTOM;
+ edge = LAB_EDGES_ALL;
}
uint32_t serial =
*/
struct view *view = wl_container_of(listener, view, request_move);
if (view == view->server->seat.pressed.view) {
- interactive_begin(view, LAB_INPUT_STATE_MOVE, 0);
+ interactive_begin(view, LAB_INPUT_STATE_MOVE, LAB_EDGE_NONE);
}
}