Documentation for <wlr/util/box.h>

Back to index

Table of contents

struct wlr_box

struct wlr_box {
	int x, y;
	int width, height;
};

A box representing a rectangle region in a 2D space.

The x and y coordinates are inclusive, and the width and height lengths are exclusive. In other words, the box starts from the coordinates (x, y), and goes up to but not including (x + width, y + height).

wlr_box_closest_point()

void wlr_box_closest_point(​const struct wlr_box *box, double x, double y, double *dest_x, double *dest_y);

Finds the closest point within the box bounds.

Returns NAN if the box is empty.

wlr_box_contains_box()

bool wlr_box_contains_box(​const struct wlr_box *bigger, const struct wlr_box *smaller);

wlr_box_contains_point()

bool wlr_box_contains_point(​const struct wlr_box *box, double x, double y);

wlr_box_empty()

bool wlr_box_empty(​const struct wlr_box *box);

wlr_box_equal()

bool wlr_box_equal(​const struct wlr_box *a, const struct wlr_box *b);

wlr_box_intersection()

bool wlr_box_intersection(​struct wlr_box *dest, const struct wlr_box *box_a, const struct wlr_box *box_b);

wlr_box_transform()

void wlr_box_transform(​struct wlr_box *dest, const struct wlr_box *box, enum wl_output_transform transform, int width, int height);

Transforms a box inside a (0, 0, width, height) box.

struct wlr_fbox

struct wlr_fbox {
	double x, y;
	double width, height;
};

A floating-point box representing a rectangle region in a 2D space.

struct wlr_fbox has the same semantics as struct wlr_box.

wlr_fbox_empty()

bool wlr_fbox_empty(​const struct wlr_fbox *box);

wlr_fbox_equal()

bool wlr_fbox_equal(​const struct wlr_fbox *a, const struct wlr_fbox *b);

wlr_fbox_transform()

void wlr_fbox_transform(​struct wlr_fbox *dest, const struct wlr_fbox *box, enum wl_output_transform transform, double width, double height);

Transforms a floating-point box inside a (0, 0, width, height) box.