mirror of
https://github.com/cage-kiosk/cage.git
synced 2026-03-17 05:34:19 -04:00
output: refactor get_surface_box
The function also did an intersection check, so it did more than just getting the surface box. This refactoring makes it more clear. This commit also fixes a bug in coordinate spaces that makes dialogs render properly over multiple outputs.
This commit is contained in:
parent
23f8d609ce
commit
2f9442906d
1 changed files with 22 additions and 36 deletions
58
output.c
58
output.c
|
|
@ -49,55 +49,41 @@ struct surface_iterator_data {
|
||||||
double ox, oy;
|
double ox, oy;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: this doesn't just get the surface box; it also indicates if said box overlaps
|
static bool
|
||||||
// with the current output box.
|
intersects_with_output(struct cg_output *output, struct wlr_output_layout *output_layout, struct wlr_box *surface_box)
|
||||||
static bool // TODO: remove surface_iterator_data argument?
|
|
||||||
get_surface_box(struct surface_iterator_data *data,
|
|
||||||
struct wlr_surface *surface, int sx, int sy,
|
|
||||||
struct wlr_box *surface_box)
|
|
||||||
{
|
{
|
||||||
struct cg_output *output = data->output;
|
/* Since the surface_box's x- and y-coordinates are already output local,
|
||||||
|
* the x- and y-coordinates of this box need to be 0 for this function to
|
||||||
if (!wlr_surface_has_buffer(surface)) {
|
* work correctly. */
|
||||||
return false;
|
struct wlr_box output_box = {0};
|
||||||
}
|
wlr_output_effective_resolution(output->wlr_output, &output_box.width, &output_box.height);
|
||||||
|
|
||||||
struct wlr_box box = {
|
|
||||||
.x = sx + surface->sx,
|
|
||||||
.y = sy + surface->sy,
|
|
||||||
.width = surface->current.width,
|
|
||||||
.height = surface->current.height,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct cg_server *server = output->server;
|
|
||||||
struct wlr_box *output_box = wlr_output_layout_get_box(server->output_layout, output->wlr_output);
|
|
||||||
|
|
||||||
struct wlr_box intersection;
|
struct wlr_box intersection;
|
||||||
bool intersects = wlr_box_intersection(&intersection, output_box, &box);
|
return wlr_box_intersection(&intersection, &output_box, surface_box);
|
||||||
|
|
||||||
// TODO: why can't we do this before the intersection check?
|
|
||||||
box.x += data->ox;
|
|
||||||
box.y += data->oy;
|
|
||||||
|
|
||||||
if (surface_box) {
|
|
||||||
memcpy(surface_box, &box, sizeof(struct wlr_box));
|
|
||||||
}
|
|
||||||
|
|
||||||
return intersects;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
output_for_each_surface_iterator(struct wlr_surface *surface, int sx, int sy, void *user_data)
|
output_for_each_surface_iterator(struct wlr_surface *surface, int sx, int sy, void *user_data)
|
||||||
{
|
{
|
||||||
struct surface_iterator_data *data = user_data;
|
struct surface_iterator_data *data = user_data;
|
||||||
|
struct cg_output *output = data->output;
|
||||||
|
|
||||||
struct wlr_box box;
|
if (!wlr_surface_has_buffer(surface)) {
|
||||||
bool intersects = get_surface_box(data, surface, sx, sy, &box);
|
|
||||||
if (!intersects) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
data->user_iterator(data->output, surface, &box, data->user_data);
|
struct wlr_box surface_box = {
|
||||||
|
.x = data->ox + sx + surface->sx,
|
||||||
|
.y = data->oy + sy + surface->sy,
|
||||||
|
.width = surface->current.width,
|
||||||
|
.height = surface->current.height,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!intersects_with_output(output, output->server->output_layout, &surface_box)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
data->user_iterator(data->output, surface, &surface_box, data->user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue