Mir

Merge lp:~alan-griffiths/mir/placement-notification into lp:mir

Proposed by Alan Griffiths on 2016-09-13
Status: Merged
Approved by: Alan Griffiths on 2016-09-15
Approved revision: 3707
Merged at revision: 3702
Proposed branch: lp:~alan-griffiths/mir/placement-notification
Merge into: lp:mir
Diff against target: 785 lines (+339/-8)
31 files modified
include/client/mir/event_printer.h (+2/-1)
include/client/mir/events/event_builders.h (+4/-0)
include/client/mir_toolkit/events/event.h (+13/-1)
include/client/mir_toolkit/events/surface_placement.h (+47/-0)
include/server/mir/scene/null_surface_observer.h (+1/-0)
include/server/mir/scene/surface.h (+2/-0)
include/server/mir/scene/surface_observer.h (+1/-0)
include/test/mir/test/doubles/stub_surface.h (+1/-0)
src/client/event.cpp (+12/-0)
src/client/event_printer.cpp (+14/-1)
src/client/events/event_builders.cpp (+18/-3)
src/client/rpc/mir_protobuf_rpc_channel.cpp (+7/-1)
src/client/symbols.map (+3/-1)
src/common/events/CMakeLists.txt (+1/-0)
src/common/events/event.cpp (+7/-0)
src/common/events/surface_placement_event.cpp (+50/-0)
src/common/symbols.map (+5/-0)
src/include/common/mir/events/event.h (+2/-0)
src/include/common/mir/events/surface_placement_event.h (+40/-0)
src/include/server/mir/scene/surface_event_source.h (+1/-0)
src/include/server/mir/scene/surface_observers.h (+1/-0)
src/server/scene/basic_surface.cpp (+12/-0)
src/server/scene/basic_surface.h (+1/-0)
src/server/scene/legacy_surface_change_notification.cpp (+4/-0)
src/server/scene/legacy_surface_change_notification.h (+1/-0)
src/server/scene/null_surface_observer.cpp (+1/-0)
src/server/scene/surface_event_source.cpp (+5/-0)
src/server/symbols.map (+2/-0)
tests/acceptance-tests/test_custom_window_management.cpp (+77/-0)
tests/include/mir/test/doubles/stub_scene_surface.h (+1/-0)
tests/mir_test_framework/stub_surface.cpp (+3/-0)
To merge this branch: bzr merge lp:~alan-griffiths/mir/placement-notification
Reviewer Review Type Date Requested Status
Mir CI Bot continuous-integration Approve on 2016-09-15
Kevin DuBois (community) Approve on 2016-09-15
Gerry Boland Abstain on 2016-09-15
Chris Halse Rogers 2016-09-13 Approve on 2016-09-15
Review via email: mp+305599@code.launchpad.net

Commit Message

Plumb relative placement notifications through from a surface to the client callback

Description of the Change

Plumb relative placement notifications through from a surface to the client callback.

This doesn't contain the window management logic to generate the notification, but provided the infrastructure needed to deliver it to the client.

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

PASSED: Continuous integration, rev:3704
https://mir-jenkins.ubuntu.com/job/mir-ci/1706/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/2134
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/2196
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/2187
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/2187
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/2187
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2162
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2162/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/2162
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2162/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2162
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2162/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/2162
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2162/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/2162
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/2162/artifact/output/*zip*/output.zip

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

review: Approve (continuous-integration)
Alan Griffiths (alan-griffiths) wrote :

There's an implementation of the window-management side of this in lp:~alan-griffiths/miral/placement-notification/

Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3705
https://mir-jenkins.ubuntu.com/job/mir-ci/1713/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/2143
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/2205
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/2196
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/2196
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/2196
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2171
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2171/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/2171
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2171/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2171
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2171/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/2171
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2171/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/2171
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/2171/artifact/output/*zip*/output.zip

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

review: Approve (continuous-integration)
Chris Halse Rogers (raof) wrote :

Is there a reason we're sending a rectangle rather than just the top-left corner coordinates? The client already knows the size of the surface.

review: Needs Information
Kevin DuBois (kdub) wrote :

The client knows the size via the 'resize' callback... I think it would be clearer if it was told its 'placement' rather than 'size' (so, I'd rather deprecate using 'resize' in favor of placement, which contains x/y and size)

Chris Halse Rogers (raof) wrote :

Well, it knows its size because that's the size of the MirSurface that
got created.

And ‘placement’ is strictly for parent-relatively-positioned
surfaces - we'd still need a resize event (or most placement events
would contain a meaningless (0,0) for top-left).

Kevin DuBois (kdub) wrote :

needs info:

I got a bit confused about what the placement was relevant to, I assume its relative to the current position, and this event is to confirm that the placement request occurred?

+ surface_placement_event.cpp ${PROJECT_SOURCE_DIR}/src/include/common/mir/events/surface_placement_event.h

why not include_directories?

review: Needs Information
Alan Griffiths (alan-griffiths) wrote :

> needs info:
>
> I got a bit confused about what the placement was relevant to, I assume its
> relative to the current position, and this event is to confirm that the
> placement request occurred?

placement requests are relative to the parent, and so is the result.

> + surface_placement_event.cpp
> ${PROJECT_SOURCE_DIR}/src/include/common/mir/events/surface_placement_event.h
>
> why not include_directories?

I don't understand the question, what has include_directories got to do with adding source files?

Alan Griffiths (alan-griffiths) wrote :

