aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorTony Crisci <tony@dubstepdish.com>2017-08-17 10:12:36 -0400
committerDrew DeVault <sir@cmpwn.com>2017-08-17 21:05:13 -0400
commit5a9baf487e0161cfbf9481c31eb6f72be0ec2fbe (patch)
tree2b79e8a851c68531018447f62c021766f5ad5d96 /examples
parent420bd3e4223d67c7bfe153be365caec342a18238 (diff)
add helper methods for intersection
Diffstat (limited to 'examples')
-rw-r--r--examples/output-layout.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/examples/output-layout.c b/examples/output-layout.c
index cc363504..13abb6a1 100644
--- a/examples/output-layout.c
+++ b/examples/output-layout.c
@@ -46,24 +46,20 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
struct sample_state *sample = state->data;
struct wlr_output *wlr_output = output->output;
- int32_t width, height;
- wlr_output_effective_resolution(wlr_output, &width, &height);
-
wlr_output_make_current(wlr_output);
wlr_renderer_begin(sample->renderer, wlr_output);
- float matrix[16];
-
- // transform global coordinates to local coordinates
- int local_x = sample->x_offs;
- int local_y = sample->y_offs;
+ if (wlr_output_layout_intersects(sample->layout, output->output,
+ sample->x_offs, sample->y_offs,
+ sample->x_offs + 128, sample->y_offs + 128)) {
+ float matrix[16];
- wlr_output_layout_output_coords(sample->layout, output->output, &local_x,
- &local_y);
+ // transform global coordinates to local coordinates
+ int local_x = sample->x_offs;
+ int local_y = sample->y_offs;
+ wlr_output_layout_output_coords(sample->layout, output->output, &local_x,
+ &local_y);
- if (local_x < width && local_x + 128 > 0 && local_y < height &&
- local_y + 128 > 0) {
- // render the image if it intersects with the output
wlr_texture_get_matrix(sample->cat_texture, &matrix,
&wlr_output->transform_matrix, local_x, local_y);
wlr_render_with_matrix(sample->renderer,