Merge lp:~3v1n0/unity/lockscreen-panel into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Merged at revision: 3705
Proposed branch: lp:~3v1n0/unity/lockscreen-panel
Merge into: lp:unity
Prerequisite: lp:~3v1n0/unity/lockscreen-review
Diff against target: 1623 lines (+781/-146)
35 files modified
UnityCore/SessionManager.h (+2/-0)
lockscreen/BackgroundSettings.cpp (+24/-41)
lockscreen/CMakeLists.txt (+1/-0)
lockscreen/LockScreenAbstractShield.h (+6/-1)
lockscreen/LockScreenController.cpp (+22/-6)
lockscreen/LockScreenController.h (+3/-1)
lockscreen/LockScreenPanel.cpp (+225/-0)
lockscreen/LockScreenPanel.h (+75/-0)
lockscreen/LockScreenSettings.cpp (+38/-0)
lockscreen/LockScreenSettings.h (+11/-0)
lockscreen/LockScreenShield.cpp (+56/-52)
lockscreen/LockScreenShield.h (+10/-11)
lockscreen/LockScreenShieldFactory.cpp (+2/-2)
lockscreen/LockScreenShieldFactory.h (+2/-2)
lockscreen/UserAuthenticatorPam.cpp (+1/-1)
lockscreen/UserPromptView.cpp (+1/-2)
lockscreen/pch/lockscreen_pch.hh (+2/-1)
panel/PanelIndicatorEntryView.cpp (+1/-1)
panel/PanelIndicatorsView.cpp (+8/-0)
panel/PanelIndicatorsView.h (+1/-0)
panel/PanelMenuView.cpp (+0/-1)
panel/PanelMenuView.h (+0/-1)
panel/PanelView.cpp (+6/-14)
panel/PanelView.h (+1/-2)
plugins/unityshell/src/unityshell.cpp (+28/-4)
plugins/unityshell/src/unityshell.h (+3/-0)
services/panel-service.c (+1/-1)
shutdown/CMakeLists.txt (+1/-0)
shutdown/SessionDBusManager.cpp (+180/-0)
shutdown/SessionDBusManager.h (+50/-0)
shutdown/StandaloneSession.cpp (+1/-0)
tests/data/external.gschema.xml (+6/-0)
tests/test_lockscreen_controller.cpp (+11/-2)
tests/test_mock_session_manager.h (+1/-0)
unity-shared/WindowManager.h (+1/-0)
To merge this branch: bzr merge lp:~3v1n0/unity/lockscreen-panel
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Andrea Azzarone (community) Approve
Brandon Schaefer (community) Approve
Review via email: mp+209797@code.launchpad.net

Commit message

LockScreenPanel: added a light version of PanelView for Lockscreen only, using PanelIndicatorsView

 - Indicators scrubbing using mouse works again
 - Indicators key navigation is supported (Alt+F10 included)
 - Indicators will be correctly visible in light themes as well
 - Show hostname (optionally) on the top left side of the panel
 - LockScreenSettings now bind settings from unity-greeter dconf path

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

LGTM

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Andrea Azzarone (azzar1) wrote :

