Mir

Merge lp:~vanvugt/mir/surface-types into lp:~mir-team/mir/trunk

Proposed by Daniel van Vugt
Status: Merged
Approved by: Daniel van Vugt
Approved revision: no longer in the source branch.
Merged at revision: 526
Proposed branch: lp:~vanvugt/mir/surface-types
Merge into: lp:~mir-team/mir/trunk
Diff against target: 854 lines (+460/-1)
30 files modified
debian/control (+12/-0)
debian/mircommon-dev.install (+1/-0)
include/client/mir_toolkit/mir_client_library.h (+19/-0)
include/server/mir/frontend/session.h (+3/-0)
include/server/mir/frontend/session_mediator.h (+5/-0)
include/server/mir/frontend/session_mediator_report.h (+4/-0)
include/server/mir/frontend/surface.h (+3/-0)
include/server/mir/logging/session_mediator_report.h (+2/-0)
include/server/mir/shell/application_session.h (+2/-0)
include/shared/mir_toolkit/common.h (+49/-0)
include/test/mir_test_doubles/mock_session.h (+2/-0)
include/test/mir_test_doubles/mock_surface.h (+2/-0)
include/test/mir_test_doubles/stub_session.h (+4/-0)
include/test/mir_test_doubles/stub_surface.h (+5/-0)
src/client/mir_client_library.cpp (+22/-0)
src/client/mir_surface.cpp (+47/-0)
src/client/mir_surface.h (+11/-0)
src/server/frontend/null_session_mediator_report.cpp (+4/-0)
src/server/frontend/protobuf_message_processor.cpp (+4/-0)
src/server/frontend/session_mediator.cpp (+27/-0)
src/server/logging/session_mediator_report.cpp (+5/-0)
src/server/shell/application_session.cpp (+10/-0)
src/server/shell/surface.cpp (+45/-1)
src/server/shell/surface.h (+8/-0)
src/shared/CMakeLists.txt (+10/-0)
src/shared/protobuf/mir_protobuf.proto (+10/-0)
tests/acceptance-tests/test_client_library.cpp (+74/-0)
tests/integration-tests/cucumber/test_session_management_context.cpp (+2/-0)
tests/unit-tests/client/test_client_mir_surface.cpp (+20/-0)
tests/unit-tests/shell/test_surface.cpp (+48/-0)
To merge this branch: bzr merge lp:~vanvugt/mir/surface-types
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Robert Carr (community) Needs Fixing
Alan Griffiths Approve
Robert Ancell Approve
Review via email: mp+154261@code.launchpad.net

This proposal supersedes a proposal from 2013-03-15.

Commit message

Add support for surface types (client API, protocol and server).

This work will also form the foundation of supporting surface states.

Description of the change

Fixed conflicts from nightly upstream landings. Also moved type out of surfaces::Surface and into shell::Surface.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal

PASSED: Continuous integration, rev:554
http://jenkins.qa.ubuntu.com/job/mir-ci/69/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-quantal-amd64-ci/70//console

Click here to trigger a rebuild:
http://jenkins.qa.ubuntu.com/job/mir-ci/69//rebuild/?

review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

I don't think that surfaces::Surface needs configure(MirSurfaceAttrib attrib, int value) - AFICS attributes are a feature of shell::Surface. (And, as discussed elsewhere, surfaces::ProxySurface belongs in shell, possibly as shell::Window.)

~~~~

90 +

Trailing whitespace.

~~~~

216 === added file 'include/shared/mir/common.h'

This is not the place for parts of the toolkit API - this is for namespace mir

review: Needs Fixing
Revision history for this message
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

Is there a clear distinction between SurfaceSetting and SurfaceParameters? (And is it worth supplying SurfaceSetting to create_surface and avoiding a round-trip?)

Revision history for this message
Kevin DuBois (kdub) wrote : Posted in a previous version of this proposal

the new surface type get/set for client api looks ok to me

The acceptance test takes quite a while on the galaxy nexus, perhaps it can be shortened by using less iterations in line 757?
[ RUN ] DefaultDisplayServerTestFixture.surface_types
[ OK ] DefaultDisplayServerTestFixture.surface_types (1384 ms)
(i see about 180ms on my desktop)

small nit but with
615 +int ms::Surface::configure(MirSurfaceAttrib attrib, int value)
the name 'configure' didn't make it obvious what is going on in the function.

Also with this function, (related to the comment in it) is the surface type something that mir cares about, or the shell? This is tricky to talk about without a 'shell api', but its still a bit hazy to me what our requirements for tracking the data that the shell cares about.

although the tests look good, they do have multiple testing expectations in them because they are long.

Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Alan,

Extraneous "configure" methods:
I only added methods where I absolutely needed to, to make the code compile and run. However that was many revisions ago so I'll check to see if it's still required...

Trailing whitespace at line 90:
Will fix now.

216 === added file 'include/shared/mir/common.h'
"common.h" is not part of the "toolkit". It is used by the client toolkit and in the server.

SurfaceSetting vs SurfaceParameters
Yes they will always be different. SurfaceParameters are required information to create a surface. SurfaceSetting is something you might optionally change later; like type, state, hidden, width, height (most of which are not implemented yet but require this branch to land first).

Kevin,

Stress test takes too long:
I think 1.3 seconds is OK for a stress test, but I can shorten it if you really want.

"configure" is not self explanatory:
I kind of agree but have not yet thought of a better method name other than "set_attribute" (making the protocol call something like "set_surface_attribute"). I prefer "configure_surface". More suggestions?

Who cares about surface type?...
You're absolutely right that surface type is something only the shell will care about and act upon. However for consistency between different shells and avoiding duplication, it is reasonable for the server to store the type value in each server surface instance. Even though it will only be used by the shell. This will change as new attributes are added like "state" which will potentially be used by the server directly.

Test length:
Yes, I will always make code as concise as possible without hurting readability.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Minor fixes done.

Alan -
I can put "common.h" anywhere of course. Just remember:
  1. It's not part of the "toolkit". "toolkit" means client-only but "common.h" is also used in the server and shell.
  2. common.h has to be installed under "include/mir/..." to make it clear to external users that it's part of mir. And it is implicitly in the "mir" namespace by virtue of the "Mir" type prefixes. We can't use "namespace mir" however because it is C code, not C++.

Alan & Kevin -
I agree that "type" is not a deep server-level attribute. It only makes sense at the shell level. I could move it out of surfaces::Surface now, and into a proxy class. However I think that should be done later because the "Proxy" classes clearly need some refactoring, everyone seems to agree. I'd rather not make assumptions about what form that will take and move any members into *ProxySurface until that's done.

Also keep in mind that _most_ future configurable attributes (state, hidden, width, height etc) will be low-level and live in the server surfaces::Surface rather than the shell.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

> Minor fixes done.
>
> Alan -
> I can put "common.h" anywhere of course. Just remember:
> 1. It's not part of the "toolkit". "toolkit" means client-only but
> "common.h" is also used in the server and shell.
> 2. common.h has to be installed under "include/mir/..." to make it clear to
> external users that it's part of mir. And it is implicitly in the "mir"
> namespace by virtue of the "Mir" type prefixes. We can't use "namespace mir"
> however because it is C code, not C++.

As it is included by toolkit I think it is part of toolkit. If it were really "part of mir", then there would be no reason for it to be C code. (Is it part of some hypothetical "common" that we've just identified - if so, is "common.h" isn't a good name.)

> Alan & Kevin -
> I agree that "type" is not a deep server-level attribute. It only makes sense
> at the shell level. I could move it out of surfaces::Surface now, and into a
> proxy class. However I think that should be done later because the "Proxy"
> classes clearly need some refactoring, everyone seems to agree. I'd rather not
> make assumptions about what form that will take and move any members into
> *ProxySurface until that's done.

Perhaps it is best to wait on that refactoring and reassess after that?

> Also keep in mind that _most_ future configurable attributes (state, hidden,
> width, height etc) will be low-level and live in the server surfaces::Surface
> rather than the shell.

Are you envisaging using the same mechanism?

Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Absolutely, all attributes that can be changed after construction will use configure() eventually.

Please consider landing this branch before any ProxySurface refactoring. I am tired of fixing conflicts and refactoring it every day.

Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Also, these arguments are blocking me from starting on two other deliverables which will depend on this work.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

> Absolutely, all attributes that can be changed after construction will use
> configure() eventually.

Does that imply that e.g. you see resizing happening by setting the width and height in two configure calls? I'm not sure that is a good plan.

Why wouldn't there be a single resize(graphics::Size) call?

> Please consider landing this branch before any ProxySurface refactoring. I am
> tired of fixing conflicts and refactoring it every day.

I'm equally tired of reviewing it every day - there has to be a better way to communicate.

Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Good point. Width/height are bad examples. But I will reuse configure() for surface states soon.

Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

I tried moving common.h to: include/shared/mir_toolkit/common.h
But that fails for reasons alluded to earlier. That is such common headers need to have the same relative path in the source tree as in the install tree. Because mir_client_library.h has to be able to find common.h in both situations.

Any suggestions?

Revision history for this message
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

> I tried moving common.h to: include/shared/mir_toolkit/common.h
> But that fails for reasons alluded to earlier. That is such common headers
> need to have the same relative path in the source tree as in the install tree.
> Because mir_client_library.h has to be able to find common.h in both
> situations.
>
> Any suggestions?

I guess this comes as part of the various problems with directory names.

IMO include/shared/mir_toolkit and include/client/mir_toolkit should be installed to <target>/mir_toolkit - and that would facilitate #include <mir_toolkit/common.h>

Revision history for this message
Kevin DuBois (kdub) wrote : Posted in a previous version of this proposal

>
> I guess this comes as part of the various problems with directory names.
>
> IMO include/shared/mir_toolkit and include/client/mir_toolkit should be
> installed to <target>/mir_toolkit - and that would facilitate #include
> <mir_toolkit/common.h>

+1

Revision history for this message
Alexandros Frantzis (afrantzis) wrote : Posted in a previous version of this proposal

== include/shared/mir vs include/shared/mir_toolkit ==

The concept is that whatever is under */mir_toolkit (and only that) will be part of the toolkit interface. Since a toolkit/client needs this, mir_toolkit is the way to go. Keep in mind that this is still under shared/.

So, this is how I see things currently:

1. server/*, client/*, shared/* => which mir components need to access the definitions in the file
2. */mir, */mir_toolkit => whether the definitions are internal to mir, or (also) exposed to the toolkit API

== surfaces::Surface::set_type(),type() ==

I agree that this doesn't belong there. I don't have a problem putting it there *temporarily* to unblock work, if the related surface refactorings aren't expected to be done soon.

== configure() ==

At the Surface level, and for the limited number of attributes I am aware of, I would prefer to have explicit calls : app_session->set_surface_state(id, ...) or app_session->surface(id)->set_state(...) (since we are already exposing the surface) etc

At the RPC level: one approach is to use configure(attrib, value), another is to have <attrib>(value) calls. A third approach (not neccessarily preferable for this use case, just mentioning it for completeness) is to have, e.g.:

message SurfaceSettings {
    optional SurfaceId surfaceid = 1;
    optional int32 type = 2;
    optional int32 state = 3;
    optional bool visible = 4;
    ...
}

The frontend could then act depending on which values are actually included in the message. This method allows the client to set and retrieve all of the settings in one go.

For the number of attributes and the use cases I am aware of, my preference would be once again to be explicit, and have separate calls <attrib>().

Marking as "Needs information" => "Needs discussion"

review: Needs Information
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

I thought it was implicit that having two different top-level include directories:
  <mir/foo>
  <mir_toolkit/bar>
was obviously a bad idea. I thought that was obvious but clearly it's just my opinion now. I think eventually everything should be under "mir/" for consistency:
  <mir/foo>
  <mir/toolkit/bar>
But that's a cleanup for a another day and a different proposal.

Alexandros:
configure() needs to be generic because there are so many layers of classes in the Mir code, it does not scale to add a new function for every attribute at every layer. When I added configure() I was surprised at how many classes I had to modify. It becomes unmaintainable and excessively over-complicated if you have to do that again and again for each new attribute. Consider also reporting -- we don't want to change every type of report to add new methods to those every time a new attribute is added.
Also, we should not assume to have designed all the required attributes any time soon. New attributes will be added and some even removed over time. We don't want to go changing the protocol and half a dozen foundational classes each time.

Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

I've now been working on this branch for a month and it's been under review for two weeks. It has worked perfectly without bugs for the entire duration. Remember we're only arguing about style issues that can be fixed later.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

8 +Package: mircommon-dev

I don't think this is right as it stands - but that is probably part of a pre-existing problem with the install packages and directory structure.