> Is there a reason we're sending a rectangle rather than just the top-left
> corner coordinates? The client already knows the size of the surface.

placement may or may not resize the surface depending on the request parameters and the parent position on the output. I think it simpler for the client to await exactly one event for the placement than to await what could be either one or two.

William Hua (attente) wrote :

> > Is there a reason we're sending a rectangle rather than just the top-left
> > corner coordinates? The client already knows the size of the surface.
>
> placement may or may not resize the surface depending on the request
> parameters and the parent position on the output. I think it simpler for the
> client to await exactly one event for the placement than to await what could
> be either one or two.

+1 for this

Can we also document what the rectangle is relative to? i.e. is it relative to the client-requested position before server-side flipping or after server-side flipping.

We might actually need two rectangles... The widgets in GTK expect both the final rectangle position as well as the intermediate position (after server-side flipping, but before server-side sliding within the display boundaries). I'm a bit uncertain as to whether or not a single rectangle is enough information to infer what GTK needs.

Alan Griffiths (alan-griffiths) wrote :

> Can we also document what the rectangle is relative to? i.e. is it relative to
> the client-requested position before server-side flipping or after server-side
> flipping.

Documented that it is relative to the parent surface.

> We might actually need two rectangles... The widgets in GTK expect both the
> final rectangle position as well as the intermediate position (after server-
> side flipping, but before server-side sliding within the display boundaries).
> I'm a bit uncertain as to whether or not a single rectangle is enough
> information to infer what GTK needs.

I'm not entirely clear what the objective of this is. As implemeted in Miral the server tries a series of transformations and selects the first satisfactory result. Some of these transformations flip, some flip twice, some resize, some slide and some combine the above. That

To provide "the intermediate" I'd need to know the rules for calculating it in each scenario. (And these will get more complex with the incorporation of the "anchored in parent" constraints.)

Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3706
https://mir-jenkins.ubuntu.com/job/mir-ci/1717/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/2147
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/2210
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/2201
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/2201
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/2201
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2175
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2175/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/2175
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2175/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2175
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2175/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/2175
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2175/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/2175
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/2175/artifact/output/*zip*/output.zip

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

review: Approve (continuous-integration)
Gerry Boland (gerboland) wrote :

Basic API looks suitable for Qt. But I am curious if a user repositions the surface, does the client get new SurfacePlacementEvents? Or is this just after the WM has initially sized & placed the child surface.

review: Needs Information
Alan Griffiths (alan-griffiths) wrote :

> Basic API looks suitable for Qt. But I am curious if a user repositions the
> surface, does the client get new SurfacePlacementEvents? Or is this just after
> the WM has initially sized & placed the child surface.

At present it is only providing a response to placement requests (either initial creation or clients applying a placement to an existing surface).

I don't expect users to be able to reposition e.g. menus (lp:1616818 notwithstanding). We would need to identify scenarios where it is appropriate to send notification of user actions.

Chris Halse Rogers (raof) wrote :

If toolkit authors want the extra info, sure.

+// auto const placement_event = mir::events::make_event(surface_id, placement_);

Old detritus left in?

Otherwise seems fine.

review: Approve
Alan Griffiths (alan-griffiths) wrote :

> +// auto const placement_event = mir::events::make_event(surface_id,
> placement_);
>
> Old detritus left in?

Fixed

Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3707
https://mir-jenkins.ubuntu.com/job/mir-ci/1730/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/2161
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/2224
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/2215
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/2215
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/2215
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2189
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2189/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/2189
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2189/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2189
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2189/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/2189
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2189/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/2189
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/2189/artifact/output/*zip*/output.zip

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

review: Approve (continuous-integration)
Gerry Boland (gerboland) :
review: Abstain
Kevin DuBois (kdub) wrote :

> > needs info:
> >
> > I got a bit confused about what the placement was relevant to, I assume its
> > relative to the current position, and this event is to confirm that the
> > placement request occurred?
>
> placement requests are relative to the parent, and so is the result.
>

Ack, and added to comments, thanks.

> > + surface_placement_event.cpp
> >
> ${PROJECT_SOURCE_DIR}/src/include/common/mir/events/surface_placement_event.h
> >
> > why not include_directories?
>
> I don't understand the question, what has include_directories got to do with
> adding source files?

Apparently adding the header thusly helps with some IDE's.

review: Approve
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Autolanding.
More details in the following jenkins job:
https://mir-jenkins.ubuntu.com/job/mir-autolanding/585/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/2164/console
    None: https://mir-jenkins.ubuntu.com/job/generic-land-mp/624/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/2227
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/2218
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/2218
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/2218
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2192
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2192/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/2192
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2192/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2192
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2192/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/2192
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2192/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/2192/console

review: Needs Fixing (continuous-integration)
Alan Griffiths (alan-griffiths) wrote :

15:09:21 11: [ FAILED ] NestedServer.animated_cursor_image_changes_are_forwarded_to_host
15:09:21 11: [ FAILED ] NestedServer.can_hide_the_host_cursor

lp:1523621

