Merge lp:~feng-kylin/unity/ExtendLockscreenTheme into lp:unity
- ExtendLockscreenTheme
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Marco Trevisan (Treviño) |
Approved revision: | no longer in the source branch. |
Merged at revision: | 4073 |
Proposed branch: | lp:~feng-kylin/unity/ExtendLockscreenTheme |
Merge into: | lp:unity |
Diff against target: |
2249 lines (+1260/-233) 34 files modified
UnityCore/GnomeSessionManager.cpp (+40/-0) UnityCore/GnomeSessionManager.h (+2/-0) UnityCore/GnomeSessionManagerImpl.h (+3/-0) UnityCore/SessionManager.h (+2/-0) com.canonical.Unity.gschema.xml (+9/-0) lockscreen/CMakeLists.txt (+4/-0) lockscreen/KylinLockScreenShield.cpp (+99/-0) lockscreen/KylinLockScreenShield.h (+54/-0) lockscreen/KylinUserPromptView.cpp (+402/-0) lockscreen/KylinUserPromptView.h (+84/-0) lockscreen/LockScreenAbstractPromptView.h (+79/-0) lockscreen/LockScreenBaseShield.cpp (+173/-0) lockscreen/LockScreenBaseShield.h (+36/-27) lockscreen/LockScreenController.cpp (+4/-2) lockscreen/LockScreenController.h (+5/-5) lockscreen/LockScreenPromptFactory.cpp (+42/-0) lockscreen/LockScreenPromptFactory.h (+42/-0) lockscreen/LockScreenShield.cpp (+4/-132) lockscreen/LockScreenShield.h (+5/-24) lockscreen/LockScreenShieldFactory.cpp (+15/-7) lockscreen/LockScreenShieldFactory.h (+17/-16) lockscreen/UserPromptView.cpp (+1/-1) lockscreen/UserPromptView.h (+2/-1) resources/login.svg (+8/-0) resources/switch_user.svg (+13/-0) shutdown/StandaloneSession.cpp (+2/-0) tests/test_gnome_session_manager.cpp (+32/-0) tests/test_lockscreen_controller.cpp (+10/-9) tests/test_mock_session_manager.h (+3/-0) tests/test_unity_settings.cpp (+10/-0) unity-shared/TextInput.cpp (+35/-8) unity-shared/TextInput.h (+9/-1) unity-shared/UnitySettings.cpp (+7/-0) unity-shared/UnitySettings.h (+7/-0) |
To merge this branch: | bzr merge lp:~feng-kylin/unity/ExtendLockscreenTheme |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Marco Trevisan (Treviño) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email: mp+277084@code.launchpad.net |
Commit message
Extend the lockscreen theme for kylin.
Description of the change
Extend the lockscreen theme.
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
Marco Trevisan (Treviño) (3v1n0) : | # |
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
Ah, also revert the changes applied at po files at revision 4022
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
Looks nice and works well, there are some improvements to do, though.
See the inline comments I wrote.
Let's try to share the most of the code we can, and to make things to be more customizable.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:4041
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
I would prefer to call LockScreenAbstr
I can do this kind of work, so I can double-check that both implementations keep the things together.
Let me know if it's fine if I provide a branch that you can merge with this.
handsome_feng (feng-kylin) wrote : | # |
> I would prefer to call LockScreenAbstr
> moving the implementation in a cpp file.
>
> I can do this kind of work, so I can double-check that both implementations
> keep the things together.
> Let me know if it's fine if I provide a branch that you can merge with this.
Sure, It's fine.
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
So, I've done some cleanup to this, adding the LockScreenBaseS
See the merge proposal at lp:~3v1n0/unity/kylin-lockscreen-cleanup/+merge/279546 for the diff.
handsome_feng (feng-kylin) wrote : | # |
> So, I've done some cleanup to this, adding the LockScreenBaseS
> can merge with lp:~3v1n0/unity/kylin-lockscreen-cleanup
>
> See the merge proposal at lp:~3v1n0/unity/kylin-lockscreen-
> cleanup/
I have merged your branch, it works well. thank you!
and I modified some copyright notices in some file(not sure whether it's right,
If there is anything wrong, please point it out :) ).
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:4047
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
Ok, I can say it looks good now...
Thanks a lot!
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
This branch doesn't build anymore now when merged to trunk:
/«BUILDDIR»
/«BUILDDIR»
text_
Can you please fix this by replacing "show_caps_lock" with "show_lock_
Thanks
handsome_feng (feng-kylin) wrote : | # |
> This branch doesn't build anymore now when merged to trunk:
>
> /«BUILDDIR»
> member function 'void unity::
> string&, bool, const PromiseAuthCode
> /«BUILDDIR»
> 15: error: 'class unity::TextInput' has no member named 'show_caps_lock'
> text_input-
>
> Can you please fix this by replacing "show_caps_lock" with
> "show_lock_
>
> Thanks
Done.
Preview Diff
1 | === modified file 'UnityCore/GnomeSessionManager.cpp' | |||
2 | --- UnityCore/GnomeSessionManager.cpp 2015-09-10 15:37:07 +0000 | |||
3 | +++ UnityCore/GnomeSessionManager.cpp 2016-01-15 01:41:44 +0000 | |||
4 | @@ -155,6 +155,13 @@ | |||
5 | 155 | }); | 155 | }); |
6 | 156 | } | 156 | } |
7 | 157 | 157 | ||
8 | 158 | { | ||
9 | 159 | dm_seat_proxy_ = std::make_shared<glib::DBusProxy>("org.freedesktop.Accounts", | ||
10 | 160 | ("/org/freedesktop/Accounts/User" + std::to_string(getuid())).c_str(), | ||
11 | 161 | "org.freedesktop.Accounts.User", | ||
12 | 162 | G_BUS_TYPE_SYSTEM); | ||
13 | 163 | } | ||
14 | 164 | |||
15 | 158 | CallLogindMethod("CanHibernate", nullptr, [this] (GVariant* variant, glib::Error const& err) { | 165 | CallLogindMethod("CanHibernate", nullptr, [this] (GVariant* variant, glib::Error const& err) { |
16 | 159 | if (err) | 166 | if (err) |
17 | 160 | { | 167 | { |
18 | @@ -429,6 +436,22 @@ | |||
19 | 429 | }); | 436 | }); |
20 | 430 | } | 437 | } |
21 | 431 | 438 | ||
22 | 439 | void GnomeManager::Impl::CallDisplayManagerSeatMethod(std::string const& method, GVariant* parameters) | ||
23 | 440 | { | ||
24 | 441 | const char* xdg_seat_path = test_mode_ ? "/org/freedesktop/DisplayManager/Seat0" : g_getenv("XDG_SEAT_PATH"); | ||
25 | 442 | |||
26 | 443 | auto proxy = std::make_shared<glib::DBusProxy>(test_mode_ ? testing::DBUS_NAME : "org.freedesktop.DisplayManager", | ||
27 | 444 | glib::gchar_to_string(xdg_seat_path), | ||
28 | 445 | "org.freedesktop.DisplayManager.Seat", | ||
29 | 446 | test_mode_ ? G_BUS_TYPE_SESSION : G_BUS_TYPE_SYSTEM); | ||
30 | 447 | proxy->CallBegin(method, parameters, [this, proxy] (GVariant*, glib::Error const& e) { | ||
31 | 448 | if (e) | ||
32 | 449 | { | ||
33 | 450 | LOG_ERROR(logger) << "DisplayManager Seat call failed: " << e.Message(); | ||
34 | 451 | } | ||
35 | 452 | }); | ||
36 | 453 | } | ||
37 | 454 | |||
38 | 432 | void GnomeManager::Impl::LockScreen(bool prompt) | 455 | void GnomeManager::Impl::LockScreen(bool prompt) |
39 | 433 | { | 456 | { |
40 | 434 | EnsureCancelPendingAction(); | 457 | EnsureCancelPendingAction(); |
41 | @@ -490,6 +513,13 @@ | |||
42 | 490 | return inhibitors.GetBool(); | 513 | return inhibitors.GetBool(); |
43 | 491 | } | 514 | } |
44 | 492 | 515 | ||
45 | 516 | void GnomeManager::Impl::UserIconFile(std::function<void(std::string const&)> const& callback) | ||
46 | 517 | { | ||
47 | 518 | dm_seat_proxy_->GetProperty("IconFile", [this, callback] (GVariant *value) { | ||
48 | 519 | callback(glib::Variant(value).GetString()); | ||
49 | 520 | }); | ||
50 | 521 | } | ||
51 | 522 | |||
52 | 493 | bool GnomeManager::Impl::IsUserInGroup(std::string const& user_name, std::string const& group_name) | 523 | bool GnomeManager::Impl::IsUserInGroup(std::string const& user_name, std::string const& group_name) |
53 | 494 | { | 524 | { |
54 | 495 | auto group = getgrnam(group_name.c_str()); | 525 | auto group = getgrnam(group_name.c_str()); |
55 | @@ -535,6 +565,11 @@ | |||
56 | 535 | return glib::gchar_to_string(g_get_host_name()); | 565 | return glib::gchar_to_string(g_get_host_name()); |
57 | 536 | } | 566 | } |
58 | 537 | 567 | ||
59 | 568 | void GnomeManager::UserIconFile(std::function<void(std::string const&)> const& callback) const | ||
60 | 569 | { | ||
61 | 570 | impl_->UserIconFile(callback); | ||
62 | 571 | } | ||
63 | 572 | |||
64 | 538 | void GnomeManager::ScreenSaverActivate() | 573 | void GnomeManager::ScreenSaverActivate() |
65 | 539 | { | 574 | { |
66 | 540 | screensaver_requested.emit(true); | 575 | screensaver_requested.emit(true); |
67 | @@ -665,6 +700,11 @@ | |||
68 | 665 | }); | 700 | }); |
69 | 666 | } | 701 | } |
70 | 667 | 702 | ||
71 | 703 | void GnomeManager::SwitchToGreeter() | ||
72 | 704 | { | ||
73 | 705 | impl_->CallDisplayManagerSeatMethod("SwitchToGreeter"); | ||
74 | 706 | } | ||
75 | 707 | |||
76 | 668 | bool GnomeManager::CanLock() const | 708 | bool GnomeManager::CanLock() const |
77 | 669 | { | 709 | { |
78 | 670 | if (is_locked()) | 710 | if (is_locked()) |
79 | 671 | 711 | ||
80 | === modified file 'UnityCore/GnomeSessionManager.h' | |||
81 | --- UnityCore/GnomeSessionManager.h 2014-05-16 04:24:05 +0000 | |||
82 | +++ UnityCore/GnomeSessionManager.h 2016-01-15 01:41:44 +0000 | |||
83 | @@ -36,6 +36,7 @@ | |||
84 | 36 | std::string RealName() const; | 36 | std::string RealName() const; |
85 | 37 | std::string UserName() const; | 37 | std::string UserName() const; |
86 | 38 | std::string HostName() const; | 38 | std::string HostName() const; |
87 | 39 | void UserIconFile(std::function<void(std::string const&)> const&) const; | ||
88 | 39 | 40 | ||
89 | 40 | void ScreenSaverActivate(); | 41 | void ScreenSaverActivate(); |
90 | 41 | void ScreenSaverDeactivate(); | 42 | void ScreenSaverDeactivate(); |
91 | @@ -46,6 +47,7 @@ | |||
92 | 46 | void Shutdown(); | 47 | void Shutdown(); |
93 | 47 | void Suspend(); | 48 | void Suspend(); |
94 | 48 | void Hibernate(); | 49 | void Hibernate(); |
95 | 50 | void SwitchToGreeter(); | ||
96 | 49 | 51 | ||
97 | 50 | bool CanLock() const; | 52 | bool CanLock() const; |
98 | 51 | bool CanShutdown() const; | 53 | bool CanShutdown() const; |
99 | 52 | 54 | ||
100 | === modified file 'UnityCore/GnomeSessionManagerImpl.h' | |||
101 | --- UnityCore/GnomeSessionManagerImpl.h 2015-01-24 00:56:37 +0000 | |||
102 | +++ UnityCore/GnomeSessionManagerImpl.h 2016-01-15 01:41:44 +0000 | |||
103 | @@ -54,6 +54,7 @@ | |||
104 | 54 | bool HasInhibitors(); | 54 | bool HasInhibitors(); |
105 | 55 | void EnsureCancelPendingAction(); | 55 | void EnsureCancelPendingAction(); |
106 | 56 | void LockScreen(bool prompt); | 56 | void LockScreen(bool prompt); |
107 | 57 | void UserIconFile(std::function<void(std::string const&)> const& callback); | ||
108 | 57 | 58 | ||
109 | 58 | GVariant* OnShellMethodCall(std::string const& method, GVariant* parameters); | 59 | GVariant* OnShellMethodCall(std::string const& method, GVariant* parameters); |
110 | 59 | void CallGnomeSessionMethod(std::string const& method, GVariant* parameters = nullptr, | 60 | void CallGnomeSessionMethod(std::string const& method, GVariant* parameters = nullptr, |
111 | @@ -61,6 +62,7 @@ | |||
112 | 61 | void CallUPowerMethod(std::string const& method, glib::DBusProxy::ReplyCallback const& cb = nullptr); | 62 | void CallUPowerMethod(std::string const& method, glib::DBusProxy::ReplyCallback const& cb = nullptr); |
113 | 62 | void CallLogindMethod(std::string const& method, GVariant* parameters = nullptr, glib::DBusProxy::CallFinishedCallback const& cb = nullptr); | 63 | void CallLogindMethod(std::string const& method, GVariant* parameters = nullptr, glib::DBusProxy::CallFinishedCallback const& cb = nullptr); |
114 | 63 | void CallConsoleKitMethod(std::string const& method, GVariant* parameters = nullptr); | 64 | void CallConsoleKitMethod(std::string const& method, GVariant* parameters = nullptr); |
115 | 65 | void CallDisplayManagerSeatMethod(std::string const& method, GVariant* parameters = nullptr); | ||
116 | 64 | bool InteractiveMode(); | 66 | bool InteractiveMode(); |
117 | 65 | void UpdateHaveOtherOpenSessions(); | 67 | void UpdateHaveOtherOpenSessions(); |
118 | 66 | 68 | ||
119 | @@ -78,6 +80,7 @@ | |||
120 | 78 | glib::DBusProxy::Ptr login_proxy_; | 80 | glib::DBusProxy::Ptr login_proxy_; |
121 | 79 | glib::DBusProxy::Ptr presence_proxy_; | 81 | glib::DBusProxy::Ptr presence_proxy_; |
122 | 80 | glib::DBusProxy::Ptr dm_proxy_; | 82 | glib::DBusProxy::Ptr dm_proxy_; |
123 | 83 | glib::DBusProxy::Ptr dm_seat_proxy_; | ||
124 | 81 | 84 | ||
125 | 82 | int open_sessions_; | 85 | int open_sessions_; |
126 | 83 | }; | 86 | }; |
127 | 84 | 87 | ||
128 | === modified file 'UnityCore/SessionManager.h' | |||
129 | --- UnityCore/SessionManager.h 2014-05-16 04:24:05 +0000 | |||
130 | +++ UnityCore/SessionManager.h 2016-01-15 01:41:44 +0000 | |||
131 | @@ -44,6 +44,7 @@ | |||
132 | 44 | virtual std::string RealName() const = 0; | 44 | virtual std::string RealName() const = 0; |
133 | 45 | virtual std::string UserName() const = 0; | 45 | virtual std::string UserName() const = 0; |
134 | 46 | virtual std::string HostName() const = 0; | 46 | virtual std::string HostName() const = 0; |
135 | 47 | virtual void UserIconFile(std::function<void(std::string const&)> const&) const = 0; | ||
136 | 47 | 48 | ||
137 | 48 | virtual void ScreenSaverActivate() = 0; | 49 | virtual void ScreenSaverActivate() = 0; |
138 | 49 | virtual void ScreenSaverDeactivate() = 0; | 50 | virtual void ScreenSaverDeactivate() = 0; |
139 | @@ -54,6 +55,7 @@ | |||
140 | 54 | virtual void Shutdown() = 0; | 55 | virtual void Shutdown() = 0; |
141 | 55 | virtual void Suspend() = 0; | 56 | virtual void Suspend() = 0; |
142 | 56 | virtual void Hibernate() = 0; | 57 | virtual void Hibernate() = 0; |
143 | 58 | virtual void SwitchToGreeter() = 0; | ||
144 | 57 | 59 | ||
145 | 58 | virtual bool CanLock() const = 0; | 60 | virtual bool CanLock() const = 0; |
146 | 59 | virtual bool CanShutdown() const = 0; | 61 | virtual bool CanShutdown() const = 0; |
147 | 60 | 62 | ||
148 | === modified file 'com.canonical.Unity.gschema.xml' | |||
149 | --- com.canonical.Unity.gschema.xml 2015-09-17 16:44:26 +0000 | |||
150 | +++ com.canonical.Unity.gschema.xml 2016-01-15 01:41:44 +0000 | |||
151 | @@ -9,6 +9,10 @@ | |||
152 | 9 | <value nick="Not Expanded" value="0" /> | 9 | <value nick="Not Expanded" value="0" /> |
153 | 10 | <value nick="Expanded" value="1" /> | 10 | <value nick="Expanded" value="1" /> |
154 | 11 | </enum> | 11 | </enum> |
155 | 12 | <enum id="desktop-type-enum"> | ||
156 | 13 | <value nick="Ubuntu" value="0" /> | ||
157 | 14 | <value nick="UbuntuKylin" value="1" /> | ||
158 | 15 | </enum> | ||
159 | 12 | 16 | ||
160 | 13 | <schema path="/com/canonical/unity/" id="com.canonical.Unity" gettext-domain="unity"> | 17 | <schema path="/com/canonical/unity/" id="com.canonical.Unity" gettext-domain="unity"> |
161 | 14 | <key enum="form-factor-enum" name="form-factor"> | 18 | <key enum="form-factor-enum" name="form-factor"> |
162 | @@ -21,6 +25,11 @@ | |||
163 | 21 | <summary>Whether the home screen should be expanded.</summary> | 25 | <summary>Whether the home screen should be expanded.</summary> |
164 | 22 | <description>Whether the home screen should be expanded.</description> | 26 | <description>Whether the home screen should be expanded.</description> |
165 | 23 | </key> | 27 | </key> |
166 | 28 | <key enum="desktop-type-enum" name="desktop-type"> | ||
167 | 29 | <default>"Ubuntu"</default> | ||
168 | 30 | <summary>The current desktop name.</summary> | ||
169 | 31 | <description>The current desktop name.</description> | ||
170 | 32 | </key> | ||
171 | 24 | <key type="i" name="minimize-count"> | 33 | <key type="i" name="minimize-count"> |
172 | 25 | <default>0</default> | 34 | <default>0</default> |
173 | 26 | <summary>Number of times a normal window has been minimized.</summary> | 35 | <summary>Number of times a normal window has been minimized.</summary> |
174 | 27 | 36 | ||
175 | === modified file 'lockscreen/CMakeLists.txt' | |||
176 | --- lockscreen/CMakeLists.txt 2015-07-31 12:16:54 +0000 | |||
177 | +++ lockscreen/CMakeLists.txt 2016-01-15 01:41:44 +0000 | |||
178 | @@ -19,11 +19,15 @@ | |||
179 | 19 | set (LOCKSCREEN_SOURCES | 19 | set (LOCKSCREEN_SOURCES |
180 | 20 | BackgroundSettings.cpp | 20 | BackgroundSettings.cpp |
181 | 21 | CofView.cpp | 21 | CofView.cpp |
182 | 22 | KylinUserPromptView.cpp | ||
183 | 23 | KylinLockScreenShield.cpp | ||
184 | 22 | LockScreenController.cpp | 24 | LockScreenController.cpp |
185 | 25 | LockScreenBaseShield.cpp | ||
186 | 23 | LockScreenSettings.cpp | 26 | LockScreenSettings.cpp |
187 | 24 | LockScreenShield.cpp | 27 | LockScreenShield.cpp |
188 | 25 | LockScreenShieldFactory.cpp | 28 | LockScreenShieldFactory.cpp |
189 | 26 | LockScreenPanel.cpp | 29 | LockScreenPanel.cpp |
190 | 30 | LockScreenPromptFactory.cpp | ||
191 | 27 | LockScreenAcceleratorController.cpp | 31 | LockScreenAcceleratorController.cpp |
192 | 28 | LockScreenAccelerators.cpp | 32 | LockScreenAccelerators.cpp |
193 | 29 | ScreenSaverDBusManager.cpp | 33 | ScreenSaverDBusManager.cpp |
194 | 30 | 34 | ||
195 | === added file 'lockscreen/KylinLockScreenShield.cpp' | |||
196 | --- lockscreen/KylinLockScreenShield.cpp 1970-01-01 00:00:00 +0000 | |||
197 | +++ lockscreen/KylinLockScreenShield.cpp 2016-01-15 01:41:44 +0000 | |||
198 | @@ -0,0 +1,99 @@ | |||
199 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
200 | 2 | /* | ||
201 | 3 | * Copyright (C) 2015 Canonical Ltd | ||
202 | 4 | * 2015, National University of Defense Technology(NUDT) & Kylin Ltd | ||
203 | 5 | * | ||
204 | 6 | * This program is free software: you can redistribute it and/or modify | ||
205 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
206 | 8 | * published by the Free Software Foundation. | ||
207 | 9 | * | ||
208 | 10 | * This program is distributed in the hope that it will be useful, | ||
209 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
210 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
211 | 13 | * GNU General Public License for more details. | ||
212 | 14 | * | ||
213 | 15 | * You should have received a copy of the GNU General Public License | ||
214 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
215 | 17 | * | ||
216 | 18 | * Authored by: Marco Trevisan <marco.trevisan@canonical.com> | ||
217 | 19 | * handsome_feng <jianfengli@ubuntukylin.com> | ||
218 | 20 | */ | ||
219 | 21 | |||
220 | 22 | #include "KylinLockScreenShield.h" | ||
221 | 23 | |||
222 | 24 | #include <Nux/VLayout.h> | ||
223 | 25 | #include <Nux/HLayout.h> | ||
224 | 26 | |||
225 | 27 | #include "CofView.h" | ||
226 | 28 | #include "LockScreenSettings.h" | ||
227 | 29 | #include "LockScreenAbstractPromptView.h" | ||
228 | 30 | |||
229 | 31 | namespace unity | ||
230 | 32 | { | ||
231 | 33 | namespace lockscreen | ||
232 | 34 | { | ||
233 | 35 | |||
234 | 36 | KylinShield::KylinShield(session::Manager::Ptr const& session_manager, | ||
235 | 37 | Accelerators::Ptr const& accelerators, | ||
236 | 38 | nux::ObjectPtr<AbstractUserPromptView> const& prompt_view, | ||
237 | 39 | int monitor_num, bool is_primary) | ||
238 | 40 | : BaseShield(session_manager, nullptr, accelerators, prompt_view, monitor_num, is_primary) | ||
239 | 41 | { | ||
240 | 42 | is_primary ? ShowPrimaryView() : ShowSecondaryView(); | ||
241 | 43 | EnableInputWindow(true); | ||
242 | 44 | } | ||
243 | 45 | |||
244 | 46 | void KylinShield::ShowPrimaryView() | ||
245 | 47 | { | ||
246 | 48 | if (primary_layout_) | ||
247 | 49 | { | ||
248 | 50 | if (prompt_view_) | ||
249 | 51 | { | ||
250 | 52 | prompt_view_->scale = scale(); | ||
251 | 53 | prompt_layout_->AddView(prompt_view_.GetPointer()); | ||
252 | 54 | } | ||
253 | 55 | |||
254 | 56 | GrabScreen(false); | ||
255 | 57 | SetLayout(primary_layout_.GetPointer()); | ||
256 | 58 | return; | ||
257 | 59 | } | ||
258 | 60 | |||
259 | 61 | GrabScreen(true); | ||
260 | 62 | nux::Layout* main_layout = new nux::VLayout(); | ||
261 | 63 | primary_layout_ = main_layout; | ||
262 | 64 | SetLayout(primary_layout_.GetPointer()); | ||
263 | 65 | |||
264 | 66 | prompt_layout_ = new nux::HLayout(); | ||
265 | 67 | |||
266 | 68 | if (prompt_view_) | ||
267 | 69 | { | ||
268 | 70 | prompt_view_->scale = scale(); | ||
269 | 71 | prompt_layout_->AddView(prompt_view_.GetPointer()); | ||
270 | 72 | } | ||
271 | 73 | |||
272 | 74 | // 10 is just a random number to center the prompt view. | ||
273 | 75 | main_layout->AddSpace(0, 10); | ||
274 | 76 | main_layout->AddLayout(prompt_layout_.GetPointer(), 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FIX); | ||
275 | 77 | main_layout->AddSpace(0, 10); | ||
276 | 78 | } | ||
277 | 79 | |||
278 | 80 | nux::Area* KylinShield::FindKeyFocusArea(unsigned etype, unsigned long keysym, unsigned long modifiers) | ||
279 | 81 | { | ||
280 | 82 | if (primary) | ||
281 | 83 | { | ||
282 | 84 | grab_key.emit(modifiers, keysym); | ||
283 | 85 | |||
284 | 86 | if (prompt_view_) | ||
285 | 87 | { | ||
286 | 88 | auto* focus_view = prompt_view_->focus_view(); | ||
287 | 89 | |||
288 | 90 | if (focus_view && focus_view->GetInputEventSensitivity()) | ||
289 | 91 | return focus_view; | ||
290 | 92 | } | ||
291 | 93 | } | ||
292 | 94 | |||
293 | 95 | return nullptr; | ||
294 | 96 | } | ||
295 | 97 | |||
296 | 98 | } | ||
297 | 99 | } | ||
298 | 0 | 100 | ||
299 | === added file 'lockscreen/KylinLockScreenShield.h' | |||
300 | --- lockscreen/KylinLockScreenShield.h 1970-01-01 00:00:00 +0000 | |||
301 | +++ lockscreen/KylinLockScreenShield.h 2016-01-15 01:41:44 +0000 | |||
302 | @@ -0,0 +1,54 @@ | |||
303 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
304 | 2 | /* | ||
305 | 3 | * Copyright (C) 2015 Canonical Ltd | ||
306 | 4 | * 2015, National University of Defense Technology(NUDT) & Kylin Ltd | ||
307 | 5 | * | ||
308 | 6 | * This program is free software: you can redistribute it and/or modify | ||
309 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
310 | 8 | * published by the Free Software Foundation. | ||
311 | 9 | * | ||
312 | 10 | * This program is distributed in the hope that it will be useful, | ||
313 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
314 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
315 | 13 | * GNU General Public License for more details. | ||
316 | 14 | * | ||
317 | 15 | * You should have received a copy of the GNU General Public License | ||
318 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
319 | 17 | * | ||
320 | 18 | * Authored by: Marco Trevisan <marco.trevisan@canonical.com> | ||
321 | 19 | * handsome_feng <jianfengli@ubuntukylin.com> | ||
322 | 20 | */ | ||
323 | 21 | |||
324 | 22 | #ifndef UNITY_KYLIN_LOCKSCREEN_SHIELD_H | ||
325 | 23 | #define UNITY_KYLIN_LOCKSCREEN_SHIELD_H | ||
326 | 24 | |||
327 | 25 | #include <UnityCore/ConnectionManager.h> | ||
328 | 26 | #include <UnityCore/GLibSource.h> | ||
329 | 27 | #include "LockScreenBaseShield.h" | ||
330 | 28 | |||
331 | 29 | namespace unity | ||
332 | 30 | { | ||
333 | 31 | namespace lockscreen | ||
334 | 32 | { | ||
335 | 33 | |||
336 | 34 | class AbstractUserPromptView; | ||
337 | 35 | |||
338 | 36 | class KylinShield : public BaseShield | ||
339 | 37 | { | ||
340 | 38 | public: | ||
341 | 39 | KylinShield(session::Manager::Ptr const&, | ||
342 | 40 | Accelerators::Ptr const&, | ||
343 | 41 | nux::ObjectPtr<AbstractUserPromptView> const&, | ||
344 | 42 | int monitor, bool is_primary); | ||
345 | 43 | |||
346 | 44 | protected: | ||
347 | 45 | nux::Area* FindKeyFocusArea(unsigned int, unsigned long, unsigned long) override; | ||
348 | 46 | |||
349 | 47 | private: | ||
350 | 48 | void ShowPrimaryView() override; | ||
351 | 49 | }; | ||
352 | 50 | |||
353 | 51 | } | ||
354 | 52 | } | ||
355 | 53 | |||
356 | 54 | #endif | ||
357 | 0 | 55 | ||
358 | === added file 'lockscreen/KylinUserPromptView.cpp' | |||
359 | --- lockscreen/KylinUserPromptView.cpp 1970-01-01 00:00:00 +0000 | |||
360 | +++ lockscreen/KylinUserPromptView.cpp 2016-01-15 01:41:44 +0000 | |||
361 | @@ -0,0 +1,402 @@ | |||
362 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
363 | 2 | /* | ||
364 | 3 | * Copyright (C) 2015 Canonical Ltd | ||
365 | 4 | * 2015, National University of Defense Technology(NUDT) & Kylin Ltd | ||
366 | 5 | * | ||
367 | 6 | * This program is free software: you can redistribute it and/or modify | ||
368 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
369 | 8 | * published by the Free Software Foundation. | ||
370 | 9 | * | ||
371 | 10 | * This program is distributed in the hope that it will be useful, | ||
372 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
373 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
374 | 13 | * GNU General Public License for more details. | ||
375 | 14 | * | ||
376 | 15 | * You should have received a copy of the GNU General Public License | ||
377 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
378 | 17 | * | ||
379 | 18 | * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com> | ||
380 | 19 | * handsome_feng <jianfengli@ubuntukylin.com> | ||
381 | 20 | */ | ||
382 | 21 | |||
383 | 22 | #include "KylinUserPromptView.h" | ||
384 | 23 | |||
385 | 24 | #include "config.h" | ||
386 | 25 | #include <gtk/gtk.h> | ||
387 | 26 | #include <glib/gi18n-lib.h> | ||
388 | 27 | |||
389 | 28 | #include <boost/algorithm/string/trim.hpp> | ||
390 | 29 | #include <Nux/VLayout.h> | ||
391 | 30 | #include <Nux/HLayout.h> | ||
392 | 31 | #include <NuxCore/Logger.h> | ||
393 | 32 | #include "Variant.h" | ||
394 | 33 | |||
395 | 34 | #include "LockScreenSettings.h" | ||
396 | 35 | #include "unity-shared/CairoTexture.h" | ||
397 | 36 | #include "unity-shared/TextInput.h" | ||
398 | 37 | #include "unity-shared/StaticCairoText.h" | ||
399 | 38 | #include "unity-shared/RawPixel.h" | ||
400 | 39 | #include "unity-shared/IconTexture.h" | ||
401 | 40 | #include "unity-shared/TextureCache.h" | ||
402 | 41 | |||
403 | 42 | namespace unity | ||
404 | 43 | { | ||
405 | 44 | namespace lockscreen | ||
406 | 45 | { | ||
407 | 46 | namespace | ||
408 | 47 | { | ||
409 | 48 | const RawPixel AVATAR_SIZE = 128_em; | ||
410 | 49 | const RawPixel ACTIVATOR_ICON_SIZE = 34_em; | ||
411 | 50 | const RawPixel LAYOUT_MARGIN = 20_em; | ||
412 | 51 | const RawPixel MSG_LAYOUT_MARGIN = 15_em; | ||
413 | 52 | const RawPixel MSG_LAYOUT_PADDING = 33_em; | ||
414 | 53 | const RawPixel PROMPT_LAYOUT_MARGIN = 5_em; | ||
415 | 54 | const RawPixel SWITCH_ICON_SIZE = 34_em; | ||
416 | 55 | const RawPixel TEXT_INPUT_HEIGHT = 36_em; | ||
417 | 56 | const RawPixel TEXT_INPUT_WIDTH = 320_em; | ||
418 | 57 | const int PROMPT_FONT_SIZE = 14; | ||
419 | 58 | |||
420 | 59 | const std::string ACTIVATOR_ICON = "login.svg"; | ||
421 | 60 | |||
422 | 61 | std::string SanitizeMessage(std::string const& message) | ||
423 | 62 | { | ||
424 | 63 | std::string msg = boost::algorithm::trim_copy(message); | ||
425 | 64 | |||
426 | 65 | if (msg.empty()) | ||
427 | 66 | return msg; | ||
428 | 67 | |||
429 | 68 | if (msg[msg.size()-1] == ':') | ||
430 | 69 | msg = msg.substr(0, msg.size()-1); | ||
431 | 70 | |||
432 | 71 | if (msg == "Password") | ||
433 | 72 | return _("Password"); | ||
434 | 73 | |||
435 | 74 | if (msg == "login") | ||
436 | 75 | return _("Username"); | ||
437 | 76 | |||
438 | 77 | return msg; | ||
439 | 78 | } | ||
440 | 79 | |||
441 | 80 | } | ||
442 | 81 | |||
443 | 82 | KylinUserPromptView::KylinUserPromptView(session::Manager::Ptr const& session_manager) | ||
444 | 83 | : AbstractUserPromptView(session_manager) | ||
445 | 84 | , scale(1.0) | ||
446 | 85 | , session_manager_(session_manager) | ||
447 | 86 | , username_(nullptr) | ||
448 | 87 | , msg_layout_(nullptr) | ||
449 | 88 | , prompt_layout_(nullptr) | ||
450 | 89 | , avatar_layout_(nullptr) | ||
451 | 90 | , switch_icon_(nullptr) | ||
452 | 91 | , avatar_(nullptr) | ||
453 | 92 | , avatar_icon_file("") | ||
454 | 93 | { | ||
455 | 94 | user_authenticator_.echo_on_requested.connect([this](std::string const& message, PromiseAuthCodePtr const& promise){ | ||
456 | 95 | AddPrompt(message, true, promise); | ||
457 | 96 | }); | ||
458 | 97 | |||
459 | 98 | user_authenticator_.echo_off_requested.connect([this](std::string const& message, PromiseAuthCodePtr const& promise){ | ||
460 | 99 | AddPrompt(message, false, promise); | ||
461 | 100 | }); | ||
462 | 101 | |||
463 | 102 | user_authenticator_.message_requested.connect([this](std::string const& message){ | ||
464 | 103 | AddMessage(message, nux::color::White); | ||
465 | 104 | }); | ||
466 | 105 | |||
467 | 106 | user_authenticator_.error_requested.connect([this](std::string const& message){ | ||
468 | 107 | AddMessage(message, nux::color::Red); | ||
469 | 108 | }); | ||
470 | 109 | |||
471 | 110 | user_authenticator_.clear_prompts.connect([this](){ | ||
472 | 111 | ResetLayout(); | ||
473 | 112 | }); | ||
474 | 113 | |||
475 | 114 | scale.changed.connect(sigc::hide(sigc::mem_fun(this, &KylinUserPromptView::UpdateSize))); | ||
476 | 115 | |||
477 | 116 | session_manager_->UserIconFile([this] (std::string const& value) { | ||
478 | 117 | avatar_icon_file = value; | ||
479 | 118 | AddAvatar(value, AVATAR_SIZE.CP(scale)); | ||
480 | 119 | }); | ||
481 | 120 | |||
482 | 121 | UpdateSize(); | ||
483 | 122 | ResetLayout(); | ||
484 | 123 | |||
485 | 124 | user_authenticator_.AuthenticateStart(session_manager_->UserName(), | ||
486 | 125 | sigc::mem_fun(this, &KylinUserPromptView::AuthenticationCb)); | ||
487 | 126 | } | ||
488 | 127 | |||
489 | 128 | void KylinUserPromptView::ResetLayout() | ||
490 | 129 | { | ||
491 | 130 | focus_queue_.clear(); | ||
492 | 131 | |||
493 | 132 | SetLayout(new nux::HLayout()); | ||
494 | 133 | |||
495 | 134 | static_cast<nux::HLayout*>(GetLayout())->SetHorizontalInternalMargin(LAYOUT_MARGIN.CP(scale)); | ||
496 | 135 | |||
497 | 136 | if (g_getenv("XDG_SEAT_PATH")) | ||
498 | 137 | { | ||
499 | 138 | nux::Layout* switch_layout = new nux::HLayout(); | ||
500 | 139 | |||
501 | 140 | TextureCache& cache = TextureCache::GetDefault(); | ||
502 | 141 | switch_icon_ = new IconTexture(cache.FindTexture("switch_user.svg", SWITCH_ICON_SIZE.CP(scale), SWITCH_ICON_SIZE.CP(scale))); | ||
503 | 142 | switch_layout->AddView(switch_icon_); | ||
504 | 143 | switch_icon_->mouse_click.connect([this](int x, int y, unsigned long button_flags, unsigned long key_flags) { | ||
505 | 144 | session_manager_->SwitchToGreeter(); | ||
506 | 145 | }); | ||
507 | 146 | switch_layout->SetMaximumSize(SWITCH_ICON_SIZE.CP(scale), SWITCH_ICON_SIZE.CP(scale)); | ||
508 | 147 | GetLayout()->AddLayout(switch_layout); | ||
509 | 148 | } | ||
510 | 149 | |||
511 | 150 | avatar_layout_ = new nux::VLayout(); | ||
512 | 151 | if (!avatar_icon_file().empty()) | ||
513 | 152 | AddAvatar(avatar_icon_file(), AVATAR_SIZE.CP(scale)); | ||
514 | 153 | GetLayout()->AddLayout(avatar_layout_); | ||
515 | 154 | |||
516 | 155 | nux::Layout* prompt_layout = new nux::VLayout(); | ||
517 | 156 | |||
518 | 157 | auto const& real_name = session_manager_->RealName(); | ||
519 | 158 | auto const& name = (real_name.empty() ? session_manager_->UserName() : real_name); | ||
520 | 159 | |||
521 | 160 | username_ = new unity::StaticCairoText(name); | ||
522 | 161 | username_->SetScale(scale); | ||
523 | 162 | username_->SetFont("Ubuntu "+std::to_string(PROMPT_FONT_SIZE)); | ||
524 | 163 | prompt_layout->AddView(username_); | ||
525 | 164 | |||
526 | 165 | msg_layout_ = new nux::VLayout(); | ||
527 | 166 | msg_layout_->SetVerticalInternalMargin(MSG_LAYOUT_MARGIN.CP(scale)); | ||
528 | 167 | msg_layout_->SetTopAndBottomPadding(MSG_LAYOUT_PADDING.CP(scale), 0); | ||
529 | 168 | prompt_layout->AddLayout(msg_layout_); | ||
530 | 169 | |||
531 | 170 | prompt_layout_ = new nux::VLayout(); | ||
532 | 171 | prompt_layout_->SetVerticalInternalMargin(PROMPT_LAYOUT_MARGIN.CP(scale)); | ||
533 | 172 | prompt_layout->AddLayout(prompt_layout_); | ||
534 | 173 | |||
535 | 174 | GetLayout()->AddLayout(prompt_layout); | ||
536 | 175 | QueueRelayout(); | ||
537 | 176 | QueueDraw(); | ||
538 | 177 | } | ||
539 | 178 | |||
540 | 179 | void KylinUserPromptView::UpdateSize() | ||
541 | 180 | { | ||
542 | 181 | auto width = 13 * Settings::GRID_SIZE.CP(scale); | ||
543 | 182 | auto height = 3 * Settings::GRID_SIZE.CP(scale); | ||
544 | 183 | |||
545 | 184 | SetMinimumWidth(width); | ||
546 | 185 | SetMaximumWidth(width); | ||
547 | 186 | SetMinimumHeight(height); | ||
548 | 187 | |||
549 | 188 | if (username_) | ||
550 | 189 | username_->SetScale(scale); | ||
551 | 190 | |||
552 | 191 | if (msg_layout_) | ||
553 | 192 | { | ||
554 | 193 | msg_layout_->SetVerticalInternalMargin(MSG_LAYOUT_MARGIN.CP(scale)); | ||
555 | 194 | |||
556 | 195 | for (auto* area : msg_layout_->GetChildren()) | ||
557 | 196 | { | ||
558 | 197 | area->SetMaximumWidth(TEXT_INPUT_WIDTH); | ||
559 | 198 | static_cast<StaticCairoText*>(area)->SetScale(scale); | ||
560 | 199 | } | ||
561 | 200 | } | ||
562 | 201 | |||
563 | 202 | if (prompt_layout_) | ||
564 | 203 | { | ||
565 | 204 | prompt_layout_->SetVerticalInternalMargin(PROMPT_LAYOUT_MARGIN.CP(scale)); | ||
566 | 205 | |||
567 | 206 | for (auto* area : prompt_layout_->GetChildren()) | ||
568 | 207 | { | ||
569 | 208 | auto* text_input = static_cast<TextInput*>(area); | ||
570 | 209 | text_input->SetMinimumHeight(TEXT_INPUT_HEIGHT.CP(scale)); | ||
571 | 210 | text_input->SetMaximumHeight(TEXT_INPUT_HEIGHT.CP(scale)); | ||
572 | 211 | text_input->SetMinimumWidth(TEXT_INPUT_WIDTH.CP(scale)); | ||
573 | 212 | text_input->SetMaximumWidth(TEXT_INPUT_WIDTH.CP(scale)); | ||
574 | 213 | text_input->scale = scale(); | ||
575 | 214 | } | ||
576 | 215 | } | ||
577 | 216 | |||
578 | 217 | ComputeContentSize(); | ||
579 | 218 | QueueRelayout(); | ||
580 | 219 | QueueDraw(); | ||
581 | 220 | } | ||
582 | 221 | |||
583 | 222 | bool KylinUserPromptView::InspectKeyEvent(unsigned int eventType, unsigned int key_sym, const char* character) | ||
584 | 223 | { | ||
585 | 224 | if ((eventType == nux::NUX_KEYDOWN) && (key_sym == NUX_VK_ESCAPE)) | ||
586 | 225 | { | ||
587 | 226 | if (!focus_queue_.empty()) | ||
588 | 227 | focus_queue_.front()->text_entry()->SetText(""); | ||
589 | 228 | |||
590 | 229 | return true; | ||
591 | 230 | } | ||
592 | 231 | |||
593 | 232 | return false; | ||
594 | 233 | } | ||
595 | 234 | |||
596 | 235 | void KylinUserPromptView::AuthenticationCb(bool authenticated) | ||
597 | 236 | { | ||
598 | 237 | ResetLayout(); | ||
599 | 238 | |||
600 | 239 | if (authenticated) | ||
601 | 240 | { | ||
602 | 241 | session_manager_->unlock_requested.emit(); | ||
603 | 242 | } | ||
604 | 243 | else | ||
605 | 244 | { | ||
606 | 245 | AddMessage(_("Invalid password, please try again"), nux::color::Red); | ||
607 | 246 | |||
608 | 247 | user_authenticator_.AuthenticateStart(session_manager_->UserName(), | ||
609 | 248 | sigc::mem_fun(this, &KylinUserPromptView::AuthenticationCb)); | ||
610 | 249 | } | ||
611 | 250 | } | ||
612 | 251 | |||
613 | 252 | void KylinUserPromptView::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw) | ||
614 | 253 | { | ||
615 | 254 | nux::Geometry const& geo = GetGeometry(); | ||
616 | 255 | |||
617 | 256 | graphics_engine.PushClippingRectangle(geo); | ||
618 | 257 | nux::GetPainter().PaintBackground(graphics_engine, geo); | ||
619 | 258 | |||
620 | 259 | graphics_engine.PopClippingRectangle(); | ||
621 | 260 | } | ||
622 | 261 | |||
623 | 262 | void KylinUserPromptView::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw) | ||
624 | 263 | { | ||
625 | 264 | nux::Geometry const& geo = GetGeometry(); | ||
626 | 265 | graphics_engine.PushClippingRectangle(geo); | ||
627 | 266 | |||
628 | 267 | if (GetLayout()) | ||
629 | 268 | GetLayout()->ProcessDraw(graphics_engine, force_draw); | ||
630 | 269 | |||
631 | 270 | graphics_engine.PopClippingRectangle(); | ||
632 | 271 | } | ||
633 | 272 | |||
634 | 273 | nux::View* KylinUserPromptView::focus_view() | ||
635 | 274 | { | ||
636 | 275 | if (focus_queue_.empty()) | ||
637 | 276 | return nullptr; | ||
638 | 277 | |||
639 | 278 | for (auto* view : focus_queue_) | ||
640 | 279 | if (view->text_entry()->HasKeyboardFocus()) | ||
641 | 280 | return view; | ||
642 | 281 | |||
643 | 282 | return focus_queue_.front()->text_entry(); | ||
644 | 283 | } | ||
645 | 284 | |||
646 | 285 | void KylinUserPromptView::AddPrompt(std::string const& message, bool visible, PromiseAuthCodePtr const& promise) | ||
647 | 286 | { | ||
648 | 287 | auto* text_input = new unity::TextInput(); | ||
649 | 288 | auto* text_entry = text_input->text_entry(); | ||
650 | 289 | |||
651 | 290 | text_input->scale = scale(); | ||
652 | 291 | text_input->activator_icon = ACTIVATOR_ICON; | ||
653 | 292 | text_input->activator_icon_size = ACTIVATOR_ICON_SIZE; | ||
654 | 293 | text_input->background_color = nux::Color(1.0f, 1.0f, 1.0f, 0.8f); | ||
655 | 294 | text_input->border_color = nux::Color(0.0f, 0.0f, 0.0f, 0.0f); | ||
656 | 295 | text_input->border_radius = 0; | ||
657 | 296 | text_input->hint_color = nux::Color(0.0f, 0.0f, 0.0f, 0.5f); | ||
658 | 297 | text_input->input_hint = SanitizeMessage(message); | ||
659 | 298 | text_input->hint_font_size = PROMPT_FONT_SIZE; | ||
660 | 299 | text_input->show_lock_warnings = true; | ||
661 | 300 | text_input->show_activator = true; | ||
662 | 301 | text_entry->SetPasswordMode(!visible); | ||
663 | 302 | text_entry->SetPasswordChar("•"); | ||
664 | 303 | text_entry->SetToggleCursorVisibilityOnKeyFocus(true); | ||
665 | 304 | text_entry->clipboard_enabled = false; | ||
666 | 305 | text_entry->SetTextColor(nux::color::Black); | ||
667 | 306 | |||
668 | 307 | text_input->SetMinimumHeight(TEXT_INPUT_HEIGHT.CP(scale)); | ||
669 | 308 | text_input->SetMaximumHeight(TEXT_INPUT_HEIGHT.CP(scale)); | ||
670 | 309 | text_input->SetMinimumWidth(TEXT_INPUT_WIDTH.CP(scale)); | ||
671 | 310 | text_input->SetMaximumWidth(TEXT_INPUT_WIDTH.CP(scale)); | ||
672 | 311 | prompt_layout_->AddView(text_input, 1); | ||
673 | 312 | focus_queue_.push_back(text_input); | ||
674 | 313 | |||
675 | 314 | // Don't remove it, it helps with a11y. | ||
676 | 315 | if (focus_queue_.size() == 1) | ||
677 | 316 | nux::GetWindowCompositor().SetKeyFocusArea(text_entry); | ||
678 | 317 | |||
679 | 318 | text_entry->activated.connect([this, text_input, promise](){ | ||
680 | 319 | auto* text_entry = text_input->text_entry(); | ||
681 | 320 | |||
682 | 321 | if (!text_entry->GetInputEventSensitivity()) | ||
683 | 322 | return; | ||
684 | 323 | |||
685 | 324 | if (focus_queue_.size() == 1) | ||
686 | 325 | { | ||
687 | 326 | text_input->SetSpinnerVisible(true); | ||
688 | 327 | text_input->SetSpinnerState(STATE_SEARCHING); | ||
689 | 328 | } | ||
690 | 329 | |||
691 | 330 | focus_queue_.pop_front(); | ||
692 | 331 | cached_focused_geo_ = text_entry->GetGeometry(); | ||
693 | 332 | text_entry->SetInputEventSensitivity(false); | ||
694 | 333 | QueueRelayout(); | ||
695 | 334 | QueueDraw(); | ||
696 | 335 | |||
697 | 336 | std::string const& password = text_entry->GetText(); | ||
698 | 337 | if (promise) | ||
699 | 338 | promise->set_value(password); | ||
700 | 339 | }); | ||
701 | 340 | |||
702 | 341 | GetLayout()->ComputeContentPosition(0, 0); | ||
703 | 342 | ComputeContentSize(); | ||
704 | 343 | QueueRelayout(); | ||
705 | 344 | QueueDraw(); | ||
706 | 345 | } | ||
707 | 346 | |||
708 | 347 | void KylinUserPromptView::AddMessage(std::string const& message, nux::Color const& color) | ||
709 | 348 | { | ||
710 | 349 | auto* view = new unity::StaticCairoText(""); | ||
711 | 350 | view->SetScale(scale); | ||
712 | 351 | view->SetFont(Settings::Instance().font_name()); | ||
713 | 352 | view->SetTextColor(color); | ||
714 | 353 | view->SetText(message); | ||
715 | 354 | view->SetMaximumWidth(TEXT_INPUT_WIDTH.CP(scale)); | ||
716 | 355 | msg_layout_->AddView(view); | ||
717 | 356 | |||
718 | 357 | GetLayout()->ComputeContentPosition(0, 0); | ||
719 | 358 | ComputeContentSize(); | ||
720 | 359 | QueueRelayout(); | ||
721 | 360 | QueueDraw(); | ||
722 | 361 | } | ||
723 | 362 | |||
724 | 363 | void KylinUserPromptView::AddAvatar(std::string const& icon_file, int icon_size) | ||
725 | 364 | { | ||
726 | 365 | avatar_ = new IconTexture(LoadUserIcon(icon_file, icon_size)); | ||
727 | 366 | avatar_->SetMinimumWidth(icon_size); | ||
728 | 367 | avatar_->SetMaximumWidth(icon_size); | ||
729 | 368 | avatar_layout_->AddView(avatar_); | ||
730 | 369 | |||
731 | 370 | GetLayout()->ComputeContentPosition(0, 0); | ||
732 | 371 | ComputeContentSize(); | ||
733 | 372 | QueueRelayout(); | ||
734 | 373 | QueueDraw(); | ||
735 | 374 | } | ||
736 | 375 | |||
737 | 376 | nux::ObjectPtr<nux::BaseTexture> KylinUserPromptView::LoadUserIcon(std::string const& icon_file, int icon_size) | ||
738 | 377 | { | ||
739 | 378 | glib::Error error; | ||
740 | 379 | glib::Object<GdkPixbuf> pixbuf(gdk_pixbuf_new_from_file_at_size(icon_file.c_str(), icon_size, icon_size, &error)); | ||
741 | 380 | if (!pixbuf) | ||
742 | 381 | { | ||
743 | 382 | auto* theme = gtk_icon_theme_get_default(); | ||
744 | 383 | GtkIconLookupFlags flags = GTK_ICON_LOOKUP_FORCE_SIZE; | ||
745 | 384 | pixbuf = gtk_icon_theme_load_icon(theme, "avatar-default-kylin", icon_size, flags, &error); | ||
746 | 385 | if (!pixbuf) | ||
747 | 386 | pixbuf = gtk_icon_theme_load_icon(theme, "avatar-default", icon_size, flags, &error); | ||
748 | 387 | } | ||
749 | 388 | nux::CairoGraphics cg(CAIRO_FORMAT_ARGB32, gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf)); | ||
750 | 389 | cairo_t* cr = cg.GetInternalContext(); | ||
751 | 390 | |||
752 | 391 | gdk_cairo_set_source_pixbuf(cr, pixbuf, 0, 0); | ||
753 | 392 | cairo_paint_with_alpha(cr, 1.0); | ||
754 | 393 | cairo_set_source_rgba(cr, 1.0f, 1.0f, 1.0f, 1.0f); | ||
755 | 394 | cairo_rectangle(cr, 0, 0, gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf)); | ||
756 | 395 | cairo_set_line_width(cr, 3); | ||
757 | 396 | cairo_stroke(cr); | ||
758 | 397 | |||
759 | 398 | return texture_ptr_from_cairo_graphics(cg); | ||
760 | 399 | } | ||
761 | 400 | |||
762 | 401 | } | ||
763 | 402 | } | ||
764 | 0 | 403 | ||
765 | === added file 'lockscreen/KylinUserPromptView.h' | |||
766 | --- lockscreen/KylinUserPromptView.h 1970-01-01 00:00:00 +0000 | |||
767 | +++ lockscreen/KylinUserPromptView.h 2016-01-15 01:41:44 +0000 | |||
768 | @@ -0,0 +1,84 @@ | |||
769 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
770 | 2 | /* | ||
771 | 3 | * Copyright (C) 2015 Canonical Ltd | ||
772 | 4 | * 2015, National University of Defense Technology(NUDT) & Kylin Ltd | ||
773 | 5 | * | ||
774 | 6 | * This program is free software: you can redistribute it and/or modify | ||
775 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
776 | 8 | * published by the Free Software Foundation. | ||
777 | 9 | * | ||
778 | 10 | * This program is distributed in the hope that it will be useful, | ||
779 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
780 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
781 | 13 | * GNU General Public License for more details. | ||
782 | 14 | * | ||
783 | 15 | * You should have received a copy of the GNU General Public License | ||
784 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
785 | 17 | * | ||
786 | 18 | * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com> | ||
787 | 19 | * handsome_feng <jianfengli@ubuntukylin.com> | ||
788 | 20 | */ | ||
789 | 21 | |||
790 | 22 | #ifndef UNITY_KYLIN_USER_PROMPT_BOX | ||
791 | 23 | #define UNITY_KYLIN_USER_PROMPT_BOX | ||
792 | 24 | |||
793 | 25 | #include "LockScreenAbstractPromptView.h" | ||
794 | 26 | |||
795 | 27 | namespace nux | ||
796 | 28 | { | ||
797 | 29 | class VLayout; | ||
798 | 30 | class HLayout; | ||
799 | 31 | } | ||
800 | 32 | |||
801 | 33 | namespace unity | ||
802 | 34 | { | ||
803 | 35 | |||
804 | 36 | class StaticCairoText; | ||
805 | 37 | class TextInput; | ||
806 | 38 | class IconTexture; | ||
807 | 39 | class RawPixel; | ||
808 | 40 | |||
809 | 41 | namespace lockscreen | ||
810 | 42 | { | ||
811 | 43 | |||
812 | 44 | class KylinUserPromptView : public AbstractUserPromptView | ||
813 | 45 | { | ||
814 | 46 | public: | ||
815 | 47 | KylinUserPromptView(session::Manager::Ptr const& session_manager); | ||
816 | 48 | |||
817 | 49 | nux::Property<double> scale; | ||
818 | 50 | |||
819 | 51 | nux::View* focus_view(); | ||
820 | 52 | |||
821 | 53 | void AddAvatar(std::string const& avatar_icon, int avatar_size); | ||
822 | 54 | void AddPrompt(std::string const& message, bool visible, PromiseAuthCodePtr const&); | ||
823 | 55 | void AddMessage(std::string const& message, nux::Color const& color); | ||
824 | 56 | void AuthenticationCb(bool authenticated); | ||
825 | 57 | |||
826 | 58 | protected: | ||
827 | 59 | void Draw(nux::GraphicsEngine& graphics_engine, bool force_draw); | ||
828 | 60 | void DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw); | ||
829 | 61 | void ResetLayout(); | ||
830 | 62 | void UpdateSize(); | ||
831 | 63 | bool InspectKeyEvent(unsigned int eventType, unsigned int key_sym, const char* character); | ||
832 | 64 | nux::ObjectPtr<nux::BaseTexture> LoadUserIcon(std::string const& icon_file, int icon_size); | ||
833 | 65 | |||
834 | 66 | private: | ||
835 | 67 | session::Manager::Ptr session_manager_; | ||
836 | 68 | UserAuthenticatorPam user_authenticator_; | ||
837 | 69 | StaticCairoText* username_; | ||
838 | 70 | nux::VLayout* msg_layout_; | ||
839 | 71 | nux::VLayout* prompt_layout_; | ||
840 | 72 | nux::VLayout* avatar_layout_; | ||
841 | 73 | std::deque<TextInput*> focus_queue_; | ||
842 | 74 | IconTexture* switch_icon_; | ||
843 | 75 | IconTexture* avatar_; | ||
844 | 76 | nux::Property<std::string> avatar_icon_file; | ||
845 | 77 | |||
846 | 78 | nux::Geometry cached_focused_geo_; | ||
847 | 79 | }; | ||
848 | 80 | |||
849 | 81 | } | ||
850 | 82 | } | ||
851 | 83 | |||
852 | 84 | #endif | ||
853 | 0 | 85 | ||
854 | === added file 'lockscreen/LockScreenAbstractPromptView.h' | |||
855 | --- lockscreen/LockScreenAbstractPromptView.h 1970-01-01 00:00:00 +0000 | |||
856 | +++ lockscreen/LockScreenAbstractPromptView.h 2016-01-15 01:41:44 +0000 | |||
857 | @@ -0,0 +1,79 @@ | |||
858 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
859 | 2 | /* | ||
860 | 3 | * Copyright (C) 2015 Canonical Ltd | ||
861 | 4 | * 2015, National University of Defense Technology(NUDT) & Kylin Ltd | ||
862 | 5 | * | ||
863 | 6 | * This program is free software: you can redistribute it and/or modify | ||
864 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
865 | 8 | * published by the Free Software Foundation. | ||
866 | 9 | * | ||
867 | 10 | * This program is distributed in the hope that it will be useful, | ||
868 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
869 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
870 | 13 | * GNU General Public License for more details. | ||
871 | 14 | * | ||
872 | 15 | * You should have received a copy of the GNU General Public License | ||
873 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
874 | 17 | * | ||
875 | 18 | * Authored by: handsome_feng <jianfengli@ubuntukylin.com> | ||
876 | 19 | */ | ||
877 | 20 | |||
878 | 21 | #ifndef UNITY_LOCKSCREEN_ABSTRACT_USER_PROMPT_H | ||
879 | 22 | #define UNITY_LOCKSCREEN_ABSTRACT_USER_PROMPT_H | ||
880 | 23 | |||
881 | 24 | #include <memory> | ||
882 | 25 | #include <deque> | ||
883 | 26 | |||
884 | 27 | #include <Nux/Nux.h> | ||
885 | 28 | #include <Nux/View.h> | ||
886 | 29 | #include <Nux/VLayout.h> | ||
887 | 30 | #include <UnityCore/SessionManager.h> | ||
888 | 31 | |||
889 | 32 | #include "UserAuthenticatorPam.h" | ||
890 | 33 | #include "unity-shared/IMTextEntry.h" | ||
891 | 34 | |||
892 | 35 | namespace nux | ||
893 | 36 | { | ||
894 | 37 | class VLayout; | ||
895 | 38 | } | ||
896 | 39 | namespace unity | ||
897 | 40 | { | ||
898 | 41 | |||
899 | 42 | class StaticCairoText; | ||
900 | 43 | class TextInput; | ||
901 | 44 | |||
902 | 45 | namespace lockscreen | ||
903 | 46 | { | ||
904 | 47 | |||
905 | 48 | class AbstractUserPromptView : public nux::View | ||
906 | 49 | { | ||
907 | 50 | public: | ||
908 | 51 | AbstractUserPromptView(session::Manager::Ptr const& session_manager) | ||
909 | 52 | : nux::View(NUX_TRACKER_LOCATION) | ||
910 | 53 | , session_manager_(session_manager) | ||
911 | 54 | {} | ||
912 | 55 | |||
913 | 56 | nux::Property<double> scale; | ||
914 | 57 | |||
915 | 58 | virtual nux::View* focus_view() = 0; | ||
916 | 59 | |||
917 | 60 | virtual void AuthenticationCb(bool authenticated) = 0; | ||
918 | 61 | virtual void ResetLayout() = 0; | ||
919 | 62 | virtual void UpdateSize() = 0; | ||
920 | 63 | |||
921 | 64 | protected: | ||
922 | 65 | session::Manager::Ptr session_manager_; | ||
923 | 66 | UserAuthenticatorPam user_authenticator_; | ||
924 | 67 | std::shared_ptr<nux::AbstractPaintLayer> bg_layer_; | ||
925 | 68 | StaticCairoText* username_; | ||
926 | 69 | nux::VLayout* msg_layout_; | ||
927 | 70 | nux::VLayout* prompt_layout_; | ||
928 | 71 | std::deque<TextInput*> focus_queue_; | ||
929 | 72 | |||
930 | 73 | nux::Geometry cached_focused_geo_; | ||
931 | 74 | }; | ||
932 | 75 | |||
933 | 76 | } // lockscreen | ||
934 | 77 | } // unity | ||
935 | 78 | |||
936 | 79 | #endif // UNITY_LOCKSCREEN_ABSTRACT_USER_PROMPT_H | ||
937 | 0 | 80 | ||
938 | === added file 'lockscreen/LockScreenBaseShield.cpp' | |||
939 | --- lockscreen/LockScreenBaseShield.cpp 1970-01-01 00:00:00 +0000 | |||
940 | +++ lockscreen/LockScreenBaseShield.cpp 2016-01-15 01:41:44 +0000 | |||
941 | @@ -0,0 +1,173 @@ | |||
942 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
943 | 2 | /* | ||
944 | 3 | * Copyright (C) 2015 Canonical Ltd | ||
945 | 4 | * | ||
946 | 5 | * This program is free software: you can redistribute it and/or modify | ||
947 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
948 | 7 | * published by the Free Software Foundation. | ||
949 | 8 | * | ||
950 | 9 | * This program is distributed in the hope that it will be useful, | ||
951 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
952 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
953 | 12 | * GNU General Public License for more details. | ||
954 | 13 | * | ||
955 | 14 | * You should have received a copy of the GNU General Public License | ||
956 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
957 | 16 | * | ||
958 | 17 | * Authored by: Marco Trevisan <marco.trevisan@canonical.com> | ||
959 | 18 | */ | ||
960 | 19 | |||
961 | 20 | #include "LockScreenBaseShield.h" | ||
962 | 21 | |||
963 | 22 | #include "BackgroundSettings.h" | ||
964 | 23 | #include "CofView.h" | ||
965 | 24 | #include "LockScreenAbstractPromptView.h" | ||
966 | 25 | #include "LockScreenSettings.h" | ||
967 | 26 | #include "unity-shared/MockableBaseWindow.h" | ||
968 | 27 | #include "unity-shared/UnitySettings.h" | ||
969 | 28 | #include "unity-shared/UScreen.h" | ||
970 | 29 | #include "unity-shared/WindowManager.h" | ||
971 | 30 | |||
972 | 31 | namespace unity | ||
973 | 32 | { | ||
974 | 33 | namespace lockscreen | ||
975 | 34 | { | ||
976 | 35 | namespace | ||
977 | 36 | { | ||
978 | 37 | const unsigned MAX_GRAB_WAIT = 100; | ||
979 | 38 | } | ||
980 | 39 | |||
981 | 40 | BaseShield::BaseShield(session::Manager::Ptr const& session, | ||
982 | 41 | indicator::Indicators::Ptr const& indicators, | ||
983 | 42 | Accelerators::Ptr const& accelerators, | ||
984 | 43 | nux::ObjectPtr<AbstractUserPromptView> const& prompt_view, | ||
985 | 44 | int monitor_num, bool is_primary) | ||
986 | 45 | : MockableBaseWindow("Unity Lockscreen") | ||
987 | 46 | , primary(is_primary) | ||
988 | 47 | , monitor(monitor_num) | ||
989 | 48 | , scale(1.0) | ||
990 | 49 | , session_manager_(session) | ||
991 | 50 | , indicators_(indicators) | ||
992 | 51 | , accelerators_(accelerators) | ||
993 | 52 | , prompt_view_(prompt_view) | ||
994 | 53 | , bg_settings_(std::make_shared<BackgroundSettings>()) | ||
995 | 54 | , cof_view_(nullptr) | ||
996 | 55 | { | ||
997 | 56 | UpdateScale(); | ||
998 | 57 | |||
999 | 58 | unity::Settings::Instance().dpi_changed.connect(sigc::mem_fun(this, &BaseShield::UpdateScale)); | ||
1000 | 59 | geometry_changed.connect([this] (nux::Area*, nux::Geometry&) { UpdateBackgroundTexture();}); | ||
1001 | 60 | |||
1002 | 61 | monitor.changed.connect([this] (int monitor) { | ||
1003 | 62 | UpdateScale(); | ||
1004 | 63 | UpdateBackgroundTexture(); | ||
1005 | 64 | }); | ||
1006 | 65 | |||
1007 | 66 | primary.changed.connect([this] (bool is_primary) { | ||
1008 | 67 | regrab_conn_->disconnect(); | ||
1009 | 68 | is_primary ? ShowPrimaryView() : ShowSecondaryView(); | ||
1010 | 69 | QueueRelayout(); | ||
1011 | 70 | QueueDraw(); | ||
1012 | 71 | }); | ||
1013 | 72 | |||
1014 | 73 | scale.changed.connect([this] (double scale) { | ||
1015 | 74 | if (prompt_view_ && primary()) | ||
1016 | 75 | prompt_view_->scale = scale; | ||
1017 | 76 | |||
1018 | 77 | if (cof_view_) | ||
1019 | 78 | cof_view_->scale = scale; | ||
1020 | 79 | |||
1021 | 80 | if (prompt_layout_) | ||
1022 | 81 | prompt_layout_->SetLeftAndRightPadding(2 * Settings::GRID_SIZE.CP(scale)); | ||
1023 | 82 | |||
1024 | 83 | background_layer_.reset(); | ||
1025 | 84 | UpdateBackgroundTexture(); | ||
1026 | 85 | }); | ||
1027 | 86 | |||
1028 | 87 | mouse_move.connect([this] (int x, int y, int, int, unsigned long, unsigned long) { | ||
1029 | 88 | auto const& abs_geo = GetAbsoluteGeometry(); | ||
1030 | 89 | grab_motion.emit(abs_geo.x + x, abs_geo.y + y); | ||
1031 | 90 | }); | ||
1032 | 91 | } | ||
1033 | 92 | |||
1034 | 93 | bool BaseShield::HasGrab() const | ||
1035 | 94 | { | ||
1036 | 95 | auto& wc = nux::GetWindowCompositor(); | ||
1037 | 96 | return (wc.GetPointerGrabArea() == this && wc.GetKeyboardGrabArea() == this); | ||
1038 | 97 | } | ||
1039 | 98 | |||
1040 | 99 | nux::Area* BaseShield::FindAreaUnderMouse(nux::Point const& mouse, nux::NuxEventType event_type) | ||
1041 | 100 | { | ||
1042 | 101 | nux::Area* area = BaseWindow::FindAreaUnderMouse(mouse, event_type); | ||
1043 | 102 | |||
1044 | 103 | if (!area && primary) | ||
1045 | 104 | return this; | ||
1046 | 105 | |||
1047 | 106 | return area; | ||
1048 | 107 | } | ||
1049 | 108 | |||
1050 | 109 | void BaseShield::GrabScreen(bool cancel_on_failure) | ||
1051 | 110 | { | ||
1052 | 111 | auto& wc = nux::GetWindowCompositor(); | ||
1053 | 112 | |||
1054 | 113 | if (wc.GrabPointerAdd(this) && wc.GrabKeyboardAdd(this)) | ||
1055 | 114 | { | ||
1056 | 115 | regrab_conn_->disconnect(); | ||
1057 | 116 | regrab_timeout_.reset(); | ||
1058 | 117 | grabbed.emit(); | ||
1059 | 118 | } | ||
1060 | 119 | else | ||
1061 | 120 | { | ||
1062 | 121 | auto const& retry_cb = sigc::bind(sigc::mem_fun(this, &BaseShield::GrabScreen), false); | ||
1063 | 122 | regrab_conn_ = WindowManager::Default().screen_ungrabbed.connect(retry_cb); | ||
1064 | 123 | |||
1065 | 124 | if (cancel_on_failure) | ||
1066 | 125 | { | ||
1067 | 126 | regrab_timeout_.reset(new glib::Timeout(MAX_GRAB_WAIT, [this] { | ||
1068 | 127 | grab_failed.emit(); | ||
1069 | 128 | return false; | ||
1070 | 129 | })); | ||
1071 | 130 | } | ||
1072 | 131 | } | ||
1073 | 132 | } | ||
1074 | 133 | |||
1075 | 134 | void BaseShield::UpdateBackgroundTexture() | ||
1076 | 135 | { | ||
1077 | 136 | auto const& monitor_geo = UScreen::GetDefault()->GetMonitorGeometry(monitor); | ||
1078 | 137 | |||
1079 | 138 | if (!background_layer_ || monitor_geo != background_layer_->GetGeometry()) | ||
1080 | 139 | { | ||
1081 | 140 | auto background_texture = bg_settings_->GetBackgroundTexture(monitor); | ||
1082 | 141 | background_layer_.reset(new nux::TextureLayer(background_texture->GetDeviceTexture(), nux::TexCoordXForm(), nux::color::White, true)); | ||
1083 | 142 | SetBackgroundLayer(background_layer_.get()); | ||
1084 | 143 | } | ||
1085 | 144 | } | ||
1086 | 145 | |||
1087 | 146 | void BaseShield::UpdateScale() | ||
1088 | 147 | { | ||
1089 | 148 | scale = unity::Settings::Instance().em(monitor)->DPIScale(); | ||
1090 | 149 | } | ||
1091 | 150 | |||
1092 | 151 | void BaseShield::ShowSecondaryView() | ||
1093 | 152 | { | ||
1094 | 153 | if (prompt_layout_) | ||
1095 | 154 | prompt_layout_->RemoveChildObject(prompt_view_.GetPointer()); | ||
1096 | 155 | |||
1097 | 156 | if (cof_layout_) | ||
1098 | 157 | { | ||
1099 | 158 | SetLayout(cof_layout_.GetPointer()); | ||
1100 | 159 | return; | ||
1101 | 160 | } | ||
1102 | 161 | |||
1103 | 162 | nux::Layout* main_layout = new nux::VLayout(); | ||
1104 | 163 | cof_layout_ = main_layout; | ||
1105 | 164 | SetLayout(cof_layout_.GetPointer()); | ||
1106 | 165 | |||
1107 | 166 | // The circle of friends | ||
1108 | 167 | cof_view_ = new CofView(); | ||
1109 | 168 | cof_view_->scale = scale(); | ||
1110 | 169 | main_layout->AddView(cof_view_); | ||
1111 | 170 | } | ||
1112 | 171 | |||
1113 | 172 | } // lockscreen | ||
1114 | 173 | } // unity | ||
1115 | 0 | 174 | ||
1116 | === renamed file 'lockscreen/LockScreenAbstractShield.h' => 'lockscreen/LockScreenBaseShield.h' | |||
1117 | --- lockscreen/LockScreenAbstractShield.h 2014-09-19 18:02:37 +0000 | |||
1118 | +++ lockscreen/LockScreenBaseShield.h 2016-01-15 01:41:44 +0000 | |||
1119 | @@ -1,6 +1,6 @@ | |||
1120 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
1121 | 2 | /* | 2 | /* |
1123 | 3 | * Copyright (C) 2014 Canonical Ltd | 3 | * Copyright (C) 2014-2015 Canonical Ltd |
1124 | 4 | * | 4 | * |
1125 | 5 | * This program is free software: you can redistribute it and/or modify | 5 | * This program is free software: you can redistribute it and/or modify |
1126 | 6 | * it under the terms of the GNU General Public License version 3 as | 6 | * it under the terms of the GNU General Public License version 3 as |
1127 | @@ -17,49 +17,40 @@ | |||
1128 | 17 | * Authored by: Marco Trevisan <marco.trevisan@canonical.com> | 17 | * Authored by: Marco Trevisan <marco.trevisan@canonical.com> |
1129 | 18 | */ | 18 | */ |
1130 | 19 | 19 | ||
1133 | 20 | #ifndef UNITY_LOCKSCREEN_ABSTRACT_SHIELD_H | 20 | #ifndef UNITY_LOCKSCREEN_BASE_SHIELD_H |
1134 | 21 | #define UNITY_LOCKSCREEN_ABSTRACT_SHIELD_H | 21 | #define UNITY_LOCKSCREEN_BASE_SHIELD_H |
1135 | 22 | 22 | ||
1136 | 23 | #include <NuxCore/Property.h> | 23 | #include <NuxCore/Property.h> |
1137 | 24 | #include <UnityCore/SessionManager.h> | 24 | #include <UnityCore/SessionManager.h> |
1138 | 25 | #include <UnityCore/Indicators.h> | 25 | #include <UnityCore/Indicators.h> |
1140 | 26 | 26 | #include <UnityCore/GLibSource.h> | |
1141 | 27 | #include "unity-shared/MockableBaseWindow.h" | 27 | #include "unity-shared/MockableBaseWindow.h" |
1142 | 28 | |||
1143 | 28 | #include "LockScreenAccelerators.h" | 29 | #include "LockScreenAccelerators.h" |
1144 | 29 | 30 | ||
1145 | 30 | namespace unity | 31 | namespace unity |
1146 | 31 | { | 32 | { |
1147 | 32 | namespace lockscreen | 33 | namespace lockscreen |
1148 | 33 | { | 34 | { |
1153 | 34 | 35 | class BackgroundSettings; | |
1154 | 35 | class UserPromptView; | 36 | class AbstractUserPromptView; |
1155 | 36 | 37 | class CofView; | |
1156 | 37 | class AbstractShield : public MockableBaseWindow | 38 | |
1157 | 39 | class BaseShield : public MockableBaseWindow | ||
1158 | 38 | { | 40 | { |
1159 | 39 | public: | 41 | public: |
1174 | 40 | AbstractShield(session::Manager::Ptr const& session, | 42 | BaseShield(session::Manager::Ptr const&, indicator::Indicators::Ptr const&, |
1175 | 41 | indicator::Indicators::Ptr const& indicators, | 43 | Accelerators::Ptr const&, nux::ObjectPtr<AbstractUserPromptView> const&, |
1176 | 42 | Accelerators::Ptr const& accelerators, | 44 | int monitor_num, bool is_primary); |
1163 | 43 | nux::ObjectPtr<UserPromptView> const& prompt_view, | ||
1164 | 44 | int monitor_num, bool is_primary) | ||
1165 | 45 | : MockableBaseWindow("Unity Lockscreen") | ||
1166 | 46 | , primary(is_primary) | ||
1167 | 47 | , monitor(monitor_num) | ||
1168 | 48 | , scale(1.0) | ||
1169 | 49 | , session_manager_(session) | ||
1170 | 50 | , indicators_(indicators) | ||
1171 | 51 | , accelerators_(accelerators) | ||
1172 | 52 | , prompt_view_(prompt_view) | ||
1173 | 53 | {} | ||
1177 | 54 | 45 | ||
1178 | 55 | nux::Property<bool> primary; | 46 | nux::Property<bool> primary; |
1179 | 56 | nux::Property<int> monitor; | 47 | nux::Property<int> monitor; |
1180 | 57 | nux::Property<double> scale; | 48 | nux::Property<double> scale; |
1181 | 58 | 49 | ||
1182 | 50 | bool HasGrab() const; | ||
1183 | 51 | virtual bool IsIndicatorOpen() const { return false; } | ||
1184 | 52 | virtual void ActivatePanel() {} | ||
1185 | 59 | using MockableBaseWindow::RemoveLayout; | 53 | using MockableBaseWindow::RemoveLayout; |
1186 | 60 | virtual bool HasGrab() const = 0; | ||
1187 | 61 | virtual bool IsIndicatorOpen() const = 0; | ||
1188 | 62 | virtual void ActivatePanel() = 0; | ||
1189 | 63 | 54 | ||
1190 | 64 | sigc::signal<void> grabbed; | 55 | sigc::signal<void> grabbed; |
1191 | 65 | sigc::signal<void> grab_failed; | 56 | sigc::signal<void> grab_failed; |
1192 | @@ -67,13 +58,31 @@ | |||
1193 | 67 | sigc::signal<void, unsigned long, unsigned long> grab_key; | 58 | sigc::signal<void, unsigned long, unsigned long> grab_key; |
1194 | 68 | 59 | ||
1195 | 69 | protected: | 60 | protected: |
1196 | 61 | virtual bool AcceptKeyNavFocus() { return false; } | ||
1197 | 62 | virtual void ShowPrimaryView() = 0; | ||
1198 | 63 | virtual void ShowSecondaryView(); | ||
1199 | 64 | |||
1200 | 65 | nux::Area* FindAreaUnderMouse(nux::Point const& mouse, nux::NuxEventType event_type) override; | ||
1201 | 66 | |||
1202 | 67 | void GrabScreen(bool cancel_on_failure); | ||
1203 | 68 | void UpdateBackgroundTexture(); | ||
1204 | 69 | void UpdateScale(); | ||
1205 | 70 | |||
1206 | 70 | session::Manager::Ptr session_manager_; | 71 | session::Manager::Ptr session_manager_; |
1207 | 71 | indicator::Indicators::Ptr indicators_; | 72 | indicator::Indicators::Ptr indicators_; |
1208 | 72 | Accelerators::Ptr accelerators_; | 73 | Accelerators::Ptr accelerators_; |
1210 | 73 | nux::ObjectPtr<UserPromptView> prompt_view_; | 74 | nux::ObjectPtr<AbstractUserPromptView> prompt_view_; |
1211 | 75 | std::shared_ptr<BackgroundSettings> bg_settings_; | ||
1212 | 76 | std::unique_ptr<nux::AbstractPaintLayer> background_layer_; | ||
1213 | 77 | nux::ObjectPtr<nux::Layout> primary_layout_; | ||
1214 | 78 | nux::ObjectPtr<nux::Layout> prompt_layout_; | ||
1215 | 79 | nux::ObjectPtr<nux::Layout> cof_layout_; | ||
1216 | 80 | CofView* cof_view_; | ||
1217 | 81 | connection::Wrapper regrab_conn_; | ||
1218 | 82 | glib::Source::UniquePtr regrab_timeout_; | ||
1219 | 74 | }; | 83 | }; |
1220 | 75 | 84 | ||
1221 | 76 | } // lockscreen | 85 | } // lockscreen |
1222 | 77 | } // unity | 86 | } // unity |
1223 | 78 | 87 | ||
1225 | 79 | #endif // UNITY_LOCKSCREEN_ABSTRACT_SHIELD_H | 88 | #endif // UNITY_LOCKSCREEN_BASE_SHIELD_H |
1226 | 80 | 89 | ||
1227 | === modified file 'lockscreen/LockScreenController.cpp' | |||
1228 | --- lockscreen/LockScreenController.cpp 2015-03-24 19:25:26 +0000 | |||
1229 | +++ lockscreen/LockScreenController.cpp 2016-01-15 01:41:44 +0000 | |||
1230 | @@ -23,6 +23,8 @@ | |||
1231 | 23 | #include <UnityCore/GLibDBusProxy.h> | 23 | #include <UnityCore/GLibDBusProxy.h> |
1232 | 24 | #include <NuxCore/Logger.h> | 24 | #include <NuxCore/Logger.h> |
1233 | 25 | 25 | ||
1234 | 26 | #include "LockScreenAbstractPromptView.h" | ||
1235 | 27 | #include "LockScreenPromptFactory.h" | ||
1236 | 26 | #include "LockScreenShield.h" | 28 | #include "LockScreenShield.h" |
1237 | 27 | #include "LockScreenSettings.h" | 29 | #include "LockScreenSettings.h" |
1238 | 28 | #include "unity-shared/AnimationUtils.h" | 30 | #include "unity-shared/AnimationUtils.h" |
1239 | @@ -218,13 +220,13 @@ | |||
1240 | 218 | int primary = UScreen::GetDefault()->GetMonitorWithMouse(); | 220 | int primary = UScreen::GetDefault()->GetMonitorWithMouse(); |
1241 | 219 | 221 | ||
1242 | 220 | // Keep a reference of the old prompt_view | 222 | // Keep a reference of the old prompt_view |
1244 | 221 | nux::ObjectPtr<UserPromptView> prompt_view(prompt_view_.GetPointer()); | 223 | nux::ObjectPtr<AbstractUserPromptView> prompt_view(prompt_view_.GetPointer()); |
1245 | 222 | 224 | ||
1246 | 223 | shields_.resize(num_monitors); | 225 | shields_.resize(num_monitors); |
1247 | 224 | 226 | ||
1248 | 225 | if (!prompt_view) | 227 | if (!prompt_view) |
1249 | 226 | { | 228 | { |
1251 | 227 | prompt_view = test_mode_ ? nullptr : new UserPromptView(session_manager_); | 229 | prompt_view = test_mode_ ? nux::ObjectPtr<AbstractUserPromptView>() : PromptFactory::CreatePrompt(session_manager_); |
1252 | 228 | prompt_view_ = prompt_view.GetPointer(); | 230 | prompt_view_ = prompt_view.GetPointer(); |
1253 | 229 | } | 231 | } |
1254 | 230 | 232 | ||
1255 | 231 | 233 | ||
1256 | === modified file 'lockscreen/LockScreenController.h' | |||
1257 | --- lockscreen/LockScreenController.h 2014-10-21 15:31:27 +0000 | |||
1258 | +++ lockscreen/LockScreenController.h 2016-01-15 01:41:44 +0000 | |||
1259 | @@ -24,12 +24,12 @@ | |||
1260 | 24 | #include <UnityCore/ConnectionManager.h> | 24 | #include <UnityCore/ConnectionManager.h> |
1261 | 25 | #include <UnityCore/GLibSource.h> | 25 | #include <UnityCore/GLibSource.h> |
1262 | 26 | 26 | ||
1263 | 27 | #include "LockScreenBaseShield.h" | ||
1264 | 27 | #include "LockScreenShieldFactory.h" | 28 | #include "LockScreenShieldFactory.h" |
1265 | 28 | #include "LockScreenAcceleratorController.h" | 29 | #include "LockScreenAcceleratorController.h" |
1266 | 29 | #include "ScreenSaverDBusManager.h" | 30 | #include "ScreenSaverDBusManager.h" |
1267 | 30 | #include "ShutdownNotifier.h" | 31 | #include "ShutdownNotifier.h" |
1268 | 31 | #include "SuspendNotifier.h" | 32 | #include "SuspendNotifier.h" |
1269 | 32 | #include "UserPromptView.h" | ||
1270 | 33 | #include "unity-shared/BackgroundEffectHelper.h" | 33 | #include "unity-shared/BackgroundEffectHelper.h" |
1271 | 34 | #include "unity-shared/UpstartWrapper.h" | 34 | #include "unity-shared/UpstartWrapper.h" |
1272 | 35 | 35 | ||
1273 | @@ -38,7 +38,7 @@ | |||
1274 | 38 | namespace lockscreen | 38 | namespace lockscreen |
1275 | 39 | { | 39 | { |
1276 | 40 | 40 | ||
1278 | 41 | class UserPromptView; | 41 | class AbstractUserPromptView; |
1279 | 42 | 42 | ||
1280 | 43 | class Controller : public sigc::trackable | 43 | class Controller : public sigc::trackable |
1281 | 44 | { | 44 | { |
1282 | @@ -77,9 +77,9 @@ | |||
1283 | 77 | void OnScreenSaverActivationRequest(bool activate); | 77 | void OnScreenSaverActivationRequest(bool activate); |
1284 | 78 | void OnPrimaryShieldMotion(int x, int y); | 78 | void OnPrimaryShieldMotion(int x, int y); |
1285 | 79 | 79 | ||
1289 | 80 | std::vector<nux::ObjectPtr<AbstractShield>> shields_; | 80 | std::vector<nux::ObjectPtr<BaseShield>> shields_; |
1290 | 81 | nux::ObjectWeakPtr<AbstractShield> primary_shield_; | 81 | nux::ObjectWeakPtr<BaseShield> primary_shield_; |
1291 | 82 | nux::ObjectWeakPtr<UserPromptView> prompt_view_; | 82 | nux::ObjectWeakPtr<AbstractUserPromptView> prompt_view_; |
1292 | 83 | nux::ObjectPtr<nux::BaseWindow> blank_window_; | 83 | nux::ObjectPtr<nux::BaseWindow> blank_window_; |
1293 | 84 | 84 | ||
1294 | 85 | DBusManager::Ptr dbus_manager_; | 85 | DBusManager::Ptr dbus_manager_; |
1295 | 86 | 86 | ||
1296 | === added file 'lockscreen/LockScreenPromptFactory.cpp' | |||
1297 | --- lockscreen/LockScreenPromptFactory.cpp 1970-01-01 00:00:00 +0000 | |||
1298 | +++ lockscreen/LockScreenPromptFactory.cpp 2016-01-15 01:41:44 +0000 | |||
1299 | @@ -0,0 +1,42 @@ | |||
1300 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
1301 | 2 | /* | ||
1302 | 3 | * Copyright (C) 2015 Canonical Ltd | ||
1303 | 4 | * | ||
1304 | 5 | * This program is free software: you can redistribute it and/or modify | ||
1305 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
1306 | 7 | * published by the Free Software Foundation. | ||
1307 | 8 | * | ||
1308 | 9 | * This program is distributed in the hope that it will be useful, | ||
1309 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1310 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1311 | 12 | * GNU General Public License for more details. | ||
1312 | 13 | * | ||
1313 | 14 | * You should have received a copy of the GNU General Public License | ||
1314 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1315 | 16 | * | ||
1316 | 17 | * Authored by: Marco Trevisan <marco.trevisan@canonical.com> | ||
1317 | 18 | */ | ||
1318 | 19 | |||
1319 | 20 | #include "LockScreenPromptFactory.h" | ||
1320 | 21 | #include "KylinUserPromptView.h" | ||
1321 | 22 | #include "UserPromptView.h" | ||
1322 | 23 | #include "unity-shared/UnitySettings.h" | ||
1323 | 24 | |||
1324 | 25 | namespace unity | ||
1325 | 26 | { | ||
1326 | 27 | namespace lockscreen | ||
1327 | 28 | { | ||
1328 | 29 | nux::ObjectPtr<AbstractUserPromptView> PromptFactory::CreatePrompt(session::Manager::Ptr const& sm) | ||
1329 | 30 | { | ||
1330 | 31 | nux::ObjectPtr<AbstractUserPromptView> prompt; | ||
1331 | 32 | |||
1332 | 33 | if (unity::Settings::Instance().desktop_type() == DesktopType::UBUNTUKYLIN) | ||
1333 | 34 | prompt = new KylinUserPromptView(sm); | ||
1334 | 35 | else | ||
1335 | 36 | prompt = new UserPromptView(sm); | ||
1336 | 37 | |||
1337 | 38 | return prompt; | ||
1338 | 39 | } | ||
1339 | 40 | |||
1340 | 41 | } | ||
1341 | 42 | } | ||
1342 | 0 | 43 | ||
1343 | === added file 'lockscreen/LockScreenPromptFactory.h' | |||
1344 | --- lockscreen/LockScreenPromptFactory.h 1970-01-01 00:00:00 +0000 | |||
1345 | +++ lockscreen/LockScreenPromptFactory.h 2016-01-15 01:41:44 +0000 | |||
1346 | @@ -0,0 +1,42 @@ | |||
1347 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
1348 | 2 | /* | ||
1349 | 3 | * Copyright (C) 2015 Canonical Ltd | ||
1350 | 4 | * | ||
1351 | 5 | * This program is free software: you can redistribute it and/or modify | ||
1352 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
1353 | 7 | * published by the Free Software Foundation. | ||
1354 | 8 | * | ||
1355 | 9 | * This program is distributed in the hope that it will be useful, | ||
1356 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1357 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1358 | 12 | * GNU General Public License for more details. | ||
1359 | 13 | * | ||
1360 | 14 | * You should have received a copy of the GNU General Public License | ||
1361 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1362 | 16 | * | ||
1363 | 17 | * Authored by: Marco Trevisan <marco.trevisan@canonical.com> | ||
1364 | 18 | */ | ||
1365 | 19 | |||
1366 | 20 | #ifndef UNITY_LOCKSCREEN_PROMPT_FACTORY | ||
1367 | 21 | #define UNITY_LOCKSCREEN_PROMPT_FACTORY | ||
1368 | 22 | |||
1369 | 23 | #include <NuxCore/NuxCore.h> | ||
1370 | 24 | #include <UnityCore/SessionManager.h> | ||
1371 | 25 | |||
1372 | 26 | namespace unity | ||
1373 | 27 | { | ||
1374 | 28 | class MockableBaseWindow; | ||
1375 | 29 | |||
1376 | 30 | namespace lockscreen | ||
1377 | 31 | { | ||
1378 | 32 | class AbstractUserPromptView; | ||
1379 | 33 | |||
1380 | 34 | struct PromptFactory | ||
1381 | 35 | { | ||
1382 | 36 | static nux::ObjectPtr<AbstractUserPromptView> CreatePrompt(session::Manager::Ptr const&); | ||
1383 | 37 | }; | ||
1384 | 38 | |||
1385 | 39 | } | ||
1386 | 40 | } | ||
1387 | 41 | |||
1388 | 42 | #endif // UNITY_LOCKSCREEN_PROMPT_FACTORY | ||
1389 | 0 | 43 | ||
1390 | === modified file 'lockscreen/LockScreenShield.cpp' | |||
1391 | --- lockscreen/LockScreenShield.cpp 2014-09-19 20:44:05 +0000 | |||
1392 | +++ lockscreen/LockScreenShield.cpp 2016-01-15 01:41:44 +0000 | |||
1393 | @@ -21,127 +21,35 @@ | |||
1394 | 21 | 21 | ||
1395 | 22 | #include <Nux/VLayout.h> | 22 | #include <Nux/VLayout.h> |
1396 | 23 | #include <Nux/HLayout.h> | 23 | #include <Nux/HLayout.h> |
1397 | 24 | #include <Nux/PaintLayer.h> | ||
1398 | 25 | 24 | ||
1399 | 26 | #include "BackgroundSettings.h" | ||
1400 | 27 | #include "CofView.h" | ||
1401 | 28 | #include "LockScreenPanel.h" | 25 | #include "LockScreenPanel.h" |
1402 | 29 | #include "LockScreenSettings.h" | 26 | #include "LockScreenSettings.h" |
1407 | 30 | #include "UserPromptView.h" | 27 | #include "LockScreenAbstractPromptView.h" |
1404 | 31 | #include "unity-shared/UScreen.h" | ||
1405 | 32 | #include "unity-shared/UnitySettings.h" | ||
1406 | 33 | #include "unity-shared/WindowManager.h" | ||
1408 | 34 | 28 | ||
1409 | 35 | namespace unity | 29 | namespace unity |
1410 | 36 | { | 30 | { |
1411 | 37 | namespace lockscreen | 31 | namespace lockscreen |
1412 | 38 | { | 32 | { |
1413 | 39 | namespace | ||
1414 | 40 | { | ||
1415 | 41 | const unsigned MAX_GRAB_WAIT = 100; | ||
1416 | 42 | } | ||
1417 | 43 | 33 | ||
1418 | 44 | Shield::Shield(session::Manager::Ptr const& session_manager, | 34 | Shield::Shield(session::Manager::Ptr const& session_manager, |
1419 | 45 | indicator::Indicators::Ptr const& indicators, | 35 | indicator::Indicators::Ptr const& indicators, |
1420 | 46 | Accelerators::Ptr const& accelerators, | 36 | Accelerators::Ptr const& accelerators, |
1422 | 47 | nux::ObjectPtr<UserPromptView> const& prompt_view, | 37 | nux::ObjectPtr<AbstractUserPromptView> const& prompt_view, |
1423 | 48 | int monitor_num, bool is_primary) | 38 | int monitor_num, bool is_primary) |
1426 | 49 | : AbstractShield(session_manager, indicators, accelerators, prompt_view, monitor_num, is_primary) | 39 | : BaseShield(session_manager, indicators, accelerators, prompt_view, monitor_num, is_primary) |
1425 | 50 | , bg_settings_(std::make_shared<BackgroundSettings>()) | ||
1427 | 51 | , panel_view_(nullptr) | 40 | , panel_view_(nullptr) |
1428 | 52 | , cof_view_(nullptr) | ||
1429 | 53 | { | 41 | { |
1430 | 54 | UpdateScale(); | ||
1431 | 55 | is_primary ? ShowPrimaryView() : ShowSecondaryView(); | 42 | is_primary ? ShowPrimaryView() : ShowSecondaryView(); |
1432 | 56 | |||
1433 | 57 | EnableInputWindow(true); | 43 | EnableInputWindow(true); |
1434 | 58 | 44 | ||
1435 | 59 | unity::Settings::Instance().dpi_changed.connect(sigc::mem_fun(this, &Shield::UpdateScale)); | ||
1436 | 60 | geometry_changed.connect([this] (nux::Area*, nux::Geometry&) { UpdateBackgroundTexture();}); | ||
1437 | 61 | |||
1438 | 62 | monitor.changed.connect([this] (int monitor) { | 45 | monitor.changed.connect([this] (int monitor) { |
1439 | 63 | UpdateScale(); | ||
1440 | 64 | |||
1441 | 65 | if (panel_view_) | 46 | if (panel_view_) |
1442 | 66 | panel_view_->monitor = monitor; | 47 | panel_view_->monitor = monitor; |
1443 | 67 | |||
1444 | 68 | UpdateBackgroundTexture(); | ||
1445 | 69 | }); | 48 | }); |
1446 | 70 | 49 | ||
1447 | 71 | primary.changed.connect([this] (bool is_primary) { | 50 | primary.changed.connect([this] (bool is_primary) { |
1448 | 72 | regrab_conn_->disconnect(); | ||
1449 | 73 | is_primary ? ShowPrimaryView() : ShowSecondaryView(); | ||
1450 | 74 | if (panel_view_) panel_view_->SetInputEventSensitivity(is_primary); | 51 | if (panel_view_) panel_view_->SetInputEventSensitivity(is_primary); |
1521 | 75 | QueueRelayout(); | 52 | }); |
1452 | 76 | QueueDraw(); | ||
1453 | 77 | }); | ||
1454 | 78 | |||
1455 | 79 | scale.changed.connect([this] (double scale) { | ||
1456 | 80 | if (prompt_view_ && primary()) | ||
1457 | 81 | prompt_view_->scale = scale; | ||
1458 | 82 | |||
1459 | 83 | if (cof_view_) | ||
1460 | 84 | cof_view_->scale = scale; | ||
1461 | 85 | |||
1462 | 86 | if (prompt_layout_) | ||
1463 | 87 | prompt_layout_->SetLeftAndRightPadding(2 * Settings::GRID_SIZE.CP(scale)); | ||
1464 | 88 | |||
1465 | 89 | background_layer_.reset(); | ||
1466 | 90 | UpdateBackgroundTexture(); | ||
1467 | 91 | }); | ||
1468 | 92 | |||
1469 | 93 | mouse_move.connect([this] (int x, int y, int, int, unsigned long, unsigned long) { | ||
1470 | 94 | auto const& abs_geo = GetAbsoluteGeometry(); | ||
1471 | 95 | grab_motion.emit(abs_geo.x + x, abs_geo.y + y); | ||
1472 | 96 | }); | ||
1473 | 97 | } | ||
1474 | 98 | |||
1475 | 99 | void Shield::UpdateScale() | ||
1476 | 100 | { | ||
1477 | 101 | scale = unity::Settings::Instance().em(monitor)->DPIScale(); | ||
1478 | 102 | } | ||
1479 | 103 | |||
1480 | 104 | void Shield::UpdateBackgroundTexture() | ||
1481 | 105 | { | ||
1482 | 106 | auto const& monitor_geo = UScreen::GetDefault()->GetMonitorGeometry(monitor); | ||
1483 | 107 | |||
1484 | 108 | if (!background_layer_ || monitor_geo != background_layer_->GetGeometry()) | ||
1485 | 109 | { | ||
1486 | 110 | auto background_texture = bg_settings_->GetBackgroundTexture(monitor); | ||
1487 | 111 | background_layer_.reset(new nux::TextureLayer(background_texture->GetDeviceTexture(), nux::TexCoordXForm(), nux::color::White, true)); | ||
1488 | 112 | SetBackgroundLayer(background_layer_.get()); | ||
1489 | 113 | } | ||
1490 | 114 | } | ||
1491 | 115 | |||
1492 | 116 | void Shield::GrabScreen(bool cancel_on_failure) | ||
1493 | 117 | { | ||
1494 | 118 | auto& wc = nux::GetWindowCompositor(); | ||
1495 | 119 | |||
1496 | 120 | if (wc.GrabPointerAdd(this) && wc.GrabKeyboardAdd(this)) | ||
1497 | 121 | { | ||
1498 | 122 | regrab_conn_->disconnect(); | ||
1499 | 123 | regrab_timeout_.reset(); | ||
1500 | 124 | grabbed.emit(); | ||
1501 | 125 | } | ||
1502 | 126 | else | ||
1503 | 127 | { | ||
1504 | 128 | auto const& retry_cb = sigc::bind(sigc::mem_fun(this, &Shield::GrabScreen), false); | ||
1505 | 129 | regrab_conn_ = WindowManager::Default().screen_ungrabbed.connect(retry_cb); | ||
1506 | 130 | |||
1507 | 131 | if (cancel_on_failure) | ||
1508 | 132 | { | ||
1509 | 133 | regrab_timeout_.reset(new glib::Timeout(MAX_GRAB_WAIT, [this] { | ||
1510 | 134 | grab_failed.emit(); | ||
1511 | 135 | return false; | ||
1512 | 136 | })); | ||
1513 | 137 | } | ||
1514 | 138 | } | ||
1515 | 139 | } | ||
1516 | 140 | |||
1517 | 141 | bool Shield::HasGrab() const | ||
1518 | 142 | { | ||
1519 | 143 | auto& wc = nux::GetWindowCompositor(); | ||
1520 | 144 | return (wc.GetPointerGrabArea() == this && wc.GetKeyboardGrabArea() == this); | ||
1522 | 145 | } | 53 | } |
1523 | 146 | 54 | ||
1524 | 147 | void Shield::ShowPrimaryView() | 55 | void Shield::ShowPrimaryView() |
1525 | @@ -181,27 +89,6 @@ | |||
1526 | 181 | main_layout->AddSpace(0, 10); | 89 | main_layout->AddSpace(0, 10); |
1527 | 182 | } | 90 | } |
1528 | 183 | 91 | ||
1529 | 184 | void Shield::ShowSecondaryView() | ||
1530 | 185 | { | ||
1531 | 186 | if (prompt_layout_) | ||
1532 | 187 | prompt_layout_->RemoveChildObject(prompt_view_.GetPointer()); | ||
1533 | 188 | |||
1534 | 189 | if (cof_layout_) | ||
1535 | 190 | { | ||
1536 | 191 | SetLayout(cof_layout_.GetPointer()); | ||
1537 | 192 | return; | ||
1538 | 193 | } | ||
1539 | 194 | |||
1540 | 195 | nux::Layout* main_layout = new nux::VLayout(); | ||
1541 | 196 | cof_layout_ = main_layout; | ||
1542 | 197 | SetLayout(cof_layout_.GetPointer()); | ||
1543 | 198 | |||
1544 | 199 | // The circle of friends | ||
1545 | 200 | cof_view_ = new CofView(); | ||
1546 | 201 | cof_view_->scale = scale(); | ||
1547 | 202 | main_layout->AddView(cof_view_); | ||
1548 | 203 | } | ||
1549 | 204 | |||
1550 | 205 | Panel* Shield::CreatePanel() | 92 | Panel* Shield::CreatePanel() |
1551 | 206 | { | 93 | { |
1552 | 207 | if (!indicators_ || !session_manager_) | 94 | if (!indicators_ || !session_manager_) |
1553 | @@ -259,21 +146,6 @@ | |||
1554 | 259 | return nullptr; | 146 | return nullptr; |
1555 | 260 | } | 147 | } |
1556 | 261 | 148 | ||
1557 | 262 | bool Shield::AcceptKeyNavFocus() | ||
1558 | 263 | { | ||
1559 | 264 | return false; | ||
1560 | 265 | } | ||
1561 | 266 | |||
1562 | 267 | nux::Area* Shield::FindAreaUnderMouse(nux::Point const& mouse, nux::NuxEventType event_type) | ||
1563 | 268 | { | ||
1564 | 269 | nux::Area* area = BaseWindow::FindAreaUnderMouse(mouse, event_type); | ||
1565 | 270 | |||
1566 | 271 | if (!area && primary) | ||
1567 | 272 | return this; | ||
1568 | 273 | |||
1569 | 274 | return area; | ||
1570 | 275 | } | ||
1571 | 276 | |||
1572 | 277 | bool Shield::IsIndicatorOpen() const | 149 | bool Shield::IsIndicatorOpen() const |
1573 | 278 | { | 150 | { |
1574 | 279 | return panel_view_ ? panel_view_->active() : false; | 151 | return panel_view_ ? panel_view_->active() : false; |
1575 | 280 | 152 | ||
1576 | === modified file 'lockscreen/LockScreenShield.h' | |||
1577 | --- lockscreen/LockScreenShield.h 2014-09-19 18:02:37 +0000 | |||
1578 | +++ lockscreen/LockScreenShield.h 2016-01-15 01:41:44 +0000 | |||
1579 | @@ -21,56 +21,37 @@ | |||
1580 | 21 | #define UNITY_LOCKSCREEN_SHIELD_H | 21 | #define UNITY_LOCKSCREEN_SHIELD_H |
1581 | 22 | 22 | ||
1582 | 23 | #include <UnityCore/ConnectionManager.h> | 23 | #include <UnityCore/ConnectionManager.h> |
1585 | 24 | #include <UnityCore/GLibSource.h> | 24 | #include "LockScreenBaseShield.h" |
1584 | 25 | #include "LockScreenAbstractShield.h" | ||
1586 | 26 | 25 | ||
1587 | 27 | namespace unity | 26 | namespace unity |
1588 | 28 | { | 27 | { |
1589 | 29 | namespace lockscreen | 28 | namespace lockscreen |
1590 | 30 | { | 29 | { |
1591 | 31 | 30 | ||
1595 | 32 | class BackgroundSettings; | 31 | class AbstractUserPromptView; |
1593 | 33 | class UserAuthenticator; | ||
1594 | 34 | class UserPromptView; | ||
1596 | 35 | class Panel; | 32 | class Panel; |
1597 | 36 | class CofView; | ||
1598 | 37 | 33 | ||
1600 | 38 | class Shield : public AbstractShield | 34 | class Shield : public BaseShield |
1601 | 39 | { | 35 | { |
1602 | 40 | public: | 36 | public: |
1603 | 41 | Shield(session::Manager::Ptr const&, | 37 | Shield(session::Manager::Ptr const&, |
1604 | 42 | indicator::Indicators::Ptr const&, | 38 | indicator::Indicators::Ptr const&, |
1605 | 43 | Accelerators::Ptr const&, | 39 | Accelerators::Ptr const&, |
1607 | 44 | nux::ObjectPtr<UserPromptView> const&, | 40 | nux::ObjectPtr<AbstractUserPromptView> const&, |
1608 | 45 | int monitor, bool is_primary); | 41 | int monitor, bool is_primary); |
1609 | 46 | 42 | ||
1610 | 47 | bool HasGrab() const override; | ||
1611 | 48 | bool IsIndicatorOpen() const override; | 43 | bool IsIndicatorOpen() const override; |
1612 | 49 | void ActivatePanel() override; | 44 | void ActivatePanel() override; |
1613 | 50 | 45 | ||
1614 | 51 | protected: | 46 | protected: |
1615 | 52 | bool AcceptKeyNavFocus() override; | ||
1616 | 53 | nux::Area* FindKeyFocusArea(unsigned int, unsigned long, unsigned long) override; | 47 | nux::Area* FindKeyFocusArea(unsigned int, unsigned long, unsigned long) override; |
1617 | 54 | nux::Area* FindAreaUnderMouse(nux::Point const&, nux::NuxEventType) override; | ||
1618 | 55 | 48 | ||
1619 | 56 | private: | 49 | private: |
1625 | 57 | void UpdateBackgroundTexture(); | 50 | void ShowPrimaryView() override; |
1621 | 58 | void GrabScreen(bool cancel_on_failure); | ||
1622 | 59 | void ShowPrimaryView(); | ||
1623 | 60 | void ShowSecondaryView(); | ||
1624 | 61 | void UpdateScale(); | ||
1626 | 62 | Panel* CreatePanel(); | 51 | Panel* CreatePanel(); |
1627 | 63 | 52 | ||
1628 | 64 | std::shared_ptr<BackgroundSettings> bg_settings_; | ||
1629 | 65 | std::unique_ptr<nux::AbstractPaintLayer> background_layer_; | ||
1630 | 66 | nux::ObjectPtr<nux::Layout> primary_layout_; | ||
1631 | 67 | nux::ObjectPtr<nux::Layout> prompt_layout_; | ||
1632 | 68 | nux::ObjectPtr<nux::Layout> cof_layout_; | ||
1633 | 69 | connection::Wrapper panel_active_conn_; | 53 | connection::Wrapper panel_active_conn_; |
1634 | 70 | connection::Wrapper regrab_conn_; | ||
1635 | 71 | glib::Source::UniquePtr regrab_timeout_; | ||
1636 | 72 | Panel* panel_view_; | 54 | Panel* panel_view_; |
1637 | 73 | CofView* cof_view_; | ||
1638 | 74 | }; | 55 | }; |
1639 | 75 | 56 | ||
1640 | 76 | } | 57 | } |
1641 | 77 | 58 | ||
1642 | === modified file 'lockscreen/LockScreenShieldFactory.cpp' | |||
1643 | --- lockscreen/LockScreenShieldFactory.cpp 2014-07-11 17:45:39 +0000 | |||
1644 | +++ lockscreen/LockScreenShieldFactory.cpp 2016-01-15 01:41:44 +0000 | |||
1645 | @@ -19,20 +19,28 @@ | |||
1646 | 19 | 19 | ||
1647 | 20 | #include "LockScreenShieldFactory.h" | 20 | #include "LockScreenShieldFactory.h" |
1648 | 21 | #include "LockScreenShield.h" | 21 | #include "LockScreenShield.h" |
1650 | 22 | #include "UserPromptView.h" | 22 | #include "KylinLockScreenShield.h" |
1651 | 23 | #include "unity-shared/UnitySettings.h" | ||
1652 | 23 | 24 | ||
1653 | 24 | namespace unity | 25 | namespace unity |
1654 | 25 | { | 26 | { |
1655 | 26 | namespace lockscreen | 27 | namespace lockscreen |
1656 | 27 | { | 28 | { |
1657 | 28 | 29 | ||
1663 | 29 | nux::ObjectPtr<AbstractShield> ShieldFactory::CreateShield(session::Manager::Ptr const& session_manager, | 30 | nux::ObjectPtr<BaseShield> ShieldFactory::CreateShield(session::Manager::Ptr const& session_manager, |
1664 | 30 | indicator::Indicators::Ptr const& indicators, | 31 | indicator::Indicators::Ptr const& indicators, |
1665 | 31 | Accelerators::Ptr const& accelerators, | 32 | Accelerators::Ptr const& accelerators, |
1666 | 32 | nux::ObjectPtr<UserPromptView> const& prompt_view, | 33 | nux::ObjectPtr<AbstractUserPromptView> const& prompt_view, |
1667 | 33 | int monitor, bool is_primary) | 34 | int monitor, bool is_primary) |
1668 | 34 | { | 35 | { |
1670 | 35 | return nux::ObjectPtr<Shield>(new Shield(session_manager, indicators, accelerators, prompt_view, monitor, is_primary)); | 36 | nux::ObjectPtr<BaseShield> shield; |
1671 | 37 | |||
1672 | 38 | if (Settings::Instance().desktop_type() == DesktopType::UBUNTUKYLIN) | ||
1673 | 39 | shield = new KylinShield(session_manager, accelerators, prompt_view, monitor, is_primary); | ||
1674 | 40 | else | ||
1675 | 41 | shield = new Shield(session_manager, indicators, accelerators, prompt_view, monitor, is_primary); | ||
1676 | 42 | |||
1677 | 43 | return shield; | ||
1678 | 36 | } | 44 | } |
1679 | 37 | 45 | ||
1680 | 38 | } | 46 | } |
1681 | 39 | 47 | ||
1682 | === modified file 'lockscreen/LockScreenShieldFactory.h' | |||
1683 | --- lockscreen/LockScreenShieldFactory.h 2014-07-11 17:45:39 +0000 | |||
1684 | +++ lockscreen/LockScreenShieldFactory.h 2016-01-15 01:41:44 +0000 | |||
1685 | @@ -20,18 +20,19 @@ | |||
1686 | 20 | #ifndef UNITY_LOCKSCREEN_SHIELD_FACTORY | 20 | #ifndef UNITY_LOCKSCREEN_SHIELD_FACTORY |
1687 | 21 | #define UNITY_LOCKSCREEN_SHIELD_FACTORY | 21 | #define UNITY_LOCKSCREEN_SHIELD_FACTORY |
1688 | 22 | 22 | ||
1691 | 23 | #include <Nux/Nux.h> | 23 | #include <NuxCore/NuxCore.h> |
1692 | 24 | #include "LockScreenAbstractShield.h" | 24 | #include <UnityCore/SessionManager.h> |
1693 | 25 | #include <UnityCore/Indicators.h> | ||
1694 | 26 | #include "LockScreenAccelerators.h" | ||
1695 | 25 | 27 | ||
1696 | 26 | namespace unity | 28 | namespace unity |
1697 | 27 | { | 29 | { |
1698 | 28 | |||
1699 | 29 | class MockableBaseWindow; | 30 | class MockableBaseWindow; |
1700 | 30 | 31 | ||
1701 | 31 | namespace lockscreen | 32 | namespace lockscreen |
1702 | 32 | { | 33 | { |
1705 | 33 | 34 | class AbstractUserPromptView; | |
1706 | 34 | class UserPromptView; | 35 | class BaseShield; |
1707 | 35 | 36 | ||
1708 | 36 | struct ShieldFactoryInterface | 37 | struct ShieldFactoryInterface |
1709 | 37 | { | 38 | { |
1710 | @@ -39,23 +40,23 @@ | |||
1711 | 39 | 40 | ||
1712 | 40 | virtual ~ShieldFactoryInterface() = default; | 41 | virtual ~ShieldFactoryInterface() = default; |
1713 | 41 | 42 | ||
1719 | 42 | virtual nux::ObjectPtr<AbstractShield> CreateShield(session::Manager::Ptr const&, | 43 | virtual nux::ObjectPtr<BaseShield> CreateShield(session::Manager::Ptr const&, |
1720 | 43 | indicator::Indicators::Ptr const&, | 44 | indicator::Indicators::Ptr const&, |
1721 | 44 | Accelerators::Ptr const&, | 45 | Accelerators::Ptr const&, |
1722 | 45 | nux::ObjectPtr<UserPromptView> const&, | 46 | nux::ObjectPtr<AbstractUserPromptView> const&, |
1723 | 46 | int monitor, bool is_primary) = 0; | 47 | int monitor, bool is_primary) = 0; |
1724 | 47 | }; | 48 | }; |
1725 | 48 | 49 | ||
1726 | 49 | struct ShieldFactory : ShieldFactoryInterface | 50 | struct ShieldFactory : ShieldFactoryInterface |
1727 | 50 | { | 51 | { |
1733 | 51 | nux::ObjectPtr<AbstractShield> CreateShield(session::Manager::Ptr const&, | 52 | nux::ObjectPtr<BaseShield> CreateShield(session::Manager::Ptr const&, |
1734 | 52 | indicator::Indicators::Ptr const&, | 53 | indicator::Indicators::Ptr const&, |
1735 | 53 | Accelerators::Ptr const&, | 54 | Accelerators::Ptr const&, |
1736 | 54 | nux::ObjectPtr<UserPromptView> const&, | 55 | nux::ObjectPtr<AbstractUserPromptView> const&, |
1737 | 55 | int monitor, bool is_primary) override; | 56 | int monitor, bool is_primary) override; |
1738 | 56 | }; | 57 | }; |
1739 | 57 | 58 | ||
1740 | 58 | } | 59 | } |
1741 | 59 | } | 60 | } |
1742 | 60 | 61 | ||
1744 | 61 | #endif | 62 | #endif // UNITY_LOCKSCREEN_SHIELD_FACTORY |
1745 | 62 | 63 | ||
1746 | === modified file 'lockscreen/UserPromptView.cpp' | |||
1747 | --- lockscreen/UserPromptView.cpp 2015-11-06 13:50:59 +0000 | |||
1748 | +++ lockscreen/UserPromptView.cpp 2016-01-15 01:41:44 +0000 | |||
1749 | @@ -100,7 +100,7 @@ | |||
1750 | 100 | } | 100 | } |
1751 | 101 | 101 | ||
1752 | 102 | UserPromptView::UserPromptView(session::Manager::Ptr const& session_manager) | 102 | UserPromptView::UserPromptView(session::Manager::Ptr const& session_manager) |
1754 | 103 | : nux::View(NUX_TRACKER_LOCATION) | 103 | : AbstractUserPromptView(session_manager) |
1755 | 104 | , scale(1.0) | 104 | , scale(1.0) |
1756 | 105 | , session_manager_(session_manager) | 105 | , session_manager_(session_manager) |
1757 | 106 | , username_(nullptr) | 106 | , username_(nullptr) |
1758 | 107 | 107 | ||
1759 | === modified file 'lockscreen/UserPromptView.h' | |||
1760 | --- lockscreen/UserPromptView.h 2014-07-28 16:58:13 +0000 | |||
1761 | +++ lockscreen/UserPromptView.h 2016-01-15 01:41:44 +0000 | |||
1762 | @@ -27,6 +27,7 @@ | |||
1763 | 27 | #include <Nux/View.h> | 27 | #include <Nux/View.h> |
1764 | 28 | #include <UnityCore/SessionManager.h> | 28 | #include <UnityCore/SessionManager.h> |
1765 | 29 | 29 | ||
1766 | 30 | #include "LockScreenAbstractPromptView.h" | ||
1767 | 30 | #include "UserAuthenticatorPam.h" | 31 | #include "UserAuthenticatorPam.h" |
1768 | 31 | #include "unity-shared/IMTextEntry.h" | 32 | #include "unity-shared/IMTextEntry.h" |
1769 | 32 | 33 | ||
1770 | @@ -44,7 +45,7 @@ | |||
1771 | 44 | namespace lockscreen | 45 | namespace lockscreen |
1772 | 45 | { | 46 | { |
1773 | 46 | 47 | ||
1775 | 47 | class UserPromptView : public nux::View | 48 | class UserPromptView : public AbstractUserPromptView |
1776 | 48 | { | 49 | { |
1777 | 49 | public: | 50 | public: |
1778 | 50 | UserPromptView(session::Manager::Ptr const& session_manager); | 51 | UserPromptView(session::Manager::Ptr const& session_manager); |
1779 | 51 | 52 | ||
1780 | === added file 'resources/login.svg' | |||
1781 | --- resources/login.svg 1970-01-01 00:00:00 +0000 | |||
1782 | +++ resources/login.svg 2016-01-15 01:41:44 +0000 | |||
1783 | @@ -0,0 +1,8 @@ | |||
1784 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
1785 | 2 | <!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> | ||
1786 | 3 | <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> | ||
1787 | 4 | <svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" | ||
1788 | 5 | viewBox="0 0 34 34" enable-background="new 0 0 34 34" xml:space="preserve"> | ||
1789 | 6 | <rect x="0" display="none" fill="#CABADA" width="34" height="34"/> | ||
1790 | 7 | <polygon fill="#1A2A7C" points="7,16 21.6,16 16,10 20,10 26.9,17.5 20,25 16,25 21.5,19 7,19 "/> | ||
1791 | 8 | </svg> | ||
1792 | 0 | 9 | ||
1793 | === added file 'resources/switch_user.svg' | |||
1794 | --- resources/switch_user.svg 1970-01-01 00:00:00 +0000 | |||
1795 | +++ resources/switch_user.svg 2016-01-15 01:41:44 +0000 | |||
1796 | @@ -0,0 +1,13 @@ | |||
1797 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
1798 | 2 | <!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> | ||
1799 | 3 | <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> | ||
1800 | 4 | <svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" | ||
1801 | 5 | viewBox="0 0 34 34" enable-background="new 0 0 34 34" xml:space="preserve"> | ||
1802 | 6 | <rect x="0" display="none" fill="#CABADA" width="34" height="34"/> | ||
1803 | 7 | <polygon display="none" fill="#1A2A7C" points="7,16 21.6,16 16,10 20,10 26.9,17.5 20,25 16,25 21.5,19 7,19 "/> | ||
1804 | 8 | <g> | ||
1805 | 9 | <path fill="#FFFFFF" d="M17,1c8.8,0,16,7.2,16,16s-7.2,16-16,16S1,25.8,1,17S8.1,1,17,1 M17,0C7.6,0,0,7.6,0,17s7.6,17,17,17 | ||
1806 | 10 | s17-7.6,17-17S26.3,0,17,0L17,0z"/> | ||
1807 | 11 | </g> | ||
1808 | 12 | <polygon fill="#FFFFFF" points="13.9,9.6 19.2,9.6 14.9,14.8 27.6,14.8 27.6,20.1 14.8,20.1 19.1,25.4 13.9,25.4 6.4,17.5 "/> | ||
1809 | 13 | </svg> | ||
1810 | 0 | 14 | ||
1811 | === modified file 'shutdown/StandaloneSession.cpp' | |||
1812 | --- shutdown/StandaloneSession.cpp 2014-05-16 04:24:05 +0000 | |||
1813 | +++ shutdown/StandaloneSession.cpp 2016-01-15 01:41:44 +0000 | |||
1814 | @@ -39,6 +39,7 @@ | |||
1815 | 39 | std::string RealName() const { return "Marco Trevisan"; } | 39 | std::string RealName() const { return "Marco Trevisan"; } |
1816 | 40 | std::string UserName() const { return "marco"; } | 40 | std::string UserName() const { return "marco"; } |
1817 | 41 | std::string HostName() const { return "tricky"; } | 41 | std::string HostName() const { return "tricky"; } |
1818 | 42 | void UserIconFile(std::function<void(std::string const&)> const&) const { std::cout << "UserIconFile" << std::endl; } | ||
1819 | 42 | 43 | ||
1820 | 43 | void ScreenSaverActivate() { std::cout << "ScreenSaverActivate" << std::endl; } | 44 | void ScreenSaverActivate() { std::cout << "ScreenSaverActivate" << std::endl; } |
1821 | 44 | void ScreenSaverDeactivate() { std::cout << "ScreenSaverDeactivate" << std::endl; } | 45 | void ScreenSaverDeactivate() { std::cout << "ScreenSaverDeactivate" << std::endl; } |
1822 | @@ -49,6 +50,7 @@ | |||
1823 | 49 | void Shutdown() { std::cout << "Shutdown" << std::endl; } | 50 | void Shutdown() { std::cout << "Shutdown" << std::endl; } |
1824 | 50 | void Suspend() { std::cout << "Suspend" << std::endl; } | 51 | void Suspend() { std::cout << "Suspend" << std::endl; } |
1825 | 51 | void Hibernate() { std::cout << "Hibernate" << std::endl; } | 52 | void Hibernate() { std::cout << "Hibernate" << std::endl; } |
1826 | 53 | void SwitchToGreeter() { std::cout << "SwitchToGreeter" << std::endl; } | ||
1827 | 52 | 54 | ||
1828 | 53 | void CancelAction() { std::cout << "CancelAction" << std::endl; } | 55 | void CancelAction() { std::cout << "CancelAction" << std::endl; } |
1829 | 54 | 56 | ||
1830 | 55 | 57 | ||
1831 | === modified file 'tests/test_gnome_session_manager.cpp' | |||
1832 | --- tests/test_gnome_session_manager.cpp 2015-09-30 21:02:08 +0000 | |||
1833 | +++ tests/test_gnome_session_manager.cpp 2016-01-15 01:41:44 +0000 | |||
1834 | @@ -42,6 +42,7 @@ | |||
1835 | 42 | const std::string CONSOLE_KIT_PATH = "/org/freedesktop/ConsoleKit/Manager"; | 42 | const std::string CONSOLE_KIT_PATH = "/org/freedesktop/ConsoleKit/Manager"; |
1836 | 43 | const std::string SESSION_MANAGER_PATH = "/org/gnome/SessionManager"; | 43 | const std::string SESSION_MANAGER_PATH = "/org/gnome/SessionManager"; |
1837 | 44 | const std::string SESSION_MANAGER_PRESENCE_PATH = "/org/gnome/SessionManager/Presence"; | 44 | const std::string SESSION_MANAGER_PRESENCE_PATH = "/org/gnome/SessionManager/Presence"; |
1838 | 45 | const std::string DISPLAY_MANAGER_SEAT_PATH = "/org/freedesktop/DisplayManager/Seat0"; | ||
1839 | 45 | 46 | ||
1840 | 46 | const std::string SESSION_OPTIONS = "com.canonical.indicator.session"; | 47 | const std::string SESSION_OPTIONS = "com.canonical.indicator.session"; |
1841 | 47 | const std::string SUPPRESS_DIALOGS_KEY = "suppress-logout-restart-shutdown"; | 48 | const std::string SUPPRESS_DIALOGS_KEY = "suppress-logout-restart-shutdown"; |
1842 | @@ -137,6 +138,13 @@ | |||
1843 | 137 | </node> | 138 | </node> |
1844 | 138 | )"; | 139 | )"; |
1845 | 139 | 140 | ||
1846 | 141 | const std::string DISPLAY_MANAGER_SEAT = | ||
1847 | 142 | R"(<node> | ||
1848 | 143 | <interface name="org.freedesktop.DisplayManager.Seat"> | ||
1849 | 144 | <method name="SwitchToGreeter"/> | ||
1850 | 145 | </interface> | ||
1851 | 146 | </node> | ||
1852 | 147 | )"; | ||
1853 | 140 | } | 148 | } |
1854 | 141 | 149 | ||
1855 | 142 | struct MockGnomeSessionManager : session::GnomeManager { | 150 | struct MockGnomeSessionManager : session::GnomeManager { |
1856 | @@ -208,6 +216,9 @@ | |||
1857 | 208 | return nullptr; | 216 | return nullptr; |
1858 | 209 | }); | 217 | }); |
1859 | 210 | 218 | ||
1860 | 219 | display_manager_seat_ = std::make_shared<DBusServer>(); | ||
1861 | 220 | display_manager_seat_->AddObjects(introspection::DISPLAY_MANAGER_SEAT, DISPLAY_MANAGER_SEAT_PATH); | ||
1862 | 221 | |||
1863 | 211 | manager = std::make_shared<MockGnomeSessionManager>(); | 222 | manager = std::make_shared<MockGnomeSessionManager>(); |
1864 | 212 | shell_proxy_ = std::make_shared<DBusProxy>(TEST_SERVER_NAME, SHELL_OBJECT_PATH, SHELL_INTERFACE); | 223 | shell_proxy_ = std::make_shared<DBusProxy>(TEST_SERVER_NAME, SHELL_OBJECT_PATH, SHELL_INTERFACE); |
1865 | 213 | 224 | ||
1866 | @@ -228,6 +239,7 @@ | |||
1867 | 228 | Utils::WaitUntilMSec([] { return logind_->IsConnected(); }); | 239 | Utils::WaitUntilMSec([] { return logind_->IsConnected(); }); |
1868 | 229 | Utils::WaitUntilMSec([] { return console_kit_->IsConnected(); }); | 240 | Utils::WaitUntilMSec([] { return console_kit_->IsConnected(); }); |
1869 | 230 | Utils::WaitUntilMSec([] { return session_manager_->IsConnected(); }); | 241 | Utils::WaitUntilMSec([] { return session_manager_->IsConnected(); }); |
1870 | 242 | Utils::WaitUntilMSec([] { return display_manager_seat_->IsConnected(); }); | ||
1871 | 231 | Utils::WaitUntilMSec([] { return shell_proxy_->IsConnected();}); | 243 | Utils::WaitUntilMSec([] { return shell_proxy_->IsConnected();}); |
1872 | 232 | ASSERT_TRUE(shell_proxy_->IsConnected()); | 244 | ASSERT_TRUE(shell_proxy_->IsConnected()); |
1873 | 233 | EnableInteractiveShutdown(true); | 245 | EnableInteractiveShutdown(true); |
1874 | @@ -277,6 +289,7 @@ | |||
1875 | 277 | logind_.reset(); | 289 | logind_.reset(); |
1876 | 278 | console_kit_.reset(); | 290 | console_kit_.reset(); |
1877 | 279 | session_manager_.reset(); | 291 | session_manager_.reset(); |
1878 | 292 | display_manager_seat_.reset(); | ||
1879 | 280 | } | 293 | } |
1880 | 281 | 294 | ||
1881 | 282 | bool SettingsAvailable() | 295 | bool SettingsAvailable() |
1882 | @@ -342,6 +355,7 @@ | |||
1883 | 342 | static DBusServer::Ptr console_kit_; | 355 | static DBusServer::Ptr console_kit_; |
1884 | 343 | static DBusServer::Ptr logind_; | 356 | static DBusServer::Ptr logind_; |
1885 | 344 | static DBusServer::Ptr session_manager_; | 357 | static DBusServer::Ptr session_manager_; |
1886 | 358 | static DBusServer::Ptr display_manager_seat_; | ||
1887 | 345 | static DBusProxy::Ptr shell_proxy_; | 359 | static DBusProxy::Ptr shell_proxy_; |
1888 | 346 | }; | 360 | }; |
1889 | 347 | 361 | ||
1890 | @@ -350,6 +364,7 @@ | |||
1891 | 350 | DBusServer::Ptr TestGnomeSessionManager::console_kit_; | 364 | DBusServer::Ptr TestGnomeSessionManager::console_kit_; |
1892 | 351 | DBusServer::Ptr TestGnomeSessionManager::logind_; | 365 | DBusServer::Ptr TestGnomeSessionManager::logind_; |
1893 | 352 | DBusServer::Ptr TestGnomeSessionManager::session_manager_; | 366 | DBusServer::Ptr TestGnomeSessionManager::session_manager_; |
1894 | 367 | DBusServer::Ptr TestGnomeSessionManager::display_manager_seat_; | ||
1895 | 353 | DBusProxy::Ptr TestGnomeSessionManager::shell_proxy_; | 368 | DBusProxy::Ptr TestGnomeSessionManager::shell_proxy_; |
1896 | 354 | bool TestGnomeSessionManager::can_shutdown_; | 369 | bool TestGnomeSessionManager::can_shutdown_; |
1897 | 355 | bool TestGnomeSessionManager::can_suspend_; | 370 | bool TestGnomeSessionManager::can_suspend_; |
1898 | @@ -390,6 +405,23 @@ | |||
1899 | 390 | EXPECT_EQ(manager->HostName(), g_get_host_name()); | 405 | EXPECT_EQ(manager->HostName(), g_get_host_name()); |
1900 | 391 | } | 406 | } |
1901 | 392 | 407 | ||
1902 | 408 | TEST_F(TestGnomeSessionManager, SwitchToGreeter) | ||
1903 | 409 | { | ||
1904 | 410 | bool switch_called = false; | ||
1905 | 411 | |||
1906 | 412 | display_manager_seat_->GetObjects().front()->SetMethodsCallsHandler([&] (std::string const& method, GVariant*) { | ||
1907 | 413 | if (method == "SwitchToGreeter") | ||
1908 | 414 | switch_called = true; | ||
1909 | 415 | |||
1910 | 416 | return static_cast<GVariant*>(nullptr); | ||
1911 | 417 | }); | ||
1912 | 418 | |||
1913 | 419 | manager->SwitchToGreeter(); | ||
1914 | 420 | |||
1915 | 421 | Utils::WaitUntilMSec(switch_called); | ||
1916 | 422 | EXPECT_TRUE(switch_called); | ||
1917 | 423 | } | ||
1918 | 424 | |||
1919 | 393 | TEST_F(TestGnomeSessionManager, ScreenSaverActivate) | 425 | TEST_F(TestGnomeSessionManager, ScreenSaverActivate) |
1920 | 394 | { | 426 | { |
1921 | 395 | bool signal_emitted = false; | 427 | bool signal_emitted = false; |
1922 | 396 | 428 | ||
1923 | === modified file 'tests/test_lockscreen_controller.cpp' | |||
1924 | --- tests/test_lockscreen_controller.cpp 2014-09-19 18:02:37 +0000 | |||
1925 | +++ tests/test_lockscreen_controller.cpp 2016-01-15 01:41:44 +0000 | |||
1926 | @@ -20,7 +20,7 @@ | |||
1927 | 20 | #include <gmock/gmock.h> | 20 | #include <gmock/gmock.h> |
1928 | 21 | using namespace testing; | 21 | using namespace testing; |
1929 | 22 | 22 | ||
1931 | 23 | #include "lockscreen/UserPromptView.h" | 23 | #include "lockscreen/LockScreenAbstractPromptView.h" |
1932 | 24 | #include "lockscreen/LockScreenController.h" | 24 | #include "lockscreen/LockScreenController.h" |
1933 | 25 | 25 | ||
1934 | 26 | #include <Nux/NuxTimerTickSource.h> | 26 | #include <Nux/NuxTimerTickSource.h> |
1935 | @@ -51,26 +51,27 @@ | |||
1936 | 51 | } | 51 | } |
1937 | 52 | 52 | ||
1938 | 53 | 53 | ||
1940 | 54 | struct MockShield : AbstractShield | 54 | struct MockShield : BaseShield |
1941 | 55 | { | 55 | { |
1942 | 56 | MockShield() | 56 | MockShield() |
1944 | 57 | : AbstractShield(nullptr, nullptr, nullptr, nux::ObjectPtr<UserPromptView>(), 0, false) | 57 | : BaseShield(nullptr, nullptr, nullptr, nux::ObjectPtr<AbstractUserPromptView>(), 0, false) |
1945 | 58 | {} | 58 | {} |
1946 | 59 | 59 | ||
1947 | 60 | MOCK_CONST_METHOD0(IsIndicatorOpen, bool()); | 60 | MOCK_CONST_METHOD0(IsIndicatorOpen, bool()); |
1948 | 61 | MOCK_METHOD0(ActivatePanel, void()); | 61 | MOCK_METHOD0(ActivatePanel, void()); |
1949 | 62 | MOCK_CONST_METHOD0(HasGrab, bool()); | 62 | MOCK_CONST_METHOD0(HasGrab, bool()); |
1950 | 63 | MOCK_METHOD0(ShowPrimaryView, void()); | ||
1951 | 63 | }; | 64 | }; |
1952 | 64 | 65 | ||
1953 | 65 | struct ShieldFactoryMock : ShieldFactoryInterface | 66 | struct ShieldFactoryMock : ShieldFactoryInterface |
1954 | 66 | { | 67 | { |
1960 | 67 | nux::ObjectPtr<AbstractShield> CreateShield(session::Manager::Ptr const&, | 68 | nux::ObjectPtr<BaseShield> CreateShield(session::Manager::Ptr const&, |
1961 | 68 | indicator::Indicators::Ptr const&, | 69 | indicator::Indicators::Ptr const&, |
1962 | 69 | Accelerators::Ptr const&, | 70 | Accelerators::Ptr const&, |
1963 | 70 | nux::ObjectPtr<UserPromptView> const&, | 71 | nux::ObjectPtr<AbstractUserPromptView> const&, |
1964 | 71 | int, bool) override | 72 | int, bool) override |
1965 | 72 | { | 73 | { |
1967 | 73 | return nux::ObjectPtr<AbstractShield>(new MockShield()); | 74 | return nux::ObjectPtr<BaseShield>(new MockShield()); |
1968 | 74 | } | 75 | } |
1969 | 75 | }; | 76 | }; |
1970 | 76 | 77 | ||
1971 | 77 | 78 | ||
1972 | === modified file 'tests/test_mock_session_manager.h' | |||
1973 | --- tests/test_mock_session_manager.h 2014-05-16 04:24:05 +0000 | |||
1974 | +++ tests/test_mock_session_manager.h 2016-01-15 01:41:44 +0000 | |||
1975 | @@ -28,10 +28,12 @@ | |||
1976 | 28 | struct MockManager : Manager | 28 | struct MockManager : Manager |
1977 | 29 | { | 29 | { |
1978 | 30 | typedef std::shared_ptr<MockManager> Ptr; | 30 | typedef std::shared_ptr<MockManager> Ptr; |
1979 | 31 | typedef std::function<void(std::string const&)> ReplyCallback; | ||
1980 | 31 | 32 | ||
1981 | 32 | MOCK_CONST_METHOD0(RealName, std::string()); | 33 | MOCK_CONST_METHOD0(RealName, std::string()); |
1982 | 33 | MOCK_CONST_METHOD0(UserName, std::string()); | 34 | MOCK_CONST_METHOD0(UserName, std::string()); |
1983 | 34 | MOCK_CONST_METHOD0(HostName, std::string()); | 35 | MOCK_CONST_METHOD0(HostName, std::string()); |
1984 | 36 | MOCK_CONST_METHOD1(UserIconFile, void(ReplyCallback const&)); | ||
1985 | 35 | 37 | ||
1986 | 36 | MOCK_METHOD0(ScreenSaverActivate, void()); | 38 | MOCK_METHOD0(ScreenSaverActivate, void()); |
1987 | 37 | MOCK_METHOD0(ScreenSaverDeactivate, void()); | 39 | MOCK_METHOD0(ScreenSaverDeactivate, void()); |
1988 | @@ -43,6 +45,7 @@ | |||
1989 | 43 | MOCK_METHOD0(Suspend, void()); | 45 | MOCK_METHOD0(Suspend, void()); |
1990 | 44 | MOCK_METHOD0(Hibernate, void()); | 46 | MOCK_METHOD0(Hibernate, void()); |
1991 | 45 | MOCK_METHOD0(CancelAction, void()); | 47 | MOCK_METHOD0(CancelAction, void()); |
1992 | 48 | MOCK_METHOD0(SwitchToGreeter, void()); | ||
1993 | 46 | 49 | ||
1994 | 47 | MOCK_CONST_METHOD0(CanLock, bool()); | 50 | MOCK_CONST_METHOD0(CanLock, bool()); |
1995 | 48 | MOCK_CONST_METHOD0(CanShutdown, bool()); | 51 | MOCK_CONST_METHOD0(CanShutdown, bool()); |
1996 | 49 | 52 | ||
1997 | === modified file 'tests/test_unity_settings.cpp' | |||
1998 | --- tests/test_unity_settings.cpp 2014-03-21 19:45:29 +0000 | |||
1999 | +++ tests/test_unity_settings.cpp 2016-01-15 01:41:44 +0000 | |||
2000 | @@ -53,12 +53,14 @@ | |||
2001 | 53 | , sig_receiver(unity_settings) | 53 | , sig_receiver(unity_settings) |
2002 | 54 | { | 54 | { |
2003 | 55 | g_settings_set_enum(gsettings, "form-factor", static_cast<int>(unity::FormFactor::DESKTOP)); | 55 | g_settings_set_enum(gsettings, "form-factor", static_cast<int>(unity::FormFactor::DESKTOP)); |
2004 | 56 | g_settings_set_enum(gsettings, "desktop-type", static_cast<int>(unity::DesktopType::UBUNTU)); | ||
2005 | 56 | } | 57 | } |
2006 | 57 | 58 | ||
2007 | 58 | ~TestUnitySettings() | 59 | ~TestUnitySettings() |
2008 | 59 | { | 60 | { |
2009 | 60 | sig_receiver.notify_callbacks(); | 61 | sig_receiver.notify_callbacks(); |
2010 | 61 | g_settings_reset(gsettings, "form-factor"); | 62 | g_settings_reset(gsettings, "form-factor"); |
2011 | 63 | g_settings_reset(gsettings, "desktop-type"); | ||
2012 | 62 | } | 64 | } |
2013 | 63 | }; | 65 | }; |
2014 | 64 | 66 | ||
2015 | @@ -78,6 +80,14 @@ | |||
2016 | 78 | EXPECT_EQ(unity_settings->form_factor(), unity::FormFactor::NETBOOK); | 80 | EXPECT_EQ(unity_settings->form_factor(), unity::FormFactor::NETBOOK); |
2017 | 79 | } | 81 | } |
2018 | 80 | 82 | ||
2019 | 83 | TEST_F(TestUnitySettings, GetDesktopType) | ||
2020 | 84 | { | ||
2021 | 85 | ASSERT_NE(unity_settings->desktop_type(), unity::DesktopType::UBUNTUKYLIN); | ||
2022 | 86 | |||
2023 | 87 | g_settings_set_enum(gsettings, "desktop-type", static_cast<int>(unity::DesktopType::UBUNTUKYLIN)); | ||
2024 | 88 | EXPECT_EQ(unity_settings->desktop_type(), unity::DesktopType::UBUNTUKYLIN); | ||
2025 | 89 | } | ||
2026 | 90 | |||
2027 | 81 | TEST_F(TestUnitySettings, FormFactorChangedSignal_Extern) | 91 | TEST_F(TestUnitySettings, FormFactorChangedSignal_Extern) |
2028 | 82 | { | 92 | { |
2029 | 83 | EXPECT_CALL(sig_receiver, FormFactorChanged(unity::FormFactor::NETBOOK)); | 93 | EXPECT_CALL(sig_receiver, FormFactorChanged(unity::FormFactor::NETBOOK)); |
2030 | 84 | 94 | ||
2031 | === modified file 'unity-shared/TextInput.cpp' | |||
2032 | --- unity-shared/TextInput.cpp 2015-12-16 09:03:56 +0000 | |||
2033 | +++ unity-shared/TextInput.cpp 2016-01-15 01:41:44 +0000 | |||
2034 | @@ -54,6 +54,7 @@ | |||
2035 | 54 | const RawPixel TOOLTIP_OFFSET = 10_em; | 54 | const RawPixel TOOLTIP_OFFSET = 10_em; |
2036 | 55 | const RawPixel DEFAULT_ICON_SIZE = 22_em; | 55 | const RawPixel DEFAULT_ICON_SIZE = 22_em; |
2037 | 56 | 56 | ||
2038 | 57 | std::string ACTIVATOR_ICON = "arrow_right.png"; | ||
2039 | 57 | std::string WARNING_ICON = "dialog-warning-symbolic"; | 58 | std::string WARNING_ICON = "dialog-warning-symbolic"; |
2040 | 58 | // Fonts | 59 | // Fonts |
2041 | 59 | const std::string HINT_LABEL_DEFAULT_FONT_NAME = "Ubuntu"; | 60 | const std::string HINT_LABEL_DEFAULT_FONT_NAME = "Ubuntu"; |
2042 | @@ -88,9 +89,15 @@ | |||
2043 | 88 | 89 | ||
2044 | 89 | TextInput::TextInput(NUX_FILE_LINE_DECL) | 90 | TextInput::TextInput(NUX_FILE_LINE_DECL) |
2045 | 90 | : View(NUX_FILE_LINE_PARAM) | 91 | : View(NUX_FILE_LINE_PARAM) |
2046 | 92 | , activator_icon(ACTIVATOR_ICON) | ||
2047 | 93 | , activator_icon_size(DEFAULT_ICON_SIZE) | ||
2048 | 94 | , background_color(nux::Color(0.0f, 0.0f, 0.0f, 0.35f)) | ||
2049 | 95 | , border_color(nux::Color(1.0f, 1.0f, 1.0f, 0.7f)) | ||
2050 | 96 | , border_radius(BORDER_RADIUS) | ||
2051 | 91 | , input_hint("") | 97 | , input_hint("") |
2052 | 92 | , hint_font_name(HINT_LABEL_DEFAULT_FONT_NAME) | 98 | , hint_font_name(HINT_LABEL_DEFAULT_FONT_NAME) |
2053 | 93 | , hint_font_size(HINT_LABEL_FONT_SIZE) | 99 | , hint_font_size(HINT_LABEL_FONT_SIZE) |
2054 | 100 | , hint_color(nux::Color(1.0f, 1.0f, 1.0f, 0.5f)) | ||
2055 | 94 | , show_activator(false) | 101 | , show_activator(false) |
2056 | 95 | , show_lock_warnings(false) | 102 | , show_lock_warnings(false) |
2057 | 96 | , scale(1.0) | 103 | , scale(1.0) |
2058 | @@ -109,7 +116,9 @@ | |||
2059 | 109 | hint_layout_->SetLeftAndRightPadding(HINT_PADDING.CP(scale), HINT_PADDING.CP(scale)); | 116 | hint_layout_->SetLeftAndRightPadding(HINT_PADDING.CP(scale), HINT_PADDING.CP(scale)); |
2060 | 110 | 117 | ||
2061 | 111 | hint_ = new StaticCairoText(""); | 118 | hint_ = new StaticCairoText(""); |
2063 | 112 | hint_->SetTextColor(nux::Color(1.0f, 1.0f, 1.0f, 0.5f)); | 119 | hint_->SetTextColor(hint_color); |
2064 | 120 | hint_color.changed.connect(sigc::hide(sigc::mem_fun(this, &TextInput::UpdateHintColor))); | ||
2065 | 121 | |||
2066 | 113 | hint_->SetScale(scale); | 122 | hint_->SetScale(scale); |
2067 | 114 | hint_layout_->AddView(hint_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); | 123 | hint_layout_->AddView(hint_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); |
2068 | 115 | hint_font_name.changed.connect(sigc::hide(sigc::mem_fun(this, &TextInput::UpdateHintFont))); | 124 | hint_font_name.changed.connect(sigc::hide(sigc::mem_fun(this, &TextInput::UpdateHintFont))); |
2069 | @@ -146,10 +155,18 @@ | |||
2070 | 146 | Settings::Instance().font_scaling.changed.connect(sigc::hide(sigc::mem_fun(this, &TextInput::UpdateSize))); | 155 | Settings::Instance().font_scaling.changed.connect(sigc::hide(sigc::mem_fun(this, &TextInput::UpdateSize))); |
2071 | 147 | 156 | ||
2072 | 148 | // Activator | 157 | // Activator |
2074 | 149 | activator_ = new IconTexture(LoadActivatorIcon(DEFAULT_ICON_SIZE.CP(scale))); | 158 | activator_ = new IconTexture(LoadActivatorIcon(activator_icon(), activator_icon_size().CP(scale))); |
2075 | 150 | activator_->SetVisible(show_activator()); | 159 | activator_->SetVisible(show_activator()); |
2076 | 151 | layout_->AddView(activator_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); | 160 | layout_->AddView(activator_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); |
2077 | 152 | 161 | ||
2078 | 162 | activator_icon.changed.connect([this] (std::string icon) { | ||
2079 | 163 | activator_->SetTexture(LoadActivatorIcon(icon, activator_icon_size().CP(scale))); | ||
2080 | 164 | }); | ||
2081 | 165 | |||
2082 | 166 | activator_icon_size.changed.connect([this] (RawPixel icon_size) { | ||
2083 | 167 | activator_->SetTexture(LoadActivatorIcon(activator_icon(), icon_size.CP(scale))); | ||
2084 | 168 | }); | ||
2085 | 169 | |||
2086 | 153 | show_activator.changed.connect([this] (bool value) { | 170 | show_activator.changed.connect([this] (bool value) { |
2087 | 154 | activator_->SetVisible(value); | 171 | activator_->SetVisible(value); |
2088 | 155 | }); | 172 | }); |
2089 | @@ -185,6 +202,11 @@ | |||
2090 | 185 | warning_->mouse_leave.connect([this] (int x, int y, int button, int key_flags) { | 202 | warning_->mouse_leave.connect([this] (int x, int y, int button, int key_flags) { |
2091 | 186 | tooltip_timeout_ ? tooltip_timeout_.reset() : QueueDraw(); | 203 | tooltip_timeout_ ? tooltip_timeout_.reset() : QueueDraw(); |
2092 | 187 | }); | 204 | }); |
2093 | 205 | |||
2094 | 206 | //background | ||
2095 | 207 | background_color.changed.connect([this] (nux::Color color) { UpdateBackground(true); }); | ||
2096 | 208 | border_color.changed.connect([this] (nux::Color color) { UpdateBackground(true); }); | ||
2097 | 209 | border_radius.changed.connect([this] (int radius) { UpdateBackground(true); }); | ||
2098 | 188 | } | 210 | } |
2099 | 189 | 211 | ||
2100 | 190 | void TextInput::UpdateSize() | 212 | void TextInput::UpdateSize() |
2101 | @@ -208,7 +230,7 @@ | |||
2102 | 208 | hint_->SetMaximumHeight(pango_entry_->GetMinimumHeight()); | 230 | hint_->SetMaximumHeight(pango_entry_->GetMinimumHeight()); |
2103 | 209 | 231 | ||
2104 | 210 | spinner_->scale = scale; | 232 | spinner_->scale = scale; |
2106 | 211 | activator_->SetTexture(LoadActivatorIcon(DEFAULT_ICON_SIZE.CP(scale))); | 233 | activator_->SetTexture(LoadActivatorIcon(activator_icon(), activator_icon_size().CP(scale))); |
2107 | 212 | warning_->SetTexture(LoadWarningIcon(DEFAULT_ICON_SIZE.CP(scale))); | 234 | warning_->SetTexture(LoadWarningIcon(DEFAULT_ICON_SIZE.CP(scale))); |
2108 | 213 | warning_tooltip_.Release(); | 235 | warning_tooltip_.Release(); |
2109 | 214 | 236 | ||
2110 | @@ -254,10 +276,15 @@ | |||
2111 | 254 | hint_->SetFont((hint_font_name() + " " + std::to_string(hint_font_size())).c_str()); | 276 | hint_->SetFont((hint_font_name() + " " + std::to_string(hint_font_size())).c_str()); |
2112 | 255 | } | 277 | } |
2113 | 256 | 278 | ||
2115 | 257 | nux::ObjectPtr<nux::BaseTexture> TextInput::LoadActivatorIcon(int icon_size) | 279 | void TextInput::UpdateHintColor() |
2116 | 280 | { | ||
2117 | 281 | hint_->SetTextColor(hint_color); | ||
2118 | 282 | } | ||
2119 | 283 | |||
2120 | 284 | nux::ObjectPtr<nux::BaseTexture> TextInput::LoadActivatorIcon(std::string const& icon_file, int icon_size) | ||
2121 | 258 | { | 285 | { |
2122 | 259 | TextureCache& cache = TextureCache::GetDefault(); | 286 | TextureCache& cache = TextureCache::GetDefault(); |
2124 | 260 | return cache.FindTexture("arrow_right.png", icon_size, icon_size); | 287 | return cache.FindTexture(icon_file, icon_size, icon_size); |
2125 | 261 | } | 288 | } |
2126 | 262 | 289 | ||
2127 | 263 | nux::ObjectPtr<nux::BaseTexture> TextInput::LoadWarningIcon(int icon_size) | 290 | nux::ObjectPtr<nux::BaseTexture> TextInput::LoadWarningIcon(int icon_size) |
2128 | @@ -459,15 +486,15 @@ | |||
2129 | 459 | cairo_graphics.DrawRoundedRectangle(cr, | 486 | cairo_graphics.DrawRoundedRectangle(cr, |
2130 | 460 | 1.0f, | 487 | 1.0f, |
2131 | 461 | 0.5, 0.5, | 488 | 0.5, 0.5, |
2133 | 462 | BORDER_RADIUS, | 489 | border_radius(), |
2134 | 463 | (last_width_/scale) - 1, (last_height_/scale) - 1, | 490 | (last_width_/scale) - 1, (last_height_/scale) - 1, |
2135 | 464 | false); | 491 | false); |
2136 | 465 | 492 | ||
2137 | 466 | cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); | 493 | cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
2139 | 467 | cairo_set_source_rgba(cr, 0.0f, 0.0f, 0.0f, 0.35f); | 494 | cairo_set_source_rgba(cr, background_color().red, background_color().green, background_color().blue, background_color().alpha); |
2140 | 468 | cairo_fill_preserve(cr); | 495 | cairo_fill_preserve(cr); |
2141 | 469 | cairo_set_line_width(cr, 1); | 496 | cairo_set_line_width(cr, 1); |
2143 | 470 | cairo_set_source_rgba(cr, 1.0f, 1.0f, 1.0f, 0.7f); | 497 | cairo_set_source_rgba(cr, border_color().red, border_color().green, border_color().blue, border_color().alpha); |
2144 | 471 | cairo_stroke(cr); | 498 | cairo_stroke(cr); |
2145 | 472 | 499 | ||
2146 | 473 | auto texture2D = texture_ptr_from_cairo_graphics(cairo_graphics); | 500 | auto texture2D = texture_ptr_from_cairo_graphics(cairo_graphics); |
2147 | 474 | 501 | ||
2148 | === modified file 'unity-shared/TextInput.h' | |||
2149 | --- unity-shared/TextInput.h 2015-11-06 11:40:31 +0000 | |||
2150 | +++ unity-shared/TextInput.h 2016-01-15 01:41:44 +0000 | |||
2151 | @@ -26,6 +26,7 @@ | |||
2152 | 26 | 26 | ||
2153 | 27 | #include "Introspectable.h" | 27 | #include "Introspectable.h" |
2154 | 28 | #include "IMTextEntry.h" | 28 | #include "IMTextEntry.h" |
2155 | 29 | #include "RawPixel.h" | ||
2156 | 29 | #include "SearchBarSpinner.h" | 30 | #include "SearchBarSpinner.h" |
2157 | 30 | 31 | ||
2158 | 31 | namespace nux | 32 | namespace nux |
2159 | @@ -57,10 +58,16 @@ | |||
2160 | 57 | 58 | ||
2161 | 58 | IMTextEntry* text_entry() const; | 59 | IMTextEntry* text_entry() const; |
2162 | 59 | 60 | ||
2163 | 61 | nux::Property<std::string> activator_icon; | ||
2164 | 62 | nux::Property<RawPixel> activator_icon_size; | ||
2165 | 63 | nux::Property<nux::Color> background_color; | ||
2166 | 64 | nux::Property<nux::Color> border_color; | ||
2167 | 65 | nux::Property<int> border_radius; | ||
2168 | 60 | nux::RWProperty<std::string> input_string; | 66 | nux::RWProperty<std::string> input_string; |
2169 | 61 | nux::Property<std::string> input_hint; | 67 | nux::Property<std::string> input_hint; |
2170 | 62 | nux::Property<std::string> hint_font_name; | 68 | nux::Property<std::string> hint_font_name; |
2171 | 63 | nux::Property<int> hint_font_size; | 69 | nux::Property<int> hint_font_size; |
2172 | 70 | nux::Property<nux::Color> hint_color; | ||
2173 | 64 | nux::ROProperty<bool> im_active; | 71 | nux::ROProperty<bool> im_active; |
2174 | 65 | nux::ROProperty<bool> im_preedit; | 72 | nux::ROProperty<bool> im_preedit; |
2175 | 66 | nux::Property<bool> show_activator; | 73 | nux::Property<bool> show_activator; |
2176 | @@ -70,6 +77,7 @@ | |||
2177 | 70 | private: | 77 | private: |
2178 | 71 | void OnFontChanged(); | 78 | void OnFontChanged(); |
2179 | 72 | void UpdateHintFont(); | 79 | void UpdateHintFont(); |
2180 | 80 | void UpdateHintColor(); | ||
2181 | 73 | void Draw(nux::GraphicsEngine& GfxContext, bool force_draw); | 81 | void Draw(nux::GraphicsEngine& GfxContext, bool force_draw); |
2182 | 74 | void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw); | 82 | void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw); |
2183 | 75 | void UpdateBackground(bool force); | 83 | void UpdateBackground(bool force); |
2184 | @@ -84,7 +92,7 @@ | |||
2185 | 84 | void CheckLocks(); | 92 | void CheckLocks(); |
2186 | 85 | void OnLockStateChanged(bool); | 93 | void OnLockStateChanged(bool); |
2187 | 86 | 94 | ||
2189 | 87 | nux::ObjectPtr<nux::BaseTexture> LoadActivatorIcon(int icon_size); | 95 | nux::ObjectPtr<nux::BaseTexture> LoadActivatorIcon(std::string const& icon_file, int icon_size); |
2190 | 88 | nux::ObjectPtr<nux::BaseTexture> LoadWarningIcon(int icon_size); | 96 | nux::ObjectPtr<nux::BaseTexture> LoadWarningIcon(int icon_size); |
2191 | 89 | void LoadWarningTooltip(); | 97 | void LoadWarningTooltip(); |
2192 | 90 | 98 | ||
2193 | 91 | 99 | ||
2194 | === modified file 'unity-shared/UnitySettings.cpp' | |||
2195 | --- unity-shared/UnitySettings.cpp 2015-05-22 13:20:22 +0000 | |||
2196 | +++ unity-shared/UnitySettings.cpp 2016-01-15 01:41:44 +0000 | |||
2197 | @@ -38,6 +38,7 @@ | |||
2198 | 38 | const std::string SETTINGS_NAME = "com.canonical.Unity"; | 38 | const std::string SETTINGS_NAME = "com.canonical.Unity"; |
2199 | 39 | const std::string FORM_FACTOR = "form-factor"; | 39 | const std::string FORM_FACTOR = "form-factor"; |
2200 | 40 | const std::string DOUBLE_CLICK_ACTIVATE = "double-click-activate"; | 40 | const std::string DOUBLE_CLICK_ACTIVATE = "double-click-activate"; |
2201 | 41 | const std::string DESKTOP_TYPE = "desktop-type"; | ||
2202 | 41 | 42 | ||
2203 | 42 | const std::string LIM_SETTINGS = "com.canonical.Unity.IntegratedMenus"; | 43 | const std::string LIM_SETTINGS = "com.canonical.Unity.IntegratedMenus"; |
2204 | 43 | const std::string CLICK_MOVEMENT_THRESHOLD = "click-movement-threshold"; | 44 | const std::string CLICK_MOVEMENT_THRESHOLD = "click-movement-threshold"; |
2205 | @@ -94,6 +95,7 @@ | |||
2206 | 94 | parent_->form_factor.SetSetterFunction(sigc::mem_fun(this, &Impl::SetFormFactor)); | 95 | parent_->form_factor.SetSetterFunction(sigc::mem_fun(this, &Impl::SetFormFactor)); |
2207 | 95 | parent_->double_click_activate.SetGetterFunction(sigc::mem_fun(this, &Impl::GetDoubleClickActivate)); | 96 | parent_->double_click_activate.SetGetterFunction(sigc::mem_fun(this, &Impl::GetDoubleClickActivate)); |
2208 | 96 | parent_->remote_content.SetGetterFunction(sigc::mem_fun(this, &Impl::GetRemoteContentEnabled)); | 97 | parent_->remote_content.SetGetterFunction(sigc::mem_fun(this, &Impl::GetRemoteContentEnabled)); |
2209 | 98 | parent_->desktop_type.SetGetterFunction(sigc::mem_fun(this, &Impl::GetDesktopType)); | ||
2210 | 97 | 99 | ||
2211 | 98 | for (unsigned i = 0; i < monitors::MAX; ++i) | 100 | for (unsigned i = 0; i < monitors::MAX; ++i) |
2212 | 99 | em_converters_.emplace_back(std::make_shared<EMConverter>()); | 101 | em_converters_.emplace_back(std::make_shared<EMConverter>()); |
2213 | @@ -218,6 +220,11 @@ | |||
2214 | 218 | return cached_double_click_activate_; | 220 | return cached_double_click_activate_; |
2215 | 219 | } | 221 | } |
2216 | 220 | 222 | ||
2217 | 223 | DesktopType GetDesktopType() const | ||
2218 | 224 | { | ||
2219 | 225 | return static_cast<DesktopType>(g_settings_get_enum(usettings_, DESKTOP_TYPE.c_str())); | ||
2220 | 226 | } | ||
2221 | 227 | |||
2222 | 221 | int GetFontSize() const | 228 | int GetFontSize() const |
2223 | 222 | { | 229 | { |
2224 | 223 | gint font_size; | 230 | gint font_size; |
2225 | 224 | 231 | ||
2226 | === modified file 'unity-shared/UnitySettings.h' | |||
2227 | --- unity-shared/UnitySettings.h 2015-05-22 13:20:22 +0000 | |||
2228 | +++ unity-shared/UnitySettings.h 2016-01-15 01:41:44 +0000 | |||
2229 | @@ -35,6 +35,12 @@ | |||
2230 | 35 | TV | 35 | TV |
2231 | 36 | }; | 36 | }; |
2232 | 37 | 37 | ||
2233 | 38 | enum class DesktopType | ||
2234 | 39 | { | ||
2235 | 40 | UBUNTU, | ||
2236 | 41 | UBUNTUKYLIN | ||
2237 | 42 | }; | ||
2238 | 43 | |||
2239 | 38 | class Settings | 44 | class Settings |
2240 | 39 | { | 45 | { |
2241 | 40 | public: | 46 | public: |
2242 | @@ -51,6 +57,7 @@ | |||
2243 | 51 | 57 | ||
2244 | 52 | nux::RWProperty<FormFactor> form_factor; | 58 | nux::RWProperty<FormFactor> form_factor; |
2245 | 53 | nux::Property<bool> is_standalone; | 59 | nux::Property<bool> is_standalone; |
2246 | 60 | nux::ROProperty<DesktopType> desktop_type; | ||
2247 | 54 | nux::ROProperty<bool> double_click_activate; | 61 | nux::ROProperty<bool> double_click_activate; |
2248 | 55 | nux::Property<unsigned> lim_movement_thresold; | 62 | nux::Property<unsigned> lim_movement_thresold; |
2249 | 56 | nux::Property<unsigned> lim_double_click_wait; | 63 | nux::Property<unsigned> lim_double_click_wait; |
As a first thing (i'm going into details soon), I think you should properly re-base your changes with trunk because this branch is reverting many changes happened upstream.
Looking at what changed, I think you should probably uncommit your last revision (4040, which is the one causing troubles), and push here again.
So:
bzr shelve --all -m tmp
bzr uncommit
bzr revert
bzr push --overwrite lp:~feng-kylin/unity/ExtendLockscreenTheme
bzr unshelve
If you need to revert 4038, use:
bzr merge -r 4038..4037 .