Merge lp:~feng-kylin/unity/ExtendLockscreenTheme into lp:unity

Proposed by handsome_feng
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
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.

To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

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 .

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) :
review: Needs Fixing
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Ah, also revert the changes applied at po files at revision 4022

Revision history for this message
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.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

I would prefer to call LockScreenAbstractShield as LockScreenBaseShield and 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.

Revision history for this message
handsome_feng (feng-kylin) wrote :

> I would prefer to call LockScreenAbstractShield as LockScreenBaseShield and
> 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.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

So, I've done some cleanup to this, adding the LockScreenBaseShield class, you can merge with lp:~3v1n0/unity/kylin-lockscreen-cleanup

See the merge proposal at lp:~3v1n0/unity/kylin-lockscreen-cleanup/+merge/279546 for the diff.

Revision history for this message
handsome_feng (feng-kylin) wrote :

> So, I've done some cleanup to this, adding the LockScreenBaseShield class, you
> can merge with lp:~3v1n0/unity/kylin-lockscreen-cleanup
>
> See the merge proposal at lp:~3v1n0/unity/kylin-lockscreen-
> cleanup/+merge/279546 for the diff.

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 :) ).

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Ok, I can say it looks good now...

Thanks a lot!

review: Approve
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

This branch doesn't build anymore now when merged to trunk:

/«BUILDDIR»/unity-7.4.0+16.04.20160114/lockscreen/KylinUserPromptView.cpp: In member function 'void unity::lockscreen::KylinUserPromptView::AddPrompt(const string&, bool, const PromiseAuthCodePtr&)':
/«BUILDDIR»/unity-7.4.0+16.04.20160114/lockscreen/KylinUserPromptView.cpp:299:15: error: 'class unity::TextInput' has no member named 'show_caps_lock'
   text_input->show_caps_lock = true;

Can you please fix this by replacing "show_caps_lock" with "show_lock_warnings" ?

Thanks

Revision history for this message
handsome_feng (feng-kylin) wrote :

> This branch doesn't build anymore now when merged to trunk:
>
> /«BUILDDIR»/unity-7.4.0+16.04.20160114/lockscreen/KylinUserPromptView.cpp: In
> member function 'void unity::lockscreen::KylinUserPromptView::AddPrompt(const
> string&, bool, const PromiseAuthCodePtr&)':
> /«BUILDDIR»/unity-7.4.0+16.04.20160114/lockscreen/KylinUserPromptView.cpp:299:
> 15: error: 'class unity::TextInput' has no member named 'show_caps_lock'
> text_input->show_caps_lock = true;
>
> Can you please fix this by replacing "show_caps_lock" with
> "show_lock_warnings" ?
>
> Thanks

Done.

Preview Diff

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