Mir

Merge lp://qastaging/~vanvugt/mir/resize-events into lp://qastaging/mir

Proposed by Daniel van Vugt
Status: Merged
Approved by: Alan Griffiths
Approved revision: no longer in the source branch.
Merged at revision: 1259
Proposed branch: lp://qastaging/~vanvugt/mir/resize-events
Merge into: lp://qastaging/mir
Diff against target: 275 lines (+131/-8)
7 files modified
examples/eglapp.c (+19/-4)
examples/fingerpaint.c (+12/-0)
include/shared/mir_toolkit/event.h (+12/-1)
src/server/frontend/event_sender.cpp (+1/-1)
src/server/scene/surface_impl.cpp (+9/-0)
tests/unit-tests/frontend/test_event_sender.cpp (+36/-0)
tests/unit-tests/scene/test_surface_impl.cpp (+42/-2)
To merge this branch: bzr merge lp://qastaging/~vanvugt/mir/resize-events
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alan Griffiths Approve
Alexandros Frantzis (community) Approve
Review via email: mp+196679@code.qastaging.launchpad.net

Commit message

Add mir_event_type_resize / MirResizeEvent, allowing clients to react
immediately to surface resizing. (LP: #1227744)

Description of the change

You will see FIXME comments in the example code. I spent several days prototyping solutions to bug 1194384 to avoid the FIXMEs, before realizing it's a much bigger can of worms and beyond this scope of this work. Most importantly, the design of resize events is not affected by the presence of a fix for bug 1194384. So any sufficiently powerful toolkit (one with its own event queue and/or locking primitives) will be able to utilize MirResizeEvent immediately, without needing a fix for bug 1194384.

I admit, this was not my first choice of design. I started with "size" being a MirSurfaceAttrib with value:
    int value = (width << 16) | height;
However as nice as that was reusing the existing logic and maintaining "size" as an "attribute", it was a bit kludgy and I feared reviewers would disapprove of the shifting. Not to mention the 4-gigapixel limitation ;)

I also prototyped a solution where size was a multi-value MirSurfaceAttrib. However modifying all the code to support multi-value MirSurfaceAttrib's resulted in a mess that I did not like at all.

And then there were several other possible designs I disliked so much I did not even prototype. So this is a compromise, which I think more people will approve of.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

157 +TEST(TestEventSender, sends_all_but_input_events)

I don't think this test does what you think. E.g. you can comment out the following lines and it still passes:

168 + EXPECT_CALL(*msg_sender, send(_))
169 + .Times(0);

It would be better written as a series of individual (or parameterized) tests

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

Alan,

I don't think that's a valid argument. You can comment out asserts/expectations from any tests and they will of course pass.

The point is to verify send is never called at all for those event types. And that it is called for other event types. I just re-tested changing "Times(0)" to "Times(1)" and the test then fails. So the test is correct.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> Alan,
>
> I don't think that's a valid argument. You can comment out
> asserts/expectations from any tests and they will of course pass.
>
> The point is to verify send is never called at all for those event types. And
> that it is called for other event types. I just re-tested changing "Times(0)"
> to "Times(1)" and the test then fails. So the test is correct.

Sorry, I wasn't clear.

The canonical way to write a test is /1/ setup, /2/ expectations, /3/ execution and /4/ validation.

You've mixed expectations and execution - but that doesn't change the way the fact that validation only occurs at the end. Essentially you've written:

TEST(TestEventSender, sends_all_but_input_events)
{
    using namespace testing;

    // Setup
    auto msg_sender = std::make_shared<MockMsgSender>();
    mfd::EventSender event_sender(msg_sender);
    MirEvent event;
    memset(&event, 0, sizeof event);

    // Expectations
    InSequence seq;
    EXPECT_CALL(*msg_sender, send(_))
        .Times(2);

    // Execution
    event.type = mir_event_type_surface;
    event_sender.handle_event(event);
    event.type = mir_event_type_resize;
    event_sender.handle_event(event);
    event.type = mir_event_type_key;
    event_sender.handle_event(event);
    event.type = mir_event_type_motion;
    event_sender.handle_event(event);
}

Which doesn't give any information on which events generate which calls - just that there are two of them.

Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Looks good.

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

ack

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches