aboutsummaryrefslogtreecommitdiff
path: root/src/fb.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fb.c')
-rw-r--r--src/fb.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/fb.c b/src/fb.c
index 4e351e8..f73948a 100644
--- a/src/fb.c
+++ b/src/fb.c
@@ -74,7 +74,7 @@ static float project_component(float r, float start, float size, float dim) {
}
bool pw_fb_coordinates(struct pw_framebuffer *fb, float wx, float wy,
- struct pw_coordinates *coords) {
+ bool relative, struct pw_coordinates *coords) {
if (!fb) {
return SDL_InvalidParamError("fb");
}
@@ -93,6 +93,14 @@ bool pw_fb_coordinates(struct pw_framebuffer *fb, float wx, float wy,
return false;
}
+ float sx, sy;
+ if (relative) {
+ sx = sy = 0.;
+ } else {
+ sx = fb->target.x;
+ sy = fb->target.y;
+ }
+
float rx, ry;
if (!SDL_RenderCoordinatesFromWindow(renderer, wx, wy, &rx, &ry)) {
return false;
@@ -101,8 +109,8 @@ bool pw_fb_coordinates(struct pw_framebuffer *fb, float wx, float wy,
return SDL_SetError("unreasonable render coordinates");
}
- coords->x = project_component(rx, fb->target.x, fb->target.w, PW_FB_WIDTH);
- coords->y = project_component(ry, fb->target.y, fb->target.h, PW_FB_HEIGHT);
+ coords->x = project_component(rx, sx, fb->target.w, PW_FB_WIDTH);
+ coords->y = project_component(ry, sy, fb->target.h, PW_FB_HEIGHT);
return true;
}