mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-23 10:29:49 +01:00
Merge pull request #1441 from Timidger/box-parameter-standardize
Standardize the wlr_box input paramaters
This commit is contained in:
commit
b6b1bf9490
11 changed files with 34 additions and 36 deletions
|
@ -637,8 +637,9 @@ static bool drm_connector_set_cursor(struct wlr_output *output,
|
|||
plane->surf.height, output->transform);
|
||||
|
||||
struct wlr_box hotspot = { .x = hotspot_x, .y = hotspot_y };
|
||||
wlr_box_transform(&hotspot, wlr_output_transform_invert(output->transform),
|
||||
plane->surf.width, plane->surf.height, &hotspot);
|
||||
wlr_box_transform(&hotspot, &hotspot,
|
||||
wlr_output_transform_invert(output->transform),
|
||||
plane->surf.width, plane->surf.height);
|
||||
|
||||
if (plane->cursor_hotspot_x != hotspot.x ||
|
||||
plane->cursor_hotspot_y != hotspot.y) {
|
||||
|
@ -737,7 +738,7 @@ static bool drm_connector_move_cursor(struct wlr_output *output,
|
|||
|
||||
enum wl_output_transform transform =
|
||||
wlr_output_transform_invert(output->transform);
|
||||
wlr_box_transform(&box, transform, width, height, &box);
|
||||
wlr_box_transform(&box, &box, transform, width, height);
|
||||
|
||||
if (plane != NULL) {
|
||||
box.x -= plane->cursor_hotspot_x;
|
||||
|
|
|
@ -93,9 +93,9 @@ static bool output_set_cursor(struct wlr_output *wlr_output,
|
|||
struct wlr_wl_backend *backend = output->backend;
|
||||
|
||||
struct wlr_box hotspot = { .x = hotspot_x, .y = hotspot_y };
|
||||
wlr_box_transform(&hotspot,
|
||||
wlr_box_transform(&hotspot, &hotspot,
|
||||
wlr_output_transform_invert(wlr_output->transform),
|
||||
output->cursor.width, output->cursor.height, &hotspot);
|
||||
output->cursor.width, output->cursor.height);
|
||||
|
||||
// TODO: use output->wlr_output.transform to transform pixels and hotpot
|
||||
output->cursor.hotspot_x = hotspot.x;
|
||||
|
|
|
@ -21,8 +21,8 @@ struct wlr_box {
|
|||
void wlr_box_closest_point(const struct wlr_box *box, double x, double y,
|
||||
double *dest_x, double *dest_y);
|
||||
|
||||
bool wlr_box_intersection(const struct wlr_box *box_a,
|
||||
const struct wlr_box *box_b, struct wlr_box *dest);
|
||||
bool wlr_box_intersection(struct wlr_box *dest, const struct wlr_box *box_a,
|
||||
const struct wlr_box *box_b);
|
||||
|
||||
bool wlr_box_contains_point(const struct wlr_box *box, double x, double y);
|
||||
|
||||
|
@ -31,16 +31,14 @@ bool wlr_box_empty(const struct wlr_box *box);
|
|||
/**
|
||||
* Transforms a box inside a `width` x `height` box.
|
||||
*/
|
||||
void wlr_box_transform(const struct wlr_box *box,
|
||||
enum wl_output_transform transform, int width, int height,
|
||||
struct wlr_box *dest);
|
||||
void wlr_box_transform(struct wlr_box *dest, const struct wlr_box *box,
|
||||
enum wl_output_transform transform, int width, int height);
|
||||
|
||||
/**
|
||||
* Creates the smallest box that contains the box rotated about its center.
|
||||
*/
|
||||
void wlr_box_rotated_bounds(const struct wlr_box *box, float rotation,
|
||||
struct wlr_box *dest);
|
||||
void wlr_box_rotated_bounds(struct wlr_box *dest, const struct wlr_box *box, float rotation);
|
||||
|
||||
void wlr_box_from_pixman_box32(const pixman_box32_t box, struct wlr_box *dest);
|
||||
void wlr_box_from_pixman_box32(struct wlr_box *dest, const pixman_box32_t box);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -73,8 +73,8 @@ static void gles2_scissor(struct wlr_renderer *wlr_renderer,
|
|||
PUSH_GLES2_DEBUG;
|
||||
if (box != NULL) {
|
||||
struct wlr_box gl_box;
|
||||
wlr_box_transform(box, WL_OUTPUT_TRANSFORM_FLIPPED_180,
|
||||
renderer->viewport_width, renderer->viewport_height, &gl_box);
|
||||
wlr_box_transform(&gl_box, box, WL_OUTPUT_TRANSFORM_FLIPPED_180,
|
||||
renderer->viewport_width, renderer->viewport_height);
|
||||
|
||||
glScissor(gl_box.x, gl_box.y, gl_box.width, gl_box.height);
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
|
|
|
@ -217,7 +217,7 @@ static bool surface_intersect_output(struct wlr_surface *surface,
|
|||
.x = lx, .y = ly,
|
||||
.width = surface->current.width, .height = surface->current.height,
|
||||
};
|
||||
wlr_box_rotated_bounds(&layout_box, rotation, &layout_box);
|
||||
wlr_box_rotated_bounds(&layout_box, &layout_box, rotation);
|
||||
return wlr_output_layout_intersects(output_layout, wlr_output, &layout_box);
|
||||
}
|
||||
|
||||
|
@ -238,7 +238,7 @@ static void scissor_output(struct roots_output *output, pixman_box32_t *rect) {
|
|||
|
||||
enum wl_output_transform transform =
|
||||
wlr_output_transform_invert(wlr_output->transform);
|
||||
wlr_box_transform(&box, transform, ow, oh, &box);
|
||||
wlr_box_transform(&box, &box, transform, ow, oh);
|
||||
|
||||
wlr_renderer_scissor(renderer, &box);
|
||||
}
|
||||
|
@ -269,7 +269,7 @@ static void render_surface(struct wlr_surface *surface, int sx, int sy,
|
|||
}
|
||||
|
||||
struct wlr_box rotated;
|
||||
wlr_box_rotated_bounds(&box, rotation, &rotated);
|
||||
wlr_box_rotated_bounds(&rotated, &box, rotation);
|
||||
|
||||
pixman_region32_t damage;
|
||||
pixman_region32_init(&damage);
|
||||
|
@ -335,7 +335,7 @@ static void render_decorations(struct roots_view *view,
|
|||
get_decoration_box(view, output, &box);
|
||||
|
||||
struct wlr_box rotated;
|
||||
wlr_box_rotated_bounds(&box, view->rotation, &rotated);
|
||||
wlr_box_rotated_bounds(&rotated, &box, view->rotation);
|
||||
|
||||
pixman_region32_t damage;
|
||||
pixman_region32_init(&damage);
|
||||
|
@ -605,7 +605,7 @@ static void damage_whole_surface(struct wlr_surface *surface, int sx, int sy,
|
|||
return;
|
||||
}
|
||||
|
||||
wlr_box_rotated_bounds(&box, rotation, &box);
|
||||
wlr_box_rotated_bounds(&box, &box, rotation);
|
||||
|
||||
wlr_output_damage_add_box(output->damage, &box);
|
||||
}
|
||||
|
@ -628,7 +628,7 @@ static void damage_whole_decoration(struct roots_view *view,
|
|||
struct wlr_box box;
|
||||
get_decoration_box(view, output, &box);
|
||||
|
||||
wlr_box_rotated_bounds(&box, view->rotation, &box);
|
||||
wlr_box_rotated_bounds(&box, &box, view->rotation);
|
||||
|
||||
wlr_output_damage_add_box(output->damage, &box);
|
||||
}
|
||||
|
|
|
@ -31,8 +31,8 @@ bool wlr_box_empty(const struct wlr_box *box) {
|
|||
return box == NULL || box->width <= 0 || box->height <= 0;
|
||||
}
|
||||
|
||||
bool wlr_box_intersection(const struct wlr_box *box_a,
|
||||
const struct wlr_box *box_b, struct wlr_box *dest) {
|
||||
bool wlr_box_intersection(struct wlr_box *dest, const struct wlr_box *box_a,
|
||||
const struct wlr_box *box_b) {
|
||||
bool a_empty = wlr_box_empty(box_a);
|
||||
bool b_empty = wlr_box_empty(box_b);
|
||||
|
||||
|
@ -66,9 +66,8 @@ bool wlr_box_contains_point(const struct wlr_box *box, double x, double y) {
|
|||
}
|
||||
}
|
||||
|
||||
void wlr_box_transform(const struct wlr_box *box,
|
||||
enum wl_output_transform transform, int width, int height,
|
||||
struct wlr_box *dest) {
|
||||
void wlr_box_transform(struct wlr_box *dest, const struct wlr_box *box,
|
||||
enum wl_output_transform transform, int width, int height) {
|
||||
struct wlr_box src = *box;
|
||||
|
||||
if (transform % 2 == 0) {
|
||||
|
@ -115,8 +114,8 @@ void wlr_box_transform(const struct wlr_box *box,
|
|||
}
|
||||
}
|
||||
|
||||
void wlr_box_rotated_bounds(const struct wlr_box *box, float rotation,
|
||||
struct wlr_box *dest) {
|
||||
void wlr_box_rotated_bounds(struct wlr_box *dest, const struct wlr_box *box,
|
||||
float rotation) {
|
||||
if (rotation == 0) {
|
||||
*dest = *box;
|
||||
return;
|
||||
|
@ -144,7 +143,7 @@ void wlr_box_rotated_bounds(const struct wlr_box *box, float rotation,
|
|||
dest->height = ceil(fmax(y1, y2) - fmin(y1, y2));
|
||||
}
|
||||
|
||||
void wlr_box_from_pixman_box32(const pixman_box32_t box, struct wlr_box *dest) {
|
||||
void wlr_box_from_pixman_box32(struct wlr_box *dest, const pixman_box32_t box) {
|
||||
*dest = (struct wlr_box){
|
||||
.x = box.x1,
|
||||
.y = box.y1,
|
||||
|
|
|
@ -545,7 +545,7 @@ static void output_scissor(struct wlr_output *output, pixman_box32_t *rect) {
|
|||
|
||||
enum wl_output_transform transform =
|
||||
wlr_output_transform_invert(output->transform);
|
||||
wlr_box_transform(&box, transform, ow, oh, &box);
|
||||
wlr_box_transform(&box, &box, transform, ow, oh);
|
||||
|
||||
wlr_renderer_scissor(renderer, &box);
|
||||
}
|
||||
|
@ -665,7 +665,7 @@ static void output_cursor_update_visible(struct wlr_output_cursor *cursor) {
|
|||
|
||||
struct wlr_box intersection;
|
||||
bool visible =
|
||||
wlr_box_intersection(&output_box, &cursor_box, &intersection);
|
||||
wlr_box_intersection(&intersection, &output_box, &cursor_box);
|
||||
|
||||
if (cursor->surface != NULL) {
|
||||
if (cursor->visible && !visible) {
|
||||
|
|
|
@ -256,7 +256,7 @@ bool wlr_output_layout_intersects(struct wlr_output_layout *layout,
|
|||
wl_list_for_each(l_output, &layout->outputs, link) {
|
||||
struct wlr_box *output_box =
|
||||
output_layout_output_get_box(l_output);
|
||||
if (wlr_box_intersection(output_box, target_lbox, &out_box)) {
|
||||
if (wlr_box_intersection(&out_box, output_box, target_lbox)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -269,7 +269,7 @@ bool wlr_output_layout_intersects(struct wlr_output_layout *layout,
|
|||
}
|
||||
|
||||
struct wlr_box *output_box = output_layout_output_get_box(l_output);
|
||||
return wlr_box_intersection(output_box, target_lbox, &out_box);
|
||||
return wlr_box_intersection(&out_box, output_box, target_lbox);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -184,7 +184,7 @@ static void capture_output(struct wl_client *client,
|
|||
|
||||
buffer_box = *box;
|
||||
|
||||
wlr_box_transform(&buffer_box, output->transform, ow, oh, &buffer_box);
|
||||
wlr_box_transform(&buffer_box, &buffer_box, output->transform, ow, oh);
|
||||
buffer_box.x *= output->scale;
|
||||
buffer_box.y *= output->scale;
|
||||
buffer_box.width *= output->scale;
|
||||
|
|
|
@ -647,5 +647,5 @@ void wlr_xdg_surface_get_geometry(struct wlr_xdg_surface *surface,
|
|||
return;
|
||||
}
|
||||
|
||||
wlr_box_intersection(&surface->geometry, box, box);
|
||||
wlr_box_intersection(box, &surface->geometry, box);
|
||||
}
|
||||
|
|
|
@ -598,5 +598,5 @@ void wlr_xdg_surface_v6_get_geometry(struct wlr_xdg_surface_v6 *surface, struct
|
|||
return;
|
||||
}
|
||||
|
||||
wlr_box_intersection(&surface->geometry, box, box);
|
||||
wlr_box_intersection(box, &surface->geometry, box);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue