Mir

Merge lp:~vanvugt/mir/occluded-vanity into lp:mir

Proposed by Daniel van Vugt
Status: Merged
Approved by: Chris Halse Rogers
Approved revision: no longer in the source branch.
Merged at revision: 3794
Proposed branch: lp:~vanvugt/mir/occluded-vanity
Merge into: lp:mir
Diff against target: 65 lines (+27/-0)
1 file modified
src/utils/vanity.c (+27/-0)
To merge this branch: bzr merge lp:~vanvugt/mir/occluded-vanity
Reviewer Review Type Date Requested Status
Chris Halse Rogers Approve
Mir CI Bot continuous-integration Approve
Review via email: mp+309333@code.launchpad.net

Commit message

vanity: Handle VT switching and other occlusions

One problem discovered last week trying to run on a single-headed system
was that the act of VT-switching to see your results would immediately
affect the results. This tries to prevent that.

Description of the change

The workaround I landed last week was to just fix the quit keys and quit before VT-switching. But this is better.

To post a comment you must log in.
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3789
https://mir-jenkins.ubuntu.com/job/mir-ci/2053/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/2640
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/2703
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/2695
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/2695
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/2695
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2669
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2669/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2669
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2669/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2669
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2669/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/2669
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/2669/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2669
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2669/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/2669
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/2669/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/2053/rebuild

review: Approve (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

Seems reasonable.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/utils/vanity.c'
2--- src/utils/vanity.c 2016-10-21 07:53:23 +0000
3+++ src/utils/vanity.c 2016-10-26 10:38:49 +0000
4@@ -79,6 +79,7 @@
5 Buffer const* preview;
6 int expected_direction;
7 bool reset;
8+ bool occluded;
9 } State;
10
11 static Time now()
12@@ -133,6 +134,27 @@
13 return false;
14 }
15
16+static bool on_surface_event(MirSurfaceEvent const* sevent, State* state)
17+{
18+ MirSurfaceAttrib attrib = mir_surface_event_get_attribute(sevent);
19+ int value = mir_surface_event_get_attribute_value(sevent);
20+
21+ if (attrib == mir_surface_attrib_visibility)
22+ {
23+ if (value == mir_surface_visibility_exposed)
24+ {
25+ state->reset = true;
26+ state->occluded = false;
27+ }
28+ else
29+ {
30+ state->occluded = true;
31+ }
32+ }
33+
34+ return false; // Let eglapp handle the same event. We are passive.
35+}
36+
37 static void on_event(MirSurface* surface, MirEvent const* event, void* context)
38 {
39 bool handled = true;
40@@ -150,6 +172,9 @@
41 case mir_event_type_input:
42 handled = on_input_event(mir_event_get_input_event(event), state);
43 break;
44+ case mir_event_type_surface:
45+ handled = on_surface_event(mir_event_get_surface_event(event), state);
46+ break;
47 case mir_event_type_resize:
48 state->resized = true;
49 break;
50@@ -485,6 +510,7 @@
51 int const resolution = 5;
52 int see = resolution * interpret(cam, buf);
53 if ( (see != last_seen_value) &&
54+ !state->occluded && // Camera is likely seeing other things
55 (acquire_time > state->last_change_time) &&
56 ( (see > last_seen_value && state->expected_direction > 0) ||
57 (see < last_seen_value && state->expected_direction < 0)
58@@ -715,6 +741,7 @@
59 0,
60 NULL,
61 0,
62+ false,
63 false
64 };
65 MirSurface* surface = mir_eglapp_native_surface();

Subscribers

People subscribed via source and target branches