Mir

Use of anonymous struct in MirMotionEvent makes hard to use API

Bug #1322370 reported by Robert Ancell
6
This bug affects 1 person
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_coordinates[MIR_INPUT_EVENT_MAX_POINTER_COUNT];
} 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_coordinates[i].x, e->pointer_coordinates[i].y);

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++)
{
    MirPointerCoordinate *p = &e->pointer_coordinates[i];
    printf ("%f, %f\n", p->x, p->y);
}

This requires the structure to have a name.

Tags: clientapi

Related branches

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

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
    }

Changed in mir:
importance: Undecided → Low
status: New → Triaged
tags: added: clientapi
Revision history for this message
Robert Ancell (robert-ancell) wrote :

I'm in C :)

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
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.