Merge lp:~mterry/unity-mir/alpha-greeter into lp:unity-mir

Proposed by Michael Terry
Status: Merged
Approved by: Gerry Boland
Approved revision: 175
Merged at revision: 182
Proposed branch: lp:~mterry/unity-mir/alpha-greeter
Merge into: lp:unity-mir
Diff against target: 178 lines (+115/-0)
5 files modified
src/unity-mir/CMakeLists.txt (+2/-0)
src/unity-mir/displayconfigurationpolicy.cpp (+63/-0)
src/unity-mir/displayconfigurationpolicy.h (+36/-0)
src/unity-mir/shellserverconfiguration.cpp (+13/-0)
src/unity-mir/shellserverconfiguration.h (+1/-0)
To merge this branch: bzr merge lp:~mterry/unity-mir/alpha-greeter
Reviewer Review Type Date Requested Status
Gerry Boland (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Alan Griffiths Needs Information
Review via email: mp+204069@code.launchpad.net

Commit message

When part of a greeter shell, use a transparent background instead of an opaque one.

Description of the change

When part of a greeter shell, use a transparent background instead of an opaque one.

The way the unity greeter is designed, it wants to show the session beneath it as the user swipes away. This way, the background of the greeter's Mir surface won't be black.

The DisplayConfigurationPolicy class is a copy of the mg::DefaultDisplayConfigurationPolicy but with the option to search for a transparent background instead of being hard-coded to look for an opaque one.

== Checklist ==

 * Are there any related MPs required for this MP to build/function as expected?
 - No
 * Did you perform an exploratory manual test run of your code change and any related functionality?
 - Yes
 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
 - N/A

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
Gerry Boland (gerboland) wrote :

We really need a better way of configuring displays at startup (I've been looking into a similar problem just today actually).

Completely replacing the Mir implementation of DefaultDisplayConfigurationPolicy with a copy/paste just opens up code divergence problems. We should ask for something more robust for a shell to use.

Revision history for this message
Michael Terry (mterry) wrote :

I agree it's not the best. But this current system is already the result of asking mir-team to give us a way to selectively enable alpha for the greeter.

Code divergence isn't *so* bad here, because the DefaultPolicy will never be used. So anyone that wants to make a change would be doing it in unity-mir.

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

> I agree it's not the best. But this current system is already the result of
> asking mir-team to give us a way to selectively enable alpha for the greeter.
>
> Code divergence isn't *so* bad here, because the DefaultPolicy will never be
> used. So anyone that wants to make a change would be doing it in unity-mir.

Its always hard to get interfaces and defaults right until real users comes along.

Maybe explaining what you each need will help the Mir team come up with something better.

review: Needs Information
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :
Revision history for this message
Gerry Boland (gerboland) wrote :

> Its always hard to get interfaces and defaults right until real users comes
> along.
>
> Maybe explaining what you each need will help the Mir team come up with
> something better.

Hey Alan, what I need is the ability to rotate the display on startup for some devices (use-case Nexus 7: display hardwired as portrait, but we want UI in landscape).

It looks like Michael needs the ability to enable the alpha channel.

I must admit, thinking about it and possible future requirements (multiple displays especially) an obvious API doesn't strike me. Could something that could be stuck in before the configure_output calls that can let a custom implementation modify the decided parameters? Or is that just making it worse?

Revision history for this message
Michael Terry (mterry) wrote :

Ah, thank you Andreas! I missed that example when I was looking at your alpha-mode merge. That makes sense and fixes the code duplication concerns.

Revision history for this message
Michael Terry (mterry) wrote :

OK, now that Mir 0.1.4 has landed, I'll open this up for review again.

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

It might be worth nothing that (with current Mir) DisplayConfigurationPolicy::apply_to is only called if the instance of Mir is a GBM or nested session (i.e. it isn't called when running on android as I found to my surprise!).

> auto const& pos
name doesn't imply it is a pixel format. Since you're use auto, please have a variable name that indicates the purpose. At a glance, I'd read it as "position".

No other complaints code wise.

Some instructions on how to properly test would be appreciated.

review: Needs Fixing
lp:~mterry/unity-mir/alpha-greeter updated
175. By Michael Terry

Make variable name clearer

Revision history for this message
Michael Terry (mterry) wrote :

Here's how to test. It's a bear, be warned.

1) Install latest image (one with nested Mir mode).
2) Install lp:~mterry/unity-system-compositor/greeter-depth
3) Install lp:~mterry/unity8/split
4) Edit /etc/lightdm/lightdm.conf.d/90-phablet.conf to be:
[SeatDefaults]
autologin-in-background=true
autologin-user=phablet

