Use of anonymous struct in MirMotionEvent makes hard to use API
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mir |
Fix Released
|
Low
|
Daniel van Vugt | ||
mir (Ubuntu) |
Fix Released
|
Low
|
Unassigned |
Bug Description
MirMotionEvent looks like this:
typedef struct
{
MirEventType type;
...
size_t pointer_count;
struct
{
int id;
...
} pointer_
} MirMotionEvent;
If you want to iterate over pointer_coordinates you need to code something like this:
MirEventMotion *e;
for (i = 0; i < e->pointer_count; i++)
printf ("%f, %f\n", e->pointer_
It is desirable to be able to get a pointer to each coordinate to make this easier to type, i.e.
MirEventMotion *e;
for (i = 0; i < e->pointer_count; i++)
{
MirPointerC
printf ("%f, %f\n", p->x, p->y);
}
This requires the structure to have a name.
Related branches
- Alexandros Frantzis (community): Approve
- Kevin DuBois (community): Approve
- Alan Griffiths: Approve
- PS Jenkins bot (community): Approve (continuous-integration)
-
Diff: 56 lines (+21/-18)1 file modifiedinclude/shared/mir_toolkit/event.h (+21/-18)
Changed in mir: | |
assignee: | nobody → Daniel van Vugt (vanvugt) |
milestone: | none → 0.5.0 |
status: | Triaged → Fix Released |
Changed in mir (Ubuntu): | |
importance: | Undecided → Low |
status: | New → Fix Released |
If you're in C++ you could do this (or something like it):
auto p0 = &e->pointer_ coordinates[ 0];
for (int i = 0; i < e->pointer_count; ++i)
{
auto &p = p0[i];
// use p
}