From b8d2cf5610f0e0ef96ded0a5de5bda54c10c9552 Mon Sep 17 00:00:00 2001 From: quou Date: Wed, 17 Jul 2024 21:29:06 +1000 Subject: Mouse delta --- plat.c | 6 ++++++ plat.h | 1 + 2 files changed, 7 insertions(+) diff --git a/plat.c b/plat.c index 5fbfb19..da32e29 100644 --- a/plat.c +++ b/plat.c @@ -266,6 +266,7 @@ typedef struct { GC gc; int w, h; int rmx, rmy; + int omx, omy; int ms; unsigned long begin, end; XImage* bb; @@ -382,6 +383,7 @@ App* new_app(Heap* mem, int w, int h, const char* n) { a->w = w; a->h = h; i->d = XOpenDisplay(0); + i->omx = i->omy = 0; if (!i->d) { print_err("Failed to open X11 display.\n"); pbreak(error_platform_error); @@ -459,6 +461,10 @@ void app_begin(App* a) { break; } } + a->dmx = a->mx - i->omx; + a->dmy = a->my - i->omy; + i->omx = a->mx; + i->omy = a->my; } void app_rencpy( diff --git a/plat.h b/plat.h index a4e2758..1d79465 100644 --- a/plat.h +++ b/plat.h @@ -68,6 +68,7 @@ typedef struct { int w, h, s, o, mpf; int fps; int mx, my; + int dmx, dmy; Error err; Colour* fb; Heap* heap; -- cgit v1.2.3-54-g00ecf