forked from enlightenment/efl
evas: button_mask as unsigned, UB fixes.
Summary: * pointer.button is DATA32 which is unsigned, so this changes the definition of pointer_button_down_mask accordingly. * Avoids UB in mask generation: lib/evas/canvas/evas_events.c:1348:37: runtime error: left shift of 1 by 31 places cannot be represented in type 'int' Subscribers: cedric, jpeg Differential Revision: https://phab.enlightenment.org/D4019 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
parent
2db02da4bd
commit
32fd16dfc0
|
@ -517,17 +517,18 @@ class Evas.Canvas (Eo.Base, Evas.Common_Interface, Efl.Animator,
|
|||
Example:
|
||||
@code
|
||||
extern Evas *evas;
|
||||
int button_mask, i;
|
||||
unsigned int button_mask;
|
||||
int i;
|
||||
|
||||
button_mask = evas_pointer_button_down_mask_get(evas);
|
||||
printf("Buttons currently pressed:\n");
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
if ((button_mask & (1 << i)) != 0) printf("Button %i\n", i + 1);
|
||||
if ((button_mask & (1u << i)) != 0) printf("Button %i\n", i + 1);
|
||||
}
|
||||
@endcode
|
||||
*/
|
||||
return: int @warn_unused; [[A bitmask of the currently depressed buttons on the canvas.]]
|
||||
return: uint @warn_unused; [[A bitmask of the currently depressed buttons on the canvas.]]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1159,7 +1159,7 @@ _canvas_event_feed_mouse_down_internal(Eo *eo_e, int b, Evas_Button_Flags flags,
|
|||
INF("ButtonEvent:down time=%u x=%d y=%d button=%d downs=%d", timestamp, e->pointer.x, e->pointer.y, b, e->pointer.downs);
|
||||
if ((b < 1) || (b > 32)) return;
|
||||
|
||||
e->pointer.button |= (1 << (b - 1));
|
||||
e->pointer.button |= (1u << (b - 1));
|
||||
e->pointer.downs++;
|
||||
|
||||
if (e->is_frozen) return;
|
||||
|
@ -1384,7 +1384,7 @@ _canvas_event_feed_mouse_up_internal(Eo *eo_e, int b, Evas_Button_Flags flags,
|
|||
if ((b < 1) || (b > 32)) return;
|
||||
if (e->pointer.downs <= 0) return;
|
||||
|
||||
e->pointer.button &= ~(1 << (b - 1));
|
||||
e->pointer.button &= ~(1u << (b - 1));
|
||||
e->pointer.downs--;
|
||||
|
||||
if (e->is_frozen) return;
|
||||
|
@ -1496,7 +1496,7 @@ _canvas_event_feed_mouse_cancel_internal(Eo *eo_e, unsigned int timestamp, const
|
|||
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
if ((e->pointer.button & (1 << i)))
|
||||
if ((e->pointer.button & (1u << i)))
|
||||
_canvas_event_feed_mouse_up_internal(eo_e, i + 1, 0, timestamp, data, parent_pe);
|
||||
}
|
||||
EINA_LIST_FOREACH_SAFE(e->touch_points, l, ll, point)
|
||||
|
|
|
@ -559,10 +559,10 @@ _evas_canvas_pointer_canvas_xy_get(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e, Ev
|
|||
if (y) *y = e->pointer.y;
|
||||
}
|
||||
|
||||
EOLIAN static int
|
||||
EOLIAN static unsigned int
|
||||
_evas_canvas_pointer_button_down_mask_get(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e)
|
||||
{
|
||||
return (int)e->pointer.button;
|
||||
return e->pointer.button;
|
||||
}
|
||||
|
||||
EOLIAN static Eina_Bool
|
||||
|
|
Loading…
Reference in New Issue