From a9655c12307643fd29fc7f2f49d3a1403afe1c82 Mon Sep 17 00:00:00 2001 From: vcaesar Date: Sun, 1 Dec 2019 09:43:53 -0400 Subject: [PATCH] add getMousePos() multiple screens support --- mouse/goMouse.h | 4 ++-- mouse/mouse.h | 2 +- mouse/mouse_c.h | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mouse/goMouse.h b/mouse/goMouse.h index 1839e95..af7e663 100644 --- a/mouse/goMouse.h +++ b/mouse/goMouse.h @@ -70,8 +70,8 @@ bool move_mouse_smooth(size_t x, size_t y, double lowSpeed, return cbool; } -MMPoint get_mouse_pos(){ - MMPoint pos = getMousePos(); +MMPointInt32 get_mouse_pos(){ + MMPointInt32 pos = getMousePos(); // Return object with .x and .y. // printf("%zu\n%zu\n", pos.x, pos.y ); diff --git a/mouse/mouse.h b/mouse/mouse.h index d0c7dac..4438f2d 100644 --- a/mouse/mouse.h +++ b/mouse/mouse.h @@ -82,7 +82,7 @@ bool smoothlyMoveMouse(MMPoint endPoint, double lowSpeed, double highSpeed); // bool smoothlyMoveMouse(MMPoint point); /* Returns the coordinates of the mouse on the current screen. */ -MMPoint getMousePos(void); +MMPointInt32 getMousePos(void); /* Holds down or releases the mouse with the given button in the current * position. */ diff --git a/mouse/mouse_c.h b/mouse/mouse_c.h index 4a70662..5e5194b 100644 --- a/mouse/mouse_c.h +++ b/mouse/mouse_c.h @@ -144,13 +144,13 @@ void dragMouse(MMPointInt32 point, const MMMouseButton button){ #endif } -MMPoint getMousePos(){ +MMPointInt32 getMousePos(){ #if defined(IS_MACOSX) CGEventRef event = CGEventCreate(NULL); CGPoint point = CGEventGetLocation(event); CFRelease(event); - return MMPointFromCGPoint(point); + return MMPointInt32FromCGPoint(point); #elif defined(USE_X11) int x, y; /* This is all we care about. Seriously. */ Window garb1, garb2; /* Why you can't specify NULL as a parameter */ @@ -161,12 +161,12 @@ MMPoint getMousePos(){ XQueryPointer(display, XDefaultRootWindow(display), &garb1, &garb2, &x, &y, &garb_x, &garb_y, &more_garbage); - return MMPointMake(x, y); + return MMPointInt32Make(x, y); #elif defined(IS_WINDOWS) POINT point; GetCursorPos(&point); - return MMPointFromPOINT(point); + return MMPointInt32FromPOINT(point); #endif } @@ -403,7 +403,7 @@ static double crude_hypot(double x, double y){ } bool smoothlyMoveMouse(MMPoint endPoint, double lowSpeed, double highSpeed){ - MMPoint pos = getMousePos(); + MMPointInt32 pos = getMousePos(); MMSizeInt32 screenSize = getMainDisplaySize(); double velo_x = 0.0, velo_y = 0.0; double distance;