From: Holger Schemel Date: Mon, 6 Mar 2017 17:30:28 +0000 (+0100) Subject: added gadget flag to create pixel precise mouse movement events X-Git-Tag: 4.1.0.0~180 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=77a02ebe9793a8e12f8b53821aa4d47cdfbb371a;p=rocksndiamonds.git added gadget flag to create pixel precise mouse movement events --- diff --git a/src/libgame/gadgets.c b/src/libgame/gadgets.c index 6b7d2592..668641bd 100644 --- a/src/libgame/gadgets.c +++ b/src/libgame/gadgets.c @@ -1681,16 +1681,20 @@ boolean HandleGadgets(int mx, int my, int button) { int last_x = gi->event.x; int last_y = gi->event.y; + int last_mx = gi->event.mx; + int last_my = gi->event.my; - gi->event.x = mx - gi->x; - gi->event.y = my - gi->y; + gi->event.x = gi->event.mx = mx - gi->x; + gi->event.y = gi->event.my = my - gi->y; if (gi->type == GD_TYPE_DRAWING_AREA) { gi->event.x /= gi->drawing.item_xsize; gi->event.y /= gi->drawing.item_ysize; - if (last_x != gi->event.x || last_y != gi->event.y) + if (last_x != gi->event.x || last_y != gi->event.y || + ((last_mx != gi->event.mx || last_my != gi->event.my) && + gi->event_mask & GD_EVENT_PIXEL_PRECISE)) changed_position = TRUE; } else if (gi->type & GD_TYPE_TEXT_INPUT && button != 0 && !motion_status) diff --git a/src/libgame/gadgets.h b/src/libgame/gadgets.h index 8cd4716c..2fcc82f0 100644 --- a/src/libgame/gadgets.h +++ b/src/libgame/gadgets.h @@ -50,6 +50,7 @@ #define GD_EVENT_TEXT_LEAVING (1 << 6) #define GD_EVENT_INFO_ENTERING (1 << 7) #define GD_EVENT_INFO_LEAVING (1 << 8) +#define GD_EVENT_PIXEL_PRECISE (1 << 9) /* gadget button states */ #define GD_BUTTON_UNPRESSED 0 @@ -143,6 +144,7 @@ struct GadgetEvent { unsigned int type; /* event type */ int button; /* button number for button events */ + int mx, my; /* raw gadget position at event time */ int x, y; /* gadget position at event time */ boolean off_borders; /* mouse pointer outside gadget? */ int item_x, item_y, item_position; /* new item position */