summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bclient.c7
-rw-r--r--src/dclient.c8
-rw-r--r--src/input.h10
3 files changed, 21 insertions, 4 deletions
diff --git a/src/bclient.c b/src/bclient.c
index 8b8bf6d..0252d13 100644
--- a/src/bclient.c
+++ b/src/bclient.c
@@ -44,8 +44,11 @@ bclient_mouse(struct display *d, struct mouse_event *m)
/* Remove the buffer offset */
/* Clamp the position to the buffer bounds */
- m->x = clamp_value(m->x - b->xoff, b->desc.width);
- m->y = clamp_value(m->y - b->yoff, b->desc.height);
+ /* Scale the position to the dimensions the frontend expects */
+ if (b->xoff > 0 || b->yoff > 0) {
+ m->x = scale_value(m->x - b->xoff, b->desc.width, display_get_width());
+ m->y = scale_value(m->y - b->yoff, b->desc.height, display_get_height());
+ }
if (d->client->input)
xen_linpicker_input_send(d->client->input, m);
diff --git a/src/dclient.c b/src/dclient.c
index cfe01ff..72f6fad 100644
--- a/src/dclient.c
+++ b/src/dclient.c
@@ -93,8 +93,12 @@ dclient_mouse(struct display *d, struct mouse_event *m)
b = LIST_FIRST(&d->mouse_client->buffers);
/* Remove the buffer offset */
- m->x -= b->xoff;
- m->y -= b->yoff;
+ /* Clamp the position to the buffer bounds */
+ /* Scale the position to the dimensions the frontend expects */
+ if (b->xoff > 0 || b->yoff > 0) {
+ m->x = scale_value(m->x - b->xoff, b->desc.width, display_get_width());
+ m->y = scale_value(m->y - b->yoff, b->desc.height, display_get_height());
+ }
xen_linpicker_input_send(d->mouse_client->input, m);
}
diff --git a/src/input.h b/src/input.h
index 7785274..eb02850 100644
--- a/src/input.h
+++ b/src/input.h
@@ -22,6 +22,16 @@ static inline int clamp_value(int val, int max)
return val;
}
+static inline int scale_value(int val, int max, int scale)
+{
+ if (val <= 0)
+ return 0;
+ else if (val >= max)
+ return scale;
+ else
+ return (val * scale) / max;
+}
+
int
input_initialize(int argc, char *argv[]);