Mir CI Bot (mir-ci-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/client/mir/event_printer.h'
2--- include/client/mir/event_printer.h 2016-06-08 13:48:21 +0000
3+++ include/client/mir/event_printer.h 2016-09-15 08:21:15 +0000
4@@ -1,5 +1,5 @@
5 /*
6- * Copyright © 2015 Canonical Ltd.
7+ * Copyright © 2015-2016 Canonical Ltd.
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License version 3 as
11@@ -48,6 +48,7 @@
12 std::ostream& operator<<(std::ostream& out, MirKeymapEvent const& event);
13 std::ostream& operator<<(std::ostream& out, MirSurfaceEvent const& event);
14 std::ostream& operator<<(std::ostream& out, MirInputDeviceStateEvent const& event);
15+std::ostream& operator<<(std::ostream& out, MirSurfacePlacementEvent const& event);
16 std::ostream& operator<<(std::ostream& out, MirEvent const& event);
17
18 }
19
20=== modified file 'include/client/mir/events/event_builders.h'
21--- include/client/mir/events/event_builders.h 2016-05-26 20:59:38 +0000
22+++ include/client/mir/events/event_builders.h 2016-09-15 08:21:15 +0000
23@@ -23,6 +23,7 @@
24
25 #include "mir/geometry/size.h"
26 #include "mir/geometry/point.h"
27+#include "mir/geometry/rectangle.h"
28 #include "mir/frontend/surface_id.h"
29
30 #include <memory>
31@@ -57,6 +58,9 @@
32 MirFormFactor form_factor,
33 uint32_t id);
34
35+/// Surface placement event
36+EventUPtr make_event(frontend::SurfaceId const& surface_id, geometry::Rectangle placement);
37+
38 // Key event
39 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
40 std::vector<uint8_t> const& cookie, MirKeyboardAction action, xkb_keysym_t key_code,
41
42=== modified file 'include/client/mir_toolkit/events/event.h'
43--- include/client/mir_toolkit/events/event.h 2016-09-02 13:27:43 +0000
44+++ include/client/mir_toolkit/events/event.h 2016-09-15 08:21:15 +0000
45@@ -1,5 +1,5 @@
46 /*
47- * Copyright © 2014 Canonical Ltd.
48+ * Copyright © 2014-2016 Canonical Ltd.
49 *
50 * This program is free software: you can redistribute it and/or modify it
51 * under the terms of the GNU Lesser General Public License version 3,
52@@ -47,6 +47,7 @@
53 mir_event_type_input_configuration,
54 mir_event_type_surface_output,
55 mir_event_type_input_device_state,
56+ mir_event_type_surface_placement,
57 } MirEventType;
58
59 typedef struct MirSurfaceEvent MirSurfaceEvent;
60@@ -59,6 +60,7 @@
61 typedef struct MirInputConfigurationEvent MirInputConfigurationEvent;
62 typedef struct MirSurfaceOutputEvent MirSurfaceOutputEvent;
63 typedef struct MirInputDeviceStateEvent MirInputDeviceStateEvent;
64+typedef struct MirSurfacePlacementEvent MirSurfacePlacementEvent;
65
66 typedef struct MirCookie MirCookie;
67
68@@ -211,6 +213,16 @@
69 */
70 MirInputDeviceStateEvent const* mir_event_get_input_device_state_event(MirEvent const* event);
71
72+/**
73+ * Retrieve the MirSurfacePlacementEvent associated with a MirEvent of
74+ * type mir_event_type_surface_placement. The event signifies that the
75+ * the server has fulfilled a request for relative surface placement.
76+ *
77+ * \param [in] event The event
78+ * \return The associated MirSurfacePlacementEvent
79+ */
80+MirSurfacePlacementEvent const* mir_event_get_surface_placement_event(MirEvent const* event);
81+
82 /*
83 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
84 * _________________________
85
86=== added file 'include/client/mir_toolkit/events/surface_placement.h'
87--- include/client/mir_toolkit/events/surface_placement.h 1970-01-01 00:00:00 +0000
88+++ include/client/mir_toolkit/events/surface_placement.h 2016-09-15 08:21:15 +0000
89@@ -0,0 +1,47 @@
90+/*
91+ * Copyright © 2016 Canonical Ltd.
92+ *
93+ * This program is free software: you can redistribute it and/or modify it
94+ * under the terms of the GNU Lesser General Public License version 3,
95+ * as published by the Free Software Foundation.
96+ *
97+ * This program is distributed in the hope that it will be useful,
98+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
99+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
100+ * GNU Lesser General Public License for more details.
101+ *
102+ * You should have received a copy of the GNU Lesser General Public License
103+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
104+ *
105+ * Authored by: Alan Griffiths <alan@octopull.co.uk>
106+ */
107+
108+#ifndef MIR_TOOLKIT_SURFACE_PLACEMENT_H_
109+#define MIR_TOOLKIT_SURFACE_PLACEMENT_H_
110+
111+#include <mir_toolkit/client_types.h>
112+
113+#ifdef __cplusplus
114+/**
115+ * \addtogroup mir_toolkit
116+ * @{
117+ */
118+extern "C" {
119+#endif
120+
121+typedef struct MirSurfacePlacementEvent MirSurfacePlacementEvent;
122+
123+/**
124+ * Retrieve the relative position from a placement notification
125+ *
126+ * \param [in] event The placement event
127+ * \return The position relative to the parent surface
128+ */
129+MirRectangle mir_surface_placement_get_relative_position(MirSurfacePlacementEvent const* event);
130+
131+#ifdef __cplusplus
132+}
133+/**@}*/
134+#endif
135+
136+#endif //MIR_TOOLKIT_SURFACE_PLACEMENT_H_
137
138=== modified file 'include/server/mir/scene/null_surface_observer.h'
139--- include/server/mir/scene/null_surface_observer.h 2016-08-02 19:44:59 +0000
140+++ include/server/mir/scene/null_surface_observer.h 2016-09-15 08:21:15 +0000
141@@ -45,6 +45,7 @@
142 void keymap_changed(MirInputDeviceId id, std::string const& model, std::string const& layout, std::string const& variant, std::string const& options) override;
143 void renamed(char const* name) override;
144 void cursor_image_removed() override;
145+ void placed_relative(geometry::Rectangle const& placement) override;
146
147 protected:
148 NullSurfaceObserver(NullSurfaceObserver const&) = delete;
149
150=== modified file 'include/server/mir/scene/surface.h'
151--- include/server/mir/scene/surface.h 2016-08-23 03:56:40 +0000
152+++ include/server/mir/scene/surface.h 2016-09-15 08:21:15 +0000
153@@ -118,6 +118,8 @@
154
155 virtual void set_confine_pointer_state(MirPointerConfinementState state) = 0;
156 virtual MirPointerConfinementState confine_pointer_state() const = 0;
157+
158+ virtual void placed_relative(geometry::Rectangle const& placement) = 0;
159 };
160 }
161 }
162
163=== modified file 'include/server/mir/scene/surface_observer.h'
164--- include/server/mir/scene/surface_observer.h 2016-08-02 19:44:59 +0000
165+++ include/server/mir/scene/surface_observer.h 2016-09-15 08:21:15 +0000
166@@ -60,6 +60,7 @@
167 std::string const& variant, std::string const& options) = 0;
168 virtual void renamed(char const* name) = 0;
169 virtual void cursor_image_removed() = 0;
170+ virtual void placed_relative(geometry::Rectangle const& placement) = 0;
171
172 protected:
173 SurfaceObserver() = default;
174
175=== modified file 'include/test/mir/test/doubles/stub_surface.h'
176--- include/test/mir/test/doubles/stub_surface.h 2016-06-27 20:44:49 +0000
177+++ include/test/mir/test/doubles/stub_surface.h 2016-09-15 08:21:15 +0000
178@@ -72,6 +72,7 @@
179 void rename(std::string const& title) override;
180 void set_confine_pointer_state(MirPointerConfinementState state) override;
181 MirPointerConfinementState confine_pointer_state() const override;
182+ void placed_relative(geometry::Rectangle const& placement) override;
183 };
184 }
185 }
186
187=== modified file 'src/client/event.cpp'
188--- src/client/event.cpp 2016-06-10 16:12:34 +0000
189+++ src/client/event.cpp 2016-09-15 08:21:15 +0000
190@@ -23,12 +23,14 @@
191
192 #include "mir_toolkit/events/event.h"
193 #include "mir/events/event_private.h"
194+#include "mir/events/surface_placement_event.h"
195
196 #include "mir_toolkit/events/surface_event.h"
197 #include "mir_toolkit/events/resize_event.h"
198 #include "mir_toolkit/events/prompt_session_event.h"
199 #include "mir_toolkit/events/orientation_event.h"
200 #include "mir_toolkit/events/input_device_state_event.h"
201+#include "mir_toolkit/events/surface_placement.h"
202
203 #include <cstdlib>
204 #include <cstring>
205@@ -340,6 +342,16 @@
206 return ev->device_pointer_buttons(index);
207 }
208
209+MirSurfacePlacementEvent const* mir_event_get_surface_placement_event(MirEvent const* event)
210+{
211+ return event->to_surface_placement();
212+}
213+
214+MirRectangle mir_surface_placement_get_relative_position(MirSurfacePlacementEvent const* event)
215+{
216+ return event->placement();
217+}
218+
219 // TODO: Until we opaquify the MirEvent structure and add
220 // a ref count ref is implemented as copy.
221 MirEvent const* mir_event_ref(MirEvent const* ev)
222
223=== modified file 'src/client/event_printer.cpp'
224--- src/client/event_printer.cpp 2016-06-08 13:48:21 +0000
225+++ src/client/event_printer.cpp 2016-09-15 08:21:15 +0000
226@@ -1,5 +1,5 @@
227 /*
228- * Copyright © 2015 Canonical Ltd.
229+ * Copyright © 2015-2016 Canonical Ltd.
230 *
231 * This program is free software: you can redistribute it and/or modify
232 * it under the terms of the GNU Lesser General Public License version 3 as
233@@ -17,6 +17,8 @@
234 */
235
236 #include "mir/event_printer.h"
237+
238+#include "mir/events/surface_placement_event.h"
239 #include "mir/logging/input_timestamp.h"
240
241 std::ostream& mir::operator<<(std::ostream& out, MirInputEventModifier modifier)
242@@ -321,6 +323,16 @@
243 return out << ')';
244 }
245
246+std::ostream& mir::operator<<(std::ostream& out, MirSurfacePlacementEvent const& event)
247+{
248+ auto const& placement = event.placement();
249+ return out << "surface_placement_event({"
250+ << placement.left << ", "
251+ << placement.top << ", "
252+ << placement.width << ", "
253+ << placement.height << "})";
254+}
255+
256 std::ostream& mir::operator<<(std::ostream& out, MirInputDeviceStateEvent const& event)
257 {
258 out << "input_device_state(ts="
259@@ -367,6 +379,7 @@
260 PRINT_EVENT(input);
261 PRINT_EVENT(input_device_state);
262 PRINT_EVENT(keymap);
263+ PRINT_EVENT(surface_placement);
264 case mir_event_type_prompt_session_state_change:
265 return out << *mir_event_get_prompt_session_event(&event);
266 default:
267
268=== modified file 'src/client/events/event_builders.cpp'
269--- src/client/events/event_builders.cpp 2016-06-10 16:12:34 +0000
270+++ src/client/events/event_builders.cpp 2016-09-15 08:21:15 +0000
271@@ -1,5 +1,5 @@
272 /*
273- * Copyright © 2015 Canonical Ltd.
274+ * Copyright © 2015-2016 Canonical Ltd.
275 *
276 * This program is free software: you can redistribute it and/or modify it
277 * under the terms of the GNU Lesser General Public License version 3,
278@@ -16,12 +16,13 @@
279 * Author: Robert Carr <robert.carr@canonical.com>
280 */
281
282+#include "mir/events/event_builders.h"
283+
284 #define MIR_LOG_COMPONENT "event-builders"
285-
286 #include "mir/log.h"
287
288-#include "mir/events/event_builders.h"
289 #include "mir/events/event_private.h"
290+#include "mir/events/surface_placement_event.h"
291 #include "mir/cookie/blob.h"
292 #include "mir/input/xkb_mapper.h"
293 #include "mir/input/keymap.h"
294@@ -140,6 +141,20 @@
295 return make_uptr_event(e);
296 }
297
298+mir::EventUPtr mev::make_event(frontend::SurfaceId const& surface_id, geometry::Rectangle placement)
299+{
300+ auto e = new_event<MirSurfacePlacementEvent>();
301+
302+ e->set_id(surface_id.as_value());
303+ e->set_placement({
304+ placement.left().as_int(),
305+ placement.top().as_int(),
306+ placement.size.width.as_uint32_t(),
307+ placement.size.height.as_uint32_t()});
308+
309+ return make_uptr_event(e);
310+}
311+
312 namespace
313 {
314 // Never exposed in old event, so lets avoid leaking it in to a header now.
315
316=== modified file 'src/client/rpc/mir_protobuf_rpc_channel.cpp'
317--- src/client/rpc/mir_protobuf_rpc_channel.cpp 2016-08-03 06:48:47 +0000
318+++ src/client/rpc/mir_protobuf_rpc_channel.cpp 2016-09-15 08:21:15 +0000
319@@ -1,5 +1,5 @@
320 /*
321- * Copyright © 2012 Canonical Ltd.
322+ * Copyright © 2012-2016 Canonical Ltd.
323 *
324 * This program is free software: you can redistribute it and/or modify it
325 * under the terms of the GNU Lesser General Public License version 3,
326@@ -34,6 +34,7 @@
327 #include "mir/events/event_builders.h"
328 #include "mir/events/event_private.h"
329 #include "mir/events/serialization.h"
330+#include "mir/events/surface_placement_event.h"
331
332 #include "mir_protobuf.pb.h" // For Buffer frig
333 #include "mir_protobuf_wire.pb.h"
334@@ -398,6 +399,11 @@
335 if (auto map = surface_map.lock())
336 map->with_surface_do(mf::SurfaceId(e->to_surface_output()->surface_id()), send_e);
337 break;
338+ case mir_event_type_surface_placement:
339+ if (auto map = surface_map.lock())
340+ map->with_surface_do(mf::SurfaceId(e->to_surface_placement()->id()), send_e);
341+ break;
342+
343 default:
344 event_sink->handle_event(*e);
345 }
346
347=== modified file 'src/client/symbols.map'
348--- src/client/symbols.map 2016-09-09 09:55:33 +0000
349+++ src/client/symbols.map 2016-09-15 08:21:15 +0000
350@@ -420,10 +420,12 @@
351 MIR_CLIENT_0.25 { # New functions in Mir 0.25
352 global:
353 mir_connection_create_spec_for_tip;
354- mir_output_get_current_mode_index;
355+ mir_event_get_surface_placement_event;
356+ mir_output_get_current_mode_index;
357 mir_output_get_preferred_mode_index;
358 mir_output_get_subpixel_arrangement;
359 mir_connection_cancel_base_display_configuration_preview;
360+ mir_surface_placement_get_relative_position;
361 mir_display_output_type_name;
362 mir_output_type_name;
363 } MIR_CLIENT_0.24;
364
365=== modified file 'src/common/events/CMakeLists.txt'
366--- src/common/events/CMakeLists.txt 2016-06-02 05:33:50 +0000
367+++ src/common/events/CMakeLists.txt 2016-09-15 08:21:15 +0000
368@@ -28,6 +28,7 @@
369 orientation_event.cpp
370 resize_event.cpp
371 surface_output_event.cpp
372+ surface_placement_event.cpp ${PROJECT_SOURCE_DIR}/src/include/common/mir/events/surface_placement_event.h
373 )
374
375 add_library(
376
377=== modified file 'src/common/events/event.cpp'
378--- src/common/events/event.cpp 2016-06-10 16:12:34 +0000
379+++ src/common/events/event.cpp 2016-09-15 08:21:15 +0000
380@@ -32,6 +32,7 @@
381 #include "mir/events/surface_event.h"
382 #include "mir/events/surface_output_event.h"
383 #include "mir/events/input_device_state_event.h"
384+#include "mir/events/surface_placement_event.h"
385
386 MirEvent::MirEvent(MirEventType type) :
387 type_(type)
388@@ -64,6 +65,8 @@
389 return to_keymap()->clone();
390 case mir_event_type_input_device_state:
391 return to_input_device_state()->clone();
392+ case mir_event_type_surface_placement:
393+ return mir::event::deep_copy<MirSurfacePlacementEvent>(this);
394 case mir_event_type_input:
395 break;
396 }
397@@ -105,6 +108,8 @@
398 return MirKeymapEvent::deserialize(bytes);
399 case mir_event_type_input_device_state:
400 return MirInputDeviceStateEvent::deserialize(bytes);
401+ case mir_event_type_surface_placement:
402+ return mir::event::deserialize_from<MirSurfacePlacementEvent>(bytes);
403 case mir_event_type_input:
404 break;
405 }
406@@ -138,6 +143,8 @@
407 return MirKeymapEvent::serialize(event);
408 case mir_event_type_input_device_state:
409 return MirInputDeviceStateEvent::serialize(event);
410+ case mir_event_type_surface_placement:
411+ return mir::event::serialize_from<MirSurfacePlacementEvent>(event);
412 case mir_event_type_input:
413 break;
414 }
415
416=== added file 'src/common/events/surface_placement_event.cpp'
417--- src/common/events/surface_placement_event.cpp 1970-01-01 00:00:00 +0000
418+++ src/common/events/surface_placement_event.cpp 2016-09-15 08:21:15 +0000
419@@ -0,0 +1,50 @@
420+/*
421+ * Copyright © 2016 Canonical Ltd.
422+ *
423+ * This program is free software: you can redistribute it and/or modify it
424+ * under the terms of the GNU Lesser General Public License version 3,
425+ * as published by the Free Software Foundation.
426+ *
427+ * This program is distributed in the hope that it will be useful,
428+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
429+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
430+ * GNU Lesser General Public License for more details.
431+ *
432+ * You should have received a copy of the GNU Lesser General Public License
433+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
434+ *
435+ * Authored by: Alan Griffiths <alan@octopull.co.uk>
436+ */
437+
438+#include "mir/events/surface_placement_event.h"
439+
440+MirSurfacePlacementEvent::MirSurfacePlacementEvent() :
441+ MirEvent(mir_event_type_surface_placement)
442+{
443+}
444+
445+int MirSurfacePlacementEvent::id() const
446+{
447+ return id_;
448+}
449+
450+void MirSurfacePlacementEvent::set_id(int const id)
451+{
452+ id_ = id;
453+}
454+
455+MirRectangle MirSurfacePlacementEvent::placement() const
456+{
457+ return placement_;
458+}
459+
460+void MirSurfacePlacementEvent::set_placement(MirRectangle const& placement)
461+{
462+ placement_ = placement;
463+}
464+
465+MirSurfacePlacementEvent const* MirEvent::to_surface_placement() const
466+{
467+ return static_cast<MirSurfacePlacementEvent const*>(this);
468+}
469+
470
471=== modified file 'src/common/symbols.map'
472--- src/common/symbols.map 2016-09-09 09:55:33 +0000
473+++ src/common/symbols.map 2016-09-15 08:21:15 +0000
474@@ -390,6 +390,11 @@
475 MIR_COMMON_0.25 {
476 global:
477 extern "C++" {
478+ MirSurfacePlacementEvent::MirSurfacePlacementEvent*;
479+ MirSurfacePlacementEvent::id*;
480+ MirSurfacePlacementEvent::set_id*;
481+ MirSurfacePlacementEvent::placement*;
482+ MirSurfacePlacementEvent::set_placement*;
483 mir::output_type_name*;
484 };
485 } MIR_COMMON_0.24;
486
487=== modified file 'src/include/common/mir/events/event.h'
488--- src/include/common/mir/events/event.h 2016-05-26 02:12:27 +0000
489+++ src/include/common/mir/events/event.h 2016-09-15 08:21:15 +0000
490@@ -61,6 +61,8 @@
491 MirInputDeviceStateEvent* to_input_device_state();
492 MirInputDeviceStateEvent const* to_input_device_state() const;
493
494+ MirSurfacePlacementEvent const* to_surface_placement() const;
495+
496 MirEvent* clone() const;
497
498 static mir::EventUPtr deserialize(std::string const& bytes);
499
500=== added file 'src/include/common/mir/events/surface_placement_event.h'
501--- src/include/common/mir/events/surface_placement_event.h 1970-01-01 00:00:00 +0000
502+++ src/include/common/mir/events/surface_placement_event.h 2016-09-15 08:21:15 +0000
503@@ -0,0 +1,40 @@
504+/*
505+ * Copyright © 2016 Canonical Ltd.
506+ *
507+ * This program is free software: you can redistribute it and/or modify it
508+ * under the terms of the GNU Lesser General Public License version 3,
509+ * as published by the Free Software Foundation.
510+ *
511+ * This program is distributed in the hope that it will be useful,
512+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
513+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
514+ * GNU Lesser General Public License for more details.
515+ *
516+ * You should have received a copy of the GNU Lesser General Public License
517+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
518+ *
519+ * Authored by: Alan Griffiths <alan@octopull.co.uk>
520+ */
521+
522+#ifndef MIR_SURFACE_PLACEMENT_EVENT_H
523+#define MIR_SURFACE_PLACEMENT_EVENT_H
524+
525+#include "mir/events/event.h"
526+#include "mir_toolkit/client_types.h"
527+
528+struct MirSurfacePlacementEvent : MirEvent
529+{
530+ MirSurfacePlacementEvent();
531+
532+ int id() const;
533+ void set_id(int id);
534+
535+ MirRectangle placement() const;
536+ void set_placement(MirRectangle const& placement);
537+
538+private:
539+ int id_{0};
540+ MirRectangle placement_;
541+};
542+
543+#endif //MIR_SURFACE_PLACEMENT_EVENT_H
544
545=== modified file 'src/include/server/mir/scene/surface_event_source.h'
546--- src/include/server/mir/scene/surface_event_source.h 2016-01-29 08:18:22 +0000
547+++ src/include/server/mir/scene/surface_event_source.h 2016-09-15 08:21:15 +0000
548@@ -49,6 +49,7 @@
549 void client_surface_close_requested() override;
550 void keymap_changed(MirInputDeviceId id, std::string const& model, std::string const& layout,
551 std::string const& variant, std::string const& options) override;
552+ void placed_relative(geometry::Rectangle const& placement) override;
553
554 private:
555 frontend::SurfaceId const id;
556
557=== modified file 'src/include/server/mir/scene/surface_observers.h'
558--- src/include/server/mir/scene/surface_observers.h 2016-08-02 19:44:59 +0000
559+++ src/include/server/mir/scene/surface_observers.h 2016-09-15 08:21:15 +0000
560@@ -49,6 +49,7 @@
561 std::string const& variant, std::string const& options) override;
562 void renamed(char const*) override;
563 void cursor_image_removed() override;
564+ void placed_relative(geometry::Rectangle const& placement) override;
565 };
566
567 }
568
569=== modified file 'src/server/scene/basic_surface.cpp'
570--- src/server/scene/basic_surface.cpp 2016-08-24 02:09:08 +0000
571+++ src/server/scene/basic_surface.cpp 2016-09-15 08:21:15 +0000
572@@ -134,6 +134,13 @@
573 { observer->cursor_image_removed(); });
574 }
575
576+void ms::SurfaceObservers::placed_relative(geometry::Rectangle const& placement)
577+{
578+ for_each([&](std::shared_ptr<SurfaceObserver> const& observer)
579+ { observer->placed_relative(placement); });
580+}
581+
582+
583 struct ms::CursorStreamImageAdapter
584 {
585 CursorStreamImageAdapter(ms::BasicSurface &surface)
586@@ -933,3 +940,8 @@
587 {
588 return confine_pointer_state_;
589 }
590+
591+void ms::BasicSurface::placed_relative(geometry::Rectangle const& placement)
592+{
593+ observers.placed_relative(placement);
594+}
595
596=== modified file 'src/server/scene/basic_surface.h'
597--- src/server/scene/basic_surface.h 2016-08-24 02:09:08 +0000
598+++ src/server/scene/basic_surface.h 2016-09-15 08:21:15 +0000
599@@ -150,6 +150,7 @@
600
601 void set_confine_pointer_state(MirPointerConfinementState state) override;
602 MirPointerConfinementState confine_pointer_state() const override;
603+ void placed_relative(geometry::Rectangle const& placement) override;
604
605 private:
606 bool visible(std::unique_lock<std::mutex>&) const;
607
608=== modified file 'src/server/scene/legacy_surface_change_notification.cpp'
609--- src/server/scene/legacy_surface_change_notification.cpp 2016-08-02 19:44:59 +0000
610+++ src/server/scene/legacy_surface_change_notification.cpp 2016-09-15 08:21:15 +0000
611@@ -80,6 +80,10 @@
612 {
613 }
614
615+void ms::LegacySurfaceChangeNotification::placed_relative(geometry::Rectangle const& /*placement*/)
616+{
617+}
618+
619 void ms::LegacySurfaceChangeNotification::reception_mode_set_to(mi::InputReceptionMode /*mode*/)
620 {
621 notify_scene_change();
622
623=== modified file 'src/server/scene/legacy_surface_change_notification.h'
624--- src/server/scene/legacy_surface_change_notification.h 2016-08-02 19:44:59 +0000
625+++ src/server/scene/legacy_surface_change_notification.h 2016-09-15 08:21:15 +0000
626@@ -49,6 +49,7 @@
627 std::string const& variant, std::string const& options) override;
628 void renamed(char const*) override;
629 void cursor_image_removed() override;
630+ void placed_relative(geometry::Rectangle const& placement) override;
631
632 private:
633 std::function<void()> const notify_scene_change;
634
635=== modified file 'src/server/scene/null_surface_observer.cpp'
636--- src/server/scene/null_surface_observer.cpp 2016-08-02 19:44:59 +0000
637+++ src/server/scene/null_surface_observer.cpp 2016-09-15 08:21:15 +0000
638@@ -39,3 +39,4 @@
639 }
640 void ms::NullSurfaceObserver::renamed(char const*) {}
641 void ms::NullSurfaceObserver::cursor_image_removed() {}
642+void ms::NullSurfaceObserver::placed_relative(geometry::Rectangle const& /*placement*/) {}
643
644=== modified file 'src/server/scene/surface_event_source.cpp'
645--- src/server/scene/surface_event_source.cpp 2016-01-29 08:18:22 +0000
646+++ src/server/scene/surface_event_source.cpp 2016-09-15 08:21:15 +0000
647@@ -87,3 +87,8 @@
648 {
649 event_sink->handle_event(*mev::make_event(id, device_id, model, layout, variant, options));
650 }
651+
652+void ms::SurfaceEventSource::placed_relative(geometry::Rectangle const& placement)
653+{
654+ event_sink->handle_event(*mev::make_event(id, placement));
655+}
656
657=== modified file 'src/server/symbols.map'
658--- src/server/symbols.map 2016-08-26 19:01:27 +0000
659+++ src/server/symbols.map 2016-09-15 08:21:15 +0000
660@@ -840,5 +840,7 @@
661 global:
662 extern "C++" {
663 mir::Server::override_the_seat_report*;
664+ mir::scene::NullSurfaceObserver::placed_relative*;
665+ non-virtual?thunk?to?mir::scene::NullSurfaceObserver::placed_relative*;
666 };
667 } MIR_SERVER_0.24;
668
669=== modified file 'tests/acceptance-tests/test_custom_window_management.cpp'
670--- tests/acceptance-tests/test_custom_window_management.cpp 2016-08-31 10:46:40 +0000
671+++ tests/acceptance-tests/test_custom_window_management.cpp 2016-09-15 08:21:15 +0000
672@@ -18,6 +18,9 @@
673
674 #include "mir/geometry/rectangle.h"
675 #include "mir/scene/session.h"
676+#include "mir_toolkit/events/surface_placement.h"
677+#include "mir/events/event_builders.h"
678+#include "mir/scene/surface.h"
679
680 #include "mir_toolkit/mir_client_library.h"
681
682@@ -517,3 +520,77 @@
683 mir_surface_release_sync(parent);
684 mir_connection_release(connection);
685 }
686+
687+namespace
688+{
689+struct PlacementCheck
690+{
691+ PlacementCheck(MirRectangle const& placement) : expected_rect{placement} {}
692+
693+ void check(MirSurfacePlacementEvent const* placement_event)
694+ {
695+ EXPECT_THAT(mir_surface_placement_get_relative_position(placement_event).top, Eq(expected_rect.top));
696+ EXPECT_THAT(mir_surface_placement_get_relative_position(placement_event).left, Eq(expected_rect.left));
697+ EXPECT_THAT(mir_surface_placement_get_relative_position(placement_event).height, Eq(expected_rect.height));
698+ EXPECT_THAT(mir_surface_placement_get_relative_position(placement_event).width, Eq(expected_rect.width));
699+
700+ received.raise();
701+ }
702+
703+ ~PlacementCheck()
704+ {
705+ EXPECT_TRUE(received.wait_for(400ms));
706+ }
707+
708+private:
709+ MirRectangle const& expected_rect;
710+ mt::Signal received;
711+};
712+
713+void surface_placement_event_callback(MirSurface* /*surface*/, MirEvent const* event, void* context)
714+{
715+ if (mir_event_get_type(event) == mir_event_type_surface_placement)
716+ {
717+ auto const placement_event = mir_event_get_surface_placement_event(event);
718+ static_cast<PlacementCheck*>(context)->check(placement_event);
719+ }
720+}
721+}
722+
723+TEST_F(CustomWindowManagement, when_the_window_manager_places_a_surface_the_notification_reaches_the_client)
724+{
725+ int const width{800};
726+ int const height{600};
727+ MirPixelFormat const format{mir_pixel_format_bgr_888};
728+ MirRectangle placement{42, 15, 24, 7};
729+ geom::Rectangle placement_{{42, 15}, {24, 7}};
730+
731+ std::shared_ptr<ms::Surface> scene_surface;
732+
733+ auto capture_scene_surface = [&](
734+ std::shared_ptr<ms::Session> const& session,
735+ ms::SurfaceCreationParameters const& params,
736+ std::function<mf::SurfaceId(std::shared_ptr<ms::Session> const& session, ms::SurfaceCreationParameters const& params)> const& build)
737+ -> mf::SurfaceId
738+ {
739+ auto const result = build(session, params);
740+ scene_surface = session->surface(result);
741+ return result;
742+ };
743+
744+ EXPECT_CALL(window_manager, add_surface(_,_,_)).WillOnce(Invoke(capture_scene_surface));
745+
746+ start_server();
747+ auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
748+
749+ PlacementCheck placement_check{placement};
750+ auto surface_spec = mir_connection_create_spec_for_normal_surface(connection, width, height, format);
751+ mir_surface_spec_set_event_handler(surface_spec, &surface_placement_event_callback, &placement_check);
752+ auto surface = mir_surface_create_sync(surface_spec);
753+ mir_surface_spec_release(surface_spec);
754+
755+ scene_surface->placed_relative(placement_);
756+
757+ mir_surface_release_sync(surface);
758+ mir_connection_release(connection);
759+}
760
761=== modified file 'tests/include/mir/test/doubles/stub_scene_surface.h'
762--- tests/include/mir/test/doubles/stub_scene_surface.h 2016-08-10 10:43:39 +0000
763+++ tests/include/mir/test/doubles/stub_scene_surface.h 2016-09-15 08:21:15 +0000
764@@ -108,6 +108,7 @@
765
766 void set_confine_pointer_state(MirPointerConfinementState /*state*/) override {}
767 MirPointerConfinementState confine_pointer_state() const override { return {}; }
768+ void placed_relative(geometry::Rectangle const& /*placement*/) override {}
769 };
770
771 }
772
773=== modified file 'tests/mir_test_framework/stub_surface.cpp'
774--- tests/mir_test_framework/stub_surface.cpp 2016-06-27 20:44:49 +0000
775+++ tests/mir_test_framework/stub_surface.cpp 2016-09-15 08:21:15 +0000
776@@ -209,6 +209,9 @@
777 return {};
778 }
779
780+void mtd::StubSurface::placed_relative(geometry::Rectangle const& /*placement*/)
781+{
782+}
783
784 namespace
785 {

Subscribers

People subscribed via source and target branches