Look good to me now.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'UnityCore/SessionManager.h'
2--- UnityCore/SessionManager.h 2014-03-11 14:11:14 +0000
3+++ UnityCore/SessionManager.h 2014-03-11 14:11:15 +0000
4@@ -59,6 +59,8 @@
5
6 sigc::signal<void> lock_requested;
7 sigc::signal<void> unlock_requested;
8+ sigc::signal<void> locked;
9+ sigc::signal<void> unlocked;
10 sigc::signal<void, bool /* inhibitors */> logout_requested;
11 sigc::signal<void, bool /* inhibitors */> reboot_requested;
12 sigc::signal<void, bool /* inhibitors */> shutdown_requested;
13
14=== modified file 'lockscreen/BackgroundSettings.cpp'
15--- lockscreen/BackgroundSettings.cpp 2014-03-11 14:11:14 +0000
16+++ lockscreen/BackgroundSettings.cpp 2014-03-11 14:11:15 +0000
17@@ -34,12 +34,6 @@
18 namespace
19 {
20 const std::string SETTINGS_NAME = "org.gnome.desktop.background";
21-const std::string GREETER_SETTINGS = "com.canonical.unity-greeter";
22-const std::string LOGO_KEY = "logo";
23-const std::string BACKGROUND_KEY = "background";
24-const std::string BACKGROUND_COLOR_KEY = "background-color";
25-const std::string USER_BG_KEY = "draw-user-backgrounds";
26-const std::string DRAW_GRID_KEY = "draw-grid";
27
28 constexpr int GetGridOffset(int size) { return (size % Settings::GRID_SIZE) / 2; }
29 }
30@@ -57,30 +51,23 @@
31 BaseTexturePtr BackgroundSettings::GetBackgroundTexture(int monitor)
32 {
33 nux::Geometry const& geo = UScreen::GetDefault()->GetMonitorGeometry(monitor);
34- glib::Object<GSettings> greeter_settings(g_settings_new(GREETER_SETTINGS.c_str()));
35- bool user_bg = g_settings_get_boolean(greeter_settings, USER_BG_KEY.c_str()) != FALSE;
36- bool draw_grid = g_settings_get_boolean(greeter_settings, DRAW_GRID_KEY.c_str()) != FALSE;
37+ auto& settings = Settings::Instance();
38
39 nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, geo.width, geo.height);
40 cairo_t* c = cairo_graphics.GetInternalContext();
41
42 cairo_surface_t* bg_surface = nullptr;
43
44- if (user_bg)
45+ if (settings.use_user_background())
46 {
47 bg_surface = gnome_bg_create_surface(gnome_bg_, gdk_get_default_root_window(), geo.width, geo.height, FALSE);
48 }
49- else
50+ else if (!settings.background().empty())
51 {
52- glib::String bg_file(g_settings_get_string(greeter_settings, BACKGROUND_KEY.c_str()));
53-
54- if (bg_file)
55- {
56- glib::Object<GdkPixbuf> pixbuf(gdk_pixbuf_new_from_file_at_scale(bg_file, geo.width, geo.height, FALSE, NULL));
57-
58- if (pixbuf)
59- bg_surface = gdk_cairo_surface_create_from_pixbuf(pixbuf, 0, NULL);
60- }
61+ glib::Object<GdkPixbuf> pixbuf(gdk_pixbuf_new_from_file_at_scale(settings.background().c_str(), geo.width, geo.height, FALSE, NULL));
62+
63+ if (pixbuf)
64+ bg_surface = gdk_cairo_surface_create_from_pixbuf(pixbuf, 0, NULL);
65 }
66
67 if (bg_surface)
68@@ -91,43 +78,39 @@
69 }
70 else
71 {
72- nux::Color bg_color(glib::String(g_settings_get_string(greeter_settings, BACKGROUND_COLOR_KEY.c_str())).Str());
73+ auto const& bg_color = settings.background_color();
74 cairo_set_source_rgb(c, bg_color.red, bg_color.green, bg_color.blue);
75 cairo_paint(c);
76 }
77
78+ if (!settings.logo().empty())
79 {
80- glib::String logo(g_settings_get_string(greeter_settings, LOGO_KEY.c_str()));
81 int grid_x_offset = GetGridOffset(geo.width);
82 int grid_y_offset = GetGridOffset(geo.height);
83+ cairo_surface_t* logo_surface = cairo_image_surface_create_from_png(settings.logo().c_str());
84
85- if (logo && !logo.Str().empty())
86+ if (logo_surface)
87 {
88- cairo_surface_t* logo_surface = cairo_image_surface_create_from_png(logo);
89-
90- if (logo_surface)
91- {
92- int height = cairo_image_surface_get_height(logo_surface);
93- int x = grid_x_offset;
94- int y = grid_y_offset + Settings::GRID_SIZE * (geo.height / Settings::GRID_SIZE - 1) - height;
95-
96- cairo_save(c);
97- cairo_translate(c, x, y);
98-
99- cairo_set_source_surface(c, logo_surface, 0, 0);
100- cairo_paint_with_alpha(c, 0.5);
101- cairo_surface_destroy(logo_surface);
102- cairo_restore(c);
103- }
104+ int height = cairo_image_surface_get_height(logo_surface);
105+ int x = grid_x_offset;
106+ int y = grid_y_offset + Settings::GRID_SIZE * (geo.height / Settings::GRID_SIZE - 1) - height;
107+
108+ cairo_save(c);
109+ cairo_translate(c, x, y);
110+
111+ cairo_set_source_surface(c, logo_surface, 0, 0);
112+ cairo_paint_with_alpha(c, 0.5);
113+ cairo_surface_destroy(logo_surface);
114+ cairo_restore(c);
115 }
116 }
117
118- if (draw_grid)
119+ if (settings.draw_grid())
120 {
121 int width = geo.width;
122 int height = geo.height;
123 int grid_x_offset = GetGridOffset(width);
124- int grid_y_offset = GetGridOffset(height);
125+ int grid_y_offset = GetGridOffset(height) + panel::Style().Instance().PanelHeight(monitor);
126
127 // overlay grid
128 cairo_surface_t* overlay_surface = cairo_surface_create_similar(cairo_graphics.GetSurface(),
129
130=== modified file 'lockscreen/CMakeLists.txt'
131--- lockscreen/CMakeLists.txt 2014-03-11 14:11:14 +0000
132+++ lockscreen/CMakeLists.txt 2014-03-11 14:11:15 +0000
133@@ -23,6 +23,7 @@
134 LockScreenSettings.cpp
135 LockScreenShield.cpp
136 LockScreenShieldFactory.cpp
137+ LockScreenPanel.cpp
138 UserAuthenticatorPam.cpp
139 UserPromptView.cpp
140 )
141
142=== modified file 'lockscreen/LockScreenAbstractShield.h'
143--- lockscreen/LockScreenAbstractShield.h 2014-03-11 14:11:14 +0000
144+++ lockscreen/LockScreenAbstractShield.h 2014-03-11 14:11:15 +0000
145@@ -22,6 +22,7 @@
146
147 #include <NuxCore/Property.h>
148 #include <UnityCore/SessionManager.h>
149+#include <UnityCore/Indicators.h>
150
151 #include "unity-shared/MockableBaseWindow.h"
152
153@@ -33,20 +34,24 @@
154 class AbstractShield : public MockableBaseWindow
155 {
156 public:
157- AbstractShield(session::Manager::Ptr const& session, int monitor_num, bool is_primary)
158+ AbstractShield(session::Manager::Ptr const& session, indicator::Indicators::Ptr const& indicators, int monitor_num, bool is_primary)
159 : MockableBaseWindow("Unity Lockscreen")
160 , primary(is_primary)
161 , monitor(monitor_num)
162 , session_manager_(session)
163+ , indicators_(indicators)
164 {}
165
166 nux::Property<bool> primary;
167 nux::Property<int> monitor;
168
169+ virtual bool IsIndicatorOpen() const = 0;
170+
171 sigc::signal<void, int, int> grab_motion;
172
173 protected:
174 session::Manager::Ptr session_manager_;
175+ indicator::Indicators::Ptr indicators_;
176 };
177
178 } // lockscreen
179
180=== modified file 'lockscreen/LockScreenController.cpp'
181--- lockscreen/LockScreenController.cpp 2014-03-11 14:11:14 +0000
182+++ lockscreen/LockScreenController.cpp 2014-03-11 14:11:15 +0000
183@@ -19,6 +19,7 @@
184
185 #include "LockScreenController.h"
186
187+#include <UnityCore/DBusIndicators.h>
188 #include "LockScreenShield.h"
189 #include "LockScreenSettings.h"
190 #include "unity-shared/AnimationUtils.h"
191@@ -68,10 +69,14 @@
192 {
193 motion_connection_->disconnect();
194 uscreen_connection_->block();
195+ session_manager_->unlocked.emit();
196 shields_.clear();
197
198 if (Settings::Instance().lockscreen_type() == Type::UNITY)
199+ {
200 upstart_wrapper_->Emit("desktop-unlock");
201+ indicators_.reset();
202+ }
203 }
204 });
205 }
206@@ -111,7 +116,7 @@
207
208 if (i >= shields_size)
209 {
210- shield = shield_factory_->CreateShield(session_manager_, i, i == primary);
211+ shield = shield_factory_->CreateShield(session_manager_, indicators_, i, i == primary);
212 is_new = true;
213 }
214
215@@ -146,17 +151,20 @@
216
217 if (lockscreen_type == Type::NONE)
218 {
219+ session_manager_->unlocked.emit();
220 return;
221 }
222- else if (lockscreen_type == Type::LIGHTDM)
223+
224+ if (lockscreen_type == Type::LIGHTDM)
225 {
226 LockScreenUsingDisplayManager();
227 }
228 else if (lockscreen_type == Type::UNITY)
229 {
230- upstart_wrapper_->Emit("desktop-lock");
231 LockScreenUsingUnity();
232 }
233+
234+ session_manager_->locked.emit();
235 }
236
237 void Controller::LockScreenUsingDisplayManager()
238@@ -180,6 +188,9 @@
239
240 void Controller::LockScreenUsingUnity()
241 {
242+ indicators_ = std::make_shared<indicator::LockScreenDBusIndicators>();
243+ upstart_wrapper_->Emit("desktop-lock");
244+
245 ShowShields();
246 }
247
248@@ -235,9 +246,14 @@
249 return !shields_.empty();
250 }
251
252-bool Controller::IsShielded() const
253-{
254- return (fade_animator_.GetCurrentValue() == 1.0f && !shields_.empty());
255+double Controller::Opacity() const
256+{
257+ return fade_animator_.GetCurrentValue();
258+}
259+
260+bool Controller::HasOpenMenu() const
261+{
262+ return primary_shield_.IsValid() ? primary_shield_->IsIndicatorOpen() : false;
263 }
264
265 } // lockscreen
266
267=== modified file 'lockscreen/LockScreenController.h'
268--- lockscreen/LockScreenController.h 2014-03-11 14:11:14 +0000
269+++ lockscreen/LockScreenController.h 2014-03-11 14:11:15 +0000
270@@ -41,7 +41,8 @@
271 bool test_mode = false);
272
273 bool IsLocked() const;
274- bool IsShielded() const;
275+ bool HasOpenMenu() const;
276+ double Opacity() const;
277
278 private:
279 friend class TestLockScreenController;
280@@ -59,6 +60,7 @@
281 std::vector<nux::ObjectPtr<AbstractShield>> shields_;
282 nux::ObjectWeakPtr<AbstractShield> primary_shield_;
283 session::Manager::Ptr session_manager_;
284+ indicator::Indicators::Ptr indicators_;
285 UpstartWrapper::Ptr upstart_wrapper_;
286 ShieldFactoryInterface::Ptr shield_factory_;
287 nux::animation::AnimateValue<double> fade_animator_;
288
289=== added file 'lockscreen/LockScreenPanel.cpp'
290--- lockscreen/LockScreenPanel.cpp 1970-01-01 00:00:00 +0000
291+++ lockscreen/LockScreenPanel.cpp 2014-03-11 14:11:15 +0000
292@@ -0,0 +1,225 @@
293+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
294+/*
295+ * Copyright (C) 2014 Canonical Ltd
296+ *
297+ * This program is free software: you can redistribute it and/or modify
298+ * it under the terms of the GNU General Public License version 3 as
299+ * published by the Free Software Foundation.
300+ *
301+ * This program is distributed in the hope that it will be useful,
302+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
303+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304+ * GNU General Public License for more details.
305+ *
306+ * You should have received a copy of the GNU General Public License
307+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
308+ *
309+ * Authored by: Marco Trevisan <marco.trevisan@canonical.com>
310+ */
311+
312+#include "LockScreenPanel.h"
313+
314+#include <boost/algorithm/string/trim.hpp>
315+#include <Nux/HLayout.h>
316+
317+#include "LockScreenSettings.h"
318+#include "panel/PanelIndicatorsView.h"
319+#include "unity-shared/CairoTexture.h"
320+#include "unity-shared/StaticCairoText.h"
321+#include "unity-shared/PanelStyle.h"
322+#include "unity-shared/RawPixel.h"
323+#include "unity-shared/UnitySettings.h"
324+#include "unity-shared/WindowManager.h"
325+
326+namespace unity
327+{
328+namespace lockscreen
329+{
330+namespace
331+{
332+const RawPixel PADDING = 5_em;
333+}
334+
335+using namespace indicator;
336+using namespace panel;
337+
338+Panel::Panel(int monitor_, Indicators::Ptr const& indicators, session::Manager::Ptr const& session_manager)
339+ : nux::View(NUX_TRACKER_LOCATION)
340+ , active(false)
341+ , monitor(monitor_)
342+ , indicators_(indicators)
343+ , needs_geo_sync_(true)
344+{
345+ double scale = unity::Settings::Instance().em(monitor)->DPIScale();
346+ auto* layout = new nux::HLayout();
347+ layout->SetLeftAndRightPadding(PADDING.CP(scale), 0);
348+ SetLayout(layout);
349+
350+ BuildTexture();
351+
352+ // Add setting
353+ auto *hostname = new StaticCairoText(session_manager->HostName());
354+ hostname->SetFont(Settings::Instance().font_name());
355+ hostname->SetTextColor(nux::color::White);
356+ hostname->SetInputEventSensitivity(false);
357+ hostname->SetScale(scale);
358+ hostname->SetVisible(Settings::Instance().show_hostname());
359+ layout->AddView(hostname, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
360+
361+ indicators_view_ = new PanelIndicatorsView();
362+ indicators_view_->SetMonitor(monitor);
363+ indicators_view_->OverlayShown();
364+ indicators_view_->on_indicator_updated.connect(sigc::mem_fun(this, &Panel::OnIndicatorViewUpdated));
365+ layout->AddView(indicators_view_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
366+
367+ for (auto const& indicator : indicators_->GetIndicators())
368+ AddIndicator(indicator);
369+
370+ indicators_->on_object_added.connect(sigc::mem_fun(this, &Panel::AddIndicator));
371+ indicators_->on_object_removed.connect(sigc::mem_fun(this, &Panel::RemoveIndicator));
372+ indicators_->on_entry_show_menu.connect(sigc::mem_fun(this, &Panel::OnEntryShowMenu));
373+ indicators_->on_entry_activated.connect(sigc::mem_fun(this, &Panel::OnEntryActivated));
374+ indicators_->on_entry_activate_request.connect(sigc::mem_fun(this, &Panel::OnEntryActivateRequest));
375+
376+ monitor.changed.connect([this, hostname] (int monitor) {
377+ hostname->SetScale(unity::Settings::Instance().em(monitor)->DPIScale());
378+ indicators_view_->SetMonitor(monitor);
379+ BuildTexture();
380+ QueueRelayout();
381+ });
382+}
383+
384+void Panel::BuildTexture()
385+{
386+ int height = panel::Style::Instance().PanelHeight(monitor);
387+ nux::CairoGraphics context(CAIRO_FORMAT_ARGB32, 1, height);
388+ auto* cr = context.GetInternalContext();
389+ cairo_set_source_rgb(cr, 0.1, 0.1, 0.1);
390+ cairo_paint_with_alpha(cr, 0.4);
391+ bg_texture_ = texture_ptr_from_cairo_graphics(context);
392+
393+ view_layout_->SetMinimumHeight(height);
394+ view_layout_->SetMaximumHeight(height);
395+}
396+
397+void Panel::AddIndicator(Indicator::Ptr const& indicator)
398+{
399+ if (indicator->IsAppmenu())
400+ return;
401+
402+ indicators_view_->AddIndicator(indicator);
403+ QueueRelayout();
404+ QueueDraw();
405+}
406+
407+void Panel::RemoveIndicator(indicator::Indicator::Ptr const& indicator)
408+{
409+ indicators_view_->RemoveIndicator(indicator);
410+ QueueRelayout();
411+ QueueDraw();
412+}
413+
414+std::string Panel::GetPanelName() const
415+{
416+ return "LockScreenPanel" + std::to_string(monitor);
417+}
418+
419+void Panel::OnIndicatorViewUpdated()
420+{
421+ needs_geo_sync_ = true;
422+ QueueRelayout();
423+ QueueDraw();
424+}
425+
426+void Panel::OnEntryShowMenu(std::string const& entry_id, unsigned xid, int x, int y, unsigned button)
427+{
428+ if (!GetInputEventSensitivity())
429+ return;
430+
431+ // This is ugly... But Nux fault!
432+ WindowManager::Default().UnGrabMousePointer(CurrentTime, button, x, y);
433+
434+ active = true;
435+}
436+
437+void Panel::OnEntryActivateRequest(std::string const& entry_id)
438+{
439+ if (GetInputEventSensitivity())
440+ indicators_view_->ActivateEntry(entry_id, 0);
441+}
442+
443+void Panel::ActivateFirst()
444+{
445+ if (GetInputEventSensitivity())
446+ indicators_view_->ActivateIfSensitive();
447+}
448+
449+void Panel::OnEntryActivated(std::string const& panel, std::string const& entry_id, nux::Rect const&)
450+{
451+ if (!GetInputEventSensitivity() || (!panel.empty() && panel != GetPanelName()))
452+ return;
453+
454+ bool active = !entry_id.empty();
455+ if (active && !track_menu_pointer_timeout_)
456+ {
457+ track_menu_pointer_timeout_.reset(new glib::Timeout(16));
458+ track_menu_pointer_timeout_->Run([this] {
459+ nux::Point const& mouse = nux::GetGraphicsDisplay()->GetMouseScreenCoord();
460+ if (tracked_pointer_pos_ != mouse)
461+ {
462+ if (GetAbsoluteGeometry().IsPointInside(mouse.x, mouse.y))
463+ indicators_view_->ActivateEntryAt(mouse.x, mouse.y);
464+
465+ tracked_pointer_pos_ = mouse;
466+ }
467+
468+ return true;
469+ });
470+ }
471+ else if (!active)
472+ {
473+ track_menu_pointer_timeout_.reset();
474+ tracked_pointer_pos_ = {-1, -1};
475+ this->active = false;
476+ }
477+}
478+
479+void Panel::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw)
480+{
481+ auto const& geo = GetGeometry();
482+
483+ unsigned int alpha, src, dest = 0;
484+ graphics_engine.GetRenderStates().GetBlend(alpha, src, dest);
485+ graphics_engine.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
486+
487+ graphics_engine.PushClippingRectangle(geo);
488+ nux::GetPainter().PaintBackground(graphics_engine, geo);
489+
490+ nux::TexCoordXForm texxform;
491+ texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_CLAMP);
492+ graphics_engine.QRP_1Tex(geo.x, geo.y, geo.width, geo.height,
493+ bg_texture_->GetDeviceTexture(), texxform,
494+ nux::color::White);
495+
496+ view_layout_->ProcessDraw(graphics_engine, force_draw);
497+
498+ graphics_engine.PopClippingRectangle();
499+ graphics_engine.GetRenderStates().SetBlend(alpha, src, dest);
500+
501+ if (needs_geo_sync_)
502+ {
503+ EntryLocationMap locations;
504+ indicators_view_->GetGeometryForSync(locations);
505+ indicators_->SyncGeometries(GetPanelName(), locations);
506+ needs_geo_sync_ = false;
507+ }
508+}
509+
510+bool Panel::InspectKeyEvent(unsigned int event_type, unsigned int keysym, const char*)
511+{
512+ ActivateFirst();
513+ return true;
514+}
515+
516+}
517+}
518
519=== added file 'lockscreen/LockScreenPanel.h'
520--- lockscreen/LockScreenPanel.h 1970-01-01 00:00:00 +0000
521+++ lockscreen/LockScreenPanel.h 2014-03-11 14:11:15 +0000
522@@ -0,0 +1,75 @@
523+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
524+/*
525+ * Copyright (C) 2014 Canonical Ltd
526+ *
527+ * This program is free software: you can redistribute it and/or modify
528+ * it under the terms of the GNU General Public License version 3 as
529+ * published by the Free Software Foundation.
530+ *
531+ * This program is distributed in the hope that it will be useful,
532+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
533+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
534+ * GNU General Public License for more details.
535+ *
536+ * You should have received a copy of the GNU General Public License
537+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
538+ *
539+ * Authored by: Marco Trevisan <marco.trevisan@canonical.com>
540+ */
541+
542+#ifndef UNITY_LOCKSCREEN_PANEL
543+#define UNITY_LOCKSCREEN_PANEL
544+
545+#include <Nux/Nux.h>
546+#include <Nux/View.h>
547+#include <UnityCore/Indicators.h>
548+#include <UnityCore/GLibSource.h>
549+#include <UnityCore/SessionManager.h>
550+
551+namespace unity
552+{
553+namespace panel
554+{
555+class PanelIndicatorsView;
556+}
557+
558+namespace lockscreen
559+{
560+
561+class Panel : public nux::View
562+{
563+public:
564+ Panel(int monitor, indicator::Indicators::Ptr const&, session::Manager::Ptr const&);
565+
566+ nux::Property<bool> active;
567+ nux::Property<int> monitor;
568+
569+protected:
570+ void Draw(nux::GraphicsEngine& GfxContext, bool force_draw) override;
571+ bool InspectKeyEvent(unsigned int event_type, unsigned int keysym, const char*) override;
572+
573+private:
574+ void ActivateFirst();
575+ void AddIndicator(indicator::Indicator::Ptr const&);
576+ void RemoveIndicator(indicator::Indicator::Ptr const&);
577+ void OnIndicatorViewUpdated();
578+ void OnEntryActivated(std::string const& panel, std::string const& entry_id, nux::Rect const& geo);
579+ void OnEntryShowMenu(std::string const& entry_id, unsigned xid, int x, int y, unsigned button);
580+ void OnEntryActivateRequest(std::string const& entry_id);
581+
582+ void BuildTexture();
583+ std::string GetPanelName() const;
584+
585+ indicator::Indicators::Ptr indicators_;
586+ panel::PanelIndicatorsView* indicators_view_;
587+ nux::ObjectPtr<nux::BaseTexture> bg_texture_;
588+
589+ bool needs_geo_sync_;
590+ nux::Point tracked_pointer_pos_;
591+ glib::Source::UniquePtr track_menu_pointer_timeout_;
592+};
593+
594+} // lockscreen namespace
595+} // unity namespace
596+
597+#endif // UNITY_LOCKSCREEN_PANEL
598
599=== modified file 'lockscreen/LockScreenSettings.cpp'
600--- lockscreen/LockScreenSettings.cpp 2014-03-11 14:11:14 +0000
601+++ lockscreen/LockScreenSettings.cpp 2014-03-11 14:11:15 +0000
602@@ -20,6 +20,9 @@
603 #include "LockScreenSettings.h"
604
605 #include <NuxCore/Logger.h>
606+#include <sigc++/adaptors/hide.h>
607+#include <UnityCore/GLibSignal.h>
608+#include <UnityCore/GLibWrapper.h>
609
610 namespace unity
611 {
612@@ -31,8 +34,42 @@
613 namespace
614 {
615 Settings* settings_instance = nullptr;
616+
617+const std::string GREETER_SETTINGS = "com.canonical.unity-greeter";
618+const std::string LOGO_KEY = "logo";
619+const std::string FONT_KEY = "font-name";
620+const std::string BACKGROUND_KEY = "background";
621+const std::string BACKGROUND_COLOR_KEY = "background-color";
622+const std::string USER_BG_KEY = "draw-user-backgrounds";
623+const std::string DRAW_GRID_KEY = "draw-grid";
624+const std::string SHOW_HOSTNAME_KEY = "show-hostname";
625 }
626
627+struct Settings::Impl
628+{
629+ Impl()
630+ : greeter_settings_(g_settings_new(GREETER_SETTINGS.c_str()))
631+ , signal_(greeter_settings_, "changed", sigc::hide(sigc::hide(sigc::mem_fun(this, &Impl::UpdateSettings))))
632+ {
633+ UpdateSettings();
634+ }
635+
636+ void UpdateSettings()
637+ {
638+ auto* s = settings_instance;
639+ s->font_name = glib::String(g_settings_get_string(greeter_settings_, FONT_KEY.c_str())).Str();
640+ s->logo = glib::String(g_settings_get_string(greeter_settings_, LOGO_KEY.c_str())).Str();
641+ s->background = glib::String(g_settings_get_string(greeter_settings_, BACKGROUND_KEY.c_str())).Str();
642+ s->background_color = nux::Color(glib::String(g_settings_get_string(greeter_settings_, BACKGROUND_COLOR_KEY.c_str())).Str());
643+ s->show_hostname = g_settings_get_boolean(greeter_settings_, SHOW_HOSTNAME_KEY.c_str()) != FALSE;
644+ s->use_user_background = g_settings_get_boolean(greeter_settings_, USER_BG_KEY.c_str()) != FALSE;
645+ s->draw_grid = g_settings_get_boolean(greeter_settings_, DRAW_GRID_KEY.c_str()) != FALSE;
646+ }
647+
648+ glib::Object<GSettings> greeter_settings_;
649+ glib::Signal<void, GSettings*, const gchar*> signal_;
650+};
651+
652 Settings::Settings()
653 {
654 if (settings_instance)
655@@ -43,6 +80,7 @@
656 {
657 lockscreen_type = Type::UNITY;
658 settings_instance = this;
659+ impl_.reset(new Impl());
660 }
661 }
662
663
664=== modified file 'lockscreen/LockScreenSettings.h'
665--- lockscreen/LockScreenSettings.h 2014-03-11 14:11:14 +0000
666+++ lockscreen/LockScreenSettings.h 2014-03-11 14:11:15 +0000
667@@ -45,8 +45,19 @@
668 static Settings& Instance();
669
670 nux::Property<Type> lockscreen_type;
671+ nux::Property<std::string> font_name;
672+ nux::Property<std::string> logo;
673+ nux::Property<std::string> background;
674+ nux::Property<nux::Color> background_color;
675+ nux::Property<bool> show_hostname;
676+ nux::Property<bool> use_user_background;
677+ nux::Property<bool> draw_grid;
678
679 static const int GRID_SIZE = 40;
680+
681+private:
682+ struct Impl;
683+ std::unique_ptr<Impl> impl_;
684 };
685
686 }
687
688=== modified file 'lockscreen/LockScreenShield.cpp'
689--- lockscreen/LockScreenShield.cpp 2014-03-11 14:11:14 +0000
690+++ lockscreen/LockScreenShield.cpp 2014-03-11 14:11:15 +0000
691@@ -22,26 +22,25 @@
692 #include <Nux/VLayout.h>
693 #include <Nux/HLayout.h>
694 #include <Nux/PaintLayer.h>
695-#include <UnityCore/DBusIndicators.h>
696
697 #include "BackgroundSettings.h"
698 #include "CofView.h"
699+#include "LockScreenPanel.h"
700 #include "LockScreenSettings.h"
701 #include "UserPromptView.h"
702-#include "panel/PanelView.h"
703-#include "unity-shared/GnomeKeyGrabber.h"
704-#include "unity-shared/PanelStyle.h"
705 #include "unity-shared/UScreen.h"
706+#include "unity-shared/WindowManager.h"
707
708 namespace unity
709 {
710 namespace lockscreen
711 {
712
713-Shield::Shield(session::Manager::Ptr const& session_manager, int monitor_num, bool is_primary)
714- : AbstractShield(session_manager, monitor_num, is_primary)
715- , bg_settings_(new BackgroundSettings)
716+Shield::Shield(session::Manager::Ptr const& session_manager, indicator::Indicators::Ptr const& indicators, int monitor_num, bool is_primary)
717+ : AbstractShield(session_manager, indicators, monitor_num, is_primary)
718+ , bg_settings_(std::make_shared<BackgroundSettings>())
719 , prompt_view_(nullptr)
720+ , panel_view_(nullptr)
721 {
722 is_primary ? ShowPrimaryView() : ShowSecondaryView();
723
724@@ -50,8 +49,8 @@
725 geometry_changed.connect([this] (nux::Area*, nux::Geometry&) { UpdateBackgroundTexture();});
726
727 monitor.changed.connect([this] (int monitor) {
728- if (primary() && panel_view_)
729- panel_view_->SetMonitor(monitor);
730+ if (panel_view_)
731+ panel_view_->monitor = monitor;
732
733 UpdateBackgroundTexture();
734 });
735@@ -64,6 +63,7 @@
736 }
737
738 is_primary ? ShowPrimaryView() : ShowSecondaryView();
739+ if (panel_view_) panel_view_->SetInputEventSensitivity(is_primary);
740 QueueRelayout();
741 QueueDraw();
742 });
743@@ -132,23 +132,29 @@
744 main_layout->AddView(cof_view);
745 }
746
747-nux::View* Shield::CreatePanel()
748+Panel* Shield::CreatePanel()
749 {
750- auto indicators = std::make_shared<indicator::LockScreenDBusIndicators>();
751- auto gnome_grabber = std::make_shared<key::GnomeGrabber>();
752- auto menu_manager = std::make_shared<menu::Manager>(indicators, gnome_grabber);
753-
754- // Hackish but ok for the moment. Would be nice to have menus without grab.
755- indicators->on_entry_show_menu.connect(sigc::mem_fun(this, &Shield::OnIndicatorEntryShowMenu));
756- indicators->on_entry_activated.connect(sigc::mem_fun(this, &Shield::OnIndicatorEntryActivated));
757-
758- panel::PanelView* panel_view = new panel::PanelView(this, menu_manager, /*lockscreen_mode*/ true);
759- panel_view->SetMaximumHeight(panel::Style::Instance().PanelHeight(monitor));
760- panel_view->SetOpacity(0.5);
761- panel_view->SetMonitor(monitor);
762- panel_view_ = panel_view;
763-
764- return panel_view;
765+ if (!indicators_ || !session_manager_)
766+ return nullptr;
767+
768+ panel_view_ = new Panel(monitor, indicators_, session_manager_);
769+ panel_active_conn_ = panel_view_->active.changed.connect([this] (bool active) {
770+ if (primary())
771+ {
772+ if (active)
773+ {
774+ UnGrabPointer();
775+ UnGrabKeyboard();
776+ }
777+ else
778+ {
779+ GrabPointer();
780+ GrabKeyboard();
781+ }
782+ }
783+ });
784+
785+ return panel_view_;
786 }
787
788 UserPromptView* Shield::CreatePromptView()
789@@ -165,38 +171,31 @@
790 return prompt_view;
791 }
792
793-void Shield::OnIndicatorEntryShowMenu(std::string const&, unsigned, int, int, unsigned)
794-{
795- if (primary())
796- {
797- UnGrabPointer();
798- UnGrabKeyboard();
799- }
800-}
801-
802-void Shield::OnIndicatorEntryActivated(std::string const& panel, std::string const& entry, nux::Geometry const& geo)
803-{
804- if (primary() && entry.empty() and geo.IsNull()) /* on menu closed */
805- {
806- GrabPointer();
807- GrabKeyboard();
808- }
809-}
810-
811-nux::Area* Shield::FindKeyFocusArea(unsigned int, unsigned long, unsigned long)
812-{
813- if (primary && prompt_view_)
814- {
815- auto* focus_view = prompt_view_->focus_view();
816-
817- if (focus_view && focus_view->GetInputEventSensitivity())
818- return focus_view;
819+nux::Area* Shield::FindKeyFocusArea(unsigned etype, unsigned long key_code, unsigned long modifiers)
820+{
821+ if (primary)
822+ {
823+ if (panel_view_)
824+ {
825+ modifiers &= (nux::NUX_STATE_ALT | nux::NUX_STATE_CTRL | nux::NUX_STATE_SUPER | nux::NUX_STATE_SHIFT);
826+ auto const& indicators_key = WindowManager::Default().activate_indicators_key();
827+
828+ if (indicators_key.first == modifiers && indicators_key.second == key_code)
829+ return panel_view_;
830+ }
831+
832+ if (prompt_view_)
833+ {
834+ auto* focus_view = prompt_view_->focus_view();
835+
836+ if (focus_view && focus_view->GetInputEventSensitivity())
837+ return focus_view;
838+ }
839 }
840
841 return nullptr;
842 }
843
844-
845 bool Shield::AcceptKeyNavFocus()
846 {
847 return false;
848@@ -212,5 +211,10 @@
849 return area;
850 }
851
852+bool Shield::IsIndicatorOpen() const
853+{
854+ return panel_view_ ? panel_view_->active() : false;
855+}
856+
857 }
858 }
859
860=== modified file 'lockscreen/LockScreenShield.h'
861--- lockscreen/LockScreenShield.h 2014-03-11 14:11:14 +0000
862+++ lockscreen/LockScreenShield.h 2014-03-11 14:11:15 +0000
863@@ -20,26 +20,27 @@
864 #ifndef UNITY_LOCKSCREEN_SHIELD_H
865 #define UNITY_LOCKSCREEN_SHIELD_H
866
867+#include <UnityCore/ConnectionManager.h>
868 #include "LockScreenAbstractShield.h"
869
870 namespace unity
871 {
872-namespace panel
873-{
874-class PanelView;
875-}
876 namespace lockscreen
877 {
878
879 class BackgroundSettings;
880 class UserAuthenticator;
881 class UserPromptView;
882+class Panel;
883
884 class Shield : public AbstractShield
885 {
886 public:
887- Shield(session::Manager::Ptr const& session_manager, int monitor, bool is_primary);
888-
889+ Shield(session::Manager::Ptr const&, indicator::Indicators::Ptr const&, int monitor, bool is_primary);
890+
891+ bool IsIndicatorOpen() const;
892+
893+protected:
894 bool AcceptKeyNavFocus() override;
895 nux::Area* FindKeyFocusArea(unsigned int, unsigned long, unsigned long) override;
896 nux::Area* FindAreaUnderMouse(nux::Point const&, nux::NuxEventType) override;
897@@ -48,18 +49,16 @@
898 void UpdateBackgroundTexture();
899 void ShowPrimaryView();
900 void ShowSecondaryView();
901- nux::View* CreatePanel();
902+ Panel* CreatePanel();
903 UserPromptView* CreatePromptView();
904
905- void OnIndicatorEntryShowMenu(std::string const&, unsigned, int, int, unsigned);
906- void OnIndicatorEntryActivated(std::string const& panel, std::string const& entry, nux::Geometry const& geo);
907-
908 std::shared_ptr<BackgroundSettings> bg_settings_;
909 std::unique_ptr<nux::AbstractPaintLayer> background_layer_;
910 nux::ObjectPtr<nux::Layout> primary_layout_;
911 nux::ObjectPtr<nux::Layout> cof_layout_;
912+ connection::Wrapper panel_active_conn_;
913 UserPromptView* prompt_view_;
914- panel::PanelView* panel_view_;
915+ Panel* panel_view_;
916 };
917
918 }
919
920=== modified file 'lockscreen/LockScreenShieldFactory.cpp'
921--- lockscreen/LockScreenShieldFactory.cpp 2014-03-11 14:11:14 +0000
922+++ lockscreen/LockScreenShieldFactory.cpp 2014-03-11 14:11:15 +0000
923@@ -25,9 +25,9 @@
924 namespace lockscreen
925 {
926
927-nux::ObjectPtr<AbstractShield> ShieldFactory::CreateShield(session::Manager::Ptr const& session_manager, int monitor, bool is_primary)
928+nux::ObjectPtr<AbstractShield> ShieldFactory::CreateShield(session::Manager::Ptr const& session_manager, indicator::Indicators::Ptr const& indicators, int monitor, bool is_primary)
929 {
930- return nux::ObjectPtr<Shield>(new Shield(session_manager, monitor, is_primary));
931+ return nux::ObjectPtr<Shield>(new Shield(session_manager, indicators, monitor, is_primary));
932 }
933
934 }
935
936=== modified file 'lockscreen/LockScreenShieldFactory.h'
937--- lockscreen/LockScreenShieldFactory.h 2014-03-11 14:11:14 +0000
938+++ lockscreen/LockScreenShieldFactory.h 2014-03-11 14:11:15 +0000
939@@ -37,12 +37,12 @@
940
941 virtual ~ShieldFactoryInterface() = default;
942
943- virtual nux::ObjectPtr<AbstractShield> CreateShield(session::Manager::Ptr const&, int monitor, bool is_primary) = 0;
944+ virtual nux::ObjectPtr<AbstractShield> CreateShield(session::Manager::Ptr const&, indicator::Indicators::Ptr const&, int monitor, bool is_primary) = 0;
945 };
946
947 struct ShieldFactory : ShieldFactoryInterface
948 {
949- nux::ObjectPtr<AbstractShield> CreateShield(session::Manager::Ptr const&, int monitor, bool is_primary) override;
950+ nux::ObjectPtr<AbstractShield> CreateShield(session::Manager::Ptr const&, indicator::Indicators::Ptr const&, int monitor, bool is_primary) override;
951 };
952
953 }
954
955=== modified file 'lockscreen/UserAuthenticatorPam.cpp'
956--- lockscreen/UserAuthenticatorPam.cpp 2014-03-11 14:11:14 +0000
957+++ lockscreen/UserAuthenticatorPam.cpp 2014-03-11 14:11:15 +0000
958@@ -77,7 +77,7 @@
959 if (num_msg <= 0)
960 return PAM_CONV_ERR;
961
962- auto* tmp_response = g_new0(pam_response, num_msg);
963+ auto* tmp_response = static_cast<pam_response*>(calloc(num_msg, sizeof(pam_response)));
964
965 if (!tmp_response)
966 return PAM_CONV_ERR;
967
968=== modified file 'lockscreen/UserPromptView.cpp'
969--- lockscreen/UserPromptView.cpp 2014-03-11 14:11:14 +0000
970+++ lockscreen/UserPromptView.cpp 2014-03-11 14:11:15 +0000
971@@ -39,7 +39,6 @@
972 const RawPixel MSG_LAYOUT_MARGIN = 15_em;
973 const RawPixel PROMPT_LAYOUT_MARGIN = 5_em;
974 const int PROMPT_FONT_SIZE = 13;
975-const int MESSAGE_FONT_SIZE = 11;
976
977 nux::AbstractPaintLayer* CrateBackgroundLayer(int width, int height)
978 {
979@@ -267,7 +266,7 @@
980 void UserPromptView::AddMessage(std::string const& message, nux::Color const& color)
981 {
982 auto* view = new unity::StaticCairoText("");
983- view->SetFont("Ubuntu "+std::to_string(MESSAGE_FONT_SIZE));
984+ view->SetFont(Settings::Instance().font_name());
985 view->SetTextColor(color);
986 view->SetText(message);
987
988
989=== modified file 'lockscreen/pch/lockscreen_pch.hh'
990--- lockscreen/pch/lockscreen_pch.hh 2014-03-11 14:11:14 +0000
991+++ lockscreen/pch/lockscreen_pch.hh 2014-03-11 14:11:15 +0000
992@@ -28,4 +28,5 @@
993 #include <security/pam_appl.h>
994
995 #include <Nux/Nux.h>
996-#include <UnityCore/SessionManager.h>
997\ No newline at end of file
998+#include <UnityCore/SessionManager.h>
999+#include <UnityCore/Indicators.h>
1000\ No newline at end of file
1001
1002=== modified file 'panel/PanelIndicatorEntryView.cpp'
1003--- panel/PanelIndicatorEntryView.cpp 2014-02-28 15:01:24 +0000
1004+++ panel/PanelIndicatorEntryView.cpp 2014-03-11 14:11:15 +0000
1005@@ -387,7 +387,7 @@
1006 pango_layout_get_pixel_size(layout, &extents.width, &extents.height);
1007 int y = (height - extents.height) / 2;
1008
1009- if (overlay_showing_)
1010+ if (overlay_showing_ && !IsActive())
1011 {
1012 cairo_move_to(cr, x, y);
1013 cairo_set_source_rgb(cr, 1.0f, 1.0f, 1.0f);
1014
1015=== modified file 'panel/PanelIndicatorsView.cpp'
1016--- panel/PanelIndicatorsView.cpp 2014-02-25 02:38:26 +0000
1017+++ panel/PanelIndicatorsView.cpp 2014-03-11 14:11:15 +0000
1018@@ -42,6 +42,7 @@
1019 , opacity(1.0f, sigc::mem_fun(this, &PanelIndicatorsView::SetOpacity))
1020 , layout_(new nux::HLayout("", NUX_TRACKER_LOCATION))
1021 , monitor_(0)
1022+, overlay_showing_(false)
1023 {
1024 opacity.DisableNotifications();
1025 layout_->SetContentDistribution(nux::MAJOR_POSITION_END);
1026@@ -327,6 +328,9 @@
1027 auto view = new PanelIndicatorEntryView(entry, padding, type);
1028 AddEntryView(view, pos);
1029
1030+ if (overlay_showing_)
1031+ view->OverlayShown();
1032+
1033 return view;
1034 }
1035
1036@@ -368,12 +372,16 @@
1037
1038 void PanelIndicatorsView::OverlayShown()
1039 {
1040+ overlay_showing_ = true;
1041+
1042 for (auto const& entry: entries_)
1043 entry.second->OverlayShown();
1044 }
1045
1046 void PanelIndicatorsView::OverlayHidden()
1047 {
1048+ overlay_showing_ = false;
1049+
1050 for (auto const& entry: entries_)
1051 entry.second->OverlayHidden();
1052 }
1053
1054=== modified file 'panel/PanelIndicatorsView.h'
1055--- panel/PanelIndicatorsView.h 2014-02-18 04:47:43 +0000
1056+++ panel/PanelIndicatorsView.h 2014-03-11 14:11:15 +0000
1057@@ -98,6 +98,7 @@
1058 Entries entries_;
1059
1060 int monitor_;
1061+ bool overlay_showing_;
1062
1063 private:
1064 bool SetOpacity(double& target, double const& new_value);
1065
1066=== modified file 'panel/PanelMenuView.cpp'
1067--- panel/PanelMenuView.cpp 2014-02-27 05:45:23 +0000
1068+++ panel/PanelMenuView.cpp 2014-03-11 14:11:15 +0000
1069@@ -64,7 +64,6 @@
1070 , is_desktop_focused_(false)
1071 , last_active_view_(nullptr)
1072 , new_application_(nullptr)
1073- , overlay_showing_(false)
1074 , switcher_showing_(false)
1075 , spread_showing_(false)
1076 , launcher_keynav_(false)
1077
1078=== modified file 'panel/PanelMenuView.h'
1079--- panel/PanelMenuView.h 2014-02-27 05:45:23 +0000
1080+++ panel/PanelMenuView.h 2014-03-11 14:11:15 +0000
1081@@ -176,7 +176,6 @@
1082 nux::Geometry last_geo_;
1083 nux::Geometry title_geo_;
1084
1085- bool overlay_showing_;
1086 bool switcher_showing_;
1087 bool spread_showing_;
1088 bool launcher_keynav_;
1089
1090=== modified file 'panel/PanelView.cpp'
1091--- panel/PanelView.cpp 2014-03-11 14:11:14 +0000
1092+++ panel/PanelView.cpp 2014-03-11 14:11:15 +0000
1093@@ -48,7 +48,7 @@
1094
1095 NUX_IMPLEMENT_OBJECT_TYPE(PanelView);
1096
1097-PanelView::PanelView(MockableBaseWindow* parent, menu::Manager::Ptr const& menus, bool lockscreen_mode, NUX_FILE_LINE_DECL)
1098+PanelView::PanelView(MockableBaseWindow* parent, menu::Manager::Ptr const& menus, NUX_FILE_LINE_DECL)
1099 : View(NUX_FILE_LINE_PARAM)
1100 , parent_(parent)
1101 , remote_(menus->Indicators())
1102@@ -59,7 +59,6 @@
1103 , opacity_(1.0f)
1104 , monitor_(0)
1105 , stored_dash_width_(0)
1106- , lockscreen_mode_(lockscreen_mode)
1107 , bg_effect_helper_(this)
1108 {
1109 auto& wm = WindowManager::Default();
1110@@ -98,22 +97,15 @@
1111 menu_view_->EnableDropdownMenu(true, remote_);
1112 AddPanelView(menu_view_, 0);
1113
1114- if (lockscreen_mode_)
1115- menu_view_->SetVisible(false);
1116-
1117 SetCompositionLayout(layout_);
1118
1119- tray_ = nullptr;
1120- if (!lockscreen_mode_)
1121- {
1122- tray_ = new PanelTray(monitor_);
1123- layout_->AddView(tray_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
1124- AddChild(tray_);
1125- }
1126+ tray_ = new PanelTray(monitor_);
1127+ layout_->AddView(tray_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
1128+ AddChild(tray_);
1129
1130 indicators_ = new PanelIndicatorsView();
1131 indicators_->SetMonitor(monitor_);
1132- AddPanelView(indicators_, lockscreen_mode_ ? 1 : 0);
1133+ AddPanelView(indicators_, 0);
1134
1135 for (auto const& object : remote_->GetIndicators())
1136 OnObjectAdded(object);
1137@@ -301,7 +293,7 @@
1138 {
1139 bg_blur_texture_ = bg_effect_helper_.GetBlurRegion();
1140 }
1141- else if(!lockscreen_mode_)
1142+ else
1143 {
1144 bg_blur_texture_ = bg_effect_helper_.GetRegion();
1145 }
1146
1147=== modified file 'panel/PanelView.h'
1148--- panel/PanelView.h 2014-03-11 14:11:14 +0000
1149+++ panel/PanelView.h 2014-02-25 22:10:53 +0000
1150@@ -51,7 +51,7 @@
1151 {
1152 NUX_DECLARE_OBJECT_TYPE(PanelView, nux::View);
1153 public:
1154- PanelView(MockableBaseWindow* parent, menu::Manager::Ptr const&, bool lockscreen_mode_ = false, NUX_FILE_LINE_PROTO);
1155+ PanelView(MockableBaseWindow* parent, menu::Manager::Ptr const&, NUX_FILE_LINE_PROTO);
1156 ~PanelView();
1157
1158 MockableBaseWindow* GetParent() const
1159@@ -140,7 +140,6 @@
1160 float opacity_;
1161 int monitor_;
1162 int stored_dash_width_;
1163- bool lockscreen_mode_;
1164
1165 connection::Manager on_indicator_updated_connections_;
1166 connection::Manager maximized_opacity_toggle_connections_;
1167
1168=== modified file 'plugins/unityshell/src/unityshell.cpp'
1169--- plugins/unityshell/src/unityshell.cpp 2014-03-11 14:11:14 +0000
1170+++ plugins/unityshell/src/unityshell.cpp 2014-03-11 14:11:15 +0000
1171@@ -338,6 +338,7 @@
1172 optionSetShowDesktopKeyInitiate(boost::bind(&UnityScreen::showDesktopKeyInitiate, this, _1, _2, _3));
1173 optionSetPanelFirstMenuInitiate(boost::bind(&UnityScreen::showPanelFirstMenuKeyInitiate, this, _1, _2, _3));
1174 optionSetPanelFirstMenuTerminate(boost::bind(&UnityScreen::showPanelFirstMenuKeyTerminate, this, _1, _2, _3));
1175+ optionSetPanelFirstMenuNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
1176 optionSetAutomaximizeValueNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
1177 optionSetDashTapDurationNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
1178 optionSetAltTabTimeoutNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
1179@@ -2582,6 +2583,15 @@
1180 WindowManager::Default().close_window_key = std::make_pair(modifiers, keysym);
1181 }
1182
1183+void UnityScreen::UpdateActivateIndicatorsKey()
1184+{
1185+ CompAction::KeyBinding const& keybind = optionGetPanelFirstMenu().key();
1186+ KeySym keysym = XkbKeycodeToKeysym(screen->dpy(), keybind.keycode(), 0, 0);
1187+ unsigned modifiers = CompizModifiersToNux(keybind.modifiers());
1188+
1189+ WindowManager::Default().activate_indicators_key = std::make_pair(modifiers, keysym);
1190+}
1191+
1192 bool UnityScreen::initPluginActions()
1193 {
1194 PluginAdapter& adapter = PluginAdapter::Default();
1195@@ -2810,12 +2820,21 @@
1196
1197 GLWindowPaintAttrib wAttrib = attrib;
1198
1199- if (window->type() != CompWindowTypePopupMenuMask)
1200+ if (uScreen->lockscreen_controller_->IsLocked())
1201 {
1202- if (uScreen->lockscreen_controller_->IsShielded())
1203+ if (window->type() != CompWindowTypePopupMenuMask ||
1204+ !uScreen->lockscreen_controller_->HasOpenMenu())
1205 {
1206- wAttrib.opacity = 0;
1207- return gWindow->glPaint(wAttrib, matrix, region, mask);
1208+ // For some reasons PAINT_WINDOW_NO_CORE_INSTANCE_MASK doesn't work here
1209+ // (well, it works too much, as it applies to menus too), so we need
1210+ // to paint the windows at the proper opacity, overriding any other
1211+ // paint plugin (animation, fade?) that might interfere with us.
1212+ wAttrib.opacity = COMPIZ_COMPOSITE_OPAQUE * (1.0f - uScreen->lockscreen_controller_->Opacity());
1213+ int old_index = gWindow->glPaintGetCurrentIndex();
1214+ gWindow->glPaintSetCurrentIndex(MAXSHORT);
1215+ bool ret = gWindow->glPaint(wAttrib, matrix, region, mask);
1216+ gWindow->glPaintSetCurrentIndex(old_index);
1217+ return ret;
1218 }
1219 }
1220
1221@@ -3502,6 +3521,9 @@
1222 case UnityshellOptions::LockScreenType:
1223 lockscreen_settings_.lockscreen_type = static_cast<lockscreen::Type>(optionGetLockScreenType());
1224 break;
1225+ case UnityshellOptions::PanelFirstMenu:
1226+ UpdateActivateIndicatorsKey();
1227+ break;
1228 default:
1229 break;
1230 }
1231@@ -3644,11 +3666,13 @@
1232
1233 // Setup Session Controller
1234 auto manager = std::make_shared<session::GnomeManager>();
1235+ session_dbus_manager_ = std::make_shared<session::DBusManager>(manager);
1236 session_controller_ = std::make_shared<session::Controller>(manager);
1237 AddChild(session_controller_.get());
1238
1239 // Setup Lockscreen Controller
1240 lockscreen_controller_ = std::make_shared<lockscreen::Controller>(manager);
1241+ UpdateActivateIndicatorsKey();
1242
1243 auto on_launcher_size_changed = [this] (nux::Area* area, int w, int h) {
1244 /* The launcher geometry includes 1px used to draw the right margin
1245
1246=== modified file 'plugins/unityshell/src/unityshell.h'
1247--- plugins/unityshell/src/unityshell.h 2014-03-11 14:11:14 +0000
1248+++ plugins/unityshell/src/unityshell.h 2014-03-11 14:11:15 +0000
1249@@ -67,6 +67,7 @@
1250 #include "ScreenIntrospection.h"
1251 #include "SwitcherController.h"
1252 #include "SessionController.h"
1253+#include "SessionDBusManager.h"
1254 #include "SpreadFilter.h"
1255 #include "UBusWrapper.h"
1256 #include "UnityshellPrivate.h"
1257@@ -299,6 +300,7 @@
1258 unsigned XModifiersToNux(unsigned input) const;
1259
1260 void UpdateCloseWindowKey(CompAction::KeyBinding const&);
1261+ void UpdateActivateIndicatorsKey();
1262
1263 bool getMipmap () override { return false; }
1264
1265@@ -329,6 +331,7 @@
1266 switcher::Controller::Ptr switcher_controller_;
1267 hud::Controller::Ptr hud_controller_;
1268 shortcut::Controller::Ptr shortcut_controller_;
1269+ session::DBusManager::Ptr session_dbus_manager_;
1270 session::Controller::Ptr session_controller_;
1271 std::shared_ptr<lockscreen::Controller> lockscreen_controller_;
1272 debug::DebugDBusInterface debugger_;
1273
1274=== modified file 'services/panel-service.c'
1275--- services/panel-service.c 2014-03-11 14:11:14 +0000
1276+++ services/panel-service.c 2014-03-11 14:11:15 +0000
1277@@ -1327,7 +1327,7 @@
1278 IndicatorNg *indicator;
1279
1280 filename = g_build_filename (INDICATOR_SERVICE_DIR, name, NULL);
1281- indicator = indicator_ng_new_for_profile (filename, !lockscreen_mode ? "desktop" : "desktop_greeter", &error);
1282+ indicator = indicator_ng_new_for_profile (filename, !lockscreen_mode ? "desktop" : "desktop_lockscreen", &error);
1283 if (indicator)
1284 {
1285 load_indicator (self, INDICATOR_OBJECT (indicator), name);
1286
1287=== modified file 'shutdown/CMakeLists.txt'
1288--- shutdown/CMakeLists.txt 2013-02-17 23:55:54 +0000
1289+++ shutdown/CMakeLists.txt 2014-03-11 14:11:15 +0000
1290@@ -19,6 +19,7 @@
1291 set (SHUTDOWN_SOURCES
1292 SessionButton.cpp
1293 SessionController.cpp
1294+ SessionDBusManager.cpp
1295 SessionView.cpp
1296 )
1297
1298
1299=== added file 'shutdown/SessionDBusManager.cpp'
1300--- shutdown/SessionDBusManager.cpp 1970-01-01 00:00:00 +0000
1301+++ shutdown/SessionDBusManager.cpp 2014-03-11 14:11:15 +0000
1302@@ -0,0 +1,180 @@
1303+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
1304+/*
1305+ * Copyright (C) 2014 Canonical Ltd
1306+ *
1307+ * This program is free software: you can redistribute it and/or modify
1308+ * it under the terms of the GNU General Public License version 3 as
1309+ * published by the Free Software Foundation.
1310+ *
1311+ * This program is distributed in the hope that it will be useful,
1312+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1313+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1314+ * GNU General Public License for more details.
1315+ *
1316+ * You should have received a copy of the GNU General Public License
1317+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1318+ *
1319+ * Authored by: Marco Trevisan <marco.trevisan@canonical.com>
1320+ */
1321+
1322+#include "SessionDBusManager.h"
1323+
1324+namespace unity
1325+{
1326+namespace session
1327+{
1328+namespace dbus
1329+{
1330+const std::string NAME = "com.canonical.Unity";
1331+const std::string INTERFACE = "com.canonical.Unity.Session";
1332+const std::string OBJECT_PATH = "/com/canonical/Unity/Session";
1333+const std::string INTROSPECTION_XML =
1334+R"(<node>
1335+ <interface name="com.canonical.Unity.Session">
1336+ <method name="RealName">
1337+ <arg type="s" direction="out" name="realname" />
1338+ </method>
1339+ <method name="UserName">
1340+ <arg type="s" direction="out" name="username" />
1341+ </method>
1342+ <method name="HostName">
1343+ <arg type="s" direction="out" name="hostname" />
1344+ </method>
1345+ <method name="Lock" />
1346+ <method name="Logout" />
1347+ <method name="RequestLogout" />
1348+ <method name="Reboot" />
1349+ <method name="RequestReboot" />
1350+ <method name="Shutdown" />
1351+ <method name="RequestShutdown" />
1352+ <method name="Suspend" />
1353+ <method name="Hibernate" />
1354+ <method name="CancelAction" />
1355+ <method name="CanShutdown">
1356+ <arg type="b" direction="out" name="canshutdown" />
1357+ </method>
1358+ <method name="CanSuspend">
1359+ <arg type="b" direction="out" name="cansuspend" />
1360+ </method>
1361+ <method name="CanHibernate">
1362+ <arg type="b" direction="out" name="canhibernate" />
1363+ </method>
1364+
1365+ <signal name="LockRequested" />
1366+ <signal name="Locked" />
1367+ <signal name="UnlockRequested" />
1368+ <signal name="Unlocked" />
1369+ <signal name="LogoutRequested">
1370+ <arg type="b" name="have_inhibitors" />
1371+ </signal>
1372+ <signal name="RebootRequested">
1373+ <arg type="b" name="have_inhibitors" />
1374+ </signal>
1375+ <signal name="ShutdownRequested">
1376+ <arg type="b" name="have_inhibitors" />
1377+ </signal>
1378+ </interface>
1379+</node>)";
1380+}
1381+
1382+DBusManager::DBusManager(session::Manager::Ptr const& session)
1383+ : session_(session)
1384+ , server_(dbus::NAME)
1385+{
1386+ server_.AddObjects(dbus::INTROSPECTION_XML, dbus::OBJECT_PATH);
1387+ object_ = server_.GetObject(dbus::INTERFACE);
1388+ object_->SetMethodsCallsHandler([this] (std::string const& method, GVariant*) -> GVariant* {
1389+ if (method == "RealName")
1390+ {
1391+ return g_variant_new("(s)", session_->RealName().c_str());
1392+ }
1393+ else if (method == "UserName")
1394+ {
1395+ return g_variant_new("(s)", session_->UserName().c_str());
1396+ }
1397+ else if (method == "HostName")
1398+ {
1399+ return g_variant_new("(s)", session_->HostName().c_str());
1400+ }
1401+ else if (method == "Lock")
1402+ {
1403+ session_->LockScreen();
1404+ }
1405+ else if (method == "Logout")
1406+ {
1407+ session_->Logout();
1408+ }
1409+ else if (method == "RequestLogout")
1410+ {
1411+ session_->logout_requested.emit(false);
1412+ }
1413+ else if (method == "Reboot")
1414+ {
1415+ session_->Reboot();
1416+ }
1417+ else if (method == "RequestReboot")
1418+ {
1419+ session_->reboot_requested.emit(false);
1420+ }
1421+ else if (method == "Shutdown")
1422+ {
1423+ session_->Shutdown();
1424+ }
1425+ else if (method == "RequestShutdown")
1426+ {
1427+ session_->shutdown_requested.emit(false);
1428+ }
1429+ else if (method == "Suspend")
1430+ {
1431+ session_->Suspend();
1432+ }
1433+ else if (method == "Hibernate")
1434+ {
1435+ session_->Hibernate();
1436+ }
1437+ else if (method == "CancelAction")
1438+ {
1439+ session_->CancelAction();
1440+ session_->cancel_requested.emit();
1441+ }
1442+ else if (method == "CanShutdown")
1443+ {
1444+ return g_variant_new("(b)", session_->CanShutdown() != FALSE);
1445+ }
1446+ else if (method == "CanSuspend")
1447+ {
1448+ return g_variant_new("(b)", session_->CanSuspend() != FALSE);
1449+ }
1450+ else if (method == "CanHibernate")
1451+ {
1452+ return g_variant_new("(b)", session_->CanHibernate() != FALSE);
1453+ }
1454+
1455+ return nullptr;
1456+ });
1457+
1458+ connections_.Add(session_->lock_requested.connect([this] {
1459+ object_->EmitSignal("LockRequested");
1460+ }));
1461+ connections_.Add(session_->locked.connect([this] {
1462+ object_->EmitSignal("Locked");
1463+ }));
1464+ connections_.Add(session_->unlock_requested.connect([this] {
1465+ object_->EmitSignal("UnlockRequested");
1466+ }));
1467+ connections_.Add(session_->unlocked.connect([this] {
1468+ object_->EmitSignal("Unlocked");
1469+ }));
1470+ connections_.Add(session_->logout_requested.connect([this] (bool inhibitors) {
1471+ object_->EmitSignal("LogoutRequested", g_variant_new("(b)", inhibitors));
1472+ }));
1473+ connections_.Add(session_->reboot_requested.connect([this] (bool inhibitors) {
1474+ object_->EmitSignal("RebootRequested", g_variant_new("(b)", inhibitors));
1475+ }));
1476+ connections_.Add(session_->shutdown_requested.connect([this] (bool inhibitors) {
1477+ object_->EmitSignal("ShutdownRequested", g_variant_new("(b)", inhibitors));
1478+ }));
1479+}
1480+
1481+} // session
1482+} // unity
1483
1484=== added file 'shutdown/SessionDBusManager.h'
1485--- shutdown/SessionDBusManager.h 1970-01-01 00:00:00 +0000
1486+++ shutdown/SessionDBusManager.h 2014-03-11 14:11:15 +0000
1487@@ -0,0 +1,50 @@
1488+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
1489+/*
1490+ * Copyright (C) 2014 Canonical Ltd
1491+ *
1492+ * This program is free software: you can redistribute it and/or modify
1493+ * it under the terms of the GNU General Public License version 3 as
1494+ * published by the Free Software Foundation.
1495+ *
1496+ * This program is distributed in the hope that it will be useful,
1497+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1498+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1499+ * GNU General Public License for more details.
1500+ *
1501+ * You should have received a copy of the GNU General Public License
1502+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1503+ *
1504+ * Authored by: Marco Trevisan <marco.trevisan@canonical.com>
1505+ */
1506+
1507+#ifndef UNITYSHELL_SESSION_DBUS_MANAGER_H
1508+#define UNITYSHELL_SESSION_DBUS_MANAGER_H
1509+
1510+#include <UnityCore/ConnectionManager.h>
1511+#include <UnityCore/GLibDBusServer.h>
1512+#include <UnityCore/SessionManager.h>
1513+
1514+namespace unity
1515+{
1516+namespace session
1517+{
1518+
1519+class DBusManager
1520+{
1521+public:
1522+ typedef std::shared_ptr<DBusManager> Ptr;
1523+
1524+ DBusManager(session::Manager::Ptr const& manager);
1525+ virtual ~DBusManager() = default;
1526+
1527+private:
1528+ session::Manager::Ptr session_;
1529+ glib::DBusServer server_;
1530+ glib::DBusObject::Ptr object_;
1531+ connection::Manager connections_;
1532+};
1533+
1534+} // session
1535+} // unity
1536+
1537+#endif
1538
1539=== modified file 'shutdown/StandaloneSession.cpp'
1540--- shutdown/StandaloneSession.cpp 2013-03-07 22:30:02 +0000
1541+++ shutdown/StandaloneSession.cpp 2014-03-11 14:11:15 +0000
1542@@ -38,6 +38,7 @@
1543
1544 std::string RealName() const { return "Marco Trevisan"; }
1545 std::string UserName() const { return "marco"; }
1546+ std::string HostName() const { return "tricky"; }
1547
1548 void LockScreen() { std::cout << "LockScreen" << std::endl; }
1549 void Logout() { std::cout << "Logout" << std::endl; }
1550
1551=== modified file 'tests/data/external.gschema.xml'
1552--- tests/data/external.gschema.xml 2014-03-11 14:11:14 +0000
1553+++ tests/data/external.gschema.xml 2014-03-11 14:11:15 +0000
1554@@ -57,6 +57,9 @@
1555 <key type="s" name="logo">
1556 <default>'/usr/share/unity-greeter/logo.png'</default>
1557 </key>
1558+ <key type="s" name="font-name">
1559+ <default>'Ubuntu 11'</default>
1560+ </key>
1561 <key type="s" name="background">
1562 <default>'/usr/share/backgrounds/warty-final-ubuntu.png'</default>
1563 </key>
1564@@ -69,5 +72,8 @@
1565 <key type="b" name="draw-grid">
1566 <default>true</default>
1567 </key>
1568+ <key type="b" name="show-hostname">
1569+ <default>true</default>
1570+ </key>
1571 </schema>
1572 </schemalist>
1573
1574=== modified file 'tests/test_lockscreen_controller.cpp'
1575--- tests/test_lockscreen_controller.cpp 2014-03-11 14:11:14 +0000
1576+++ tests/test_lockscreen_controller.cpp 2014-03-11 14:11:15 +0000
1577@@ -62,11 +62,20 @@
1578
1579 }
1580
1581+struct MockShield : AbstractShield
1582+{
1583+ MockShield()
1584+ : AbstractShield(nullptr, nullptr, 0, false)
1585+ {}
1586+
1587+ MOCK_CONST_METHOD0(IsIndicatorOpen, bool());
1588+};
1589+
1590 struct ShieldFactoryMock : ShieldFactoryInterface
1591 {
1592- nux::ObjectPtr<AbstractShield> CreateShield(session::Manager::Ptr const&, int, bool) override
1593+ nux::ObjectPtr<AbstractShield> CreateShield(session::Manager::Ptr const&, indicator::Indicators::Ptr const&, int, bool) override
1594 {
1595- return nux::ObjectPtr<AbstractShield>(new AbstractShield(nullptr, 0, false));
1596+ return nux::ObjectPtr<AbstractShield>(new MockShield());
1597 }
1598 };
1599
1600
1601=== modified file 'tests/test_mock_session_manager.h'
1602--- tests/test_mock_session_manager.h 2013-03-07 21:26:57 +0000
1603+++ tests/test_mock_session_manager.h 2014-03-11 14:11:15 +0000
1604@@ -31,6 +31,7 @@
1605
1606 MOCK_CONST_METHOD0(RealName, std::string());
1607 MOCK_CONST_METHOD0(UserName, std::string());
1608+ MOCK_CONST_METHOD0(HostName, std::string());
1609
1610 MOCK_METHOD0(LockScreen, void());
1611 MOCK_METHOD0(Logout, void());
1612
1613=== modified file 'unity-shared/WindowManager.h'
1614--- unity-shared/WindowManager.h 2014-02-17 21:17:51 +0000
1615+++ unity-shared/WindowManager.h 2014-03-11 14:11:15 +0000
1616@@ -166,6 +166,7 @@
1617
1618 // Nux Modifiers, Nux Keycode (= X11 KeySym)
1619 nux::Property<std::pair<unsigned, unsigned>> close_window_key;
1620+ nux::Property<std::pair<unsigned, unsigned>> activate_indicators_key;
1621 nux::Property<nux::Color> average_color;
1622
1623 // Signals