Mir

Merge lp:~mir-team/mir/fix-1336548 into lp:mir

Proposed by Robert Carr
Status: Merged
Approved by: Alan Griffiths
Approved revision: no longer in the source branch.
Merged at revision: 1747
Proposed branch: lp:~mir-team/mir/fix-1336548
Merge into: lp:mir
Diff against target: 62 lines (+33/-2)
2 files modified
src/server/scene/basic_surface.cpp (+1/-2)
tests/unit-tests/scene/test_basic_surface.cpp (+32/-0)
To merge this branch: bzr merge lp:~mir-team/mir/fix-1336548
Reviewer Review Type Date Requested Status
Alan Griffiths Approve
Daniel d'Andrada (community) Approve
Daniel van Vugt Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+225241@code.launchpad.net

Commit message

BasicSurface::configure: Ensures result is properly initialized
(LP: #1336548)

Description of the change

BasicSurface::configure: Ensures result is properly initialized

See bug

To post a comment you must log in.
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

For consistency, shouldn't you remove the line "result = value;" from "case mir_surface_attrib_swapinterval:"?

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

Focus not being gettable was somewhat intentional in that it has no use (would be redundant) if you also had a function to ask which surface has focus (which would be more useful).

But I see no harm in this new form either.

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

*Needs Discussion*

Isn't the underlying problem that focus isn't really an attribute? It isn't something that we get a client request to set that then needs validation by a configurator?

AFAICS someone simply used the attribute transport mechanism as a convenience for sending a focus event to the client without clearly separating that mechanism from the attribute setting protocol.

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

I don't think there is an underlying problem in this case so much as just a function that fails to uphold its contract due to developer error and lack of test.

"It isn't something that we get a client request to set that then needs validation by a configurator?"

I'm not sure this is a a good definition for a surface attribute. For things like mir_surface_attrib_state this already becomes inaccurate, i.e. the wm may cause you to become maximized and it has nothing to do with a client request.

I think of surface attributes client+server surface properties which exist on a spectrum of server/client writable.

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

I think the fundamental problem is that MirSurfaceEvent only presently implements attributes that are stored within each surface. Maybe we can try to be more flexible in future and also support attributes that are not /part/ of the surface object, like focus should be.

In fact there is no problem with MirSurfaceEvent at all. I think it would just be nice to redesign the server side to not store/emit focus from the surface object itself. Focus is a feature of the shell.

All for another day... those discussions are related but don't need to block a change as simple as this one.

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

It fixes the bug.

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

> All for another day... those discussions are related but don't need to block a
> change as simple as this one.

yep

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

Autolanding job was failing with...

bzrlib.errors.UnknownErrorFromSmartServer: Server sent an unexpected error: ('error', 'GhostRevisionsHaveNoRevno', 'Could not determine revno for {<email address hidden>} because its ancestry shows a ghost at {tarmac-20140616214108-3x1aupo3am5qe439}')

merged devel in the hope of resolving

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/server/scene/basic_surface.cpp'
2--- src/server/scene/basic_surface.cpp 2014-07-04 04:43:42 +0000
3+++ src/server/scene/basic_surface.cpp 2014-07-07 09:21:42 +0000
4@@ -449,14 +449,13 @@
5
6 int ms::BasicSurface::configure(MirSurfaceAttrib attrib, int value)
7 {
8- int result = 0;
9 bool allow_dropping = false;
10
11 /*
12 * TODO: In future, query the shell implementation for the subset of
13 * attributes/types it implements.
14 */
15- value = configurator->select_attribute_value(*this, attrib, value);
16+ int result = value = configurator->select_attribute_value(*this, attrib, value);
17 switch (attrib)
18 {
19 case mir_surface_attrib_type:
20
21=== modified file 'tests/unit-tests/scene/test_basic_surface.cpp'
22--- tests/unit-tests/scene/test_basic_surface.cpp 2014-06-27 13:40:34 +0000
23+++ tests/unit-tests/scene/test_basic_surface.cpp 2014-07-07 09:21:42 +0000
24@@ -510,6 +510,38 @@
25 }, std::logic_error);
26 }
27
28+TEST_F(BasicSurfaceTest, configure_returns_value_set_by_configurator)
29+{
30+ using namespace testing;
31+
32+ struct FocusSwappingConfigurator : public StubSurfaceConfigurator
33+ {
34+ int select_attribute_value(ms::Surface const&, MirSurfaceAttrib attrib, int value) override
35+ {
36+ if (attrib != mir_surface_attrib_focus)
37+ return value;
38+ else if (value == mir_surface_focused)
39+ return mir_surface_unfocused;
40+ else
41+ return mir_surface_focused;
42+ }
43+ };
44+
45+ ms::BasicSurface surface{
46+ name,
47+ rect,
48+ false,
49+ mock_buffer_stream,
50+ std::shared_ptr<mi::InputChannel>(),
51+ mt::fake_shared(mock_sender),
52+ std::make_shared<FocusSwappingConfigurator>(),
53+ nullptr,
54+ report};
55+
56+ EXPECT_EQ(mir_surface_unfocused, surface.configure(mir_surface_attrib_focus, mir_surface_focused));
57+ EXPECT_EQ(mir_surface_focused, surface.configure(mir_surface_attrib_focus, mir_surface_unfocused));
58+}
59+
60 TEST_F(BasicSurfaceTest, calls_send_event_on_consume)
61 {
62 using namespace ::testing;

Subscribers

People subscribed via source and target branches