From a4810203ccfcdba2460331b46d7be4d9535f904a Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Thu, 24 Aug 2017 11:46:40 -0400 Subject: [PATCH] change output layout coords to double type --- examples/output-layout.c | 4 ++-- include/wlr/types/wlr_output_layout.h | 2 +- types/wlr_cursor.c | 5 ++--- types/wlr_output_layout.c | 10 +++++----- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/examples/output-layout.c b/examples/output-layout.c index 0dcbc1f8..041d5788 100644 --- a/examples/output-layout.c +++ b/examples/output-layout.c @@ -49,8 +49,8 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts float matrix[16]; // transform global coordinates to local coordinates - int local_x = sample->x_offs; - int local_y = sample->y_offs; + double local_x = sample->x_offs; + double local_y = sample->y_offs; wlr_output_layout_output_coords(sample->layout, output->output, &local_x, &local_y); diff --git a/include/wlr/types/wlr_output_layout.h b/include/wlr/types/wlr_output_layout.h index 52cc9423..9094f02f 100644 --- a/include/wlr/types/wlr_output_layout.h +++ b/include/wlr/types/wlr_output_layout.h @@ -38,7 +38,7 @@ void wlr_output_layout_remove(struct wlr_output_layout *layout, * coordinates relative to the given reference output. */ void wlr_output_layout_output_coords(struct wlr_output_layout *layout, - struct wlr_output *reference, int *x, int *y); + struct wlr_output *reference, double *x, double *y); bool wlr_output_layout_contains_point(struct wlr_output_layout *layout, struct wlr_output *reference, int x, int y); diff --git a/types/wlr_cursor.c b/types/wlr_cursor.c index 9a303d37..c9937c73 100644 --- a/types/wlr_cursor.c +++ b/types/wlr_cursor.c @@ -82,10 +82,9 @@ bool wlr_cursor_warp(struct wlr_cursor *cur, double x, double y) { struct wlr_output_layout_output *l_output; wl_list_for_each(l_output, &cur->state->layout->outputs, link) { - int output_x = x; - int output_y = y; + double output_x = x; + double output_y = y; - // TODO fix double to int rounding issues wlr_output_layout_output_coords(cur->state->layout, l_output->output, &output_x, &output_y); wlr_output_move_cursor(l_output->output, output_x - hotspot_x, diff --git a/types/wlr_output_layout.c b/types/wlr_output_layout.c index 3593eae6..a26a4794 100644 --- a/types/wlr_output_layout.c +++ b/types/wlr_output_layout.c @@ -113,16 +113,16 @@ void wlr_output_layout_remove(struct wlr_output_layout *layout, } void wlr_output_layout_output_coords(struct wlr_output_layout *layout, - struct wlr_output *reference, int *x, int *y) { + struct wlr_output *reference, double *x, double *y) { assert(layout && reference); - int src_x = *x; - int src_y = *y; + double src_x = *x; + double src_y = *y; struct wlr_output_layout_output *_output; wl_list_for_each(_output, &layout->outputs, link) { if (_output->output == reference) { - *x = src_x - _output->x; - *y = src_y - _output->y; + *x = src_x - (double)_output->x; + *y = src_y - (double)_output->y; return; } }