This all will install a split greeter that is started at the same time as the session. There's a bit of a race at the moment, so you might see the session for a second or two first. But the greeter will come up.

If you swipe away the greeter, you'll see black as you swipe. Swipe far enough and it will disappear into the session. Then:

5) Install lp:~mterry/unity-mir/alpha-greeter (this branch)

Now when you reboot, you will notice that instead of black, you can see through the greeter into the session as you swipe.

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

Tests ok, code fine. +1 from me

review: Approve
Revision history for this message
Gerry Boland (gerboland) wrote :

@mterry: please add the descriptiong the review checklist questions & your answers from https://wiki.ubuntu.com/Process/Merges/Checklists/Unity-Mir

• Did you perform an exploratory manual test run of the code change and any related functionality?
Yes

• Did CI run pass? If not, please explain why.
It did

Revision history for this message
Michael Terry (mterry) wrote :

Checklist added!

lp:~mterry/unity-mir/alpha-greeter updated
176. By Michael Terry

Merge from trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/unity-mir/CMakeLists.txt'
2--- src/unity-mir/CMakeLists.txt 2014-02-07 16:10:12 +0000
3+++ src/unity-mir/CMakeLists.txt 2014-02-19 23:28:37 +0000
4@@ -15,6 +15,7 @@
5 UNITY_MIR_HEADERS
6
7 dbusscreen.h
8+ displayconfigurationpolicy.h
9 initialsurfaceplacementstrategy.h
10 qmirserverapplication.h
11 qmirserver.h
12@@ -36,6 +37,7 @@
13 unity-mir SHARED
14
15 dbusscreen.cpp
16+ displayconfigurationpolicy.cpp
17 initialsurfaceplacementstrategy.cpp
18 qmirserverapplication.cpp
19 qmirserver.cpp
20
21=== added file 'src/unity-mir/displayconfigurationpolicy.cpp'
22--- src/unity-mir/displayconfigurationpolicy.cpp 1970-01-01 00:00:00 +0000
23+++ src/unity-mir/displayconfigurationpolicy.cpp 2014-02-19 23:28:37 +0000
24@@ -0,0 +1,63 @@
25+/*
26+ * Copyright (C) 2013,2014 Canonical, Ltd.
27+ *
28+ * This program is free software: you can redistribute it and/or modify it under
29+ * the terms of the GNU Lesser General Public License version 3, as published by
30+ * the Free Software Foundation.
31+ *
32+ * This program is distributed in the hope that it will be useful, but WITHOUT
33+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
34+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
35+ * Lesser General Public License for more details.
36+ *
37+ * You should have received a copy of the GNU Lesser General Public License
38+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
39+ */
40+
41+#include "displayconfigurationpolicy.h"
42+#include "logging.h"
43+
44+#include "mir/graphics/display_configuration.h"
45+#include "mir/graphics/pixel_format_utils.h"
46+
47+#include <algorithm>
48+
49+namespace geom = mir::geometry;
50+namespace mg = mir::graphics;
51+
52+DisplayConfigurationPolicy::DisplayConfigurationPolicy(std::shared_ptr<mg::DisplayConfigurationPolicy> const& base_policy, bool with_alpha)
53+ : base_policy{base_policy},
54+ with_alpha{with_alpha}
55+{
56+}
57+
58+void DisplayConfigurationPolicy::apply_to(mg::DisplayConfiguration& conf)
59+{
60+ DLOG("DisplayConfigurationPolicy::apply_to (this=%p, conf=%p)", this, &conf);
61+
62+ base_policy->apply_to(conf);
63+ conf.for_each_output(
64+ [&](mg::DisplayConfigurationOutput const& conf_output)
65+ {
66+ if (!conf_output.connected || !conf_output.used) return;
67+
68+ auto const& format = find_if(conf_output.pixel_formats.begin(),
69+ conf_output.pixel_formats.end(),
70+ [&](MirPixelFormat format) -> bool
71+ {
72+ return mg::contains_alpha(format) == with_alpha;
73+ }
74+ );
75+
76+ // keep the default settings if nothing was found
77+ if (format == conf_output.pixel_formats.end())
78+ return;
79+
80+ conf.configure_output(conf_output.id, true, conf_output.top_left,
81+ conf_output.current_mode_index,
82+ *format,
83+ conf_output.power_mode,
84+ conf_output.orientation
85+ );
86+ });
87+}
88
89=== added file 'src/unity-mir/displayconfigurationpolicy.h'
90--- src/unity-mir/displayconfigurationpolicy.h 1970-01-01 00:00:00 +0000
91+++ src/unity-mir/displayconfigurationpolicy.h 2014-02-19 23:28:37 +0000
92@@ -0,0 +1,36 @@
93+/*
94+ * Copyright (C) 2013,2014 Canonical, Ltd.
95+ *
96+ * This program is free software: you can redistribute it and/or modify it under
97+ * the terms of the GNU Lesser General Public License version 3, as published by
98+ * the Free Software Foundation.
99+ *
100+ * This program is distributed in the hope that it will be useful, but WITHOUT
101+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
102+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
103+ * Lesser General Public License for more details.
104+ *
105+ * You should have received a copy of the GNU Lesser General Public License
106+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
107+ */
108+
109+#ifndef DISPLAYCONFIGURATIONPOLICY_H
110+#define DISPLAYCONFIGURATIONPOLICY_H
111+
112+#include "mir/graphics/display_configuration_policy.h"
113+
114+#include <memory>
115+
116+class DisplayConfigurationPolicy : public mir::graphics::DisplayConfigurationPolicy
117+{
118+public:
119+ DisplayConfigurationPolicy(std::shared_ptr<mir::graphics::DisplayConfigurationPolicy> const& base_policy,
120+ bool with_alpha);
121+ void apply_to(mir::graphics::DisplayConfiguration& conf);
122+
123+private:
124+ std::shared_ptr<mir::graphics::DisplayConfigurationPolicy> const base_policy;
125+ bool const with_alpha;
126+};
127+
128+#endif // DISPLAYCONFIGURATIONPOLICY_H
129
130=== modified file 'src/unity-mir/shellserverconfiguration.cpp'
131--- src/unity-mir/shellserverconfiguration.cpp 2014-02-07 16:10:12 +0000
132+++ src/unity-mir/shellserverconfiguration.cpp 2014-02-19 23:28:37 +0000
133@@ -16,6 +16,7 @@
134
135 #include "shellserverconfiguration.h"
136
137+#include "displayconfigurationpolicy.h"
138 #include "unityprotobufservice.h"
139 #include "initialsurfaceplacementstrategy.h"
140 #include "serverstatuslistener.h"
141@@ -27,6 +28,7 @@
142 #include "focussetter.h"
143 #include "logging.h"
144
145+namespace mg = mir::graphics;
146 namespace msh = mir::shell;
147
148 ShellServerConfiguration::ShellServerConfiguration(int argc, char const* argv[], QObject* parent)
149@@ -41,6 +43,17 @@
150 {
151 }
152
153+std::shared_ptr<mg::DisplayConfigurationPolicy>
154+ShellServerConfiguration::the_display_configuration_policy()
155+{
156+ return display_configuration_policy(
157+ [this]
158+ {
159+ bool alpha = (qgetenv("XDG_SESSION_CLASS") == "greeter");
160+ return std::make_shared<DisplayConfigurationPolicy>(DefaultServerConfiguration::the_display_configuration_policy(), alpha);
161+ });
162+}
163+
164 std::shared_ptr<msh::PlacementStrategy>
165 ShellServerConfiguration::the_shell_placement_strategy()
166 {
167
168=== modified file 'src/unity-mir/shellserverconfiguration.h'
169--- src/unity-mir/shellserverconfiguration.h 2014-02-06 12:12:21 +0000
170+++ src/unity-mir/shellserverconfiguration.h 2014-02-19 23:28:37 +0000
171@@ -47,6 +47,7 @@
172 ~ShellServerConfiguration();
173
174 /* mir specific */
175+ std::shared_ptr<mir::graphics::DisplayConfigurationPolicy> the_display_configuration_policy() override;
176 std::shared_ptr<mir::shell::PlacementStrategy> the_shell_placement_strategy() override;
177 std::shared_ptr<mir::shell::SessionListener> the_shell_session_listener() override;
178 std::shared_ptr<mir::shell::SurfaceConfigurator> the_shell_surface_configurator() override;

Subscribers

People subscribed via source and target branches