We need to be able to install the client process toolkit headers. (shared/mir_toolkit/* + client/mir_toolkit/*)

We need to be able to install the server process toolkit headers. (shared/mir_toolkit/* + server/mir_toolkit/*)

We need to be able to install for building against the library headers. (shared/mir/* + server/mir/* + shared/mir_toolkit/common.h)

I don't have a better proposal to hand, but something needs fixing.

~~~~

As I've said before I don't think that surfaces::Surface needs configure(MirSurfaceAttrib attrib, int value) - AFICS attributes are a feature of shell::Surface.

But I guess we can delete it a few minutes after it lands.

review: Abstain
Revision history for this message
Robert Ancell (robert-ancell) wrote : Posted in a previous version of this proposal

I'm unsure about why we have mircommon, but that can be solved outside of this.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

I might be able to install "common.h" twice; for client and server. Thus eliminating the mircommon-dev package. If you want me to give it a go?.. But there's obviously redundancy doing that.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

I think we need a discussion about the different user code targets we want to support and organizing headers to support them. But this MP isn't the place for it.

I'd still prefer not putting attributes that belong on shell::Surface onto surface::Surface.

Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Work in progress again. As happens every day, there are conflicts from upstream I need to resolve.

I will also re-visit the shell::Surface discussion now that shell::Surface actually exists.

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

I'm not sure if these are consistent:

316 + // I assume the type can only change from the client side. Otherwise
317 + // we would have to send off a message to retrieve the latest...
...
619 + bool set_type(MirSurfaceType t);

This is a public member function - that suggest that it could, potentially, be called other than as the result of a call from a client process.

Also, given the expectation of using a graphics toolkit within the server process is "client side" the right terminology?

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

820 + EXPECT_EQ(surf.configure(mir_surface_attrib_type,
821 + mir_surface_type_popover),
822 + mir_surface_type_popover);

Expected and actual reversed

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

Alan's concerns addressed.

And if you want to be that pedantic about gtest syntax, see bug 1149157.

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

> Alan's concerns addressed.
>
> And if you want to be that pedantic about gtest syntax, see bug 1149157.

My "concern" is about getting clear output from a test failure.

If I wanted to be pedantic I'd "Need Fixing" the tests that don't test a single thing described by the test name.

review: Approve
Revision history for this message
Robert Carr (robertcarr) wrote :

Looks good! excited to get surface attributes in.

Some minor style nits:

>>+/**
>>+ * Set the type (purpose) of a surface. This is not guaranteed to always work
>>+ * with some shell types (e.g. phone/tablet UIs). As such, you may have to
>>+ * wait on the function and check the result using mir_surface_get_type.
>>+ * \param [in] surface The surface to operate on
>>+ * \param [in] type The new type of the surface
>>+ * \return A wait handle that can be passed to mir_wait_for
>>+ */

Only nitting here because it's public header. I found this a little confusing to read (i.e. mention of phone/tablet is a little distracting). I would write it like this:

"Set the type (role) of a surface. Success of this operation is dependent on server policy. As such, you may have to wait on the function and check the result using mir_suface_get_type"

>>+ mir_surface_type_arraysize_
Do we do this elsewhere (trailing underscore), should we?

>> 427:
I find the continuous mention in comments and the variable attrib_cache of "cache" confusing. In this sense of the word cache, mir_toolkit:MirSurface itself is a cache of the latest Surface state returned from the server. Reading cache here makes me think there is some extra caching behavior going on, whereas really it's no different than surface geometry!

Revision history for this message
Robert Carr (robertcarr) wrote :

>> 477:
I can't find the test for this

review: Needs Information
Revision history for this message
Robert Carr (robertcarr) wrote :

>> 305:
Whitespace

>> 821:

This would be more in line with the rest of the code style if there were a few tests:

TEST_F(ShellSurface, default_surface_type_is_normal)
TEST_F(ShellSurface, takes_surface_type_from_configure)
TEST_F(ShellSurface, invalid_surface_type_throw_behavior)

This would improve the failure output significantly I think

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

racarr,

comment confusion: Yeah easy to fix, later.

mir_surface_type_arraysize_: This is similar to a convention I have used for a long time. There is no precedent in the mir source AFAIK. It is adapted from the original version I proposed 3 weeks ago: "MirSurfaceType_ARRAYSIZE" which is the style Google uses in protobuf.

427: Comments can be clarified. But not worth a reproposal.

477: The test for the whole configure_surface stack is covered by:
TEST_F(DefaultDisplayServerTestFixture, surface_types)

305: That indentation is no mistake. I moved it to stay within 80 columns.

821: I am adjusting my style to suit you guys. It won't happen over night but it is happening. I don't think this is a blocker.

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 'debian/control'
--- debian/control 2013-03-12 03:50:42 +0000
+++ debian/control 2013-03-21 04:05:24 +0000
@@ -58,11 +58,22 @@
58 .58 .
59 Contains the shared library needed by server applications for Mir.59 Contains the shared library needed by server applications for Mir.
6060
61Package: mircommon-dev
62Section: libdevel
63Architecture: any
64Depends: ${misc:Depends},
65Description: Display server for Ubuntu - development headers
66 Mir is a display server running on linux systems, with a focus on efficiency,
67 robust operation and a well-defined driver model.
68 .
69 Contains header files required for server and/or client development.
70
61Package: libmirserver-dev71Package: libmirserver-dev
62Section: libdevel72Section: libdevel
63Architecture: any73Architecture: any
64Depends: libmirserver0 (= ${binary:Version}),74Depends: libmirserver0 (= ${binary:Version}),
65 libmirprotobuf-dev (= ${source:Version}),75 libmirprotobuf-dev (= ${source:Version}),
76 mircommon-dev (= ${source:Version}),
66 ${misc:Depends},77 ${misc:Depends},
67Description: Display server for Ubuntu - development headers78Description: Display server for Ubuntu - development headers
68 Mir is a display server running on linux systems, with a focus on efficiency,79 Mir is a display server running on linux systems, with a focus on efficiency,
@@ -86,6 +97,7 @@
86Architecture: any97Architecture: any
87Depends: libmirclient0 (= ${binary:Version}),98Depends: libmirclient0 (= ${binary:Version}),
88 libmirprotobuf-dev (= ${source:Version}),99 libmirprotobuf-dev (= ${source:Version}),
100 mircommon-dev (= ${source:Version}),
89 ${misc:Depends},101 ${misc:Depends},
90Description: Display server for Ubuntu - development headers102Description: Display server for Ubuntu - development headers
91 Mir is a display server running on linux systems, with a focus on efficiency,103 Mir is a display server running on linux systems, with a focus on efficiency,
92104
=== added file 'debian/mircommon-dev.install'
--- debian/mircommon-dev.install 1970-01-01 00:00:00 +0000
+++ debian/mircommon-dev.install 2013-03-21 04:05:24 +0000
@@ -0,0 +1,1 @@
1usr/include/mir_toolkit/*.h
02
=== modified file 'include/client/mir_toolkit/mir_client_library.h'
--- include/client/mir_toolkit/mir_client_library.h 2013-03-20 10:26:48 +0000
+++ include/client/mir_toolkit/mir_client_library.h 2013-03-21 04:05:24 +0000
@@ -18,6 +18,8 @@
18#ifndef MIR_CLIENT_LIBRARY_H18#ifndef MIR_CLIENT_LIBRARY_H
19#define MIR_CLIENT_LIBRARY_H19#define MIR_CLIENT_LIBRARY_H
2020
21#include <mir_toolkit/common.h>
22
21#ifdef __cplusplus23#ifdef __cplusplus
22/** The C client API24/** The C client API
23 */25 */
@@ -358,6 +360,23 @@
358 */360 */
359int mir_debug_surface_id(MirSurface *surface);361int mir_debug_surface_id(MirSurface *surface);
360362
363/**
364 * Set the type (purpose) of a surface. This is not guaranteed to always work
365 * with some shell types (e.g. phone/tablet UIs). As such, you may have to
366 * wait on the function and check the result using mir_surface_get_type.
367 * \param [in] surface The surface to operate on
368 * \param [in] type The new type of the surface
369 * \return A wait handle that can be passed to mir_wait_for
370 */
371MirWaitHandle* mir_surface_set_type(MirSurface *surface, MirSurfaceType type);
372
373/**
374 * Get the type (purpose) of a surface.
375 * \param [in] surface The surface to query
376 * \return The type of the surface
377 */
378MirSurfaceType mir_surface_get_type(MirSurface *surface);
379
361#ifdef __cplusplus380#ifdef __cplusplus
362}381}
363}382}
364383
=== modified file 'include/server/mir/frontend/session.h'
--- include/server/mir/frontend/session.h 2013-03-19 03:05:30 +0000
+++ include/server/mir/frontend/session.h 2013-03-21 04:05:24 +0000
@@ -19,6 +19,7 @@
19#ifndef MIR_FRONTEND_SESSION_H_19#ifndef MIR_FRONTEND_SESSION_H_
20#define MIR_FRONTEND_SESSION_H_20#define MIR_FRONTEND_SESSION_H_
2121
22#include "mir_toolkit/common.h"
22#include "mir/frontend/surface_id.h"23#include "mir/frontend/surface_id.h"
2324
24#include <mutex>25#include <mutex>
@@ -49,6 +50,8 @@
49 virtual void hide() = 0;50 virtual void hide() = 0;
50 virtual void show() = 0;51 virtual void show() = 0;
5152
53 virtual int configure_surface(SurfaceId id, MirSurfaceAttrib attrib, int value) = 0;
54
52protected:55protected:
53 Session() = default;56 Session() = default;
54 Session(Session const&) = delete;57 Session(Session const&) = delete;
5558
=== modified file 'include/server/mir/frontend/session_mediator.h'
--- include/server/mir/frontend/session_mediator.h 2013-03-19 03:05:30 +0000
+++ include/server/mir/frontend/session_mediator.h 2013-03-21 04:05:24 +0000
@@ -100,6 +100,11 @@
100 mir::protobuf::DRMAuthMagicStatus* response,100 mir::protobuf::DRMAuthMagicStatus* response,
101 google::protobuf::Closure* done);101 google::protobuf::Closure* done);
102102
103 void configure_surface(google::protobuf::RpcController* controller,
104 const mir::protobuf::SurfaceSetting*,
105 mir::protobuf::SurfaceSetting*,
106 google::protobuf::Closure* done);
107
103private:108private:
104 std::shared_ptr<Shell> const shell;109 std::shared_ptr<Shell> const shell;
105 std::shared_ptr<graphics::Platform> const graphics_platform;110 std::shared_ptr<graphics::Platform> const graphics_platform;
106111
=== modified file 'include/server/mir/frontend/session_mediator_report.h'
--- include/server/mir/frontend/session_mediator_report.h 2013-03-19 03:05:30 +0000
+++ include/server/mir/frontend/session_mediator_report.h 2013-03-21 04:05:24 +0000
@@ -42,6 +42,8 @@
4242
43 virtual void session_drm_auth_magic_called(std::string const& app_name) = 0;43 virtual void session_drm_auth_magic_called(std::string const& app_name) = 0;
4444
45 virtual void session_configure_surface_called(std::string const& app_name) = 0;
46
45 virtual void session_error(47 virtual void session_error(
46 std::string const& app_name,48 std::string const& app_name,
47 char const* method,49 char const* method,
@@ -63,6 +65,8 @@
6365
64 virtual void session_drm_auth_magic_called(std::string const& app_name);66 virtual void session_drm_auth_magic_called(std::string const& app_name);
6567
68 virtual void session_configure_surface_called(std::string const& app_name);
69
66 virtual void session_error(70 virtual void session_error(
67 std::string const& app_name,71 std::string const& app_name,
68 char const* method,72 char const* method,
6973
=== modified file 'include/server/mir/frontend/surface.h'
--- include/server/mir/frontend/surface.h 2013-03-20 10:56:07 +0000
+++ include/server/mir/frontend/surface.h 2013-03-21 04:05:24 +0000
@@ -23,6 +23,7 @@
23#include "mir/geometry/pixel_format.h"23#include "mir/geometry/pixel_format.h"
24#include "mir/geometry/point.h"24#include "mir/geometry/point.h"
25#include "mir/geometry/size.h"25#include "mir/geometry/size.h"
26#include "mir_toolkit/common.h"
2627
27#include <memory>28#include <memory>
2829
@@ -60,6 +61,8 @@
60 virtual bool supports_input() const = 0;61 virtual bool supports_input() const = 0;
61 virtual int client_input_fd() const = 0;62 virtual int client_input_fd() const = 0;
6263
64 virtual int configure(MirSurfaceAttrib attrib, int value) = 0;
65
63protected:66protected:
64 Surface() = default;67 Surface() = default;
65 Surface(Surface const&) = delete;68 Surface(Surface const&) = delete;
6669
=== modified file 'include/server/mir/logging/session_mediator_report.h'
--- include/server/mir/logging/session_mediator_report.h 2013-03-19 03:05:30 +0000
+++ include/server/mir/logging/session_mediator_report.h 2013-03-21 04:05:24 +0000
@@ -47,6 +47,8 @@
4747
48 virtual void session_drm_auth_magic_called(std::string const& app_name);48 virtual void session_drm_auth_magic_called(std::string const& app_name);
4949
50 virtual void session_configure_surface_called(std::string const& app_name);
51
50 virtual void session_error(52 virtual void session_error(
51 std::string const& app_name,53 std::string const& app_name,
52 char const* method,54 char const* method,
5355
=== modified file 'include/server/mir/shell/application_session.h'
--- include/server/mir/shell/application_session.h 2013-03-20 10:56:07 +0000
+++ include/server/mir/shell/application_session.h 2013-03-21 04:05:24 +0000
@@ -47,6 +47,8 @@
47 void hide();47 void hide();
48 void show();48 void show();
4949
50 int configure_surface(frontend::SurfaceId id, MirSurfaceAttrib attrib, int value);
51
50protected:52protected:
51 ApplicationSession(ApplicationSession const&) = delete;53 ApplicationSession(ApplicationSession const&) = delete;
52 ApplicationSession& operator=(ApplicationSession const&) = delete;54 ApplicationSession& operator=(ApplicationSession const&) = delete;
5355
=== added file 'include/shared/mir_toolkit/common.h'
--- include/shared/mir_toolkit/common.h 1970-01-01 00:00:00 +0000
+++ include/shared/mir_toolkit/common.h 2013-03-21 04:05:24 +0000
@@ -0,0 +1,49 @@
1/*
2 * Simple definitions common to client and server.
3 *
4 * Copyright © 2013 Canonical Ltd.
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License version 3 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * Author: Daniel van Vugt <daniel.van.vugt@canonical.com>
19 */
20
21#ifndef MIR_COMMON_H_
22#define MIR_COMMON_H_
23
24/* This is C code. Not C++. */
25
26/*
27 * Attributes of a surface that the client and server/shell may wish to
28 * get or set over the wire.
29 */
30typedef enum MirSurfaceAttrib
31{
32 mir_surface_attrib_type,
33 mir_surface_attrib_arraysize_
34} MirSurfaceAttrib;
35
36typedef enum MirSurfaceType
37{
38 mir_surface_type_normal,
39 mir_surface_type_utility,
40 mir_surface_type_dialog,
41 mir_surface_type_overlay,
42 mir_surface_type_freestyle,
43 mir_surface_type_popover,
44 mir_surface_type_arraysize_
45} MirSurfaceType;
46
47/* TODO: Surface states here */
48
49#endif
050
=== modified file 'include/test/mir_test_doubles/mock_session.h'
--- include/test/mir_test_doubles/mock_session.h 2013-03-19 03:05:30 +0000
+++ include/test/mir_test_doubles/mock_session.h 2013-03-21 04:05:24 +0000
@@ -41,6 +41,8 @@
41 41
42 MOCK_METHOD0(hide, void());42 MOCK_METHOD0(hide, void());
43 MOCK_METHOD0(show, void());43 MOCK_METHOD0(show, void());
44
45 MOCK_METHOD3(configure_surface, int(frontend::SurfaceId, MirSurfaceAttrib, int));
44};46};
4547
46}48}
4749
=== modified file 'include/test/mir_test_doubles/mock_surface.h'
--- include/test/mir_test_doubles/mock_surface.h 2013-03-20 10:56:07 +0000
+++ include/test/mir_test_doubles/mock_surface.h 2013-03-21 04:05:24 +0000
@@ -49,6 +49,8 @@
49 49
50 MOCK_CONST_METHOD0(supports_input, bool());50 MOCK_CONST_METHOD0(supports_input, bool());
51 MOCK_CONST_METHOD0(client_input_fd, int());51 MOCK_CONST_METHOD0(client_input_fd, int());
52
53 MOCK_METHOD2(configure, int(MirSurfaceAttrib, int));
52};54};
5355
54}56}
5557
=== modified file 'include/test/mir_test_doubles/stub_session.h'
--- include/test/mir_test_doubles/stub_session.h 2013-03-19 03:05:30 +0000
+++ include/test/mir_test_doubles/stub_session.h 2013-03-21 04:05:24 +0000
@@ -54,6 +54,10 @@
54 void show()54 void show()
55 {55 {
56 }56 }
57 int configure_surface(frontend::SurfaceId, MirSurfaceAttrib, int)
58 {
59 return 0;
60 }
57};61};
5862
59}63}
6064
=== modified file 'include/test/mir_test_doubles/stub_surface.h'
--- include/test/mir_test_doubles/stub_surface.h 2013-03-18 15:43:58 +0000
+++ include/test/mir_test_doubles/stub_surface.h 2013-03-21 04:05:24 +0000
@@ -53,6 +53,11 @@
53 {53 {
54 return std::shared_ptr<compositor::Buffer>();54 return std::shared_ptr<compositor::Buffer>();
55 }55 }
56
57 virtual int configure(MirSurfaceAttrib, int)
58 {
59 return 0;
60 }
56 61
57 virtual bool supports_input() const62 virtual bool supports_input() const
58 {63 {
5964
=== modified file 'src/client/mir_client_library.cpp'
--- src/client/mir_client_library.cpp 2013-03-20 05:11:57 +0000
+++ src/client/mir_client_library.cpp 2013-03-21 04:05:24 +0000
@@ -272,3 +272,25 @@
272{272{
273 // Ignore273 // Ignore
274}274}
275
276mir_toolkit::MirWaitHandle* mir_toolkit::mir_surface_set_type(MirSurface *surf,
277 MirSurfaceType type)
278{
279 return surf ? surf->configure(mir_surface_attrib_type, type) : NULL;
280}
281
282MirSurfaceType mir_toolkit::mir_surface_get_type(MirSurface *surf)
283{
284 MirSurfaceType type = mir_surface_type_normal;
285
286 if (surf)
287 {
288 // Only the client will ever change the type of a surface so it is
289 // safe to get the type from a local cache surf->attrib().
290
291 int t = surf->attrib(mir_surface_attrib_type);
292 type = static_cast<MirSurfaceType>(t);
293 }
294
295 return type;
296}
275297
=== modified file 'src/client/mir_surface.cpp'
--- src/client/mir_surface.cpp 2013-03-07 08:04:05 +0000
+++ src/client/mir_surface.cpp 2013-03-21 04:05:24 +0000
@@ -50,6 +50,10 @@
50 message.set_buffer_usage(params.buffer_usage);50 message.set_buffer_usage(params.buffer_usage);
5151
52 server.create_surface(0, &message, &surface, gp::NewCallback(this, &MirSurface::created, callback, context));52 server.create_surface(0, &message, &surface, gp::NewCallback(this, &MirSurface::created, callback, context));
53
54 for (int i = 0; i < mir_surface_attrib_arraysize_; i++)
55 attrib_cache[i] = -1;
56 attrib_cache[mir_surface_attrib_type] = mir_surface_type_normal;
53}57}
5458
55mir_toolkit::MirSurface::~MirSurface()59mir_toolkit::MirSurface::~MirSurface()
@@ -226,3 +230,46 @@
226{230{
227 return *accelerated_window;231 return *accelerated_window;
228}232}
233
234MirWaitHandle* MirSurface::configure(MirSurfaceAttrib at, int value)
235{
236 mp::SurfaceSetting setting;
237 setting.mutable_surfaceid()->CopyFrom(surface.id());
238 setting.set_attrib(at);
239 setting.set_ivalue(value);
240
241 configure_wait_handle.expect_result();
242 server.configure_surface(0, &setting, &configure_result,
243 google::protobuf::NewCallback(this, &MirSurface::on_configured));
244
245 return &configure_wait_handle;
246}
247
248void MirSurface::on_configured()
249{
250 if (configure_result.has_surfaceid() &&
251 configure_result.surfaceid().value() == surface.id().value() &&
252 configure_result.has_attrib())
253 {
254 switch (configure_result.attrib())
255 {
256 case mir_surface_attrib_type:
257 if (configure_result.has_ivalue())
258 {
259 int t = configure_result.ivalue();
260 attrib_cache[mir_surface_attrib_type] = t;
261 } // else error is probably set due to an unsupported attrib/value
262 break;
263 default:
264 assert(false);
265 break;
266 }
267
268 configure_wait_handle.result_received();
269 }
270}
271
272int MirSurface::attrib(MirSurfaceAttrib at) const
273{
274 return attrib_cache[at];
275}
229276
=== modified file 'src/client/mir_surface.h'
--- src/client/mir_surface.h 2013-03-15 07:40:59 +0000
+++ src/client/mir_surface.h 2013-03-21 04:05:24 +0000
@@ -23,6 +23,7 @@
23#include "mir/geometry/pixel_format.h"23#include "mir/geometry/pixel_format.h"
24#include "mir/geometry/dimensions.h"24#include "mir/geometry/dimensions.h"
25#include "mir_toolkit/mir_client_library.h"25#include "mir_toolkit/mir_client_library.h"
26#include "mir_toolkit/common.h"
26#include "client_buffer_depository.h"27#include "client_buffer_depository.h"
27#include "mir_wait_handle.h"28#include "mir_wait_handle.h"
28#include "mir_client_surface.h"29#include "mir_client_surface.h"
@@ -72,7 +73,11 @@
72 void release_cpu_region();73 void release_cpu_region();
73 EGLNativeWindowType generate_native_window();74 EGLNativeWindowType generate_native_window();
7475
76 MirWaitHandle* configure(MirSurfaceAttrib a, int value);
77 int attrib(MirSurfaceAttrib a) const;
78
75private:79private:
80 void on_configured();
76 void process_incoming_buffer();81 void process_incoming_buffer();
77 void populate(MirBufferPackage& buffer_package);82 void populate(MirBufferPackage& buffer_package);
78 void created(mir_surface_lifecycle_callback callback, void * context);83 void created(mir_surface_lifecycle_callback callback, void * context);
@@ -88,6 +93,7 @@
88 MirConnection *connection;93 MirConnection *connection;
89 MirWaitHandle create_wait_handle;94 MirWaitHandle create_wait_handle;
90 MirWaitHandle next_buffer_wait_handle;95 MirWaitHandle next_buffer_wait_handle;
96 MirWaitHandle configure_wait_handle;
9197
92 int last_buffer_id;98 int last_buffer_id;
9399
@@ -96,6 +102,11 @@
96102
97 std::shared_ptr<mir::client::Logger> logger;103 std::shared_ptr<mir::client::Logger> logger;
98 std::shared_ptr<EGLNativeWindowType> accelerated_window;104 std::shared_ptr<EGLNativeWindowType> accelerated_window;
105
106 mir::protobuf::SurfaceSetting configure_result;
107
108 // Cache of latest SurfaceSettings returned from the server
109 int attrib_cache[mir_surface_attrib_arraysize_];
99};110};
100111
101#endif /* MIR_CLIENT_PRIVATE_MIR_WAIT_HANDLE_H_ */112#endif /* MIR_CLIENT_PRIVATE_MIR_WAIT_HANDLE_H_ */
102113
=== modified file 'src/server/frontend/null_session_mediator_report.cpp'
--- src/server/frontend/null_session_mediator_report.cpp 2013-03-19 03:05:30 +0000
+++ src/server/frontend/null_session_mediator_report.cpp 2013-03-21 04:05:24 +0000
@@ -42,6 +42,10 @@
42{42{
43}43}
4444
45void mir::frontend::NullSessionMediatorReport::session_configure_surface_called(std::string const&)
46{
47}
48
45void mir::frontend::NullSessionMediatorReport::session_error(49void mir::frontend::NullSessionMediatorReport::session_error(
46 std::string const&,50 std::string const&,
47 char const* ,51 char const* ,
4852
=== modified file 'src/server/frontend/protobuf_message_processor.cpp'
--- src/server/frontend/protobuf_message_processor.cpp 2013-03-07 08:04:05 +0000
+++ src/server/frontend/protobuf_message_processor.cpp 2013-03-21 04:05:24 +0000
@@ -176,6 +176,10 @@
176 {176 {
177 invoke(&protobuf::DisplayServer::select_focus_by_lightdm_id, invocation);177 invoke(&protobuf::DisplayServer::select_focus_by_lightdm_id, invocation);
178 }178 }
179 else if ("configure_surface" == invocation.method_name())
180 {
181 invoke(&protobuf::DisplayServer::configure_surface, invocation);
182 }
179 else if ("disconnect" == invocation.method_name())183 else if ("disconnect" == invocation.method_name())
180 {184 {
181 invoke(&protobuf::DisplayServer::disconnect, invocation);185 invoke(&protobuf::DisplayServer::disconnect, invocation);
182186
=== modified file 'src/server/frontend/session_mediator.cpp'
--- src/server/frontend/session_mediator.cpp 2013-03-20 05:11:57 +0000
+++ src/server/frontend/session_mediator.cpp 2013-03-21 04:05:24 +0000
@@ -23,6 +23,7 @@
23#include "mir/frontend/surface.h"23#include "mir/frontend/surface.h"
24#include "mir/frontend/surface_creation_parameters.h"24#include "mir/frontend/surface_creation_parameters.h"
25#include "mir/frontend/resource_cache.h"25#include "mir/frontend/resource_cache.h"
26#include "mir_toolkit/common.h"
26#include "mir/compositor/buffer_ipc_package.h"27#include "mir/compositor/buffer_ipc_package.h"
27#include "mir/compositor/buffer_id.h"28#include "mir/compositor/buffer_id.h"
28#include "mir/compositor/buffer.h"29#include "mir/compositor/buffer.h"
@@ -220,3 +221,29 @@
220 done->Run();221 done->Run();
221}222}
222223
224void mir::frontend::SessionMediator::configure_surface(
225 google::protobuf::RpcController*, // controller,
226 const mir::protobuf::SurfaceSetting* request,
227 mir::protobuf::SurfaceSetting* response,
228 google::protobuf::Closure* done)
229{
230 MirSurfaceAttrib attrib = static_cast<MirSurfaceAttrib>(request->attrib());
231
232 // Required response fields:
233 response->mutable_surfaceid()->CopyFrom(request->surfaceid());
234 response->set_attrib(attrib);
235
236 if (session.get() == nullptr)
237 BOOST_THROW_EXCEPTION(std::logic_error("Invalid application session"));
238
239 report->session_configure_surface_called(session->name());
240
241 auto const id = frontend::SurfaceId(request->surfaceid().value());
242 int value = request->ivalue();
243 int newvalue = session->configure_surface(id, attrib, value);
244
245 response->set_ivalue(newvalue);
246
247 done->Run();
248}
249
223250
=== modified file 'src/server/logging/session_mediator_report.cpp'
--- src/server/logging/session_mediator_report.cpp 2013-03-19 03:05:30 +0000
+++ src/server/logging/session_mediator_report.cpp 2013-03-21 04:05:24 +0000
@@ -63,6 +63,11 @@
63 log->log<Logger::informational>("session_drm_auth_magic_called(\"" + app_name + "\")", component);63 log->log<Logger::informational>("session_drm_auth_magic_called(\"" + app_name + "\")", component);
64}64}
6565
66void ml::SessionMediatorReport::session_configure_surface_called(std::string const& app_name)
67{
68 log->log<Logger::informational>("session_configure_surface_called(\"" + app_name + "\")", component);
69}
70
66void ml::SessionMediatorReport::session_error(71void ml::SessionMediatorReport::session_error(
67 std::string const& app_name,72 std::string const& app_name,
68 char const* method,73 char const* method,
6974
=== modified file 'src/server/shell/application_session.cpp'
--- src/server/shell/application_session.cpp 2013-03-20 10:56:07 +0000
+++ src/server/shell/application_session.cpp 2013-03-21 04:05:24 +0000
@@ -122,3 +122,13 @@
122 id_s.second->show();122 id_s.second->show();
123 }123 }
124}124}
125
126int msh::ApplicationSession::configure_surface(mf::SurfaceId id,
127 MirSurfaceAttrib attrib,
128 int value)
129{
130 std::unique_lock<std::mutex> lock(surfaces_mutex);
131 std::shared_ptr<mf::Surface> surf(checked_find(id)->second);
132
133 return surf->configure(attrib, value);
134}
125135
=== modified file 'src/server/shell/surface.cpp'
--- src/server/shell/surface.cpp 2013-03-19 03:05:30 +0000
+++ src/server/shell/surface.cpp 2013-03-21 04:05:24 +0000
@@ -35,7 +35,8 @@
35 std::shared_ptr<input::InputChannel> const& input_channel)35 std::shared_ptr<input::InputChannel> const& input_channel)
36 : builder(builder),36 : builder(builder),
37 input_channel(input_channel),37 input_channel(input_channel),
38 surface(builder->create_surface(params))38 surface(builder->create_surface(params)),
39 type_value(mir_surface_type_normal)
39{40{
40}41}
4142
@@ -133,3 +134,46 @@
133 BOOST_THROW_EXCEPTION(std::logic_error("Surface does not support input"));134 BOOST_THROW_EXCEPTION(std::logic_error("Surface does not support input"));
134 return input_channel->client_fd();135 return input_channel->client_fd();
135}136}
137
138int msh::Surface::configure(MirSurfaceAttrib attrib, int value)
139{
140 int result = 0;
141
142 /*
143 * TODO: In future, query the shell implementation for the subset of
144 * attributes/types it implements.
145 */
146 switch (attrib)
147 {
148 case mir_surface_attrib_type:
149 if (!set_type(static_cast<MirSurfaceType>(value)))
150 BOOST_THROW_EXCEPTION(std::logic_error("Invalid surface "
151 "type."));
152 result = type();
153 break;
154 default:
155 BOOST_THROW_EXCEPTION(std::logic_error("Invalid surface "
156 "attribute."));
157 break;
158 }
159
160 return result;
161}
162
163MirSurfaceType msh::Surface::type() const
164{
165 return type_value;
166}
167
168bool msh::Surface::set_type(MirSurfaceType t)
169{
170 bool valid = false;
171
172 if (t >= 0 && t < mir_surface_type_arraysize_)
173 {
174 type_value = t;
175 valid = true;
176 }
177
178 return valid;
179}
136180
=== modified file 'src/server/shell/surface.h'
--- src/server/shell/surface.h 2013-03-20 10:56:07 +0000
+++ src/server/shell/surface.h 2013-03-21 04:05:24 +0000
@@ -22,6 +22,7 @@
2222
23#include "mir/frontend/surface.h"23#include "mir/frontend/surface.h"
24#include "mir/surfaces/surface.h"24#include "mir/surfaces/surface.h"
25#include "mir_toolkit/common.h"
2526
26namespace mir27namespace mir
27{28{
@@ -66,10 +67,17 @@
66 virtual bool supports_input() const;67 virtual bool supports_input() const;
67 virtual int client_input_fd() const;68 virtual int client_input_fd() const;
6869
70 virtual int configure(MirSurfaceAttrib attrib, int value);
71 virtual MirSurfaceType type() const;
72
69private:73private:
74 bool set_type(MirSurfaceType t); // Use configure() to make public changes
75
70 std::shared_ptr<SurfaceBuilder> const builder;76 std::shared_ptr<SurfaceBuilder> const builder;
71 std::shared_ptr<mir::input::InputChannel> const input_channel;77 std::shared_ptr<mir::input::InputChannel> const input_channel;
72 std::weak_ptr<mir::surfaces::Surface> const surface;78 std::weak_ptr<mir::surfaces::Surface> const surface;
79
80 MirSurfaceType type_value;
73};81};
74}82}
75}83}
7684
=== modified file 'src/shared/CMakeLists.txt'
--- src/shared/CMakeLists.txt 2013-03-13 17:54:59 +0000
+++ src/shared/CMakeLists.txt 2013-03-21 04:05:24 +0000
@@ -5,3 +5,13 @@
5 MIR_GENERATED_INCLUDE_DIRECTORIES5 MIR_GENERATED_INCLUDE_DIRECTORIES
6 ${MIR_GENERATED_INCLUDE_DIRECTORIES}6 ${MIR_GENERATED_INCLUDE_DIRECTORIES}
7 PARENT_SCOPE)7 PARENT_SCOPE)
8
9# Some headers contain common definitions required for both client and
10# server development...
11set (MIR_COMMON_HEADERS
12 ${CMAKE_SOURCE_DIR}/include/shared/mir_toolkit/common.h
13)
14
15# TODO: Find a more elegant include/ structure. Ideally one in which everything
16# lives under "include/mir/".
17install (FILES ${MIR_COMMON_HEADERS} DESTINATION "include/mir_toolkit/")
818
=== modified file 'src/shared/protobuf/mir_protobuf.proto'
--- src/shared/protobuf/mir_protobuf.proto 2013-03-19 03:05:30 +0000
+++ src/shared/protobuf/mir_protobuf.proto 2013-03-21 04:05:24 +0000
@@ -114,6 +114,14 @@
114 optional string error = 127;114 optional string error = 127;
115}115}
116116
117message SurfaceSetting {
118 optional SurfaceId surfaceid = 1;
119 optional int32 attrib = 2;
120 optional int32 ivalue = 3;
121 // optional string svalue = 4; // Expected for future use
122 optional string error = 127;
123}
124
117service DisplayServer {125service DisplayServer {
118 // Platform independent requests126 // Platform independent requests
119 rpc connect(ConnectParameters) returns (Connection);127 rpc connect(ConnectParameters) returns (Connection);
@@ -127,5 +135,7 @@
127 rpc drm_auth_magic(DRMMagic) returns (DRMAuthMagicStatus);135 rpc drm_auth_magic(DRMMagic) returns (DRMAuthMagicStatus);
128136
129 rpc test_file_descriptors(Void) returns (Buffer);137 rpc test_file_descriptors(Void) returns (Buffer);
138
139 rpc configure_surface(SurfaceSetting) returns (SurfaceSetting);
130}140}
131141
132142
=== modified file 'tests/acceptance-tests/test_client_library.cpp'
--- tests/acceptance-tests/test_client_library.cpp 2013-03-20 05:11:57 +0000
+++ tests/acceptance-tests/test_client_library.cpp 2013-03-21 04:05:24 +0000
@@ -205,6 +205,80 @@
205 launch_client_process(client_config);205 launch_client_process(client_config);
206}206}
207207
208TEST_F(DefaultDisplayServerTestFixture, surface_types)
209{
210 struct ClientConfig : ClientConfigCommon
211 {
212 void exec()
213 {
214
215 mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__, connection_callback, this));
216
217 ASSERT_TRUE(connection != NULL);
218 EXPECT_TRUE(mir_connection_is_valid(connection));
219 EXPECT_STREQ(mir_connection_get_error_message(connection), "");
220
221 MirSurfaceParameters const request_params =
222 {
223 __PRETTY_FUNCTION__,
224 640, 480,
225 mir_pixel_format_abgr_8888,
226 mir_buffer_usage_hardware
227 };
228
229 mir_wait_for(mir_surface_create(connection, &request_params, create_surface_callback, this));
230
231 ASSERT_TRUE(surface != NULL);
232 EXPECT_TRUE(mir_surface_is_valid(surface));
233 EXPECT_STREQ(mir_surface_get_error_message(surface), "");
234
235 EXPECT_EQ(mir_surface_type_normal,
236 mir_surface_get_type(surface));
237
238 mir_wait_for(mir_surface_set_type(surface,
239 mir_surface_type_freestyle));
240 EXPECT_EQ(mir_surface_type_freestyle,
241 mir_surface_get_type(surface));
242
243 mir_wait_for(mir_surface_set_type(surface,
244 static_cast<MirSurfaceType>(999)));
245 EXPECT_EQ(mir_surface_type_freestyle,
246 mir_surface_get_type(surface));
247
248 mir_wait_for(mir_surface_set_type(surface,
249 mir_surface_type_dialog));
250 EXPECT_EQ(mir_surface_type_dialog,
251 mir_surface_get_type(surface));
252
253 mir_wait_for(mir_surface_set_type(surface,
254 static_cast<MirSurfaceType>(888)));
255 EXPECT_EQ(mir_surface_type_dialog,
256 mir_surface_get_type(surface));
257
258 // Stress-test synchronization logic with some flooding
259 for (int i = 0; i < 100; i++)
260 {
261 mir_surface_set_type(surface, mir_surface_type_normal);
262 mir_surface_set_type(surface, mir_surface_type_utility);
263 mir_surface_set_type(surface, mir_surface_type_dialog);
264 mir_surface_set_type(surface, mir_surface_type_overlay);
265 mir_surface_set_type(surface, mir_surface_type_freestyle);
266 mir_wait_for(mir_surface_set_type(surface,
267 mir_surface_type_popover));
268 ASSERT_EQ(mir_surface_type_popover,
269 mir_surface_get_type(surface));
270 }
271
272 mir_wait_for(mir_surface_release(surface, release_surface_callback,
273 this));
274
275 mir_connection_release(connection);
276 }
277 } client_config;
278
279 launch_client_process(client_config);
280}
281
208TEST_F(DefaultDisplayServerTestFixture, client_library_creates_multiple_surfaces)282TEST_F(DefaultDisplayServerTestFixture, client_library_creates_multiple_surfaces)
209{283{
210 int const n_surfaces = 13;284 int const n_surfaces = 13;
211285
=== modified file 'tests/integration-tests/cucumber/test_session_management_context.cpp'
--- tests/integration-tests/cucumber/test_session_management_context.cpp 2013-03-20 05:11:57 +0000
+++ tests/integration-tests/cucumber/test_session_management_context.cpp 2013-03-21 04:05:24 +0000
@@ -64,6 +64,8 @@
64 MOCK_CONST_METHOD0(pixel_format, mir::geometry::PixelFormat ());64 MOCK_CONST_METHOD0(pixel_format, mir::geometry::PixelFormat ());
65 MOCK_CONST_METHOD0(client_buffer, std::shared_ptr<mc::Buffer> ());65 MOCK_CONST_METHOD0(client_buffer, std::shared_ptr<mc::Buffer> ());
6666
67 MOCK_METHOD2(configure, int(MirSurfaceAttrib, int));
68
67 MOCK_CONST_METHOD0(supports_input, bool());69 MOCK_CONST_METHOD0(supports_input, bool());
68 MOCK_CONST_METHOD0(client_input_fd, int());70 MOCK_CONST_METHOD0(client_input_fd, int());
69};71};
7072
=== modified file 'tests/unit-tests/client/test_client_mir_surface.cpp'
--- tests/unit-tests/client/test_client_mir_surface.cpp 2013-03-07 08:04:05 +0000
+++ tests/unit-tests/client/test_client_mir_surface.cpp 2013-03-21 04:05:24 +0000
@@ -376,3 +376,23 @@
376 EXPECT_EQ(pf, geom::PixelFormat::abgr_8888);376 EXPECT_EQ(pf, geom::PixelFormat::abgr_8888);
377}377}
378378
379TEST_F(MirClientSurfaceTest, default_surface_type)
380{
381 using namespace testing;
382 using namespace mir::protobuf;
383
384 EXPECT_CALL(*mock_depository, deposit_package_rv(_,_,_,_))
385 .Times(1);
386
387 auto surface = std::make_shared<MirSurface> (connection.get(),
388 *client_comm_channel,
389 logger,
390 mock_depository,
391 params,
392 &empty_callback,
393 (void*) NULL);
394 surface->get_create_wait_handle()->wait_for_result();
395
396 EXPECT_EQ(mir_surface_type_normal,
397 surface->attrib(mir_surface_attrib_type));
398}
379399
=== modified file 'tests/unit-tests/shell/test_surface.cpp'
--- tests/unit-tests/shell/test_surface.cpp 2013-03-20 05:11:57 +0000
+++ tests/unit-tests/shell/test_surface.cpp 2013-03-21 04:05:24 +0000
@@ -307,3 +307,51 @@
307 }, std::logic_error);307 }, std::logic_error);
308}308}
309309
310TEST_F(ShellSurface, attributes)
311{
312 using namespace testing;
313
314 msh::Surface surf(
315 mt::fake_shared(surface_builder),
316 mf::a_surface(),
317 null_input_channel);
318
319 EXPECT_THROW({
320 surf.configure(static_cast<MirSurfaceAttrib>(111), 222);
321 }, std::logic_error);
322}
323
324TEST_F(ShellSurface, types)
325{
326 using namespace testing;
327
328 msh::Surface surf(
329 mt::fake_shared(surface_builder),
330 mf::a_surface(),
331 null_input_channel);
332
333 EXPECT_EQ(mir_surface_type_normal, surf.type());
334
335 EXPECT_EQ(mir_surface_type_utility,
336 surf.configure(mir_surface_attrib_type,
337 mir_surface_type_utility));
338 EXPECT_EQ(mir_surface_type_utility, surf.type());
339
340 EXPECT_THROW({
341 surf.configure(mir_surface_attrib_type, 999);
342 }, std::logic_error);
343 EXPECT_THROW({
344 surf.configure(mir_surface_attrib_type, -1);
345 }, std::logic_error);
346 EXPECT_EQ(mir_surface_type_utility, surf.type());
347
348 EXPECT_EQ(mir_surface_type_dialog,
349 surf.configure(mir_surface_attrib_type,
350 mir_surface_type_dialog));
351 EXPECT_EQ(mir_surface_type_dialog, surf.type());
352
353 EXPECT_EQ(mir_surface_type_freestyle,
354 surf.configure(mir_surface_attrib_type,
355 mir_surface_type_freestyle));
356 EXPECT_EQ(mir_surface_type_freestyle, surf.type());
357}

Subscribers

People subscribed via source and target branches