Mir

Merge lp:~raof/mir/the-least-dirty-thing into lp:mir

Proposed by Chris Halse Rogers
Status: Merged
Approved by: Alberto Aguirre
Approved revision: no longer in the source branch.
Merged at revision: 2005
Proposed branch: lp:~raof/mir/the-least-dirty-thing
Merge into: lp:mir
Diff against target: 1865 lines (+1026/-46)
53 files modified
client-ABI-sha1sums (+1/-1)
debian/control (+46/-0)
debian/libmirclient-debug-extension-dev.install (+3/-0)
debian/libmirclient-debug-extension1.install (+1/-0)
debian/libmirclient-dev.install (+1/-1)
include/client/mir_toolkit/debug/surface.h (+20/-0)
include/platform/mir/options/configuration.h (+1/-0)
include/server/mir/default_server_configuration.h (+3/-0)
include/server/mir/scene/coordinate_translator.h (+66/-0)
platform-ABI-sha1sums (+1/-1)
server-ABI-sha1sums (+3/-2)
src/client/CMakeLists.txt (+52/-2)
src/client/mir_connection.cpp (+3/-1)
src/client/mir_connection.h (+1/-0)
src/client/mir_debug_api.cpp (+39/-0)
src/client/mir_surface.cpp (+63/-0)
src/client/mir_surface.h (+16/-1)
src/client/mir_surface_api.cpp (+2/-3)
src/client/mirclient-debug-extension.pc.in (+11/-0)
src/client/mirclient.pc.in (+5/-3)
src/client/symbols-debug.map (+5/-0)
src/common/protobuf/mir_protobuf.proto (+17/-0)
src/common/symbols.map (+54/-0)
src/include/server/mir/frontend/unsupported_feature_exception.h (+41/-0)
src/platform/options/default_configuration.cpp (+4/-1)
src/platform/symbols.map (+1/-0)
src/server/frontend/CMakeLists.txt (+1/-0)
src/server/frontend/default_configuration.cpp (+21/-8)
src/server/frontend/default_ipc_factory.cpp (+6/-3)
src/server/frontend/default_ipc_factory.h (+8/-1)
src/server/frontend/protobuf_message_processor.cpp (+37/-0)
src/server/frontend/session_mediator.cpp (+30/-2)
src/server/frontend/session_mediator.h (+16/-2)
src/server/frontend/unsupported_coordinate_translator.cpp (+32/-0)
src/server/frontend/unsupported_coordinate_translator.h (+37/-0)
src/server/scene/CMakeLists.txt (+1/-0)
src/server/scene/default_configuration.cpp (+11/-0)
src/server/scene/default_coordinate_translator.cpp (+32/-0)
src/server/scene/default_coordinate_translator.h (+37/-0)
src/server/symbols.map (+6/-0)
tests/acceptance-tests/CMakeLists.txt (+2/-0)
tests/acceptance-tests/test_client_library.cpp (+0/-1)
tests/acceptance-tests/test_client_surface_events.cpp (+1/-1)
tests/acceptance-tests/test_client_surfaces.cpp (+1/-1)
tests/acceptance-tests/test_custom_input_dispatcher.cpp (+2/-2)
tests/acceptance-tests/test_debug_api.cpp (+231/-0)
tests/include/mir_test_doubles/mock_coordinate_translator.h (+42/-0)
tests/include/mir_test_doubles/mock_surface.h (+2/-1)
tests/integration-tests/CMakeLists.txt (+1/-0)
tests/integration-tests/test_stale_frames.cpp (+1/-1)
tests/unit-tests/frontend/test_session_mediator.cpp (+5/-5)
tests/unit-tests/frontend/test_session_mediator_android.cpp (+1/-1)
tests/unit-tests/frontend/test_session_mediator_mesa.cpp (+2/-1)
To merge this branch: bzr merge lp:~raof/mir/the-least-dirty-thing
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alberto Aguirre (community) Approve
Alan Griffiths Approve
Daniel van Vugt Abstain
Andreas Pokorny (community) Approve
Alexandros Frantzis (community) Approve
Kevin DuBois (community) Abstain
Review via email: mp+231679@code.launchpad.net

Commit message

Add a debug interface to translate from surface to screen coordinates.

This is the Mir part of the infrastructure for Autopilot to determine the screen location of widgets, for full-stack testing.

This is hidden behind a --debug server option, to make it absolutely clear that applications cannot depend on this functionality outside of a constrained environment.

(See also https://lists.ubuntu.com/archives/mir-devel/2014-August/000848.html)

Fixes: https://bugs.launchpad.net/mir/+bug/1346633

Description of the change

Add a translate_surface_to_screen debug interface, hidden behind running the server with --debug

This can be somewhat cleaned up when we've got real support for extensions, but should do for now.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Minor observations so far:

(1) 18 +Package: libmirclient-debug
is potentially confusing with the existing convention: packagename-dbg
so I think the dash needs removing. Something like "libmirclienttesting", since it's really not about "debugging" Mir at all.

(2) It seems we're going backwards in code bloat faster than I can keep up with fixing it. Can we avoid this part?
176 +
177 +# TODO: Extension apparatus so that mirclient-debug can be a MODULE and not
178 +# duplicate (almost) the entirity of mirclient
179 +add_library(
180 + mirclient-debug SHARED
181 +
182 + mir_debug_api.cpp
183 + $<TARGET_OBJECTS:mirclientobjects>
184 +)

(3) The amount of coupling we have is a bit excessive. Or is that an existing issue imposed by the existing class design?; "make_mediator()"

review: Needs Fixing
Revision history for this message
Kevin DuBois (kdub) wrote :

36 + Interfaces will come and go; end-user applications SHOULD NOT be linked
37 + against this library.

"interfaces come and go" is true of all the public interfaces... We should say something stronger like:
"Not all mir servers run with the capability to service this api; end-user applications SHOULD NOT depend on the functionality of this api."

review: Needs Fixing
Revision history for this message
Chris Halse Rogers (raof) wrote :

> Minor observations so far:
>
> (1) 18 +Package: libmirclient-debug
> is potentially confusing with the existing convention: packagename-dbg
> so I think the dash needs removing. Something like "libmirclienttesting",
> since it's really not about "debugging" Mir at all.

It actually is a bit about debugging Mir; at least, I've used the symbols in there to debug Mir and low-level client bits like XMir.

>
> (2) It seems we're going backwards in code bloat faster than I can keep up
> with fixing it. Can we avoid this part?

Not without either (a) exposing all the libmirclient internal symbols, or (b) adding in a real extension mechanism.

Since this library isn't expected to be installed on anything but development machines I wouldn't care if it was 100MB. I don't think we should spend any significant effort caring about its size.

We'll want an actual extension mechanism at some point in the future. At that point this can be switched to using that and libmirclient-debug-extension.so won't be almost exactly the same size as libmirclient.so

>
> (3) The amount of coupling we have is a bit excessive. Or is that an existing
> issue imposed by the existing class design?; "make_mediator()"

Yeah, that's the existing class design.

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

> "Not all mir servers run with the capability to service this api; end-user applications SHOULD NOT depend on the functionality of this api."

I agree with Kevin. I don't think it's worth having a different debugging version of the client library. Until we get an extension mechanism, I would prefer just exposing the debug APIs in our normal client library builds (like we have been doing up to now).

review: Needs Fixing
Revision history for this message
Chris Halse Rogers (raof) wrote :

From the client perspective it *is* an extension; libmirclient-debug-extension.so exposes only the three symbols we currently support; it's not a debugging version of the client library.

I can, of course, fold those symbols back into libmirclient. I think it's useful to have the non-core things split out a bit, though.

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

OK, I still have the same concerns as mentioned above. But nothing strictly blocking. That's not to say this is a proper review.

review: Abstain
Revision history for this message
Chris Halse Rogers (raof) wrote :

So, I'm not sure what needs to be done here in order to make this acceptable.

Do I need to fold the three debugging APIs back into libmirclient rather than their own DSO? Do I need to reduce the on-disc size of libmirclient-debug-extension by introducing infrastructure for extension loading in libmirclient?

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

> Do I need to fold the three debugging APIs back into libmirclient rather than their own DSO?
> Do I need to reduce the on-disc size of libmirclient-debug-extension by introducing
> infrastructure for extension loading in libmirclient?

I am fine with folding the debugging APIs back into libmirclient until we get a proper extension mechanism.

Revision history for this message
Kevin DuBois (kdub) wrote :

So, the stronger wording seems better, so that 'needs fixing' is resolved. As for having two libraries vs the one, I'm on the fence, so I won't object. I somewhat like that there's less temptation to roll these functions into the public api.

As for the DebuggingSessionMediator, it seems to me that the SessionMediator should depend on (via a constructor parameter) some object that is capable of looking up the coordinates. A debug implementation of this object would lookup the coordinates, the normal implementation would throw when the lookup is attempted.
OTOH, SessionMediator already has a pretty bloated constructor... but I'd rather have one bloated constructor on SessionMediator than a bloated constructor on both SessionMediator and DebuggingSessionMediator.

review: Abstain
Revision history for this message
Chris Halse Rogers (raof) wrote :

Yeah, I could make an extra interface for SessionMediator to depend on. I'll ask the list first about the general “how many DSOs should this be” question and then see what that version of SessionMediator would look like.

A bit ugly, because we're adding even more special-purpose code to a general interface, but until it gains an extension mechanism... :)

Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

In src/server/frontend/debugging_session_mediator.cpp
743 + response->set_x(request->x() + surface->top_left().x.as_int());
744 + response->set_y(request->y() + surface->top_left().y.as_int());

You have to transform x and y according to the surface orientation here (and in theory surface transformation but i doubt we want to be super correct - makes me wonder whether unity8 overrides that information stored at the surface? ). Furthermore in the nested case you have to forward that request to the system compositor.

So dl-load the debug extension in mirserver, and fail unlikely if not available.

Regarding the library vs internal topic. I prefer the separate library approach already implemented in this MP

review: Needs Fixing
Revision history for this message
kevin gunn (kgunn72) wrote :

As long as it's a dbug module that's not going to be part of a release image & you have to install when you want. Then I prefer the bloat-on-debug hit to keep it separated from regular ol' libmirclient.

however, is there a plan or mechanism to help resynch this with libmirclient where the code is duplicated ?
iirc, we're adding primarily for AP testing... so we'd want to keep the the functionality the same in the debug client, as to ensure the testing/config is valid and we trust the results.

Revision history for this message
Chris Halse Rogers (raof) wrote :

Clients wanting to use the debug extensions link against libmirclient as normal, and *also* libmirclient-debug-extension. There's no duplication of source code, just duplication of object code (as libmirclient-debug-extension needs access to the MirSurface implementation).

Andreas: Urgh, yeah, I guess so. I _think_ we have enough information in the nested case to do the translation without bouncing up to the host server, but it'll be safer to do so, yeah.

Revision history for this message
Kevin DuBois (kdub) wrote :

Its looking like we're coalescing around 2 DSO's then, everyone? (a second debug library is good by me)

Revision history for this message
Chris Halse Rogers (raof) wrote :

Andreas: Actually, I don't think we *do* need to forward to the system compositor - the nested compositor ensures it has a logical coordinate space that's identical to the system compositor's by means of the display configuration.

And we don't actually use the surface orientation anywhere, so I don't think we need to transform according to that either?

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

> Andreas: Actually, I don't think we *do* need to forward to the system
> compositor - the nested compositor ensures it has a logical coordinate space
> that's identical to the system compositor's by means of the display
> configuration.
>
> And we don't actually use the surface orientation anywhere, so I don't think
> we need to transform according to that either

I agree for a 'we' as in u-s-c + unity8 - since usc does not change the properties of unity8 surface. hmm.. it could still decide that unity8 and thus the client surface is not visible. But that is probably not a relevant result of the transformation? So I agree if you count demo shell out.

> And we don't actually use the surface orientation anywhere, so I don't think
> we need to transform according to that either

I thought for that calculation coordinates are given as client surface coordinates. Rotating the device turns a client surface of 400x900 pixels into a 900x400 grid. Whatever is now on 800x10, must be touched by the user at 390x800 or 10x100...

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

OK. Hopefully we will get a proper extension mechanism in the near/medium term.

509 +TEST_F(TestDebugAPI, ApiIsUnavaliableWhenServerNotStartedWithDebug)

"Unavailable"

> I thought for that calculation coordinates are given as client surface coordinates. Rotating the
> device turns a client surface of 400x900 pixels into a 900x400 grid. Whatever is now on 800x10,
> must be touched by the user at 390x800 or 10x100...

Not sure about this aspect of the code, so a weak approval for me pending further information on this.

review: Approve
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

As far as I can see qtmir/unity8 is not using mirs orientation values(, yet?). But it will need a way to influence the calculation instead.

Revision history for this message
Chris Halse Rogers (raof) wrote :

Yup. CoordinateTranslator is now available for overload by shells.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

lgtm.

one little detail .. why int32_t in the protobuf messages/int in the client api - but unsigned in the CoordinateTranslator interface and the default implementation does .as_unit32_t(). Looking at the code I believe negative values here are properly transported and returned.. and also in the case where the surface position is promoted to an unsigned int (which could be potentially negative) in 1280, there is only an addition and the result is converted back to int. A bit dirty but it should still work.

(negative positions could be possible too, if decorations are in negative coordinate space of the surface)

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

Probably best to use int32_t everywhere. Good catch.

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

We do indeed have negative coordinates. So make sure your x's and y's are signed.

Although I recommend against int32_t for a few reasons. "int" is better because:
  * On any modern platform "int" is already >= 32 bits
  * On some 64-bit platforms "int" is 64-bit and it's more efficient to use that native word size than forcing 32-bits.
  * int32_t increases coupling to yet another header.

review: Needs Fixing
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

> Although I recommend against int32_t for a few reasons. "int" is better
> because:
> * On any modern platform "int" is already >= 32 bits
> * On some 64-bit platforms "int" is 64-bit and it's more efficient to use
> that native word size than forcing 32-bits.
> * int32_t increases coupling to yet another header.

No since it involves protobuf (https://developers.google.com/protocol-buffers/docs/proto#scalar)
The type should match the type assigned in protobuf or in the very least specifically converted from int32_t to whatever internal type you use. The last thing we need is a subtle type conversion issue.

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

Alright, still needs conversion to signed ints though. Like in:
232 + virtual geometry::Point surface_to_screen(std::shared_ptr<frontend::Surface> surface,
233 + uint32_t x, uint32_t y) = 0;

Even local coordinates can go negative -- Consider what happens when you drag something like a scroll bar or image. The scrolling keeps responding even when the pointer itself is out of the window (so could be in negative coordinates).

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

Actually I still disagree with int32_t. If you make the decision to use that type just because Protobuf does, then you leak that information throughout your APIs in a very ugly way. "int" should be used instead, so that we at least hide the protocol implementation details from our client API design.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

Hah. I think we've found another area in which our stylistic preferences disagree :)

The way I see it, we currently hide the fact from our client API that Mir's coordinates system has exactly 32bits of significant data. “int” isn't hiding irrelevant implementation details, it's hiding a potentially relevant aspect of our API.

Indeed, I think we should be explicitly sizing *all* our types where they correspond to coordinates or other data types that are a part of our API that happen to be integral.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Remember we only support client and server on the same host, and only plan on supporting that. As such the client and server can safely use the same type with an unspecified width, like "int".

Only if you're supporting a networked environment with heterogeneous word sizes is it necessary to specify the size. But we have no plans to ever make Mir a network protocol.

Revision history for this message
Chris Halse Rogers (raof) wrote :

I run armhf code on my amd64 machine all the time. Local machine only does *not* imply same-word-size, or even same-endianness.

Revision history for this message
Chris Halse Rogers (raof) wrote :

And, obviously, i386/amd64 is an even more common usecase.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

> And, obviously, i386/amd64 is an even more common usecase.

hm maybe we could add something to the ci script that takes the x86 build and tries to run it with an amd64 server

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

You have an armhf client/server talking to an amd64 server/client? That sounds interesting. QEMU?

Also interesting is the idea of mixing and matching amd64 and i386 on the same host. That does sound like a plausible albeit uncommon scenario.

Still, even if there are reasonable use cases for mixing and matching I think it's much cleaner design to choose the client API and then modify the protocol to fit rather than vice-versa.

review: Abstain
Revision history for this message
Chris Halse Rogers (raof) wrote :

On Tue, Oct 14, 2014 at 5:06 PM, Daniel van Vugt
<email address hidden> wrote:
> Review: Abstain
>
> You have an armhf client/server talking to an amd64 server/client?
> That sounds interesting. QEMU?

Indeed. With dpkg multiarch the only limitation on the architecture
combinations are the qemu system hosts.

>
> Also interesting is the idea of mixing and matching amd64 and i386 on
> the same host. That does sound like a plausible albeit uncommon
> scenario.

It's actually *super* common; does Steam ship an amd64 binary, for
example? The majority of games are still i386 binaries.

If Intel has its way we'll end up with lots of x32 binaries on amd64
systems as the norm :).

>
> Still, even if there are reasonable use cases for mixing and matching
> I think it's much cleaner design to choose the client API and then
> modify the protocol to fit rather than vice-versa.

Indeed, but the client API should guarantee appropriately sized data
types :)

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

I'd rather we didn't have to do this

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

Dear protobuf: Your behaviour in registering an init thing that aborts on double-load is really annoying.

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

On 20/10/14 22:04, Chris Halse Rogers wrote:
> Dear protobuf: Your behaviour in registering an init thing that aborts on double-load is really annoying.

Yes, maybe it was a mistake to roll libmirprotobuf into libmircommon and
we should split it out again.

--
Alan Griffiths +44 (0)798 9938 758
Octopull Ltd http://www.octopull.co.uk/

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

Does what it claims to do

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

Looks like a CI hiccup unrelated to MP let's try again...

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'client-ABI-sha1sums'
--- client-ABI-sha1sums 2014-10-21 16:21:14 +0000
+++ client-ABI-sha1sums 2014-10-23 13:30:17 +0000
@@ -1,4 +1,4 @@
1cbe1e3ccfea6ab5865510f4f598ec11571fcc852 include/client/mir_toolkit/mir_client_library_debug.h13a60fb3b2b250ca67f54ade346ef658c9259c9a7 include/client/mir_toolkit/debug/surface.h
2b53736bcb22ddc09aab8275cfdd05c109fdd0f12 include/client/mir_toolkit/mir_client_library_drm.h2b53736bcb22ddc09aab8275cfdd05c109fdd0f12 include/client/mir_toolkit/mir_client_library_drm.h
31522a5fcdb01c0d9a990364539c4f1255853eef7 include/client/mir_toolkit/mir_client_library.h31522a5fcdb01c0d9a990364539c4f1255853eef7 include/client/mir_toolkit/mir_client_library.h
4e6185b680533c5fdcf1294a4797d5c3dd01d433f include/client/mir_toolkit/mir_connection.h4e6185b680533c5fdcf1294a4797d5c3dd01d433f include/client/mir_toolkit/mir_connection.h
55
=== modified file 'debian/control'
--- debian/control 2014-10-21 17:22:26 +0000
+++ debian/control 2014-10-23 13:30:17 +0000
@@ -165,6 +165,52 @@
165 .165 .
166 Contains header files required to develop against Mir.166 Contains header files required to develop against Mir.
167167
168Package: libmirclient-debug-extension1
169Section: libs
170Architecture: i386 amd64 armhf arm64
171Multi-Arch: same
172Pre-Depends: ${misc:Pre-Depends}
173Depends: ${misc:Depends},
174 ${shlibs:Depends},
175Description: Display server for Ubuntu - optional client debug interfaces
176 Mir is a display server running on linux systems, with a focus on efficiency,
177 robust operation and a well-defined driver model.
178 .
179 This package contains both a shared library containing the client side of
180 various optional debugging interfaces and the development headers required
181 to use them.
182 .
183 This is primarily useful for developing Mir servers, low-level client
184 toolkits, or for automated testing in constrained environments.
185 .
186 Not all Mir servers have the capability to service these APIs; end-user
187 applications SHOULD NOT depend on this library.
188
189Package: libmirclient-debug-extension-dev
190Section: libdevel
191Architecture: i386 amd64 armhf arm64
192Multi-Arch: same
193Pre-Depends: ${misc:Pre-Depends}
194Depends: libmirclient-debug-extension1 (= ${binary:Version})
195 ${misc:Depends},
196 ${shlibs:Depends},
197Description: Display server for Ubuntu - client debug interface headers
198 Mir is a display server running on linux systems, with a focus on efficiency,
199 robust operation and a well-defined driver model.
200 .
201 This package contains both a shared library containing the client side of
202 various optional debugging interfaces and the development headers required
203 to use them.
204 .
205 This is primarily useful for developing Mir servers, low-level client
206 toolkits, or for automated testing in constrained environments.
207 .
208 Not all Mir servers have the capability to service these APIs; end-user
209 applications SHOULD NOT depend on this library.
210 .
211 This package contains the development headers required to develop against
212 the debug extensions.
213
168Package: mir-demos214Package: mir-demos
169Architecture: i386 amd64 armhf arm64215Architecture: i386 amd64 armhf arm64
170Depends: ${misc:Depends},216Depends: ${misc:Depends},
171217
=== added file 'debian/libmirclient-debug-extension-dev.install'
--- debian/libmirclient-debug-extension-dev.install 1970-01-01 00:00:00 +0000
+++ debian/libmirclient-debug-extension-dev.install 2014-10-23 13:30:17 +0000
@@ -0,0 +1,3 @@
1usr/include/mirclient/mir_toolkit/debug
2usr/lib/*/pkgconfig/mirclient-debug-extension.pc
3usr/lib/*/libmirclient-debug-extension.so
04
=== added file 'debian/libmirclient-debug-extension1.install'
--- debian/libmirclient-debug-extension1.install 1970-01-01 00:00:00 +0000
+++ debian/libmirclient-debug-extension1.install 2014-10-23 13:30:17 +0000
@@ -0,0 +1,1 @@
1usr/lib/*/libmirclient-debug-extension.so.*
02
=== modified file 'debian/libmirclient-dev.install'
--- debian/libmirclient-dev.install 2013-06-24 12:15:28 +0000
+++ debian/libmirclient-dev.install 2014-10-23 13:30:17 +0000
@@ -1,3 +1,3 @@
1usr/include/mirclient1usr/include/mirclient/mir_toolkit/*.h
2usr/lib/*/pkgconfig/mirclient.pc2usr/lib/*/pkgconfig/mirclient.pc
3usr/lib/*/libmirclient.so3usr/lib/*/libmirclient.so
44
=== added directory 'include/client/mir_toolkit/debug'
=== renamed file 'include/client/mir_toolkit/mir_client_library_debug.h' => 'include/client/mir_toolkit/debug/surface.h'
--- include/client/mir_toolkit/mir_client_library_debug.h 2014-10-01 06:25:56 +0000
+++ include/client/mir_toolkit/debug/surface.h 2014-10-23 13:30:17 +0000
@@ -28,6 +28,7 @@
2828
29/**29/**
30 * Return the ID of a surface (only useful for debug output).30 * Return the ID of a surface (only useful for debug output).
31 * \pre The surface is valid
31 * \param [in] surface The surface32 * \param [in] surface The surface
32 * \return An internal ID that identifies the surface33 * \return An internal ID that identifies the surface
33 */34 */
@@ -43,6 +44,25 @@
43 */44 */
44uint32_t mir_debug_surface_current_buffer_id(MirSurface *surface);45uint32_t mir_debug_surface_current_buffer_id(MirSurface *surface);
4546
47/**
48 * Get the screen coordinates corresponding to a pair of surface coordinates
49 * \pre The surface is valid
50 * \param [in] surface The surface
51 * \param [in] x, y Surface coordinates to map to screen coordinates
52 * \param [out] screen_x, screen_y The screen coordinates corresponding to x, y.
53 * \return True if screen_x and screen_y contain values
54 * \note There are many cases where such a mapping does not exist or would be expensive
55 * to calculate. Only Mir servers started with the --debug option will ever return
56 * values for this call, and even when --debug is enabled servers are free to
57 * return nothing.
58 *
59 * This call will only be interesting for automated testing, where both the client
60 * and shell state is known and constrained.
61 */
62MirBool mir_debug_surface_coords_to_screen(MirSurface* surface,
63 int x, int y,
64 int* screen_x, int* screen_y);
65
46#ifdef __cplusplus66#ifdef __cplusplus
47}67}
48#endif68#endif
4969
=== modified file 'include/platform/mir/options/configuration.h'
--- include/platform/mir/options/configuration.h 2014-10-01 06:25:56 +0000
+++ include/platform/mir/options/configuration.h 2014-10-23 13:30:17 +0000
@@ -43,6 +43,7 @@
43extern char const* const frontend_threads_opt;43extern char const* const frontend_threads_opt;
44extern char const* const touchspots_opt;44extern char const* const touchspots_opt;
45extern char const* const fatal_abort_opt;45extern char const* const fatal_abort_opt;
46extern char const* const debug_opt;
4647
47extern char const* const name_opt;48extern char const* const name_opt;
48extern char const* const offscreen_opt;49extern char const* const offscreen_opt;
4950
=== modified file 'include/server/mir/default_server_configuration.h'
--- include/server/mir/default_server_configuration.h 2014-10-22 18:55:40 +0000
+++ include/server/mir/default_server_configuration.h 2014-10-23 13:30:17 +0000
@@ -101,6 +101,7 @@
101class SceneReport;101class SceneReport;
102class PromptSessionListener;102class PromptSessionListener;
103class PromptSessionManager;103class PromptSessionManager;
104class CoordinateTranslator;
104}105}
105namespace graphics106namespace graphics
106{107{
@@ -286,6 +287,7 @@
286 * @{ */287 * @{ */
287 // To customize this behaviour it is recommended you override wrap_session_coordinator().288 // To customize this behaviour it is recommended you override wrap_session_coordinator().
288 virtual std::shared_ptr<scene::SessionCoordinator> the_session_coordinator();289 virtual std::shared_ptr<scene::SessionCoordinator> the_session_coordinator();
290 virtual std::shared_ptr<scene::CoordinateTranslator> the_coordinate_translator();
289 /** @} */291 /** @} */
290292
291293
@@ -421,6 +423,7 @@
421 CachedPtr<scene::PromptSessionListener> prompt_session_listener;423 CachedPtr<scene::PromptSessionListener> prompt_session_listener;
422 CachedPtr<scene::PromptSessionManager> prompt_session_manager;424 CachedPtr<scene::PromptSessionManager> prompt_session_manager;
423 CachedPtr<scene::SessionCoordinator> session_coordinator;425 CachedPtr<scene::SessionCoordinator> session_coordinator;
426 CachedPtr<scene::CoordinateTranslator> coordinate_translator;
424 CachedPtr<EmergencyCleanup> emergency_cleanup;427 CachedPtr<EmergencyCleanup> emergency_cleanup;
425 CachedPtr<shell::HostLifecycleEventListener> host_lifecycle_event_listener;428 CachedPtr<shell::HostLifecycleEventListener> host_lifecycle_event_listener;
426429
427430
=== added file 'include/server/mir/scene/coordinate_translator.h'
--- include/server/mir/scene/coordinate_translator.h 1970-01-01 00:00:00 +0000
+++ include/server/mir/scene/coordinate_translator.h 2014-10-23 13:30:17 +0000
@@ -0,0 +1,66 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 */
18
19#ifndef MIR_SCENE_COORDINATE_TRANSLATOR_H_
20#define MIR_SCENE_COORDINATE_TRANSLATOR_H_
21
22#include "mir/geometry/point.h"
23#include <memory>
24
25namespace mir
26{
27namespace frontend
28{
29class Surface;
30}
31
32namespace scene
33{
34
35/**
36 * Support for the debug "surface to screen" coordinate translation interface.
37 * \note For shells which do surface transformations the default implementation
38 * will return incorrect results.
39 */
40class CoordinateTranslator
41{
42public:
43 virtual ~CoordinateTranslator() = default;
44
45 /**
46 * \brief Translate a surface coordinate into the screen coordinate space
47 * \param [in] surface A frontend::Surface. This will need to be dynamic_cast into
48 * the scene::Surface relevant for the shell.
49 * \param [in] x, y Coordinates to translate from the surface coordinate space
50 * \return The coordinates in the screen coordinate space.
51 * \throws A std::runtime_error if the translation cannot be performed
52 * for any reason.
53 *
54 * \note It is acceptable for this call to unconditionally throw a std::runtime_error.
55 * It is not required for normal functioning of the server or clients; clients which
56 * use the debug extension will receive an appropriate failure notice.
57 */
58 virtual geometry::Point surface_to_screen(std::shared_ptr<frontend::Surface> surface,
59 int32_t x, int32_t y) = 0;
60};
61
62
63}
64}
65
66#endif // MIR_SCENE_COORDINATE_TRANSLATOR_H_
067
=== modified file 'platform-ABI-sha1sums'
--- platform-ABI-sha1sums 2014-10-21 16:21:14 +0000
+++ platform-ABI-sha1sums 2014-10-23 13:30:17 +0000
@@ -40,7 +40,7 @@
401fbe488b4581486fd01e2f03e504f31b72c09040 include/platform/mir/graphics/platform_ipc_operations.h401fbe488b4581486fd01e2f03e504f31b72c09040 include/platform/mir/graphics/platform_ipc_operations.h
419c7712af84b6fde1970ff802ad2ea78f892c7b7e include/platform/mir/graphics/platform_ipc_package.h419c7712af84b6fde1970ff802ad2ea78f892c7b7e include/platform/mir/graphics/platform_ipc_package.h
4284c063346b3bd51b4624d9f940008d4c3f8be066 include/platform/mir/graphics/renderable.h4284c063346b3bd51b4624d9f940008d4c3f8be066 include/platform/mir/graphics/renderable.h
43f5746dab3336266cfd410ce4e4d01333df6e5b99 include/platform/mir/options/configuration.h43b19329d35a55f640edd72c0a953908995211d97e include/platform/mir/options/configuration.h
4447007c783c174f8e94d332c4b13c6b01358b48fb include/platform/mir/options/default_configuration.h4447007c783c174f8e94d332c4b13c6b01358b48fb include/platform/mir/options/default_configuration.h
45b45f14082c4f8b29efaa1b13de795dcb29deb738 include/platform/mir/options/option.h45b45f14082c4f8b29efaa1b13de795dcb29deb738 include/platform/mir/options/option.h
463c37cc31e8b290b89c311d82f02e07d342766451 include/platform/mir/options/program_option.h463c37cc31e8b290b89c311d82f02e07d342766451 include/platform/mir/options/program_option.h
4747
=== modified file 'server-ABI-sha1sums'
--- server-ABI-sha1sums 2014-10-22 18:55:40 +0000
+++ server-ABI-sha1sums 2014-10-23 13:30:17 +0000
@@ -40,7 +40,7 @@
401fbe488b4581486fd01e2f03e504f31b72c09040 include/platform/mir/graphics/platform_ipc_operations.h401fbe488b4581486fd01e2f03e504f31b72c09040 include/platform/mir/graphics/platform_ipc_operations.h
419c7712af84b6fde1970ff802ad2ea78f892c7b7e include/platform/mir/graphics/platform_ipc_package.h419c7712af84b6fde1970ff802ad2ea78f892c7b7e include/platform/mir/graphics/platform_ipc_package.h
4284c063346b3bd51b4624d9f940008d4c3f8be066 include/platform/mir/graphics/renderable.h4284c063346b3bd51b4624d9f940008d4c3f8be066 include/platform/mir/graphics/renderable.h
43f5746dab3336266cfd410ce4e4d01333df6e5b99 include/platform/mir/options/configuration.h43b19329d35a55f640edd72c0a953908995211d97e include/platform/mir/options/configuration.h
4447007c783c174f8e94d332c4b13c6b01358b48fb include/platform/mir/options/default_configuration.h4447007c783c174f8e94d332c4b13c6b01358b48fb include/platform/mir/options/default_configuration.h
45b45f14082c4f8b29efaa1b13de795dcb29deb738 include/platform/mir/options/option.h45b45f14082c4f8b29efaa1b13de795dcb29deb738 include/platform/mir/options/option.h
463c37cc31e8b290b89c311d82f02e07d342766451 include/platform/mir/options/program_option.h463c37cc31e8b290b89c311d82f02e07d342766451 include/platform/mir/options/program_option.h
@@ -48,7 +48,7 @@
48a9f284ba4b05d58fd3eeb628d1f56fe4ac188526 include/server/mir/compositor/compositor_id.h48a9f284ba4b05d58fd3eeb628d1f56fe4ac188526 include/server/mir/compositor/compositor_id.h
49878ab5c4007d16dac213a3eb0105421d8ffad206 include/server/mir/compositor/scene_element.h49878ab5c4007d16dac213a3eb0105421d8ffad206 include/server/mir/compositor/scene_element.h
504fcf34e424128b87ddc76733594e32e09ebbd486 include/server/mir/compositor/scene.h504fcf34e424128b87ddc76733594e32e09ebbd486 include/server/mir/compositor/scene.h
517e47baf423fc61960d8e4ea92eae93caf71c93e2 include/server/mir/default_server_configuration.h51c14448c8f882f44b05fa56ced7c8db51083a9bd3 include/server/mir/default_server_configuration.h
52af1ff0714be973ac76d56006a2e5991f68cd1dec include/server/mir/display_server.h52af1ff0714be973ac76d56006a2e5991f68cd1dec include/server/mir/display_server.h
53a35c5495d8fd28fc0e375b17495fc5caab51b329 include/server/mir/emergency_cleanup.h53a35c5495d8fd28fc0e375b17495fc5caab51b329 include/server/mir/emergency_cleanup.h
54938de641cb0e01e1098b007b39b151a7dfe4adc1 include/server/mir/frontend/display_changer.h54938de641cb0e01e1098b007b39b151a7dfe4adc1 include/server/mir/frontend/display_changer.h
@@ -75,6 +75,7 @@
75964069b241f1e8211386bb8735ee0f752b666949 include/server/mir/main_loop.h75964069b241f1e8211386bb8735ee0f752b666949 include/server/mir/main_loop.h
76edd5a0a6be0be57ef64c5af89fc5a65dc558648c include/server/mir/report_exception.h76edd5a0a6be0be57ef64c5af89fc5a65dc558648c include/server/mir/report_exception.h
778192727cf5fa0b2b5798b2211c2c8a4ad65c9f60 include/server/mir/run_mir.h778192727cf5fa0b2b5798b2211c2c8a4ad65c9f60 include/server/mir/run_mir.h
78c9de8b851fb22092a9a486d71cd998b4cb8392e1 include/server/mir/scene/coordinate_translator.h
7871d9082681aa39d652c88ad3b54665695b521d24 include/server/mir/scene/depth_id.h7971d9082681aa39d652c88ad3b54665695b521d24 include/server/mir/scene/depth_id.h
794e4e563ab429a13ddca7eead16f2b6cefb8edff6 include/server/mir/scene/null_surface_observer.h804e4e563ab429a13ddca7eead16f2b6cefb8edff6 include/server/mir/scene/null_surface_observer.h
80d5273f3363b0b776427d5e3f1af99f0f2bcf3fa6 include/server/mir/scene/observer.h81d5273f3363b0b776427d5e3f1af99f0f2bcf3fa6 include/server/mir/scene/observer.h
8182
=== modified file 'src/client/CMakeLists.txt'
--- src/client/CMakeLists.txt 2014-10-21 16:21:14 +0000
+++ src/client/CMakeLists.txt 2014-10-23 13:30:17 +0000
@@ -8,12 +8,18 @@
8set(PREFIX "${CMAKE_INSTALL_PREFIX}")8set(PREFIX "${CMAKE_INSTALL_PREFIX}")
9set(EXEC_PREFIX "${CMAKE_INSTALL_PREFIX}")9set(EXEC_PREFIX "${CMAKE_INSTALL_PREFIX}")
10set(LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}")10set(LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}")
11set(INCLUDEDIR "${CMAKE_INSTALL_PREFIX}/include/mirclient")11set(INCLUDEDIR "${CMAKE_INSTALL_PREFIX}/include")
12set(COMMON_INCLUDEDIR "${CMAKE_INSTALL_PREFIX}/include/mircommon")
1312
14configure_file(13configure_file(
15 ${CMAKE_CURRENT_SOURCE_DIR}/mirclient.pc.in14 ${CMAKE_CURRENT_SOURCE_DIR}/mirclient.pc.in
16 ${CMAKE_CURRENT_BINARY_DIR}/mirclient.pc15 ${CMAKE_CURRENT_BINARY_DIR}/mirclient.pc
16 @ONLY
17)
18
19configure_file(
20 ${CMAKE_CURRENT_SOURCE_DIR}/mirclient-debug-extension.pc.in
21 ${CMAKE_CURRENT_BINARY_DIR}/mirclient-debug-extension.pc
22 @ONLY
17)23)
1824
19include_directories(25include_directories(
@@ -113,3 +119,47 @@
113 FILES ${CMAKE_CURRENT_BINARY_DIR}/mirclient.pc119 FILES ${CMAKE_CURRENT_BINARY_DIR}/mirclient.pc
114 DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig120 DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
115)121)
122
123# TODO: Extension apparatus so that mirclient-debug-extension can be a MODULE and not
124# duplicate (almost) the entirity of mirclient
125
126set(MIRCLIENT_DEBUG_EXTENSION_ABI 1)
127
128add_library(
129 mirclient-debug-extension SHARED
130
131 mir_debug_api.cpp
132 $<TARGET_OBJECTS:mirclientobjects>
133)
134
135target_link_libraries(
136 mirclient-debug-extension
137
138 mirclient
139)
140
141set(debug_symbol_map ${CMAKE_CURRENT_SOURCE_DIR}/symbols-debug.map)
142
143set_target_properties(
144 mirclient-debug-extension
145
146 PROPERTIES
147 SOVERSION ${MIRCLIENT_DEBUG_EXTENSION_ABI}
148 LINK_FLAGS "-Wl,--version-script,${debug_symbol_map}"
149)
150
151install(
152 DIRECTORY ${CMAKE_SOURCE_DIR}/include/client/mir_toolkit/debug
153 DESTINATION "include/mirclient/mir_toolkit/debug"
154)
155
156install(
157 TARGETS mirclient-debug-extension
158 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
159 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
160
161install(
162 FILES ${CMAKE_CURRENT_BINARY_DIR}/mirclient-debug-extension.pc
163 DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
164)
165
116166
=== modified file 'src/client/mir_connection.cpp'
--- src/client/mir_connection.cpp 2014-10-01 06:25:56 +0000
+++ src/client/mir_connection.cpp 2014-10-23 13:30:17 +0000
@@ -87,6 +87,7 @@
87 deregisterer{this},87 deregisterer{this},
88 channel(),88 channel(),
89 server(0),89 server(0),
90 debug(0),
90 error_message(error_message)91 error_message(error_message)
91{92{
92}93}
@@ -97,6 +98,7 @@
97 platform_library{conf.the_platform_library()},98 platform_library{conf.the_platform_library()},
98 channel(conf.the_rpc_channel()),99 channel(conf.the_rpc_channel()),
99 server(channel.get(), ::google::protobuf::Service::STUB_DOESNT_OWN_CHANNEL),100 server(channel.get(), ::google::protobuf::Service::STUB_DOESNT_OWN_CHANNEL),
101 debug(channel.get(), ::google::protobuf::Service::STUB_DOESNT_OWN_CHANNEL),
100 logger(conf.the_logger()),102 logger(conf.the_logger()),
101 client_platform_factory(conf.the_client_platform_factory()),103 client_platform_factory(conf.the_client_platform_factory()),
102 input_platform(conf.the_input_platform()),104 input_platform(conf.the_input_platform()),
@@ -133,7 +135,7 @@
133 mir_surface_callback callback,135 mir_surface_callback callback,
134 void * context)136 void * context)
135{137{
136 auto surface = new MirSurface(this, server, platform->create_buffer_factory(), input_platform, params, callback, context);138 auto surface = new MirSurface(this, server, &debug, platform->create_buffer_factory(), input_platform, params, callback, context);
137139
138 return surface->get_create_wait_handle();140 return surface->get_create_wait_handle();
139}141}
140142
=== modified file 'src/client/mir_connection.h'
--- src/client/mir_connection.h 2014-10-01 06:25:56 +0000
+++ src/client/mir_connection.h 2014-10-23 13:30:17 +0000
@@ -149,6 +149,7 @@
149149
150 std::shared_ptr<google::protobuf::RpcChannel> const channel;150 std::shared_ptr<google::protobuf::RpcChannel> const channel;
151 mir::protobuf::DisplayServer::Stub server;151 mir::protobuf::DisplayServer::Stub server;
152 mir::protobuf::Debug::Stub debug;
152 std::shared_ptr<mir::logging::Logger> const logger;153 std::shared_ptr<mir::logging::Logger> const logger;
153 mir::protobuf::Void void_response;154 mir::protobuf::Void void_response;
154 mir::protobuf::Connection connect_result;155 mir::protobuf::Connection connect_result;
155156
=== added file 'src/client/mir_debug_api.cpp'
--- src/client/mir_debug_api.cpp 1970-01-01 00:00:00 +0000
+++ src/client/mir_debug_api.cpp 2014-10-23 13:30:17 +0000
@@ -0,0 +1,39 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 */
18
19#include "mir_toolkit/debug/surface.h"
20
21#include "mir_surface.h"
22
23uint32_t mir_debug_surface_current_buffer_id(MirSurface* surface)
24{
25 return surface->get_current_buffer_id();
26}
27
28int mir_debug_surface_id(MirSurface* surface)
29{
30 return surface->id();
31}
32
33MirBool mir_debug_surface_coords_to_screen(MirSurface* surface,
34 int x, int y,
35 int* screen_x, int* screen_y)
36{
37 return surface->translate_to_screen_coordinates(x, y, screen_x, screen_y) ?
38 mir_true : mir_false ;
39}
040
=== modified file 'src/client/mir_surface.cpp'
--- src/client/mir_surface.cpp 2014-10-21 16:21:14 +0000
+++ src/client/mir_surface.cpp 2014-10-23 13:30:17 +0000
@@ -51,7 +51,27 @@
51 std::shared_ptr<mircv::InputPlatform> const& input_platform,51 std::shared_ptr<mircv::InputPlatform> const& input_platform,
52 MirSurfaceParameters const & params,52 MirSurfaceParameters const & params,
53 mir_surface_callback callback, void * context)53 mir_surface_callback callback, void * context)
54 : MirSurface(allocating_connection,
55 server,
56 nullptr,
57 factory,
58 input_platform,
59 params,
60 callback, context)
61{
62}
63
64
65MirSurface::MirSurface(
66 MirConnection *allocating_connection,
67 mp::DisplayServer::Stub & server,
68 mp::Debug::Stub* debug,
69 std::shared_ptr<mcl::ClientBufferFactory> const& factory,
70 std::shared_ptr<mircv::InputPlatform> const& input_platform,
71 MirSurfaceParameters const & params,
72 mir_surface_callback callback, void * context)
54 : server(server),73 : server(server),
74 debug{debug},
55 connection(allocating_connection),75 connection(allocating_connection),
56 buffer_depository(std::make_shared<mcl::ClientBufferDepository>(factory, mir::frontend::client_buffer_cache_size)),76 buffer_depository(std::make_shared<mcl::ClientBufferDepository>(factory, mir::frontend::client_buffer_cache_size)),
57 input_platform(input_platform)77 input_platform(input_platform)
@@ -373,6 +393,49 @@
373 return &configure_wait_handle;393 return &configure_wait_handle;
374}394}
375395
396namespace
397{
398void signal_response_received(MirWaitHandle* handle)
399{
400 handle->result_received();
401}
402}
403
404bool MirSurface::translate_to_screen_coordinates(int x, int y,
405 int *screen_x, int *screen_y)
406{
407 if (!debug)
408 {
409 return false;
410 }
411
412 mp::CoordinateTranslationRequest request;
413
414 request.set_x(x);
415 request.set_y(y);
416 *request.mutable_surfaceid() = surface.id();
417 mp::CoordinateTranslationResponse response;
418
419 MirWaitHandle signal;
420 signal.expect_result();
421
422 {
423 std::lock_guard<decltype(mutex)> lock(mutex);
424
425 debug->translate_surface_to_screen(
426 nullptr,
427 &request,
428 &response,
429 google::protobuf::NewCallback(&signal_response_received, &signal));
430 }
431
432 signal.wait_for_one();
433
434 *screen_x = response.x();
435 *screen_y = response.y();
436 return !response.has_error();
437}
438
376void MirSurface::on_configured()439void MirSurface::on_configured()
377{440{
378 std::lock_guard<decltype(mutex)> lock(mutex);441 std::lock_guard<decltype(mutex)> lock(mutex);
379442
=== modified file 'src/client/mir_surface.h'
--- src/client/mir_surface.h 2014-10-21 16:21:14 +0000
+++ src/client/mir_surface.h 2014-10-23 13:30:17 +0000
@@ -62,6 +62,15 @@
62 MirSurface(62 MirSurface(
63 MirConnection *allocating_connection,63 MirConnection *allocating_connection,
64 mir::protobuf::DisplayServer::Stub & server,64 mir::protobuf::DisplayServer::Stub & server,
65 mir::protobuf::Debug::Stub* debug,
66 std::shared_ptr<mir::client::ClientBufferFactory> const& buffer_factory,
67 std::shared_ptr<mir::input::receiver::InputPlatform> const& input_platform,
68 MirSurfaceParameters const& params,
69 mir_surface_callback callback, void * context);
70
71 MirSurface(
72 MirConnection *allocating_connection,
73 mir::protobuf::DisplayServer::Stub & server,
65 std::shared_ptr<mir::client::ClientBufferFactory> const& buffer_factory,74 std::shared_ptr<mir::client::ClientBufferFactory> const& buffer_factory,
66 std::shared_ptr<mir::input::receiver::InputPlatform> const& input_platform,75 std::shared_ptr<mir::input::receiver::InputPlatform> const& input_platform,
67 MirSurfaceParameters const& params,76 MirSurfaceParameters const& params,
@@ -87,6 +96,11 @@
87 EGLNativeWindowType generate_native_window();96 EGLNativeWindowType generate_native_window();
8897
89 MirWaitHandle* configure(MirSurfaceAttrib a, int value);98 MirWaitHandle* configure(MirSurfaceAttrib a, int value);
99
100 // TODO: Some sort of extension mechanism so that this can be moved
101 // out into a separate class in the libmirclient-debug DSO.
102 bool translate_to_screen_coordinates(int x, int y,
103 int* screen_x, int* screen_y);
90 104
91 // Non-blocking105 // Non-blocking
92 int attrib(MirSurfaceAttrib a) const;106 int attrib(MirSurfaceAttrib a) const;
@@ -115,7 +129,8 @@
115 MirPixelFormat convert_ipc_pf_to_geometry(google::protobuf::int32 pf);129 MirPixelFormat convert_ipc_pf_to_geometry(google::protobuf::int32 pf);
116 void release_cpu_region();130 void release_cpu_region();
117131
118 mir::protobuf::DisplayServer::Stub & server;132 mir::protobuf::DisplayServer::Stub& server;
133 mir::protobuf::Debug::Stub* debug;
119 mir::protobuf::Surface surface;134 mir::protobuf::Surface surface;
120 mir::protobuf::BufferRequest buffer_request;135 mir::protobuf::BufferRequest buffer_request;
121 std::string error_message;136 std::string error_message;
122137
=== modified file 'src/client/mir_surface_api.cpp'
--- src/client/mir_surface_api.cpp 2014-10-01 06:25:56 +0000
+++ src/client/mir_surface_api.cpp 2014-10-23 13:30:17 +0000
@@ -18,7 +18,6 @@
1818
19#include "mir_toolkit/mir_surface.h"19#include "mir_toolkit/mir_surface.h"
20#include "mir_toolkit/mir_wait.h"20#include "mir_toolkit/mir_wait.h"
21#include "mir_toolkit/mir_client_library_debug.h"
2221
23#include "mir_connection.h"22#include "mir_connection.h"
24#include "mir_surface.h"23#include "mir_surface.h"
@@ -152,9 +151,9 @@
152 nullptr));151 nullptr));
153}152}
154153
155int mir_surface_get_id(MirSurface* surface)154int mir_surface_get_id(MirSurface* /*surface*/)
156{155{
157 return mir_debug_surface_id(surface);156 return 0;
158}157}
159158
160MirWaitHandle* mir_surface_set_type(MirSurface* surf,159MirWaitHandle* mir_surface_set_type(MirSurface* surf,
161160
=== added file 'src/client/mirclient-debug-extension.pc.in'
--- src/client/mirclient-debug-extension.pc.in 1970-01-01 00:00:00 +0000
+++ src/client/mirclient-debug-extension.pc.in 2014-10-23 13:30:17 +0000
@@ -0,0 +1,11 @@
1prefix=@PREFIX@
2exec_prefix=@EXEC_PREFIX@
3libdir=@LIBDIR@
4includedir=@INCLUDEDIR@/mirclient-debug
5common_includedir=@INCLUDEDIR@/mircommon
6
7Name: mirclient-debug
8Description: Mir client debug library
9Version: @MIR_VERSION@
10Libs: -L${libdir} -lmirclient-debug
11Cflags: -I${includedir} -I${common_includedir}
012
=== modified file 'src/client/mirclient.pc.in'
--- src/client/mirclient.pc.in 2014-10-01 06:25:56 +0000
+++ src/client/mirclient.pc.in 2014-10-23 13:30:17 +0000
@@ -1,11 +1,13 @@
1prefix=@PREFIX@1prefix=@PREFIX@
2exec_prefix=@EXEC_PREFIX@2exec_prefix=@EXEC_PREFIX@
3libdir=@LIBDIR@3libdir=@LIBDIR@
4includedir=@INCLUDEDIR@4includedir=@INCLUDEDIR@/mirclient
5common_includedir=@INCLUDEDIR@/mircommon
6
57
6Name: mirclient8Name: mirclient
7Description: Mir client library9Description: Mir client library
8Version: @MIR_VERSION@10Version: @MIR_VERSION@
9Requires.private: protobuf >= 2.4.111Requires.private: protobuf >= 2.4.1
10Libs: -L@LIBDIR@ -lmirclient12Libs: -L${libdir} -lmirclient
11Cflags: -I@INCLUDEDIR@ -I@COMMON_INCLUDEDIR@ 13Cflags: -I${includedir} -I${common_includedir}
1214
=== added file 'src/client/symbols-debug.map'
--- src/client/symbols-debug.map 1970-01-01 00:00:00 +0000
+++ src/client/symbols-debug.map 2014-10-23 13:30:17 +0000
@@ -0,0 +1,5 @@
1{
2 global:
3 mir_debug_*;
4 local: *;
5};
06
=== modified file 'src/common/protobuf/mir_protobuf.proto'
--- src/common/protobuf/mir_protobuf.proto 2014-10-21 16:21:14 +0000
+++ src/common/protobuf/mir_protobuf.proto 2014-10-23 13:30:17 +0000
@@ -228,3 +228,20 @@
228 rpc stop_prompt_session(Void) returns (Void);228 rpc stop_prompt_session(Void) returns (Void);
229 rpc exchange_buffer(BufferRequest) returns (Buffer);229 rpc exchange_buffer(BufferRequest) returns (Buffer);
230}230}
231
232message CoordinateTranslationRequest {
233 required SurfaceId surfaceid = 1;
234 required int32 x = 2;
235 required int32 y = 3;
236}
237
238message CoordinateTranslationResponse {
239 optional int32 x = 1;
240 optional int32 y = 2;
241
242 optional string error = 127;
243}
244
245service Debug {
246 rpc translate_surface_to_screen(CoordinateTranslationRequest) returns (CoordinateTranslationResponse);
247}
231248
=== modified file 'src/common/symbols.map'
--- src/common/symbols.map 2014-10-21 16:21:14 +0000
+++ src/common/symbols.map 2014-10-23 13:30:17 +0000
@@ -143,6 +143,42 @@
143 mir::protobuf::ConnectParameters::SerializeWithCachedSizes*;143 mir::protobuf::ConnectParameters::SerializeWithCachedSizes*;
144 mir::protobuf::ConnectParameters::SerializeWithCachedSizesToArray*;144 mir::protobuf::ConnectParameters::SerializeWithCachedSizesToArray*;
145 mir::protobuf::ConnectParameters::Swap*;145 mir::protobuf::ConnectParameters::Swap*;
146 mir::protobuf::CoordinateTranslationRequest::ByteSize*;
147 mir::protobuf::CoordinateTranslationRequest::Clear*;
148 mir::protobuf::CoordinateTranslationRequest::?CoordinateTranslationRequest*;
149 mir::protobuf::CoordinateTranslationRequest::CoordinateTranslationRequest*;
150 mir::protobuf::CoordinateTranslationRequest::CopyFrom*;
151 mir::protobuf::CoordinateTranslationRequest::default_instance*;
152 mir::protobuf::CoordinateTranslationRequest::descriptor*;
153 mir::protobuf::CoordinateTranslationRequest::GetMetadata*;
154 mir::protobuf::CoordinateTranslationRequest::IsInitialized*;
155 mir::protobuf::CoordinateTranslationRequest::kSurfaceidFieldNumber*;
156 mir::protobuf::CoordinateTranslationRequest::kXFieldNumber*;
157 mir::protobuf::CoordinateTranslationRequest::kYFieldNumber*;
158 mir::protobuf::CoordinateTranslationRequest::MergeFrom*;
159 mir::protobuf::CoordinateTranslationRequest::MergePartialFromCodedStream*;
160 mir::protobuf::CoordinateTranslationRequest::New*;
161 mir::protobuf::CoordinateTranslationRequest::SerializeWithCachedSizes*;
162 mir::protobuf::CoordinateTranslationRequest::SerializeWithCachedSizesToArray*;
163 mir::protobuf::CoordinateTranslationRequest::Swap*;
164 mir::protobuf::CoordinateTranslationResponse::ByteSize*;
165 mir::protobuf::CoordinateTranslationResponse::Clear*;
166 mir::protobuf::CoordinateTranslationResponse::?CoordinateTranslationResponse*;
167 mir::protobuf::CoordinateTranslationResponse::CoordinateTranslationResponse*;
168 mir::protobuf::CoordinateTranslationResponse::CopyFrom*;
169 mir::protobuf::CoordinateTranslationResponse::default_instance*;
170 mir::protobuf::CoordinateTranslationResponse::descriptor*;
171 mir::protobuf::CoordinateTranslationResponse::GetMetadata*;
172 mir::protobuf::CoordinateTranslationResponse::IsInitialized*;
173 mir::protobuf::CoordinateTranslationResponse::kErrorFieldNumber*;
174 mir::protobuf::CoordinateTranslationResponse::kXFieldNumber*;
175 mir::protobuf::CoordinateTranslationResponse::kYFieldNumber*;
176 mir::protobuf::CoordinateTranslationResponse::MergeFrom*;
177 mir::protobuf::CoordinateTranslationResponse::MergePartialFromCodedStream*;
178 mir::protobuf::CoordinateTranslationResponse::New*;
179 mir::protobuf::CoordinateTranslationResponse::SerializeWithCachedSizes*;
180 mir::protobuf::CoordinateTranslationResponse::SerializeWithCachedSizesToArray*;
181 mir::protobuf::CoordinateTranslationResponse::Swap*;
146 mir::protobuf::CursorSetting::ByteSize*;182 mir::protobuf::CursorSetting::ByteSize*;
147 mir::protobuf::CursorSetting::Clear*;183 mir::protobuf::CursorSetting::Clear*;
148 mir::protobuf::CursorSetting::CopyFrom*;184 mir::protobuf::CursorSetting::CopyFrom*;
@@ -160,6 +196,16 @@
160 mir::protobuf::CursorSetting::SerializeWithCachedSizes*;196 mir::protobuf::CursorSetting::SerializeWithCachedSizes*;
161 mir::protobuf::CursorSetting::SerializeWithCachedSizesToArray*;197 mir::protobuf::CursorSetting::SerializeWithCachedSizesToArray*;
162 mir::protobuf::CursorSetting::Swap*;198 mir::protobuf::CursorSetting::Swap*;
199 mir::protobuf::Debug::CallMethod*;
200 mir::protobuf::Debug::?Debug*;
201 mir::protobuf::Debug::descriptor*;
202 mir::protobuf::Debug::GetDescriptor*;
203 mir::protobuf::Debug::GetRequestPrototype*;
204 mir::protobuf::Debug::GetResponsePrototype*;
205 mir::protobuf::Debug_Stub::?Debug_Stub*;
206 mir::protobuf::Debug_Stub::Debug_Stub*;
207 mir::protobuf::Debug_Stub::translate_surface_to_screen*;
208 mir::protobuf::Debug::translate_surface_to_screen*;
163 mir::protobuf::DisplayCard::ByteSize*;209 mir::protobuf::DisplayCard::ByteSize*;
164 mir::protobuf::DisplayCard::Clear*;210 mir::protobuf::DisplayCard::Clear*;
165 mir::protobuf::DisplayCard::CopyFrom*;211 mir::protobuf::DisplayCard::CopyFrom*;
@@ -780,7 +826,11 @@
780 typeinfo?for?mir::protobuf::BufferRequest;826 typeinfo?for?mir::protobuf::BufferRequest;
781 typeinfo?for?mir::protobuf::Connection;827 typeinfo?for?mir::protobuf::Connection;
782 typeinfo?for?mir::protobuf::ConnectParameters;828 typeinfo?for?mir::protobuf::ConnectParameters;
829 typeinfo?for?mir::protobuf::CoordinateTranslationRequest;
830 typeinfo?for?mir::protobuf::CoordinateTranslationResponse;
783 typeinfo?for?mir::protobuf::CursorSetting;831 typeinfo?for?mir::protobuf::CursorSetting;
832 typeinfo?for?mir::protobuf::Debug;
833 typeinfo?for?mir::protobuf::Debug_Stub;
784 typeinfo?for?mir::protobuf::DisplayCard;834 typeinfo?for?mir::protobuf::DisplayCard;
785 typeinfo?for?mir::protobuf::DisplayConfiguration;835 typeinfo?for?mir::protobuf::DisplayConfiguration;
786 typeinfo?for?mir::protobuf::DisplayInfo;836 typeinfo?for?mir::protobuf::DisplayInfo;
@@ -847,7 +897,11 @@
847 vtable?for?mir::protobuf::BufferRequest;897 vtable?for?mir::protobuf::BufferRequest;
848 vtable?for?mir::protobuf::Connection;898 vtable?for?mir::protobuf::Connection;
849 vtable?for?mir::protobuf::ConnectParameters;899 vtable?for?mir::protobuf::ConnectParameters;
900 vtable?for?mir::protobuf::CoordinateTranslationRequest;
901 vtable?for?mir::protobuf::CoordinateTranslationResponse;
850 vtable?for?mir::protobuf::CursorSetting;902 vtable?for?mir::protobuf::CursorSetting;
903 vtable?for?mir::protobuf::Debug;
904 vtable?for?mir::protobuf::Debug_Stub;
851 vtable?for?mir::protobuf::DisplayCard;905 vtable?for?mir::protobuf::DisplayCard;
852 vtable?for?mir::protobuf::DisplayConfiguration;906 vtable?for?mir::protobuf::DisplayConfiguration;
853 vtable?for?mir::protobuf::DisplayInfo;907 vtable?for?mir::protobuf::DisplayInfo;
854908
=== added file 'src/include/server/mir/frontend/unsupported_feature_exception.h'
--- src/include/server/mir/frontend/unsupported_feature_exception.h 1970-01-01 00:00:00 +0000
+++ src/include/server/mir/frontend/unsupported_feature_exception.h 2014-10-23 13:30:17 +0000
@@ -0,0 +1,41 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 */
18
19
20#ifndef MIR_FRONTEND_UNSUPPORTED_FEATURE_EXCEPTION_H_
21#define MIR_FRONTEND_UNSUPPORTED_FEATURE_EXCEPTION_H_
22
23#include <stdexcept>
24
25namespace mir
26{
27namespace frontend
28{
29class unsupported_feature : public std::runtime_error
30{
31public:
32 unsupported_feature()
33 : std::runtime_error{"Unsupported feature requested"}
34 {
35 }
36};
37}
38}
39
40
41#endif /* MIR_FRONTEND_UNSUPPORTED_FEATURE_EXCEPTION_H_ */
042
=== modified file 'src/platform/options/default_configuration.cpp'
--- src/platform/options/default_configuration.cpp 2014-10-01 06:25:56 +0000
+++ src/platform/options/default_configuration.cpp 2014-10-23 13:30:17 +0000
@@ -45,6 +45,7 @@
45char const* const mo::offscreen_opt = "offscreen";45char const* const mo::offscreen_opt = "offscreen";
46char const* const mo::touchspots_opt = "enable-touchspots";46char const* const mo::touchspots_opt = "enable-touchspots";
47char const* const mo::fatal_abort_opt = "on-fatal-error-abort";47char const* const mo::fatal_abort_opt = "on-fatal-error-abort";
48char const* const mo::debug_opt = "debug";
4849
49char const* const mo::glog = "glog";50char const* const mo::glog = "glog";
50char const* const mo::glog_stderrthreshold = "glog-stderrthreshold";51char const* const mo::glog_stderrthreshold = "glog-stderrthreshold";
@@ -164,7 +165,9 @@
164 (touchspots_opt,165 (touchspots_opt,
165 "Display visualization of touchspots (e.g. for screencasting).")166 "Display visualization of touchspots (e.g. for screencasting).")
166 (fatal_abort_opt, "On \"fatal error\" conditions [e.g. drivers behaving "167 (fatal_abort_opt, "On \"fatal error\" conditions [e.g. drivers behaving "
167 "in unexpected ways] abort (to get a core dump)");168 "in unexpected ways] abort (to get a core dump)")
169 (debug_opt, "Enable extra development debugging. "
170 "This is only interesting for people doing Mir server or client development.");
168171
169 add_platform_options();172 add_platform_options();
170}173}
171174
=== modified file 'src/platform/symbols.map'
--- src/platform/symbols.map 2014-10-21 16:21:14 +0000
+++ src/platform/symbols.map 2014-10-23 13:30:17 +0000
@@ -146,6 +146,7 @@
146 mir::options::DefaultConfiguration::parse_environment*;146 mir::options::DefaultConfiguration::parse_environment*;
147 mir::options::DefaultConfiguration::the_options*;147 mir::options::DefaultConfiguration::the_options*;
148 mir::options::display_report_opt*;148 mir::options::display_report_opt*;
149 mir::options::debug_opt*;
149 mir::options::enable_input_opt*;150 mir::options::enable_input_opt*;
150 mir::options::fatal_abort_opt*;151 mir::options::fatal_abort_opt*;
151 mir::options::frontend_threads_opt*;152 mir::options::frontend_threads_opt*;
152153
=== modified file 'src/server/frontend/CMakeLists.txt'
--- src/server/frontend/CMakeLists.txt 2014-10-01 06:25:56 +0000
+++ src/server/frontend/CMakeLists.txt 2014-10-23 13:30:17 +0000
@@ -22,6 +22,7 @@
22 session_credentials.cpp22 session_credentials.cpp
23 default_configuration.cpp23 default_configuration.cpp
24 default_ipc_factory.cpp24 default_ipc_factory.cpp
25 unsupported_coordinate_translator.cpp
25)26)
2627
27add_library(28add_library(
2829
=== modified file 'src/server/frontend/default_configuration.cpp'
--- src/server/frontend/default_configuration.cpp 2014-10-01 06:25:56 +0000
+++ src/server/frontend/default_configuration.cpp 2014-10-23 13:30:17 +0000
@@ -22,6 +22,8 @@
22#include "default_ipc_factory.h"22#include "default_ipc_factory.h"
23#include "published_socket_connector.h"23#include "published_socket_connector.h"
2424
25#include "unsupported_coordinate_translator.h"
26
25#include "mir/frontend/protobuf_connection_creator.h"27#include "mir/frontend/protobuf_connection_creator.h"
26#include "mir/frontend/session_authorizer.h"28#include "mir/frontend/session_authorizer.h"
27#include "mir/options/configuration.h"29#include "mir/options/configuration.h"
@@ -29,6 +31,7 @@
2931
30namespace mf = mir::frontend;32namespace mf = mir::frontend;
31namespace mg = mir::graphics;33namespace mg = mir::graphics;
34namespace ms = mir::scene;
3235
33std::shared_ptr<mf::ConnectionCreator>36std::shared_ptr<mf::ConnectionCreator>
34mir::DefaultServerConfiguration::the_connection_creator()37mir::DefaultServerConfiguration::the_connection_creator()
@@ -137,13 +140,23 @@
137mir::DefaultServerConfiguration::new_ipc_factory(140mir::DefaultServerConfiguration::new_ipc_factory(
138 std::shared_ptr<mf::SessionAuthorizer> const& session_authorizer)141 std::shared_ptr<mf::SessionAuthorizer> const& session_authorizer)
139{142{
143 std::shared_ptr<ms::CoordinateTranslator> translator;
144 if (the_options()->is_set(options::debug_opt))
145 {
146 translator = the_coordinate_translator();
147 }
148 else
149 {
150 translator = std::make_shared<mf::UnsupportedCoordinateTranslator>();
151 }
140 return std::make_shared<mf::DefaultIpcFactory>(152 return std::make_shared<mf::DefaultIpcFactory>(
141 the_frontend_shell(),153 the_frontend_shell(),
142 the_session_mediator_report(),154 the_session_mediator_report(),
143 the_graphics_platform(),155 the_graphics_platform(),
144 the_frontend_display_changer(),156 the_frontend_display_changer(),
145 the_buffer_allocator(),157 the_buffer_allocator(),
146 the_screencast(),158 the_screencast(),
147 session_authorizer,159 session_authorizer,
148 the_cursor_images());160 the_cursor_images(),
161 translator);
149}162}
150163
=== modified file 'src/server/frontend/default_ipc_factory.cpp'
--- src/server/frontend/default_ipc_factory.cpp 2014-10-01 06:25:56 +0000
+++ src/server/frontend/default_ipc_factory.cpp 2014-10-23 13:30:17 +0000
@@ -38,7 +38,8 @@
38 std::shared_ptr<mg::GraphicBufferAllocator> const& buffer_allocator,38 std::shared_ptr<mg::GraphicBufferAllocator> const& buffer_allocator,
39 std::shared_ptr<Screencast> const& screencast,39 std::shared_ptr<Screencast> const& screencast,
40 std::shared_ptr<SessionAuthorizer> const& session_authorizer,40 std::shared_ptr<SessionAuthorizer> const& session_authorizer,
41 std::shared_ptr<mi::CursorImages> const& cursor_images) :41 std::shared_ptr<mi::CursorImages> const& cursor_images,
42 std::shared_ptr<scene::CoordinateTranslator> const& translator) :
42 shell(shell),43 shell(shell),
43 no_prompt_shell(std::make_shared<NoPromptShell>(shell)),44 no_prompt_shell(std::make_shared<NoPromptShell>(shell)),
44 sm_report(sm_report),45 sm_report(sm_report),
@@ -48,7 +49,8 @@
48 buffer_allocator(buffer_allocator),49 buffer_allocator(buffer_allocator),
49 screencast(screencast),50 screencast(screencast),
50 session_authorizer(session_authorizer),51 session_authorizer(session_authorizer),
51 cursor_images(cursor_images)52 cursor_images(cursor_images),
53 translator{translator}
52{54{
53}55}
5456
@@ -120,5 +122,6 @@
120 resource_cache(),122 resource_cache(),
121 effective_screencast,123 effective_screencast,
122 connection_context,124 connection_context,
123 cursor_images);125 cursor_images,
126 translator);
124}127}
125128
=== modified file 'src/server/frontend/default_ipc_factory.h'
--- src/server/frontend/default_ipc_factory.h 2014-10-01 06:25:56 +0000
+++ src/server/frontend/default_ipc_factory.h 2014-10-23 13:30:17 +0000
@@ -33,6 +33,11 @@
33class CursorImages;33class CursorImages;
34}34}
3535
36namespace scene
37{
38class CoordinateTranslator;
39}
40
36namespace frontend41namespace frontend
37{42{
38class Shell;43class Shell;
@@ -52,7 +57,8 @@
52 std::shared_ptr<graphics::GraphicBufferAllocator> const& buffer_allocator,57 std::shared_ptr<graphics::GraphicBufferAllocator> const& buffer_allocator,
53 std::shared_ptr<Screencast> const& screencast,58 std::shared_ptr<Screencast> const& screencast,
54 std::shared_ptr<SessionAuthorizer> const& session_authorizer,59 std::shared_ptr<SessionAuthorizer> const& session_authorizer,
55 std::shared_ptr<input::CursorImages> const& cursor_images);60 std::shared_ptr<input::CursorImages> const& cursor_images,
61 std::shared_ptr<scene::CoordinateTranslator> const& translator);
5662
57 std::shared_ptr<detail::DisplayServer> make_ipc_server(63 std::shared_ptr<detail::DisplayServer> make_ipc_server(
58 SessionCredentials const& creds,64 SessionCredentials const& creds,
@@ -83,6 +89,7 @@
83 std::shared_ptr<Screencast> const screencast;89 std::shared_ptr<Screencast> const screencast;
84 std::shared_ptr<SessionAuthorizer> const session_authorizer;90 std::shared_ptr<SessionAuthorizer> const session_authorizer;
85 std::shared_ptr<input::CursorImages> const cursor_images;91 std::shared_ptr<input::CursorImages> const cursor_images;
92 std::shared_ptr<scene::CoordinateTranslator> const translator;
86};93};
87}94}
88}95}
8996
=== modified file 'src/server/frontend/protobuf_message_processor.cpp'
--- src/server/frontend/protobuf_message_processor.cpp 2014-10-22 18:55:40 +0000
+++ src/server/frontend/protobuf_message_processor.cpp 2014-10-23 13:30:17 +0000
@@ -21,6 +21,7 @@
21#include "mir/frontend/message_processor_report.h"21#include "mir/frontend/message_processor_report.h"
22#include "mir/frontend/protobuf_message_sender.h"22#include "mir/frontend/protobuf_message_sender.h"
23#include "mir/frontend/template_protobuf_message_processor.h"23#include "mir/frontend/template_protobuf_message_processor.h"
24#include "mir/frontend/unsupported_feature_exception.h"
2425
25#include "mir_protobuf_wire.pb.h"26#include "mir_protobuf_wire.pb.h"
2627
@@ -104,6 +105,24 @@
104 self->send_response(invocation.id(), result_message);105 self->send_response(invocation.id(), result_message);
105 }106 }
106}107}
108
109// A partial-specialisation to handle error cases.
110template<class Self, class ServerX, class ParameterMessage, class ResultMessage>
111void invoke(
112 Self* self,
113 std::string* error,
114 void (ServerX::*/*function*/)(
115 ::google::protobuf::RpcController* controller,
116 const ParameterMessage* request,
117 ResultMessage* response,
118 ::google::protobuf::Closure* done),
119 Invocation const& invocation)
120{
121 ResultMessage result_message;
122 result_message.set_error(error->c_str());
123 self->send_response(invocation.id(), &result_message);
124}
125
107}126}
108}127}
109}128}
@@ -206,6 +225,24 @@
206 invoke(this, display_server.get(), &DisplayServer::disconnect, invocation);225 invoke(this, display_server.get(), &DisplayServer::disconnect, invocation);
207 result = false;226 result = false;
208 }227 }
228 else if ("translate_surface_to_screen" == invocation.method_name())
229 {
230 try
231 {
232 auto debug_interface = dynamic_cast<mir::protobuf::Debug*>(display_server.get());
233 invoke(this, debug_interface, &mir::protobuf::Debug::translate_surface_to_screen, invocation);
234 }
235 catch (mir::frontend::unsupported_feature const&)
236 {
237 std::string message{"Server does not support the client debugging interface"};
238 invoke(this,
239 &message,
240 &mir::protobuf::Debug::translate_surface_to_screen,
241 invocation);
242 std::runtime_error err{"Client attempted to use unavailable debug interface"};
243 report->exception_handled(display_server.get(), invocation.id(), err);
244 }
245 }
209 else246 else
210 {247 {
211 report->unknown_method(display_server.get(), invocation.id(), invocation.method_name());248 report->unknown_method(display_server.get(), invocation.id(), invocation.method_name());
212249
=== modified file 'src/server/frontend/session_mediator.cpp'
--- src/server/frontend/session_mediator.cpp 2014-10-21 16:21:14 +0000
+++ src/server/frontend/session_mediator.cpp 2014-10-23 13:30:17 +0000
@@ -17,13 +17,13 @@
17 */17 */
1818
19#include "session_mediator.h"19#include "session_mediator.h"
20#include "client_buffer_tracker.h"
2120
22#include "mir/frontend/session_mediator_report.h"21#include "mir/frontend/session_mediator_report.h"
23#include "mir/frontend/shell.h"22#include "mir/frontend/shell.h"
24#include "mir/frontend/session.h"23#include "mir/frontend/session.h"
25#include "mir/frontend/surface.h"24#include "mir/frontend/surface.h"
26#include "mir/scene/surface_creation_parameters.h"25#include "mir/scene/surface_creation_parameters.h"
26#include "mir/scene/coordinate_translator.h"
27#include "mir/frontend/display_changer.h"27#include "mir/frontend/display_changer.h"
28#include "resource_cache.h"28#include "resource_cache.h"
29#include "mir_toolkit/common.h"29#include "mir_toolkit/common.h"
@@ -73,7 +73,8 @@
73 std::shared_ptr<MessageResourceCache> const& resource_cache,73 std::shared_ptr<MessageResourceCache> const& resource_cache,
74 std::shared_ptr<Screencast> const& screencast,74 std::shared_ptr<Screencast> const& screencast,
75 ConnectionContext const& connection_context,75 ConnectionContext const& connection_context,
76 std::shared_ptr<mi::CursorImages> const& cursor_images) :76 std::shared_ptr<mi::CursorImages> const& cursor_images,
77 std::shared_ptr<scene::CoordinateTranslator> const& translator) :
77 client_pid_(0),78 client_pid_(0),
78 shell(shell),79 shell(shell),
79 graphics_platform(graphics_platform),80 graphics_platform(graphics_platform),
@@ -86,6 +87,7 @@
86 screencast(screencast),87 screencast(screencast),
87 connection_context(connection_context),88 connection_context(connection_context),
88 cursor_images(cursor_images),89 cursor_images(cursor_images),
90 translator{translator},
89 surface_tracker{static_cast<size_t>(client_buffer_cache_size)}91 surface_tracker{static_cast<size_t>(client_buffer_cache_size)}
90{92{
91}93}
@@ -551,6 +553,32 @@
551 done->Run();553 done->Run();
552}554}
553555
556void mir::frontend::SessionMediator::translate_surface_to_screen(
557 ::google::protobuf::RpcController* ,
558 ::mir::protobuf::CoordinateTranslationRequest const* request,
559 ::mir::protobuf::CoordinateTranslationResponse* response,
560 ::google::protobuf::Closure *done)
561{
562 {
563 std::unique_lock<std::mutex> lock(session_mutex);
564
565 auto session = weak_session.lock();
566
567 if (session.get() == nullptr)
568 BOOST_THROW_EXCEPTION(std::logic_error("Invalid application session"));
569
570 auto const id = frontend::SurfaceId(request->surfaceid().value());
571
572 auto const coords = translator->surface_to_screen(session->get_surface(id),
573 request->x(),
574 request->y());
575
576 response->set_x(coords.x.as_uint32_t());
577 response->set_y(coords.y.as_uint32_t());
578 }
579 done->Run();
580}
581
554void mf::SessionMediator::drm_auth_magic(582void mf::SessionMediator::drm_auth_magic(
555 google::protobuf::RpcController* /*controller*/,583 google::protobuf::RpcController* /*controller*/,
556 const mir::protobuf::DRMMagic* request,584 const mir::protobuf::DRMMagic* request,
557585
=== modified file 'src/server/frontend/session_mediator.h'
--- src/server/frontend/session_mediator.h 2014-10-21 16:21:14 +0000
+++ src/server/frontend/session_mediator.h 2014-10-23 13:30:17 +0000
@@ -46,6 +46,11 @@
46class CursorImages;46class CursorImages;
47}47}
4848
49namespace scene
50{
51class CoordinateTranslator;
52}
53
49/// Frontend interface. Mediates the interaction between client54/// Frontend interface. Mediates the interaction between client
50/// processes and the core of the mir system.55/// processes and the core of the mir system.
51namespace frontend56namespace frontend
@@ -62,7 +67,7 @@
62class PromptSession;67class PromptSession;
6368
64// SessionMediator relays requests from the client process into the server.69// SessionMediator relays requests from the client process into the server.
65class SessionMediator : public detail::DisplayServer70class SessionMediator : public detail::DisplayServer, public mir::protobuf::Debug
66{71{
67public:72public:
6873
@@ -76,7 +81,8 @@
76 std::shared_ptr<MessageResourceCache> const& resource_cache,81 std::shared_ptr<MessageResourceCache> const& resource_cache,
77 std::shared_ptr<Screencast> const& screencast,82 std::shared_ptr<Screencast> const& screencast,
78 ConnectionContext const& connection_context,83 ConnectionContext const& connection_context,
79 std::shared_ptr<input::CursorImages> const& cursor_images);84 std::shared_ptr<input::CursorImages> const& cursor_images,
85 std::shared_ptr<scene::CoordinateTranslator> const& translator);
8086
81 ~SessionMediator() noexcept;87 ~SessionMediator() noexcept;
8288
@@ -167,6 +173,13 @@
167 ::mir::protobuf::SocketFD* response,173 ::mir::protobuf::SocketFD* response,
168 ::google::protobuf::Closure* done) override;174 ::google::protobuf::Closure* done) override;
169175
176 // TODO: Split this into a separate thing
177 void translate_surface_to_screen(
178 ::google::protobuf::RpcController* controller,
179 ::mir::protobuf::CoordinateTranslationRequest const* request,
180 ::mir::protobuf::CoordinateTranslationResponse* response,
181 ::google::protobuf::Closure *done) override;
182
170private:183private:
171 void pack_protobuf_buffer(protobuf::Buffer& protobuf_buffer,184 void pack_protobuf_buffer(protobuf::Buffer& protobuf_buffer,
172 graphics::Buffer* graphics_buffer,185 graphics::Buffer* graphics_buffer,
@@ -193,6 +206,7 @@
193 std::shared_ptr<Screencast> const screencast;206 std::shared_ptr<Screencast> const screencast;
194 ConnectionContext const connection_context;207 ConnectionContext const connection_context;
195 std::shared_ptr<input::CursorImages> const cursor_images;208 std::shared_ptr<input::CursorImages> const cursor_images;
209 std::shared_ptr<scene::CoordinateTranslator> const translator;
196210
197 SurfaceTracker surface_tracker;211 SurfaceTracker surface_tracker;
198212
199213
=== added file 'src/server/frontend/unsupported_coordinate_translator.cpp'
--- src/server/frontend/unsupported_coordinate_translator.cpp 1970-01-01 00:00:00 +0000
+++ src/server/frontend/unsupported_coordinate_translator.cpp 2014-10-23 13:30:17 +0000
@@ -0,0 +1,32 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 */
18
19#include "unsupported_coordinate_translator.h"
20#include "mir/frontend/unsupported_feature_exception.h"
21
22#include <boost/exception/all.hpp>
23
24namespace mg = mir::geometry;
25namespace mf = mir::frontend;
26
27mg::Point mf::UnsupportedCoordinateTranslator::surface_to_screen(
28 std::shared_ptr<mf::Surface> /*surface*/,
29 int32_t /*x*/, int32_t /*y*/)
30{
31 BOOST_THROW_EXCEPTION(mir::frontend::unsupported_feature());
32}
033
=== added file 'src/server/frontend/unsupported_coordinate_translator.h'
--- src/server/frontend/unsupported_coordinate_translator.h 1970-01-01 00:00:00 +0000
+++ src/server/frontend/unsupported_coordinate_translator.h 2014-10-23 13:30:17 +0000
@@ -0,0 +1,37 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 */
18
19#ifndef MIR_FRONTEND_UNSUPPORTED_COORDINATE_TRANSLATOR_H_
20#define MIR_FRONTEND_UNSUPPORTED_COORDINATE_TRANSLATOR_H_
21
22#include "mir/scene/coordinate_translator.h"
23
24namespace mir
25{
26namespace frontend
27{
28class UnsupportedCoordinateTranslator : public scene::CoordinateTranslator
29{
30 geometry::Point surface_to_screen(std::shared_ptr<Surface> surface,
31 int32_t x, int32_t y) override;
32};
33
34}
35}
36
37#endif // MIR_FRONTEND_UNSUPPORTED_COORDINATE_TRANSLATOR_H_
038
=== modified file 'src/server/scene/CMakeLists.txt'
--- src/server/scene/CMakeLists.txt 2014-10-01 06:25:56 +0000
+++ src/server/scene/CMakeLists.txt 2014-10-23 13:30:17 +0000
@@ -23,4 +23,5 @@
23 prompt_session_container.cpp23 prompt_session_container.cpp
24 prompt_session_manager_impl.cpp24 prompt_session_manager_impl.cpp
25 rendering_tracker.cpp25 rendering_tracker.cpp
26 default_coordinate_translator.cpp
26)27)
2728
=== modified file 'src/server/scene/default_configuration.cpp'
--- src/server/scene/default_configuration.cpp 2014-10-01 06:25:56 +0000
+++ src/server/scene/default_configuration.cpp 2014-10-23 13:30:17 +0000
@@ -36,6 +36,7 @@
36#include "surface_stack.h"36#include "surface_stack.h"
37#include "threaded_snapshot_strategy.h"37#include "threaded_snapshot_strategy.h"
38#include "prompt_session_manager_impl.h"38#include "prompt_session_manager_impl.h"
39#include "default_coordinate_translator.h"
3940
40namespace mc = mir::compositor;41namespace mc = mir::compositor;
41namespace mf = mir::frontend;42namespace mf = mir::frontend;
@@ -238,3 +239,13 @@
238 the_prompt_session_listener());239 the_prompt_session_listener());
239 });240 });
240}241}
242
243std::shared_ptr<ms::CoordinateTranslator>
244mir::DefaultServerConfiguration::the_coordinate_translator()
245{
246 return coordinate_translator(
247 [this]()
248 {
249 return std::make_shared<ms::DefaultCoordinateTranslator>();
250 });
251}
241252
=== added file 'src/server/scene/default_coordinate_translator.cpp'
--- src/server/scene/default_coordinate_translator.cpp 1970-01-01 00:00:00 +0000
+++ src/server/scene/default_coordinate_translator.cpp 2014-10-23 13:30:17 +0000
@@ -0,0 +1,32 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 */
18
19#include "default_coordinate_translator.h"
20#include "basic_surface.h"
21
22namespace geom = mir::geometry;
23namespace mf = mir::frontend;
24namespace ms = mir::scene;
25
26geom::Point ms::DefaultCoordinateTranslator::surface_to_screen(std::shared_ptr<mf::Surface> surface, int32_t x,
27 int32_t y)
28{
29 auto const scene_surface = std::dynamic_pointer_cast<ms::BasicSurface>(surface);
30
31 return geom::Point{x + scene_surface->top_left().x.as_int(), y + scene_surface->top_left().y.as_int()};
32}
033
=== added file 'src/server/scene/default_coordinate_translator.h'
--- src/server/scene/default_coordinate_translator.h 1970-01-01 00:00:00 +0000
+++ src/server/scene/default_coordinate_translator.h 2014-10-23 13:30:17 +0000
@@ -0,0 +1,37 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 */
18
19#ifndef MIR_FRONTEND_DEFAULT_COORDINATE_TRANSLATOR_H_
20#define MIR_FRONTEND_DEFAULT_COORDINATE_TRANSLATOR_H_
21
22#include "mir/scene/coordinate_translator.h"
23
24namespace mir
25{
26namespace scene
27{
28class DefaultCoordinateTranslator : public CoordinateTranslator
29{
30public:
31 geometry::Point surface_to_screen(std::shared_ptr<frontend::Surface> surface, int32_t x, int32_t y);
32};
33
34}
35}
36
37#endif // MIR_FRONTEND_DEFAULT_COORDINATE_TRANSLATOR_H_
038
=== modified file 'src/server/symbols.map'
--- src/server/symbols.map 2014-10-22 18:55:40 +0000
+++ src/server/symbols.map 2014-10-23 13:30:17 +0000
@@ -39,6 +39,7 @@
39 mir::DefaultServerConfiguration::the_connection_creator*;39 mir::DefaultServerConfiguration::the_connection_creator*;
40 mir::DefaultServerConfiguration::the_connector*;40 mir::DefaultServerConfiguration::the_connector*;
41 mir::DefaultServerConfiguration::the_connector_report*;41 mir::DefaultServerConfiguration::the_connector_report*;
42 mir::DefaultServerConfiguration::the_coordinate_translator*;
42 mir::DefaultServerConfiguration::the_cursor*;43 mir::DefaultServerConfiguration::the_cursor*;
43 mir::DefaultServerConfiguration::the_cursor_images*;44 mir::DefaultServerConfiguration::the_cursor_images*;
44 mir::DefaultServerConfiguration::the_cursor_listener*;45 mir::DefaultServerConfiguration::the_cursor_listener*;
@@ -244,6 +245,9 @@
244 mir::report_exception*;245 mir::report_exception*;
245 mir::run_mir*;246 mir::run_mir*;
246 mir::scene::a_surface*;247 mir::scene::a_surface*;
248 mir::scene::CoordinateTranslator::?CoordinateTranslator*;
249 mir::scene::CoordinateTranslator::CoordinateTranslator*;
250 mir::scene::CoordinateTranslator::surface_to_screen*;
247 mir::scene::NullSurfaceObserver::alpha_set_to*;251 mir::scene::NullSurfaceObserver::alpha_set_to*;
248 mir::scene::NullSurfaceObserver::attrib_changed*;252 mir::scene::NullSurfaceObserver::attrib_changed*;
249 mir::scene::NullSurfaceObserver::cursor_image_set_to*;253 mir::scene::NullSurfaceObserver::cursor_image_set_to*;
@@ -648,6 +652,7 @@
648 typeinfo?for?mir::input::TouchVisualizer;652 typeinfo?for?mir::input::TouchVisualizer;
649 typeinfo?for?mir::input::TouchVisualizer::Spot;653 typeinfo?for?mir::input::TouchVisualizer::Spot;
650 typeinfo?for?mir::MainLoop;654 typeinfo?for?mir::MainLoop;
655 typeinfo?for?mir::scene::CoordinateTranslator;
651 typeinfo?for?mir::scene::NullSurfaceObserver;656 typeinfo?for?mir::scene::NullSurfaceObserver;
652 typeinfo?for?mir::scene::Observer;657 typeinfo?for?mir::scene::Observer;
653 typeinfo?for?mir::scene::PlacementStrategy;658 typeinfo?for?mir::scene::PlacementStrategy;
@@ -706,6 +711,7 @@
706 vtable?for?mir::input::TouchVisualizer;711 vtable?for?mir::input::TouchVisualizer;
707 vtable?for?mir::input::TouchVisualizer::Spot;712 vtable?for?mir::input::TouchVisualizer::Spot;
708 vtable?for?mir::MainLoop;713 vtable?for?mir::MainLoop;
714 vtable?for?mir::scene::CoordinateTranslator;
709 vtable?for?mir::scene::NullSurfaceObserver;715 vtable?for?mir::scene::NullSurfaceObserver;
710 vtable?for?mir::scene::Observer;716 vtable?for?mir::scene::Observer;
711 vtable?for?mir::scene::PlacementStrategy;717 vtable?for?mir::scene::PlacementStrategy;
712718
=== modified file 'tests/acceptance-tests/CMakeLists.txt'
--- tests/acceptance-tests/CMakeLists.txt 2014-10-21 16:21:14 +0000
+++ tests/acceptance-tests/CMakeLists.txt 2014-10-23 13:30:17 +0000
@@ -42,6 +42,7 @@
42 test_server_without_active_outputs.cpp42 test_server_without_active_outputs.cpp
43 test_client_input.cpp43 test_client_input.cpp
44 test_server_startup.cpp44 test_server_startup.cpp
45 test_debug_api.cpp
45 test_unresponsive_client.cpp46 test_unresponsive_client.cpp
46)47)
4748
@@ -67,6 +68,7 @@
6768
68 mirserver69 mirserver
69 mirclient70 mirclient
71 mirclient-debug-extension
70 mirplatform72 mirplatform
7173
72 mir-test74 mir-test
7375
=== modified file 'tests/acceptance-tests/test_client_library.cpp'
--- tests/acceptance-tests/test_client_library.cpp 2014-10-21 16:21:14 +0000
+++ tests/acceptance-tests/test_client_library.cpp 2014-10-23 13:30:17 +0000
@@ -17,7 +17,6 @@
17 */17 */
1818
19#include "mir_toolkit/mir_client_library.h"19#include "mir_toolkit/mir_client_library.h"
20#include "mir_toolkit/mir_client_library_debug.h"
2120
22#include "mir_test_framework/stubbed_server_configuration.h"21#include "mir_test_framework/stubbed_server_configuration.h"
23#include "mir_test_framework/in_process_server.h"22#include "mir_test_framework/in_process_server.h"
2423
=== modified file 'tests/acceptance-tests/test_client_surface_events.cpp'
--- tests/acceptance-tests/test_client_surface_events.cpp 2014-10-01 06:25:56 +0000
+++ tests/acceptance-tests/test_client_surface_events.cpp 2014-10-23 13:30:17 +0000
@@ -17,7 +17,7 @@
17 */17 */
1818
19#include "mir_toolkit/mir_client_library.h"19#include "mir_toolkit/mir_client_library.h"
20#include "mir_toolkit/mir_client_library_debug.h"20#include "mir_toolkit/debug/surface.h"
2121
22#include "mir/shell/surface_coordinator_wrapper.h"22#include "mir/shell/surface_coordinator_wrapper.h"
2323
2424
=== modified file 'tests/acceptance-tests/test_client_surfaces.cpp'
--- tests/acceptance-tests/test_client_surfaces.cpp 2014-10-01 06:25:56 +0000
+++ tests/acceptance-tests/test_client_surfaces.cpp 2014-10-23 13:30:17 +0000
@@ -17,7 +17,7 @@
17 */17 */
1818
19#include "mir_toolkit/mir_client_library.h"19#include "mir_toolkit/mir_client_library.h"
20#include "mir_toolkit/mir_client_library_debug.h"20#include "mir_toolkit/debug/surface.h"
2121
22#include "mir_test_framework/stubbed_server_configuration.h"22#include "mir_test_framework/stubbed_server_configuration.h"
23#include "mir_test_framework/basic_client_server_fixture.h"23#include "mir_test_framework/basic_client_server_fixture.h"
2424
=== modified file 'tests/acceptance-tests/test_custom_input_dispatcher.cpp'
--- tests/acceptance-tests/test_custom_input_dispatcher.cpp 2014-10-01 06:25:56 +0000
+++ tests/acceptance-tests/test_custom_input_dispatcher.cpp 2014-10-23 13:30:17 +0000
@@ -133,7 +133,7 @@
133 // may be stopped before events have been dispatched.133 // may be stopped before events have been dispatched.
134 run_in_test_process([&]134 run_in_test_process([&]
135 {135 {
136 server_config.dispatching_done.wait_for_signal_ready_for(std::chrono::seconds{5});136 server_config.dispatching_done.wait_for_signal_ready_for(std::chrono::seconds{50});
137 });137 });
138}138}
139139
@@ -179,6 +179,6 @@
179 launch_client_process(client);179 launch_client_process(client);
180 run_in_test_process([&]180 run_in_test_process([&]
181 {181 {
182 server_config.dispatching_done.wait_for_signal_ready_for(std::chrono::seconds{5});182 server_config.dispatching_done.wait_for_signal_ready_for(std::chrono::seconds{50});
183 });183 });
184}184}
185185
=== added file 'tests/acceptance-tests/test_debug_api.cpp'
--- tests/acceptance-tests/test_debug_api.cpp 1970-01-01 00:00:00 +0000
+++ tests/acceptance-tests/test_debug_api.cpp 2014-10-23 13:30:17 +0000
@@ -0,0 +1,231 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 */
18
19#include "mir/options/option.h"
20#include "mir/scene/surface_creation_parameters.h"
21#include "mir/scene/placement_strategy.h"
22#include "mir/scene/surface.h"
23#include "src/server/scene/session_container.h"
24#include "mir/shell/surface_coordinator_wrapper.h"
25
26#include "mir_test/wait_condition.h"
27#include "mir_test/client_event_matchers.h"
28#include "mir_test/barrier.h"
29#include "mir_test_framework/deferred_in_process_server.h"
30#include "mir_test_framework/stubbed_server_configuration.h"
31
32#include "mir_toolkit/mir_client_library.h"
33#include "mir_toolkit/debug/surface.h"
34
35#include <gtest/gtest.h>
36#include <gmock/gmock.h>
37
38namespace ms = mir::scene;
39
40namespace mtf = mir_test_framework;
41
42namespace
43{
44class SimpleConfigurablePlacementStrategy : public ms::PlacementStrategy
45{
46public:
47 ms::SurfaceCreationParameters place(ms::Session const& /*session*/,
48 ms::SurfaceCreationParameters const& request_parameters) override
49 {
50 auto placed = request_parameters;
51 placed.top_left = placement.top_left;
52 placed.size = placement.size;
53 return placed;
54 }
55
56 mir::geometry::Rectangle placement;
57};
58
59class SurfacePlacingConfiguration : public mtf::StubbedServerConfiguration
60{
61public:
62 SurfacePlacingConfiguration()
63 : placement_strategy{std::make_shared<SimpleConfigurablePlacementStrategy>()}
64 {
65 }
66
67 std::shared_ptr<ms::PlacementStrategy> the_placement_strategy() override
68 {
69 return placement_strategy;
70 }
71
72 void set_surface_placement(mir::geometry::Rectangle const& where)
73 {
74 placement_strategy->placement = where;
75 }
76
77 bool is_debug_server()
78 {
79 return the_options()->is_set("debug");
80 }
81
82private:
83 std::shared_ptr<SimpleConfigurablePlacementStrategy> placement_strategy;
84};
85
86char const* debugenv = "MIR_SERVER_DEBUG";
87
88void dont_kill_me_bro(MirConnection* /*unused*/, MirLifecycleState /*unused*/, void* /*unused*/)
89{
90}
91
92class TestDebugAPI : public mtf::DeferredInProcessServer
93{
94public:
95 TestDebugAPI()
96 : old_debug_env{::getenv(debugenv)}
97 {
98 mir::geometry::Rectangle surface_location;
99 surface_location.top_left.x = mir::geometry::X{0};
100 surface_location.top_left.y = mir::geometry::Y{0};
101 surface_location.size.width = mir::geometry::Width{100};
102 surface_location.size.height = mir::geometry::Height{100};
103
104 server_configuration.set_surface_placement(surface_location);
105 }
106
107 ~TestDebugAPI()
108 {
109 ::unsetenv(debugenv);
110 if (old_debug_env)
111 {
112 ::setenv(debugenv, old_debug_env, 1);
113 }
114 }
115
116 void start_server_with_debug(bool debug)
117 {
118 if (debug)
119 {
120 ::setenv(debugenv, "", 1);
121 }
122 else
123 {
124 ::unsetenv(debugenv);
125 }
126
127 if (server_configuration.is_debug_server() != debug)
128 {
129 throw std::runtime_error{"Failed to set the debug flag correctly. Have you overriden this with --debug?"};
130 }
131
132 start_server();
133 connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
134 if (!mir_connection_is_valid(connection))
135 {
136 throw std::runtime_error{std::string{"Failed to connect to test server:"} +
137 mir_connection_get_error_message(connection)};
138 }
139 mir_connection_set_lifecycle_event_callback(connection, dont_kill_me_bro, nullptr);
140 }
141
142 void TearDown() override
143 {
144 if (connection)
145 {
146 mir_connection_release(connection);
147 }
148 DeferredInProcessServer::TearDown();
149 }
150
151 mir::DefaultServerConfiguration& server_config() override
152 {
153 return server_configuration;
154 }
155
156 SurfacePlacingConfiguration server_configuration;
157 MirConnection* connection{nullptr};
158
159private:
160 char const* old_debug_env;
161};
162}
163
164TEST_F(TestDebugAPI, TranslatesSurfaceCoordinatesToScreenCoordinates)
165{
166 start_server_with_debug(true);
167
168 mir::geometry::Rectangle surface_location;
169 surface_location.top_left.x = mir::geometry::X{200};
170 surface_location.top_left.y = mir::geometry::Y{100};
171 surface_location.size.width = mir::geometry::Width{800};
172 surface_location.size.height = mir::geometry::Height{600};
173
174 server_configuration.set_surface_placement(surface_location);
175
176 ASSERT_TRUE(mir_connection_is_valid(connection));
177
178 MirSurfaceParameters const creation_parameters = {
179 __PRETTY_FUNCTION__,
180 800, 600,
181 mir_pixel_format_argb_8888,
182 mir_buffer_usage_hardware,
183 mir_display_output_id_invalid
184 };
185 auto surf = mir_connection_create_surface_sync(connection, &creation_parameters);
186 ASSERT_TRUE(mir_surface_is_valid(surf));
187
188 int screen_x, screen_y, x, y;
189 x = 35, y = 21;
190
191 ASSERT_TRUE(mir_debug_surface_coords_to_screen(surf, x, y, &screen_x, &screen_y));
192 EXPECT_EQ(x + surface_location.top_left.x.as_int(), screen_x);
193 EXPECT_EQ(y + surface_location.top_left.y.as_int(), screen_y);
194
195 mir_surface_release_sync(surf);
196
197 surface_location.top_left.x = mir::geometry::X{100};
198 surface_location.top_left.y = mir::geometry::Y{250};
199
200 server_configuration.set_surface_placement(surface_location);
201
202 surf = mir_connection_create_surface_sync(connection, &creation_parameters);
203 ASSERT_TRUE(mir_surface_is_valid(surf));
204
205 ASSERT_TRUE(mir_debug_surface_coords_to_screen(surf, x, y, &screen_x, &screen_y));
206 EXPECT_EQ(x + surface_location.top_left.x.as_int(), screen_x);
207 EXPECT_EQ(y + surface_location.top_left.y.as_int(), screen_y);
208
209 mir_surface_release_sync(surf);
210}
211
212TEST_F(TestDebugAPI, ApiIsUnavaliableWhenServerNotStartedWithDebug)
213{
214 start_server_with_debug(false);
215
216 MirSurfaceParameters const creation_parameters = {
217 __PRETTY_FUNCTION__,
218 800, 600,
219 mir_pixel_format_argb_8888,
220 mir_buffer_usage_hardware,
221 mir_display_output_id_invalid
222 };
223 auto surf = mir_connection_create_surface_sync(connection, &creation_parameters);
224 ASSERT_TRUE(mir_surface_is_valid(surf));
225
226 int screen_x, screen_y;
227
228 EXPECT_FALSE(mir_debug_surface_coords_to_screen(surf, 0, 0, &screen_x, &screen_y));
229
230 mir_surface_release_sync(surf);
231}
0232
=== added file 'tests/include/mir_test_doubles/mock_coordinate_translator.h'
--- tests/include/mir_test_doubles/mock_coordinate_translator.h 1970-01-01 00:00:00 +0000
+++ tests/include/mir_test_doubles/mock_coordinate_translator.h 2014-10-23 13:30:17 +0000
@@ -0,0 +1,42 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 */
18
19#ifndef MIR_TEST_DOUBLES_MOCK_COORDINATE_TRANSLATOR_H_
20#define MIR_TEST_DOUBLES_MOCK_COORDINATE_TRANSLATOR_H_
21
22#include "src/server/frontend/coordinate_translator.h"
23
24#include <gmock/gmock.h>
25
26namespace mir
27{
28namespace test
29{
30namespace doubles
31{
32class MockCoordinateTranslator : public mir::frontend::CoordinateTranslator
33{
34 MOCK_METHOD3(surface_to_screen, geometry::Point(std::shared_ptr<frontend::Surface>, uint32_t, uint32_t));
35};
36
37using StubCoordinateTranslator = testing::NiceMock<MockCoordinateTranslator>;
38}
39}
40}
41
42#endif /* MIR_TEST_DOUBLES_MOCK_COORDINATE_TRANSLATOR_H_ */
043
=== modified file 'tests/include/mir_test_doubles/mock_surface.h'
--- tests/include/mir_test_doubles/mock_surface.h 2014-10-01 06:25:56 +0000
+++ tests/include/mir_test_doubles/mock_surface.h 2014-10-23 13:30:17 +0000
@@ -21,6 +21,7 @@
2121
22#include "src/server/scene/basic_surface.h"22#include "src/server/scene/basic_surface.h"
23#include "src/server/report/null_report_factory.h"23#include "src/server/report/null_report_factory.h"
24#include "mock_buffer_stream.h"
2425
25#include <gmock/gmock.h>26#include <gmock/gmock.h>
2627
@@ -38,7 +39,7 @@
38 {},39 {},
39 {{},{}},40 {{},{}},
40 true,41 true,
41 {},42 std::make_shared<testing::NiceMock<MockBufferStream>>(),
42 {},43 {},
43 {},44 {},
44 {},45 {},
4546
=== modified file 'tests/integration-tests/CMakeLists.txt'
--- tests/integration-tests/CMakeLists.txt 2014-10-21 16:21:14 +0000
+++ tests/integration-tests/CMakeLists.txt 2014-10-23 13:30:17 +0000
@@ -82,6 +82,7 @@
82 mir-test82 mir-test
83 mir-test-framework83 mir-test-framework
84 mir-test-doubles84 mir-test-doubles
85 mirclient-debug-extension
8586
86 mirdraw87 mirdraw
87 mirtestdraw88 mirtestdraw
8889
=== modified file 'tests/integration-tests/test_stale_frames.cpp'
--- tests/integration-tests/test_stale_frames.cpp 2014-10-21 16:21:14 +0000
+++ tests/integration-tests/test_stale_frames.cpp 2014-10-23 13:30:17 +0000
@@ -17,7 +17,7 @@
17 */17 */
1818
19#include "mir_toolkit/mir_client_library.h"19#include "mir_toolkit/mir_client_library.h"
20#include "mir_toolkit/mir_client_library_debug.h"20#include "mir_toolkit/debug/surface.h"
2121
22#include "mir/compositor/compositor.h"22#include "mir/compositor/compositor.h"
23#include "mir/compositor/renderer_factory.h"23#include "mir/compositor/renderer_factory.h"
2424
=== modified file 'tests/unit-tests/frontend/test_session_mediator.cpp'
--- tests/unit-tests/frontend/test_session_mediator.cpp 2014-10-21 16:21:14 +0000
+++ tests/unit-tests/frontend/test_session_mediator.cpp 2014-10-23 13:30:17 +0000
@@ -259,7 +259,7 @@
259 shell, graphics_platform, graphics_changer,259 shell, graphics_platform, graphics_changer,
260 surface_pixel_formats, report,260 surface_pixel_formats, report,
261 std::make_shared<mtd::NullEventSink>(),261 std::make_shared<mtd::NullEventSink>(),
262 resource_cache, stub_screencast, &connector, nullptr}262 resource_cache, stub_screencast, &connector, nullptr, nullptr}
263 {263 {
264 using namespace ::testing;264 using namespace ::testing;
265265
@@ -316,7 +316,7 @@
316 shell, graphics_platform, graphics_changer,316 shell, graphics_platform, graphics_changer,
317 surface_pixel_formats, report,317 surface_pixel_formats, report,
318 std::make_shared<mtd::NullEventSink>(),318 std::make_shared<mtd::NullEventSink>(),
319 resource_cache, stub_screencast, context, nullptr};319 resource_cache, stub_screencast, context, nullptr, nullptr};
320320
321 EXPECT_THAT(connects_handled_count, Eq(0));321 EXPECT_THAT(connects_handled_count, Eq(0));
322322
@@ -421,7 +421,7 @@
421 surface_pixel_formats, report,421 surface_pixel_formats, report,
422 std::make_shared<mtd::NullEventSink>(),422 std::make_shared<mtd::NullEventSink>(),
423 resource_cache, std::make_shared<mtd::NullScreencast>(),423 resource_cache, std::make_shared<mtd::NullScreencast>(),
424 nullptr, nullptr);424 nullptr, nullptr, nullptr);
425 mediator.connect(nullptr, &connect_parameters, &connection, null_callback.get());425 mediator.connect(nullptr, &connect_parameters, &connection, null_callback.get());
426426
427 EXPECT_THAT(connection.display_configuration(), mt::DisplayConfigMatches(std::cref(config)));427 EXPECT_THAT(connection.display_configuration(), mt::DisplayConfigMatches(std::cref(config)));
@@ -629,7 +629,7 @@
629 surface_pixel_formats, report,629 surface_pixel_formats, report,
630 std::make_shared<mtd::NullEventSink>(), resource_cache,630 std::make_shared<mtd::NullEventSink>(), resource_cache,
631 std::make_shared<mtd::NullScreencast>(),631 std::make_shared<mtd::NullScreencast>(),
632 nullptr, nullptr};632 nullptr, nullptr, nullptr};
633633
634 mediator.connect(nullptr, &connect_parameters, &connection, null_callback.get());634 mediator.connect(nullptr, &connect_parameters, &connection, null_callback.get());
635635
@@ -876,7 +876,7 @@
876 shell, graphics_platform, graphics_changer,876 shell, graphics_platform, graphics_changer,
877 surface_pixel_formats, report,877 surface_pixel_formats, report,
878 std::make_shared<mtd::NullEventSink>(),878 std::make_shared<mtd::NullEventSink>(),
879 mt::fake_shared(mock_cache), stub_screencast, nullptr, nullptr};879 mt::fake_shared(mock_cache), stub_screencast, &connector, nullptr, nullptr};
880880
881 mediator.connect(nullptr, &connect_parameters, &connection, null_callback.get());881 mediator.connect(nullptr, &connect_parameters, &connection, null_callback.get());
882 mediator.create_surface(nullptr, &surface_parameters, &surface_response, null_callback.get());882 mediator.create_surface(nullptr, &surface_parameters, &surface_response, null_callback.get());
883883
=== modified file 'tests/unit-tests/frontend/test_session_mediator_android.cpp'
--- tests/unit-tests/frontend/test_session_mediator_android.cpp 2014-10-01 06:25:56 +0000
+++ tests/unit-tests/frontend/test_session_mediator_android.cpp 2014-10-23 13:30:17 +0000
@@ -61,7 +61,7 @@
61 mediator{shell, graphics_platform, display_changer,61 mediator{shell, graphics_platform, display_changer,
62 surface_pixel_formats, report,62 surface_pixel_formats, report,
63 std::make_shared<mtd::NullEventSink>(),63 std::make_shared<mtd::NullEventSink>(),
64 resource_cache, std::make_shared<mtd::NullScreencast>(), nullptr, nullptr},64 resource_cache, std::make_shared<mtd::NullScreencast>(), nullptr, nullptr, nullptr},
65 null_callback{google::protobuf::NewPermanentCallback(google::protobuf::DoNothing)}65 null_callback{google::protobuf::NewPermanentCallback(google::protobuf::DoNothing)}
66 {66 {
67 }67 }
6868
=== modified file 'tests/unit-tests/frontend/test_session_mediator_mesa.cpp'
--- tests/unit-tests/frontend/test_session_mediator_mesa.cpp 2014-10-21 16:21:14 +0000
+++ tests/unit-tests/frontend/test_session_mediator_mesa.cpp 2014-10-23 13:30:17 +0000
@@ -74,7 +74,8 @@
74 mediator{shell, mock_platform, display_changer,74 mediator{shell, mock_platform, display_changer,
75 surface_pixel_formats, report,75 surface_pixel_formats, report,
76 std::make_shared<mtd::NullEventSink>(),76 std::make_shared<mtd::NullEventSink>(),
77 resource_cache, std::make_shared<mtd::NullScreencast>(), nullptr, nullptr},77 resource_cache, std::make_shared<mtd::NullScreencast>(), nullptr, nullptr,
78 nullptr},
78 null_callback{google::protobuf::NewPermanentCallback(google::protobuf::DoNothing)}79 null_callback{google::protobuf::NewPermanentCallback(google::protobuf::DoNothing)}
79 {80 {
80 }81 }

Subscribers

People subscribed via source and target branches