mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-13 13:29:44 -05:00
Fix views outside output layout
This commit is contained in:
parent
80ed4d4d20
commit
1fe1d64042
9 changed files with 151 additions and 106 deletions
|
|
@ -6,7 +6,7 @@
|
|||
#include <wlr/types/wlr_box.h>
|
||||
#include <wlr/util/log.h>
|
||||
|
||||
void wlr_box_closest_point(struct wlr_box *box, double x, double y,
|
||||
void wlr_box_closest_point(const struct wlr_box *box, double x, double y,
|
||||
double *dest_x, double *dest_y) {
|
||||
// find the closest x point
|
||||
if (x < box->x) {
|
||||
|
|
@ -27,13 +27,12 @@ void wlr_box_closest_point(struct wlr_box *box, double x, double y,
|
|||
}
|
||||
}
|
||||
|
||||
bool wlr_box_empty(struct wlr_box *box) {
|
||||
bool wlr_box_empty(const struct wlr_box *box) {
|
||||
return box == NULL || box->width <= 0 || box->height <= 0;
|
||||
}
|
||||
|
||||
bool wlr_box_intersection(struct wlr_box *box_a,
|
||||
struct wlr_box *box_b, struct wlr_box **box_dest) {
|
||||
struct wlr_box *dest = *box_dest;
|
||||
bool wlr_box_intersection(const struct wlr_box *box_a,
|
||||
const struct wlr_box *box_b, struct wlr_box *dest) {
|
||||
bool a_empty = wlr_box_empty(box_a);
|
||||
bool b_empty = wlr_box_empty(box_b);
|
||||
|
||||
|
|
@ -58,7 +57,7 @@ bool wlr_box_intersection(struct wlr_box *box_a,
|
|||
return !wlr_box_empty(dest);
|
||||
}
|
||||
|
||||
bool wlr_box_contains_point(struct wlr_box *box, double x, double y) {
|
||||
bool wlr_box_contains_point(const struct wlr_box *box, double x, double y) {
|
||||
if (wlr_box_empty(box)) {
|
||||
return false;
|
||||
} else {
|
||||
|
|
@ -67,7 +66,7 @@ bool wlr_box_contains_point(struct wlr_box *box, double x, double y) {
|
|||
}
|
||||
}
|
||||
|
||||
void wlr_box_transform(struct wlr_box *box,
|
||||
void wlr_box_transform(const struct wlr_box *box,
|
||||
enum wl_output_transform transform, struct wlr_box *dest) {
|
||||
if (transform % 2 == 0) {
|
||||
dest->width = box->width;
|
||||
|
|
|
|||
|
|
@ -555,9 +555,8 @@ static void output_cursor_update_visible(struct wlr_output_cursor *cursor) {
|
|||
output_cursor_get_box(cursor, &cursor_box);
|
||||
|
||||
struct wlr_box intersection;
|
||||
struct wlr_box *intersection_ptr = &intersection;
|
||||
bool visible =
|
||||
wlr_box_intersection(&output_box, &cursor_box, &intersection_ptr);
|
||||
wlr_box_intersection(&output_box, &cursor_box, &intersection);
|
||||
|
||||
if (cursor->surface != NULL) {
|
||||
if (cursor->visible && !visible) {
|
||||
|
|
|
|||
|
|
@ -230,30 +230,38 @@ bool wlr_output_layout_contains_point(struct wlr_output_layout *layout,
|
|||
}
|
||||
|
||||
bool wlr_output_layout_intersects(struct wlr_output_layout *layout,
|
||||
struct wlr_output *reference, int x1, int y1, int x2, int y2) {
|
||||
struct wlr_output_layout_output *layout_output =
|
||||
wlr_output_layout_get(layout, reference);
|
||||
if (!layout_output) {
|
||||
struct wlr_output *reference, const struct wlr_box *target_box) {
|
||||
struct wlr_box out_box;
|
||||
|
||||
if (reference == NULL) {
|
||||
struct wlr_output_layout_output *l_output;
|
||||
wl_list_for_each(l_output, &layout->outputs, link) {
|
||||
struct wlr_box *output_box =
|
||||
wlr_output_layout_output_get_box(l_output);
|
||||
if (wlr_box_intersection(output_box, target_box, &out_box)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
struct wlr_output_layout_output *l_output =
|
||||
wlr_output_layout_get(layout, reference);
|
||||
if (!l_output) {
|
||||
return false;
|
||||
}
|
||||
|
||||
struct wlr_box *output_box = wlr_output_layout_output_get_box(l_output);
|
||||
return wlr_box_intersection(output_box, target_box, &out_box);
|
||||
}
|
||||
|
||||
struct wlr_box *output_box = wlr_output_layout_output_get_box(layout_output);
|
||||
struct wlr_box target_box = {x1, y1, x2 - x1, y2 - y1};
|
||||
|
||||
struct wlr_box out;
|
||||
struct wlr_box *out_ptr = &out;
|
||||
return wlr_box_intersection(output_box, &target_box, &out_ptr);
|
||||
}
|
||||
|
||||
struct wlr_output *wlr_output_layout_output_at(struct wlr_output_layout *layout,
|
||||
double x, double y) {
|
||||
struct wlr_output_layout_output *l_output;
|
||||
wl_list_for_each(l_output, &layout->outputs, link) {
|
||||
if (l_output->output) {
|
||||
struct wlr_box *box = wlr_output_layout_output_get_box(l_output);
|
||||
if (wlr_box_contains_point(box, x, y)) {
|
||||
return l_output->output;
|
||||
}
|
||||
struct wlr_box *box = wlr_output_layout_output_get_box(l_output);
|
||||
if (wlr_box_contains_point(box, x, y)) {
|
||||
return l_output->output;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue