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
=== modified file 'UnityCore/SessionManager.h'
--- UnityCore/SessionManager.h 2014-03-11 14:11:14 +0000
+++ UnityCore/SessionManager.h 2014-03-11 14:11:15 +0000
@@ -59,6 +59,8 @@
5959
60 sigc::signal<void> lock_requested;60 sigc::signal<void> lock_requested;
61 sigc::signal<void> unlock_requested;61 sigc::signal<void> unlock_requested;
62 sigc::signal<void> locked;
63 sigc::signal<void> unlocked;
62 sigc::signal<void, bool /* inhibitors */> logout_requested;64 sigc::signal<void, bool /* inhibitors */> logout_requested;
63 sigc::signal<void, bool /* inhibitors */> reboot_requested;65 sigc::signal<void, bool /* inhibitors */> reboot_requested;
64 sigc::signal<void, bool /* inhibitors */> shutdown_requested;66 sigc::signal<void, bool /* inhibitors */> shutdown_requested;
6567
=== modified file 'lockscreen/BackgroundSettings.cpp'
--- lockscreen/BackgroundSettings.cpp 2014-03-11 14:11:14 +0000
+++ lockscreen/BackgroundSettings.cpp 2014-03-11 14:11:15 +0000
@@ -34,12 +34,6 @@
34namespace34namespace
35{35{
36const std::string SETTINGS_NAME = "org.gnome.desktop.background";36const std::string SETTINGS_NAME = "org.gnome.desktop.background";
37const std::string GREETER_SETTINGS = "com.canonical.unity-greeter";
38const std::string LOGO_KEY = "logo";
39const std::string BACKGROUND_KEY = "background";
40const std::string BACKGROUND_COLOR_KEY = "background-color";
41const std::string USER_BG_KEY = "draw-user-backgrounds";
42const std::string DRAW_GRID_KEY = "draw-grid";
4337
44constexpr int GetGridOffset(int size) { return (size % Settings::GRID_SIZE) / 2; }38constexpr int GetGridOffset(int size) { return (size % Settings::GRID_SIZE) / 2; }
45}39}
@@ -57,30 +51,23 @@
57BaseTexturePtr BackgroundSettings::GetBackgroundTexture(int monitor)51BaseTexturePtr BackgroundSettings::GetBackgroundTexture(int monitor)
58{52{
59 nux::Geometry const& geo = UScreen::GetDefault()->GetMonitorGeometry(monitor);53 nux::Geometry const& geo = UScreen::GetDefault()->GetMonitorGeometry(monitor);
60 glib::Object<GSettings> greeter_settings(g_settings_new(GREETER_SETTINGS.c_str()));54 auto& settings = Settings::Instance();
61 bool user_bg = g_settings_get_boolean(greeter_settings, USER_BG_KEY.c_str()) != FALSE;
62 bool draw_grid = g_settings_get_boolean(greeter_settings, DRAW_GRID_KEY.c_str()) != FALSE;
6355
64 nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, geo.width, geo.height);56 nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, geo.width, geo.height);
65 cairo_t* c = cairo_graphics.GetInternalContext();57 cairo_t* c = cairo_graphics.GetInternalContext();
6658
67 cairo_surface_t* bg_surface = nullptr;59 cairo_surface_t* bg_surface = nullptr;
6860
69 if (user_bg)61 if (settings.use_user_background())
70 {62 {
71 bg_surface = gnome_bg_create_surface(gnome_bg_, gdk_get_default_root_window(), geo.width, geo.height, FALSE);63 bg_surface = gnome_bg_create_surface(gnome_bg_, gdk_get_default_root_window(), geo.width, geo.height, FALSE);
72 }64 }
73 else65 else if (!settings.background().empty())
74 {66 {
75 glib::String bg_file(g_settings_get_string(greeter_settings, BACKGROUND_KEY.c_str()));67 glib::Object<GdkPixbuf> pixbuf(gdk_pixbuf_new_from_file_at_scale(settings.background().c_str(), geo.width, geo.height, FALSE, NULL));
7668
77 if (bg_file)69 if (pixbuf)
78 {70 bg_surface = gdk_cairo_surface_create_from_pixbuf(pixbuf, 0, NULL);
79 glib::Object<GdkPixbuf> pixbuf(gdk_pixbuf_new_from_file_at_scale(bg_file, geo.width, geo.height, FALSE, NULL));
80
81 if (pixbuf)
82 bg_surface = gdk_cairo_surface_create_from_pixbuf(pixbuf, 0, NULL);
83 }
84 }71 }
8572
86 if (bg_surface)73 if (bg_surface)
@@ -91,43 +78,39 @@
91 }78 }
92 else79 else
93 {80 {
94 nux::Color bg_color(glib::String(g_settings_get_string(greeter_settings, BACKGROUND_COLOR_KEY.c_str())).Str());81 auto const& bg_color = settings.background_color();
95 cairo_set_source_rgb(c, bg_color.red, bg_color.green, bg_color.blue);82 cairo_set_source_rgb(c, bg_color.red, bg_color.green, bg_color.blue);
96 cairo_paint(c);83 cairo_paint(c);
97 }84 }
9885
86 if (!settings.logo().empty())
99 {87 {
100 glib::String logo(g_settings_get_string(greeter_settings, LOGO_KEY.c_str()));
101 int grid_x_offset = GetGridOffset(geo.width);88 int grid_x_offset = GetGridOffset(geo.width);
102 int grid_y_offset = GetGridOffset(geo.height);89 int grid_y_offset = GetGridOffset(geo.height);
90 cairo_surface_t* logo_surface = cairo_image_surface_create_from_png(settings.logo().c_str());
10391
104 if (logo && !logo.Str().empty())92 if (logo_surface)
105 {93 {
106 cairo_surface_t* logo_surface = cairo_image_surface_create_from_png(logo);94 int height = cairo_image_surface_get_height(logo_surface);
10795 int x = grid_x_offset;
108 if (logo_surface)96 int y = grid_y_offset + Settings::GRID_SIZE * (geo.height / Settings::GRID_SIZE - 1) - height;
109 {97
110 int height = cairo_image_surface_get_height(logo_surface);98 cairo_save(c);
111 int x = grid_x_offset;99 cairo_translate(c, x, y);
112 int y = grid_y_offset + Settings::GRID_SIZE * (geo.height / Settings::GRID_SIZE - 1) - height;100
113101 cairo_set_source_surface(c, logo_surface, 0, 0);
114 cairo_save(c);102 cairo_paint_with_alpha(c, 0.5);
115 cairo_translate(c, x, y);103 cairo_surface_destroy(logo_surface);
116104 cairo_restore(c);
117 cairo_set_source_surface(c, logo_surface, 0, 0);
118 cairo_paint_with_alpha(c, 0.5);
119 cairo_surface_destroy(logo_surface);
120 cairo_restore(c);
121 }
122 }105 }
123 }106 }
124107
125 if (draw_grid)108 if (settings.draw_grid())
126 {109 {
127 int width = geo.width;110 int width = geo.width;
128 int height = geo.height;111 int height = geo.height;
129 int grid_x_offset = GetGridOffset(width);112 int grid_x_offset = GetGridOffset(width);
130 int grid_y_offset = GetGridOffset(height);113 int grid_y_offset = GetGridOffset(height) + panel::Style().Instance().PanelHeight(monitor);
131114
132 // overlay grid115 // overlay grid
133 cairo_surface_t* overlay_surface = cairo_surface_create_similar(cairo_graphics.GetSurface(),116 cairo_surface_t* overlay_surface = cairo_surface_create_similar(cairo_graphics.GetSurface(),
134117
=== modified file 'lockscreen/CMakeLists.txt'
--- lockscreen/CMakeLists.txt 2014-03-11 14:11:14 +0000
+++ lockscreen/CMakeLists.txt 2014-03-11 14:11:15 +0000
@@ -23,6 +23,7 @@
23 LockScreenSettings.cpp23 LockScreenSettings.cpp
24 LockScreenShield.cpp24 LockScreenShield.cpp
25 LockScreenShieldFactory.cpp25 LockScreenShieldFactory.cpp
26 LockScreenPanel.cpp
26 UserAuthenticatorPam.cpp27 UserAuthenticatorPam.cpp
27 UserPromptView.cpp28 UserPromptView.cpp
28 )29 )
2930
=== modified file 'lockscreen/LockScreenAbstractShield.h'
--- lockscreen/LockScreenAbstractShield.h 2014-03-11 14:11:14 +0000
+++ lockscreen/LockScreenAbstractShield.h 2014-03-11 14:11:15 +0000
@@ -22,6 +22,7 @@
2222
23#include <NuxCore/Property.h>23#include <NuxCore/Property.h>
24#include <UnityCore/SessionManager.h>24#include <UnityCore/SessionManager.h>
25#include <UnityCore/Indicators.h>
2526
26#include "unity-shared/MockableBaseWindow.h"27#include "unity-shared/MockableBaseWindow.h"
2728
@@ -33,20 +34,24 @@
33class AbstractShield : public MockableBaseWindow34class AbstractShield : public MockableBaseWindow
34{35{
35public:36public:
36 AbstractShield(session::Manager::Ptr const& session, int monitor_num, bool is_primary)37 AbstractShield(session::Manager::Ptr const& session, indicator::Indicators::Ptr const& indicators, int monitor_num, bool is_primary)
37 : MockableBaseWindow("Unity Lockscreen")38 : MockableBaseWindow("Unity Lockscreen")
38 , primary(is_primary)39 , primary(is_primary)
39 , monitor(monitor_num)40 , monitor(monitor_num)
40 , session_manager_(session)41 , session_manager_(session)
42 , indicators_(indicators)
41 {}43 {}
4244
43 nux::Property<bool> primary;45 nux::Property<bool> primary;
44 nux::Property<int> monitor;46 nux::Property<int> monitor;
4547
48 virtual bool IsIndicatorOpen() const = 0;
49
46 sigc::signal<void, int, int> grab_motion;50 sigc::signal<void, int, int> grab_motion;
4751
48protected:52protected:
49 session::Manager::Ptr session_manager_;53 session::Manager::Ptr session_manager_;
54 indicator::Indicators::Ptr indicators_;
50};55};
5156
52} // lockscreen57} // lockscreen
5358
=== modified file 'lockscreen/LockScreenController.cpp'
--- lockscreen/LockScreenController.cpp 2014-03-11 14:11:14 +0000
+++ lockscreen/LockScreenController.cpp 2014-03-11 14:11:15 +0000
@@ -19,6 +19,7 @@
1919
20#include "LockScreenController.h"20#include "LockScreenController.h"
2121
22#include <UnityCore/DBusIndicators.h>
22#include "LockScreenShield.h"23#include "LockScreenShield.h"
23#include "LockScreenSettings.h"24#include "LockScreenSettings.h"
24#include "unity-shared/AnimationUtils.h"25#include "unity-shared/AnimationUtils.h"
@@ -68,10 +69,14 @@
68 {69 {
69 motion_connection_->disconnect();70 motion_connection_->disconnect();
70 uscreen_connection_->block();71 uscreen_connection_->block();
72 session_manager_->unlocked.emit();
71 shields_.clear();73 shields_.clear();
7274
73 if (Settings::Instance().lockscreen_type() == Type::UNITY)75 if (Settings::Instance().lockscreen_type() == Type::UNITY)
76 {
74 upstart_wrapper_->Emit("desktop-unlock");77 upstart_wrapper_->Emit("desktop-unlock");
78 indicators_.reset();
79 }
75 }80 }
76 });81 });
77}82}
@@ -111,7 +116,7 @@
111116
112 if (i >= shields_size)117 if (i >= shields_size)
113 {118 {
114 shield = shield_factory_->CreateShield(session_manager_, i, i == primary);119 shield = shield_factory_->CreateShield(session_manager_, indicators_, i, i == primary);
115 is_new = true;120 is_new = true;
116 }121 }
117122
@@ -146,17 +151,20 @@
146151
147 if (lockscreen_type == Type::NONE)152 if (lockscreen_type == Type::NONE)
148 {153 {
154 session_manager_->unlocked.emit();
149 return;155 return;
150 }156 }
151 else if (lockscreen_type == Type::LIGHTDM)157
158 if (lockscreen_type == Type::LIGHTDM)
152 {159 {
153 LockScreenUsingDisplayManager();160 LockScreenUsingDisplayManager();
154 }161 }
155 else if (lockscreen_type == Type::UNITY)162 else if (lockscreen_type == Type::UNITY)
156 {163 {
157 upstart_wrapper_->Emit("desktop-lock");
158 LockScreenUsingUnity();164 LockScreenUsingUnity();
159 }165 }
166
167 session_manager_->locked.emit();
160}168}
161169
162void Controller::LockScreenUsingDisplayManager()170void Controller::LockScreenUsingDisplayManager()
@@ -180,6 +188,9 @@
180188
181void Controller::LockScreenUsingUnity()189void Controller::LockScreenUsingUnity()
182{190{
191 indicators_ = std::make_shared<indicator::LockScreenDBusIndicators>();
192 upstart_wrapper_->Emit("desktop-lock");
193
183 ShowShields();194 ShowShields();
184}195}
185196
@@ -235,9 +246,14 @@
235 return !shields_.empty();246 return !shields_.empty();
236}247}
237248
238bool Controller::IsShielded() const249double Controller::Opacity() const
239{250{
240 return (fade_animator_.GetCurrentValue() == 1.0f && !shields_.empty());251 return fade_animator_.GetCurrentValue();
252}
253
254bool Controller::HasOpenMenu() const
255{
256 return primary_shield_.IsValid() ? primary_shield_->IsIndicatorOpen() : false;
241}257}
242258
243} // lockscreen259} // lockscreen
244260
=== modified file 'lockscreen/LockScreenController.h'
--- lockscreen/LockScreenController.h 2014-03-11 14:11:14 +0000
+++ lockscreen/LockScreenController.h 2014-03-11 14:11:15 +0000
@@ -41,7 +41,8 @@
41 bool test_mode = false);41 bool test_mode = false);
4242
43 bool IsLocked() const;43 bool IsLocked() const;
44 bool IsShielded() const;44 bool HasOpenMenu() const;
45 double Opacity() const;
4546
46private:47private:
47 friend class TestLockScreenController;48 friend class TestLockScreenController;
@@ -59,6 +60,7 @@
59 std::vector<nux::ObjectPtr<AbstractShield>> shields_;60 std::vector<nux::ObjectPtr<AbstractShield>> shields_;
60 nux::ObjectWeakPtr<AbstractShield> primary_shield_;61 nux::ObjectWeakPtr<AbstractShield> primary_shield_;
61 session::Manager::Ptr session_manager_;62 session::Manager::Ptr session_manager_;
63 indicator::Indicators::Ptr indicators_;
62 UpstartWrapper::Ptr upstart_wrapper_;64 UpstartWrapper::Ptr upstart_wrapper_;
63 ShieldFactoryInterface::Ptr shield_factory_;65 ShieldFactoryInterface::Ptr shield_factory_;
64 nux::animation::AnimateValue<double> fade_animator_;66 nux::animation::AnimateValue<double> fade_animator_;
6567
=== added file 'lockscreen/LockScreenPanel.cpp'
--- lockscreen/LockScreenPanel.cpp 1970-01-01 00:00:00 +0000
+++ lockscreen/LockScreenPanel.cpp 2014-03-11 14:11:15 +0000
@@ -0,0 +1,225 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3 * Copyright (C) 2014 Canonical Ltd
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authored by: Marco Trevisan <marco.trevisan@canonical.com>
18 */
19
20#include "LockScreenPanel.h"
21
22#include <boost/algorithm/string/trim.hpp>
23#include <Nux/HLayout.h>
24
25#include "LockScreenSettings.h"
26#include "panel/PanelIndicatorsView.h"
27#include "unity-shared/CairoTexture.h"
28#include "unity-shared/StaticCairoText.h"
29#include "unity-shared/PanelStyle.h"
30#include "unity-shared/RawPixel.h"
31#include "unity-shared/UnitySettings.h"
32#include "unity-shared/WindowManager.h"
33
34namespace unity
35{
36namespace lockscreen
37{
38namespace
39{
40const RawPixel PADDING = 5_em;
41}
42
43using namespace indicator;
44using namespace panel;
45
46Panel::Panel(int monitor_, Indicators::Ptr const& indicators, session::Manager::Ptr const& session_manager)
47 : nux::View(NUX_TRACKER_LOCATION)
48 , active(false)
49 , monitor(monitor_)
50 , indicators_(indicators)
51 , needs_geo_sync_(true)
52{
53 double scale = unity::Settings::Instance().em(monitor)->DPIScale();
54 auto* layout = new nux::HLayout();
55 layout->SetLeftAndRightPadding(PADDING.CP(scale), 0);
56 SetLayout(layout);
57
58 BuildTexture();
59
60 // Add setting
61 auto *hostname = new StaticCairoText(session_manager->HostName());
62 hostname->SetFont(Settings::Instance().font_name());
63 hostname->SetTextColor(nux::color::White);
64 hostname->SetInputEventSensitivity(false);
65 hostname->SetScale(scale);
66 hostname->SetVisible(Settings::Instance().show_hostname());
67 layout->AddView(hostname, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
68
69 indicators_view_ = new PanelIndicatorsView();
70 indicators_view_->SetMonitor(monitor);
71 indicators_view_->OverlayShown();
72 indicators_view_->on_indicator_updated.connect(sigc::mem_fun(this, &Panel::OnIndicatorViewUpdated));
73 layout->AddView(indicators_view_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
74
75 for (auto const& indicator : indicators_->GetIndicators())
76 AddIndicator(indicator);
77
78 indicators_->on_object_added.connect(sigc::mem_fun(this, &Panel::AddIndicator));
79 indicators_->on_object_removed.connect(sigc::mem_fun(this, &Panel::RemoveIndicator));
80 indicators_->on_entry_show_menu.connect(sigc::mem_fun(this, &Panel::OnEntryShowMenu));
81 indicators_->on_entry_activated.connect(sigc::mem_fun(this, &Panel::OnEntryActivated));
82 indicators_->on_entry_activate_request.connect(sigc::mem_fun(this, &Panel::OnEntryActivateRequest));
83
84 monitor.changed.connect([this, hostname] (int monitor) {
85 hostname->SetScale(unity::Settings::Instance().em(monitor)->DPIScale());
86 indicators_view_->SetMonitor(monitor);
87 BuildTexture();
88 QueueRelayout();
89 });
90}
91
92void Panel::BuildTexture()
93{
94 int height = panel::Style::Instance().PanelHeight(monitor);
95 nux::CairoGraphics context(CAIRO_FORMAT_ARGB32, 1, height);
96 auto* cr = context.GetInternalContext();
97 cairo_set_source_rgb(cr, 0.1, 0.1, 0.1);
98 cairo_paint_with_alpha(cr, 0.4);
99 bg_texture_ = texture_ptr_from_cairo_graphics(context);
100
101 view_layout_->SetMinimumHeight(height);
102 view_layout_->SetMaximumHeight(height);
103}
104
105void Panel::AddIndicator(Indicator::Ptr const& indicator)
106{
107 if (indicator->IsAppmenu())
108 return;
109
110 indicators_view_->AddIndicator(indicator);
111 QueueRelayout();
112 QueueDraw();
113}
114
115void Panel::RemoveIndicator(indicator::Indicator::Ptr const& indicator)
116{
117 indicators_view_->RemoveIndicator(indicator);
118 QueueRelayout();
119 QueueDraw();
120}
121
122std::string Panel::GetPanelName() const
123{
124 return "LockScreenPanel" + std::to_string(monitor);
125}
126
127void Panel::OnIndicatorViewUpdated()
128{
129 needs_geo_sync_ = true;
130 QueueRelayout();
131 QueueDraw();
132}
133
134void Panel::OnEntryShowMenu(std::string const& entry_id, unsigned xid, int x, int y, unsigned button)
135{
136 if (!GetInputEventSensitivity())
137 return;
138
139 // This is ugly... But Nux fault!
140 WindowManager::Default().UnGrabMousePointer(CurrentTime, button, x, y);
141
142 active = true;
143}
144
145void Panel::OnEntryActivateRequest(std::string const& entry_id)
146{
147 if (GetInputEventSensitivity())
148 indicators_view_->ActivateEntry(entry_id, 0);
149}
150
151void Panel::ActivateFirst()
152{
153 if (GetInputEventSensitivity())
154 indicators_view_->ActivateIfSensitive();
155}
156
157void Panel::OnEntryActivated(std::string const& panel, std::string const& entry_id, nux::Rect const&)
158{
159 if (!GetInputEventSensitivity() || (!panel.empty() && panel != GetPanelName()))
160 return;
161
162 bool active = !entry_id.empty();
163 if (active && !track_menu_pointer_timeout_)
164 {
165 track_menu_pointer_timeout_.reset(new glib::Timeout(16));
166 track_menu_pointer_timeout_->Run([this] {
167 nux::Point const& mouse = nux::GetGraphicsDisplay()->GetMouseScreenCoord();
168 if (tracked_pointer_pos_ != mouse)
169 {
170 if (GetAbsoluteGeometry().IsPointInside(mouse.x, mouse.y))
171 indicators_view_->ActivateEntryAt(mouse.x, mouse.y);
172
173 tracked_pointer_pos_ = mouse;
174 }
175
176 return true;
177 });
178 }
179 else if (!active)
180 {
181 track_menu_pointer_timeout_.reset();
182 tracked_pointer_pos_ = {-1, -1};
183 this->active = false;
184 }
185}
186
187void Panel::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw)
188{
189 auto const& geo = GetGeometry();
190
191 unsigned int alpha, src, dest = 0;
192 graphics_engine.GetRenderStates().GetBlend(alpha, src, dest);
193 graphics_engine.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
194
195 graphics_engine.PushClippingRectangle(geo);
196 nux::GetPainter().PaintBackground(graphics_engine, geo);
197
198 nux::TexCoordXForm texxform;
199 texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_CLAMP);
200 graphics_engine.QRP_1Tex(geo.x, geo.y, geo.width, geo.height,
201 bg_texture_->GetDeviceTexture(), texxform,
202 nux::color::White);
203
204 view_layout_->ProcessDraw(graphics_engine, force_draw);
205
206 graphics_engine.PopClippingRectangle();
207 graphics_engine.GetRenderStates().SetBlend(alpha, src, dest);
208
209 if (needs_geo_sync_)
210 {
211 EntryLocationMap locations;
212 indicators_view_->GetGeometryForSync(locations);
213 indicators_->SyncGeometries(GetPanelName(), locations);
214 needs_geo_sync_ = false;
215 }
216}
217
218bool Panel::InspectKeyEvent(unsigned int event_type, unsigned int keysym, const char*)
219{
220 ActivateFirst();
221 return true;
222}
223
224}
225}
0226
=== added file 'lockscreen/LockScreenPanel.h'
--- lockscreen/LockScreenPanel.h 1970-01-01 00:00:00 +0000
+++ lockscreen/LockScreenPanel.h 2014-03-11 14:11:15 +0000
@@ -0,0 +1,75 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3 * Copyright (C) 2014 Canonical Ltd
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authored by: Marco Trevisan <marco.trevisan@canonical.com>
18 */
19
20#ifndef UNITY_LOCKSCREEN_PANEL
21#define UNITY_LOCKSCREEN_PANEL
22
23#include <Nux/Nux.h>
24#include <Nux/View.h>
25#include <UnityCore/Indicators.h>
26#include <UnityCore/GLibSource.h>
27#include <UnityCore/SessionManager.h>
28
29namespace unity
30{
31namespace panel
32{
33class PanelIndicatorsView;
34}
35
36namespace lockscreen
37{
38
39class Panel : public nux::View
40{
41public:
42 Panel(int monitor, indicator::Indicators::Ptr const&, session::Manager::Ptr const&);
43
44 nux::Property<bool> active;
45 nux::Property<int> monitor;
46
47protected:
48 void Draw(nux::GraphicsEngine& GfxContext, bool force_draw) override;
49 bool InspectKeyEvent(unsigned int event_type, unsigned int keysym, const char*) override;
50
51private:
52 void ActivateFirst();
53 void AddIndicator(indicator::Indicator::Ptr const&);
54 void RemoveIndicator(indicator::Indicator::Ptr const&);
55 void OnIndicatorViewUpdated();
56 void OnEntryActivated(std::string const& panel, std::string const& entry_id, nux::Rect const& geo);
57 void OnEntryShowMenu(std::string const& entry_id, unsigned xid, int x, int y, unsigned button);
58 void OnEntryActivateRequest(std::string const& entry_id);
59
60 void BuildTexture();
61 std::string GetPanelName() const;
62
63 indicator::Indicators::Ptr indicators_;
64 panel::PanelIndicatorsView* indicators_view_;
65 nux::ObjectPtr<nux::BaseTexture> bg_texture_;
66
67 bool needs_geo_sync_;
68 nux::Point tracked_pointer_pos_;
69 glib::Source::UniquePtr track_menu_pointer_timeout_;
70};
71
72} // lockscreen namespace
73} // unity namespace
74
75#endif // UNITY_LOCKSCREEN_PANEL
076
=== modified file 'lockscreen/LockScreenSettings.cpp'
--- lockscreen/LockScreenSettings.cpp 2014-03-11 14:11:14 +0000
+++ lockscreen/LockScreenSettings.cpp 2014-03-11 14:11:15 +0000
@@ -20,6 +20,9 @@
20#include "LockScreenSettings.h"20#include "LockScreenSettings.h"
2121
22#include <NuxCore/Logger.h>22#include <NuxCore/Logger.h>
23#include <sigc++/adaptors/hide.h>
24#include <UnityCore/GLibSignal.h>
25#include <UnityCore/GLibWrapper.h>
2326
24namespace unity27namespace unity
25{28{
@@ -31,8 +34,42 @@
31namespace34namespace
32{35{
33Settings* settings_instance = nullptr;36Settings* settings_instance = nullptr;
37
38const std::string GREETER_SETTINGS = "com.canonical.unity-greeter";
39const std::string LOGO_KEY = "logo";
40const std::string FONT_KEY = "font-name";
41const std::string BACKGROUND_KEY = "background";
42const std::string BACKGROUND_COLOR_KEY = "background-color";
43const std::string USER_BG_KEY = "draw-user-backgrounds";
44const std::string DRAW_GRID_KEY = "draw-grid";
45const std::string SHOW_HOSTNAME_KEY = "show-hostname";
34}46}
3547
48struct Settings::Impl
49{
50 Impl()
51 : greeter_settings_(g_settings_new(GREETER_SETTINGS.c_str()))
52 , signal_(greeter_settings_, "changed", sigc::hide(sigc::hide(sigc::mem_fun(this, &Impl::UpdateSettings))))
53 {
54 UpdateSettings();
55 }
56
57 void UpdateSettings()
58 {
59 auto* s = settings_instance;
60 s->font_name = glib::String(g_settings_get_string(greeter_settings_, FONT_KEY.c_str())).Str();
61 s->logo = glib::String(g_settings_get_string(greeter_settings_, LOGO_KEY.c_str())).Str();
62 s->background = glib::String(g_settings_get_string(greeter_settings_, BACKGROUND_KEY.c_str())).Str();
63 s->background_color = nux::Color(glib::String(g_settings_get_string(greeter_settings_, BACKGROUND_COLOR_KEY.c_str())).Str());
64 s->show_hostname = g_settings_get_boolean(greeter_settings_, SHOW_HOSTNAME_KEY.c_str()) != FALSE;
65 s->use_user_background = g_settings_get_boolean(greeter_settings_, USER_BG_KEY.c_str()) != FALSE;
66 s->draw_grid = g_settings_get_boolean(greeter_settings_, DRAW_GRID_KEY.c_str()) != FALSE;
67 }
68
69 glib::Object<GSettings> greeter_settings_;
70 glib::Signal<void, GSettings*, const gchar*> signal_;
71};
72
36Settings::Settings()73Settings::Settings()
37{74{
38 if (settings_instance)75 if (settings_instance)
@@ -43,6 +80,7 @@
43 {80 {
44 lockscreen_type = Type::UNITY;81 lockscreen_type = Type::UNITY;
45 settings_instance = this;82 settings_instance = this;
83 impl_.reset(new Impl());
46 }84 }
47}85}
4886
4987
=== modified file 'lockscreen/LockScreenSettings.h'
--- lockscreen/LockScreenSettings.h 2014-03-11 14:11:14 +0000
+++ lockscreen/LockScreenSettings.h 2014-03-11 14:11:15 +0000
@@ -45,8 +45,19 @@
45 static Settings& Instance();45 static Settings& Instance();
4646
47 nux::Property<Type> lockscreen_type;47 nux::Property<Type> lockscreen_type;
48 nux::Property<std::string> font_name;
49 nux::Property<std::string> logo;
50 nux::Property<std::string> background;
51 nux::Property<nux::Color> background_color;
52 nux::Property<bool> show_hostname;
53 nux::Property<bool> use_user_background;
54 nux::Property<bool> draw_grid;
4855
49 static const int GRID_SIZE = 40;56 static const int GRID_SIZE = 40;
57
58private:
59 struct Impl;
60 std::unique_ptr<Impl> impl_;
50};61};
5162
52}63}
5364
=== modified file 'lockscreen/LockScreenShield.cpp'
--- lockscreen/LockScreenShield.cpp 2014-03-11 14:11:14 +0000
+++ lockscreen/LockScreenShield.cpp 2014-03-11 14:11:15 +0000
@@ -22,26 +22,25 @@
22#include <Nux/VLayout.h>22#include <Nux/VLayout.h>
23#include <Nux/HLayout.h>23#include <Nux/HLayout.h>
24#include <Nux/PaintLayer.h>24#include <Nux/PaintLayer.h>
25#include <UnityCore/DBusIndicators.h>
2625
27#include "BackgroundSettings.h"26#include "BackgroundSettings.h"
28#include "CofView.h"27#include "CofView.h"
28#include "LockScreenPanel.h"
29#include "LockScreenSettings.h"29#include "LockScreenSettings.h"
30#include "UserPromptView.h"30#include "UserPromptView.h"
31#include "panel/PanelView.h"
32#include "unity-shared/GnomeKeyGrabber.h"
33#include "unity-shared/PanelStyle.h"
34#include "unity-shared/UScreen.h"31#include "unity-shared/UScreen.h"
32#include "unity-shared/WindowManager.h"
3533
36namespace unity34namespace unity
37{35{
38namespace lockscreen36namespace lockscreen
39{37{
4038
41Shield::Shield(session::Manager::Ptr const& session_manager, int monitor_num, bool is_primary)39Shield::Shield(session::Manager::Ptr const& session_manager, indicator::Indicators::Ptr const& indicators, int monitor_num, bool is_primary)
42 : AbstractShield(session_manager, monitor_num, is_primary)40 : AbstractShield(session_manager, indicators, monitor_num, is_primary)
43 , bg_settings_(new BackgroundSettings)41 , bg_settings_(std::make_shared<BackgroundSettings>())
44 , prompt_view_(nullptr)42 , prompt_view_(nullptr)
43 , panel_view_(nullptr)
45{44{
46 is_primary ? ShowPrimaryView() : ShowSecondaryView();45 is_primary ? ShowPrimaryView() : ShowSecondaryView();
4746
@@ -50,8 +49,8 @@
50 geometry_changed.connect([this] (nux::Area*, nux::Geometry&) { UpdateBackgroundTexture();});49 geometry_changed.connect([this] (nux::Area*, nux::Geometry&) { UpdateBackgroundTexture();});
5150
52 monitor.changed.connect([this] (int monitor) {51 monitor.changed.connect([this] (int monitor) {
53 if (primary() && panel_view_)52 if (panel_view_)
54 panel_view_->SetMonitor(monitor);53 panel_view_->monitor = monitor;
5554
56 UpdateBackgroundTexture();55 UpdateBackgroundTexture();
57 });56 });
@@ -64,6 +63,7 @@
64 }63 }
6564
66 is_primary ? ShowPrimaryView() : ShowSecondaryView();65 is_primary ? ShowPrimaryView() : ShowSecondaryView();
66 if (panel_view_) panel_view_->SetInputEventSensitivity(is_primary);
67 QueueRelayout();67 QueueRelayout();
68 QueueDraw();68 QueueDraw();
69 });69 });
@@ -132,23 +132,29 @@
132 main_layout->AddView(cof_view);132 main_layout->AddView(cof_view);
133}133}
134134
135nux::View* Shield::CreatePanel()135Panel* Shield::CreatePanel()
136{136{
137 auto indicators = std::make_shared<indicator::LockScreenDBusIndicators>();137 if (!indicators_ || !session_manager_)
138 auto gnome_grabber = std::make_shared<key::GnomeGrabber>();138 return nullptr;
139 auto menu_manager = std::make_shared<menu::Manager>(indicators, gnome_grabber);139
140140 panel_view_ = new Panel(monitor, indicators_, session_manager_);
141 // Hackish but ok for the moment. Would be nice to have menus without grab.141 panel_active_conn_ = panel_view_->active.changed.connect([this] (bool active) {
142 indicators->on_entry_show_menu.connect(sigc::mem_fun(this, &Shield::OnIndicatorEntryShowMenu));142 if (primary())
143 indicators->on_entry_activated.connect(sigc::mem_fun(this, &Shield::OnIndicatorEntryActivated));143 {
144144 if (active)
145 panel::PanelView* panel_view = new panel::PanelView(this, menu_manager, /*lockscreen_mode*/ true);145 {
146 panel_view->SetMaximumHeight(panel::Style::Instance().PanelHeight(monitor));146 UnGrabPointer();
147 panel_view->SetOpacity(0.5);147 UnGrabKeyboard();
148 panel_view->SetMonitor(monitor);148 }
149 panel_view_ = panel_view;149 else
150150 {
151 return panel_view;151 GrabPointer();
152 GrabKeyboard();
153 }
154 }
155 });
156
157 return panel_view_;
152}158}
153159
154UserPromptView* Shield::CreatePromptView()160UserPromptView* Shield::CreatePromptView()
@@ -165,38 +171,31 @@
165 return prompt_view;171 return prompt_view;
166}172}
167173
168void Shield::OnIndicatorEntryShowMenu(std::string const&, unsigned, int, int, unsigned)174nux::Area* Shield::FindKeyFocusArea(unsigned etype, unsigned long key_code, unsigned long modifiers)
169{175{
170 if (primary())176 if (primary)
171 {177 {
172 UnGrabPointer();178 if (panel_view_)
173 UnGrabKeyboard();179 {
174 }180 modifiers &= (nux::NUX_STATE_ALT | nux::NUX_STATE_CTRL | nux::NUX_STATE_SUPER | nux::NUX_STATE_SHIFT);
175}181 auto const& indicators_key = WindowManager::Default().activate_indicators_key();
176182
177void Shield::OnIndicatorEntryActivated(std::string const& panel, std::string const& entry, nux::Geometry const& geo)183 if (indicators_key.first == modifiers && indicators_key.second == key_code)
178{184 return panel_view_;
179 if (primary() && entry.empty() and geo.IsNull()) /* on menu closed */185 }
180 {186
181 GrabPointer();187 if (prompt_view_)
182 GrabKeyboard();188 {
183 }189 auto* focus_view = prompt_view_->focus_view();
184}190
185191 if (focus_view && focus_view->GetInputEventSensitivity())
186nux::Area* Shield::FindKeyFocusArea(unsigned int, unsigned long, unsigned long)192 return focus_view;
187{193 }
188 if (primary && prompt_view_)
189 {
190 auto* focus_view = prompt_view_->focus_view();
191
192 if (focus_view && focus_view->GetInputEventSensitivity())
193 return focus_view;
194 }194 }
195195
196 return nullptr;196 return nullptr;
197}197}
198198
199
200bool Shield::AcceptKeyNavFocus()199bool Shield::AcceptKeyNavFocus()
201{200{
202 return false;201 return false;
@@ -212,5 +211,10 @@
212 return area;211 return area;
213}212}
214213
214bool Shield::IsIndicatorOpen() const
215{
216 return panel_view_ ? panel_view_->active() : false;
217}
218
215}219}
216}220}
217221
=== modified file 'lockscreen/LockScreenShield.h'
--- lockscreen/LockScreenShield.h 2014-03-11 14:11:14 +0000
+++ lockscreen/LockScreenShield.h 2014-03-11 14:11:15 +0000
@@ -20,26 +20,27 @@
20#ifndef UNITY_LOCKSCREEN_SHIELD_H20#ifndef UNITY_LOCKSCREEN_SHIELD_H
21#define UNITY_LOCKSCREEN_SHIELD_H21#define UNITY_LOCKSCREEN_SHIELD_H
2222
23#include <UnityCore/ConnectionManager.h>
23#include "LockScreenAbstractShield.h"24#include "LockScreenAbstractShield.h"
2425
25namespace unity26namespace unity
26{27{
27namespace panel
28{
29class PanelView;
30}
31namespace lockscreen28namespace lockscreen
32{29{
3330
34class BackgroundSettings;31class BackgroundSettings;
35class UserAuthenticator;32class UserAuthenticator;
36class UserPromptView;33class UserPromptView;
34class Panel;
3735
38class Shield : public AbstractShield36class Shield : public AbstractShield
39{37{
40public:38public:
41 Shield(session::Manager::Ptr const& session_manager, int monitor, bool is_primary);39 Shield(session::Manager::Ptr const&, indicator::Indicators::Ptr const&, int monitor, bool is_primary);
4240
41 bool IsIndicatorOpen() const;
42
43protected:
43 bool AcceptKeyNavFocus() override;44 bool AcceptKeyNavFocus() override;
44 nux::Area* FindKeyFocusArea(unsigned int, unsigned long, unsigned long) override;45 nux::Area* FindKeyFocusArea(unsigned int, unsigned long, unsigned long) override;
45 nux::Area* FindAreaUnderMouse(nux::Point const&, nux::NuxEventType) override;46 nux::Area* FindAreaUnderMouse(nux::Point const&, nux::NuxEventType) override;
@@ -48,18 +49,16 @@
48 void UpdateBackgroundTexture();49 void UpdateBackgroundTexture();
49 void ShowPrimaryView();50 void ShowPrimaryView();
50 void ShowSecondaryView();51 void ShowSecondaryView();
51 nux::View* CreatePanel();52 Panel* CreatePanel();
52 UserPromptView* CreatePromptView();53 UserPromptView* CreatePromptView();
5354
54 void OnIndicatorEntryShowMenu(std::string const&, unsigned, int, int, unsigned);
55 void OnIndicatorEntryActivated(std::string const& panel, std::string const& entry, nux::Geometry const& geo);
56
57 std::shared_ptr<BackgroundSettings> bg_settings_;55 std::shared_ptr<BackgroundSettings> bg_settings_;
58 std::unique_ptr<nux::AbstractPaintLayer> background_layer_;56 std::unique_ptr<nux::AbstractPaintLayer> background_layer_;
59 nux::ObjectPtr<nux::Layout> primary_layout_;57 nux::ObjectPtr<nux::Layout> primary_layout_;
60 nux::ObjectPtr<nux::Layout> cof_layout_;58 nux::ObjectPtr<nux::Layout> cof_layout_;
59 connection::Wrapper panel_active_conn_;
61 UserPromptView* prompt_view_;60 UserPromptView* prompt_view_;
62 panel::PanelView* panel_view_;61 Panel* panel_view_;
63};62};
6463
65}64}
6665
=== modified file 'lockscreen/LockScreenShieldFactory.cpp'
--- lockscreen/LockScreenShieldFactory.cpp 2014-03-11 14:11:14 +0000
+++ lockscreen/LockScreenShieldFactory.cpp 2014-03-11 14:11:15 +0000
@@ -25,9 +25,9 @@
25namespace lockscreen25namespace lockscreen
26{26{
2727
28nux::ObjectPtr<AbstractShield> ShieldFactory::CreateShield(session::Manager::Ptr const& session_manager, int monitor, bool is_primary)28nux::ObjectPtr<AbstractShield> ShieldFactory::CreateShield(session::Manager::Ptr const& session_manager, indicator::Indicators::Ptr const& indicators, int monitor, bool is_primary)
29{29{
30 return nux::ObjectPtr<Shield>(new Shield(session_manager, monitor, is_primary));30 return nux::ObjectPtr<Shield>(new Shield(session_manager, indicators, monitor, is_primary));
31}31}
3232
33}33}
3434
=== modified file 'lockscreen/LockScreenShieldFactory.h'
--- lockscreen/LockScreenShieldFactory.h 2014-03-11 14:11:14 +0000
+++ lockscreen/LockScreenShieldFactory.h 2014-03-11 14:11:15 +0000
@@ -37,12 +37,12 @@
3737
38 virtual ~ShieldFactoryInterface() = default;38 virtual ~ShieldFactoryInterface() = default;
3939
40 virtual nux::ObjectPtr<AbstractShield> CreateShield(session::Manager::Ptr const&, int monitor, bool is_primary) = 0;40 virtual nux::ObjectPtr<AbstractShield> CreateShield(session::Manager::Ptr const&, indicator::Indicators::Ptr const&, int monitor, bool is_primary) = 0;
41};41};
4242
43struct ShieldFactory : ShieldFactoryInterface43struct ShieldFactory : ShieldFactoryInterface
44{44{
45 nux::ObjectPtr<AbstractShield> CreateShield(session::Manager::Ptr const&, int monitor, bool is_primary) override;45 nux::ObjectPtr<AbstractShield> CreateShield(session::Manager::Ptr const&, indicator::Indicators::Ptr const&, int monitor, bool is_primary) override;
46};46};
4747
48}48}
4949
=== modified file 'lockscreen/UserAuthenticatorPam.cpp'
--- lockscreen/UserAuthenticatorPam.cpp 2014-03-11 14:11:14 +0000
+++ lockscreen/UserAuthenticatorPam.cpp 2014-03-11 14:11:15 +0000
@@ -77,7 +77,7 @@
77 if (num_msg <= 0)77 if (num_msg <= 0)
78 return PAM_CONV_ERR;78 return PAM_CONV_ERR;
7979
80 auto* tmp_response = g_new0(pam_response, num_msg);80 auto* tmp_response = static_cast<pam_response*>(calloc(num_msg, sizeof(pam_response)));
8181
82 if (!tmp_response)82 if (!tmp_response)
83 return PAM_CONV_ERR;83 return PAM_CONV_ERR;
8484
=== modified file 'lockscreen/UserPromptView.cpp'
--- lockscreen/UserPromptView.cpp 2014-03-11 14:11:14 +0000
+++ lockscreen/UserPromptView.cpp 2014-03-11 14:11:15 +0000
@@ -39,7 +39,6 @@
39const RawPixel MSG_LAYOUT_MARGIN = 15_em;39const RawPixel MSG_LAYOUT_MARGIN = 15_em;
40const RawPixel PROMPT_LAYOUT_MARGIN = 5_em;40const RawPixel PROMPT_LAYOUT_MARGIN = 5_em;
41const int PROMPT_FONT_SIZE = 13;41const int PROMPT_FONT_SIZE = 13;
42const int MESSAGE_FONT_SIZE = 11;
4342
44nux::AbstractPaintLayer* CrateBackgroundLayer(int width, int height)43nux::AbstractPaintLayer* CrateBackgroundLayer(int width, int height)
45{44{
@@ -267,7 +266,7 @@
267void UserPromptView::AddMessage(std::string const& message, nux::Color const& color)266void UserPromptView::AddMessage(std::string const& message, nux::Color const& color)
268{267{
269 auto* view = new unity::StaticCairoText("");268 auto* view = new unity::StaticCairoText("");
270 view->SetFont("Ubuntu "+std::to_string(MESSAGE_FONT_SIZE));269 view->SetFont(Settings::Instance().font_name());
271 view->SetTextColor(color);270 view->SetTextColor(color);
272 view->SetText(message);271 view->SetText(message);
273272
274273
=== modified file 'lockscreen/pch/lockscreen_pch.hh'
--- lockscreen/pch/lockscreen_pch.hh 2014-03-11 14:11:14 +0000
+++ lockscreen/pch/lockscreen_pch.hh 2014-03-11 14:11:15 +0000
@@ -28,4 +28,5 @@
28#include <security/pam_appl.h>28#include <security/pam_appl.h>
2929
30#include <Nux/Nux.h>30#include <Nux/Nux.h>
31#include <UnityCore/SessionManager.h>
32\ No newline at end of file31\ No newline at end of file
32#include <UnityCore/SessionManager.h>
33#include <UnityCore/Indicators.h>
33\ No newline at end of file34\ No newline at end of file
3435
=== modified file 'panel/PanelIndicatorEntryView.cpp'
--- panel/PanelIndicatorEntryView.cpp 2014-02-28 15:01:24 +0000
+++ panel/PanelIndicatorEntryView.cpp 2014-03-11 14:11:15 +0000
@@ -387,7 +387,7 @@
387 pango_layout_get_pixel_size(layout, &extents.width, &extents.height);387 pango_layout_get_pixel_size(layout, &extents.width, &extents.height);
388 int y = (height - extents.height) / 2;388 int y = (height - extents.height) / 2;
389389
390 if (overlay_showing_)390 if (overlay_showing_ && !IsActive())
391 {391 {
392 cairo_move_to(cr, x, y);392 cairo_move_to(cr, x, y);
393 cairo_set_source_rgb(cr, 1.0f, 1.0f, 1.0f);393 cairo_set_source_rgb(cr, 1.0f, 1.0f, 1.0f);
394394
=== modified file 'panel/PanelIndicatorsView.cpp'
--- panel/PanelIndicatorsView.cpp 2014-02-25 02:38:26 +0000
+++ panel/PanelIndicatorsView.cpp 2014-03-11 14:11:15 +0000
@@ -42,6 +42,7 @@
42, opacity(1.0f, sigc::mem_fun(this, &PanelIndicatorsView::SetOpacity))42, opacity(1.0f, sigc::mem_fun(this, &PanelIndicatorsView::SetOpacity))
43, layout_(new nux::HLayout("", NUX_TRACKER_LOCATION))43, layout_(new nux::HLayout("", NUX_TRACKER_LOCATION))
44, monitor_(0)44, monitor_(0)
45, overlay_showing_(false)
45{46{
46 opacity.DisableNotifications();47 opacity.DisableNotifications();
47 layout_->SetContentDistribution(nux::MAJOR_POSITION_END);48 layout_->SetContentDistribution(nux::MAJOR_POSITION_END);
@@ -327,6 +328,9 @@
327 auto view = new PanelIndicatorEntryView(entry, padding, type);328 auto view = new PanelIndicatorEntryView(entry, padding, type);
328 AddEntryView(view, pos);329 AddEntryView(view, pos);
329330
331 if (overlay_showing_)
332 view->OverlayShown();
333
330 return view;334 return view;
331}335}
332336
@@ -368,12 +372,16 @@
368372
369void PanelIndicatorsView::OverlayShown()373void PanelIndicatorsView::OverlayShown()
370{374{
375 overlay_showing_ = true;
376
371 for (auto const& entry: entries_)377 for (auto const& entry: entries_)
372 entry.second->OverlayShown();378 entry.second->OverlayShown();
373}379}
374380
375void PanelIndicatorsView::OverlayHidden()381void PanelIndicatorsView::OverlayHidden()
376{382{
383 overlay_showing_ = false;
384
377 for (auto const& entry: entries_)385 for (auto const& entry: entries_)
378 entry.second->OverlayHidden();386 entry.second->OverlayHidden();
379}387}
380388
=== modified file 'panel/PanelIndicatorsView.h'
--- panel/PanelIndicatorsView.h 2014-02-18 04:47:43 +0000
+++ panel/PanelIndicatorsView.h 2014-03-11 14:11:15 +0000
@@ -98,6 +98,7 @@
98 Entries entries_;98 Entries entries_;
9999
100 int monitor_;100 int monitor_;
101 bool overlay_showing_;
101102
102private:103private:
103 bool SetOpacity(double& target, double const& new_value);104 bool SetOpacity(double& target, double const& new_value);
104105
=== modified file 'panel/PanelMenuView.cpp'
--- panel/PanelMenuView.cpp 2014-02-27 05:45:23 +0000
+++ panel/PanelMenuView.cpp 2014-03-11 14:11:15 +0000
@@ -64,7 +64,6 @@
64 , is_desktop_focused_(false)64 , is_desktop_focused_(false)
65 , last_active_view_(nullptr)65 , last_active_view_(nullptr)
66 , new_application_(nullptr)66 , new_application_(nullptr)
67 , overlay_showing_(false)
68 , switcher_showing_(false)67 , switcher_showing_(false)
69 , spread_showing_(false)68 , spread_showing_(false)
70 , launcher_keynav_(false)69 , launcher_keynav_(false)
7170
=== modified file 'panel/PanelMenuView.h'
--- panel/PanelMenuView.h 2014-02-27 05:45:23 +0000
+++ panel/PanelMenuView.h 2014-03-11 14:11:15 +0000
@@ -176,7 +176,6 @@
176 nux::Geometry last_geo_;176 nux::Geometry last_geo_;
177 nux::Geometry title_geo_;177 nux::Geometry title_geo_;
178178
179 bool overlay_showing_;
180 bool switcher_showing_;179 bool switcher_showing_;
181 bool spread_showing_;180 bool spread_showing_;
182 bool launcher_keynav_;181 bool launcher_keynav_;
183182
=== modified file 'panel/PanelView.cpp'
--- panel/PanelView.cpp 2014-03-11 14:11:14 +0000
+++ panel/PanelView.cpp 2014-03-11 14:11:15 +0000
@@ -48,7 +48,7 @@
4848
49NUX_IMPLEMENT_OBJECT_TYPE(PanelView);49NUX_IMPLEMENT_OBJECT_TYPE(PanelView);
5050
51PanelView::PanelView(MockableBaseWindow* parent, menu::Manager::Ptr const& menus, bool lockscreen_mode, NUX_FILE_LINE_DECL)51PanelView::PanelView(MockableBaseWindow* parent, menu::Manager::Ptr const& menus, NUX_FILE_LINE_DECL)
52 : View(NUX_FILE_LINE_PARAM)52 : View(NUX_FILE_LINE_PARAM)
53 , parent_(parent)53 , parent_(parent)
54 , remote_(menus->Indicators())54 , remote_(menus->Indicators())
@@ -59,7 +59,6 @@
59 , opacity_(1.0f)59 , opacity_(1.0f)
60 , monitor_(0)60 , monitor_(0)
61 , stored_dash_width_(0)61 , stored_dash_width_(0)
62 , lockscreen_mode_(lockscreen_mode)
63 , bg_effect_helper_(this)62 , bg_effect_helper_(this)
64{63{
65 auto& wm = WindowManager::Default();64 auto& wm = WindowManager::Default();
@@ -98,22 +97,15 @@
98 menu_view_->EnableDropdownMenu(true, remote_);97 menu_view_->EnableDropdownMenu(true, remote_);
99 AddPanelView(menu_view_, 0);98 AddPanelView(menu_view_, 0);
10099
101 if (lockscreen_mode_)
102 menu_view_->SetVisible(false);
103
104 SetCompositionLayout(layout_);100 SetCompositionLayout(layout_);
105101
106 tray_ = nullptr;102 tray_ = new PanelTray(monitor_);
107 if (!lockscreen_mode_)103 layout_->AddView(tray_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
108 {104 AddChild(tray_);
109 tray_ = new PanelTray(monitor_);
110 layout_->AddView(tray_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
111 AddChild(tray_);
112 }
113105
114 indicators_ = new PanelIndicatorsView();106 indicators_ = new PanelIndicatorsView();
115 indicators_->SetMonitor(monitor_);107 indicators_->SetMonitor(monitor_);
116 AddPanelView(indicators_, lockscreen_mode_ ? 1 : 0);108 AddPanelView(indicators_, 0);
117109
118 for (auto const& object : remote_->GetIndicators())110 for (auto const& object : remote_->GetIndicators())
119 OnObjectAdded(object);111 OnObjectAdded(object);
@@ -301,7 +293,7 @@
301 {293 {
302 bg_blur_texture_ = bg_effect_helper_.GetBlurRegion();294 bg_blur_texture_ = bg_effect_helper_.GetBlurRegion();
303 }295 }
304 else if(!lockscreen_mode_)296 else
305 {297 {
306 bg_blur_texture_ = bg_effect_helper_.GetRegion();298 bg_blur_texture_ = bg_effect_helper_.GetRegion();
307 }299 }
308300
=== modified file 'panel/PanelView.h'
--- panel/PanelView.h 2014-03-11 14:11:14 +0000
+++ panel/PanelView.h 2014-02-25 22:10:53 +0000
@@ -51,7 +51,7 @@
51{51{
52 NUX_DECLARE_OBJECT_TYPE(PanelView, nux::View);52 NUX_DECLARE_OBJECT_TYPE(PanelView, nux::View);
53public:53public:
54 PanelView(MockableBaseWindow* parent, menu::Manager::Ptr const&, bool lockscreen_mode_ = false, NUX_FILE_LINE_PROTO);54 PanelView(MockableBaseWindow* parent, menu::Manager::Ptr const&, NUX_FILE_LINE_PROTO);
55 ~PanelView();55 ~PanelView();
5656
57 MockableBaseWindow* GetParent() const57 MockableBaseWindow* GetParent() const
@@ -140,7 +140,6 @@
140 float opacity_;140 float opacity_;
141 int monitor_;141 int monitor_;
142 int stored_dash_width_;142 int stored_dash_width_;
143 bool lockscreen_mode_;
144143
145 connection::Manager on_indicator_updated_connections_;144 connection::Manager on_indicator_updated_connections_;
146 connection::Manager maximized_opacity_toggle_connections_;145 connection::Manager maximized_opacity_toggle_connections_;
147146
=== modified file 'plugins/unityshell/src/unityshell.cpp'
--- plugins/unityshell/src/unityshell.cpp 2014-03-11 14:11:14 +0000
+++ plugins/unityshell/src/unityshell.cpp 2014-03-11 14:11:15 +0000
@@ -338,6 +338,7 @@
338 optionSetShowDesktopKeyInitiate(boost::bind(&UnityScreen::showDesktopKeyInitiate, this, _1, _2, _3));338 optionSetShowDesktopKeyInitiate(boost::bind(&UnityScreen::showDesktopKeyInitiate, this, _1, _2, _3));
339 optionSetPanelFirstMenuInitiate(boost::bind(&UnityScreen::showPanelFirstMenuKeyInitiate, this, _1, _2, _3));339 optionSetPanelFirstMenuInitiate(boost::bind(&UnityScreen::showPanelFirstMenuKeyInitiate, this, _1, _2, _3));
340 optionSetPanelFirstMenuTerminate(boost::bind(&UnityScreen::showPanelFirstMenuKeyTerminate, this, _1, _2, _3));340 optionSetPanelFirstMenuTerminate(boost::bind(&UnityScreen::showPanelFirstMenuKeyTerminate, this, _1, _2, _3));
341 optionSetPanelFirstMenuNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
341 optionSetAutomaximizeValueNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));342 optionSetAutomaximizeValueNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
342 optionSetDashTapDurationNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));343 optionSetDashTapDurationNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
343 optionSetAltTabTimeoutNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));344 optionSetAltTabTimeoutNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
@@ -2582,6 +2583,15 @@
2582 WindowManager::Default().close_window_key = std::make_pair(modifiers, keysym);2583 WindowManager::Default().close_window_key = std::make_pair(modifiers, keysym);
2583}2584}
25842585
2586void UnityScreen::UpdateActivateIndicatorsKey()
2587{
2588 CompAction::KeyBinding const& keybind = optionGetPanelFirstMenu().key();
2589 KeySym keysym = XkbKeycodeToKeysym(screen->dpy(), keybind.keycode(), 0, 0);
2590 unsigned modifiers = CompizModifiersToNux(keybind.modifiers());
2591
2592 WindowManager::Default().activate_indicators_key = std::make_pair(modifiers, keysym);
2593}
2594
2585bool UnityScreen::initPluginActions()2595bool UnityScreen::initPluginActions()
2586{2596{
2587 PluginAdapter& adapter = PluginAdapter::Default();2597 PluginAdapter& adapter = PluginAdapter::Default();
@@ -2810,12 +2820,21 @@
28102820
2811 GLWindowPaintAttrib wAttrib = attrib;2821 GLWindowPaintAttrib wAttrib = attrib;
28122822
2813 if (window->type() != CompWindowTypePopupMenuMask)2823 if (uScreen->lockscreen_controller_->IsLocked())
2814 {2824 {
2815 if (uScreen->lockscreen_controller_->IsShielded())2825 if (window->type() != CompWindowTypePopupMenuMask ||
2826 !uScreen->lockscreen_controller_->HasOpenMenu())
2816 {2827 {
2817 wAttrib.opacity = 0;2828 // For some reasons PAINT_WINDOW_NO_CORE_INSTANCE_MASK doesn't work here
2818 return gWindow->glPaint(wAttrib, matrix, region, mask);2829 // (well, it works too much, as it applies to menus too), so we need
2830 // to paint the windows at the proper opacity, overriding any other
2831 // paint plugin (animation, fade?) that might interfere with us.
2832 wAttrib.opacity = COMPIZ_COMPOSITE_OPAQUE * (1.0f - uScreen->lockscreen_controller_->Opacity());
2833 int old_index = gWindow->glPaintGetCurrentIndex();
2834 gWindow->glPaintSetCurrentIndex(MAXSHORT);
2835 bool ret = gWindow->glPaint(wAttrib, matrix, region, mask);
2836 gWindow->glPaintSetCurrentIndex(old_index);
2837 return ret;
2819 }2838 }
2820 }2839 }
28212840
@@ -3502,6 +3521,9 @@
3502 case UnityshellOptions::LockScreenType:3521 case UnityshellOptions::LockScreenType:
3503 lockscreen_settings_.lockscreen_type = static_cast<lockscreen::Type>(optionGetLockScreenType());3522 lockscreen_settings_.lockscreen_type = static_cast<lockscreen::Type>(optionGetLockScreenType());
3504 break;3523 break;
3524 case UnityshellOptions::PanelFirstMenu:
3525 UpdateActivateIndicatorsKey();
3526 break;
3505 default:3527 default:
3506 break;3528 break;
3507 }3529 }
@@ -3644,11 +3666,13 @@
36443666
3645 // Setup Session Controller3667 // Setup Session Controller
3646 auto manager = std::make_shared<session::GnomeManager>();3668 auto manager = std::make_shared<session::GnomeManager>();
3669 session_dbus_manager_ = std::make_shared<session::DBusManager>(manager);
3647 session_controller_ = std::make_shared<session::Controller>(manager);3670 session_controller_ = std::make_shared<session::Controller>(manager);
3648 AddChild(session_controller_.get());3671 AddChild(session_controller_.get());
36493672
3650 // Setup Lockscreen Controller3673 // Setup Lockscreen Controller
3651 lockscreen_controller_ = std::make_shared<lockscreen::Controller>(manager);3674 lockscreen_controller_ = std::make_shared<lockscreen::Controller>(manager);
3675 UpdateActivateIndicatorsKey();
36523676
3653 auto on_launcher_size_changed = [this] (nux::Area* area, int w, int h) {3677 auto on_launcher_size_changed = [this] (nux::Area* area, int w, int h) {
3654 /* The launcher geometry includes 1px used to draw the right margin3678 /* The launcher geometry includes 1px used to draw the right margin
36553679
=== modified file 'plugins/unityshell/src/unityshell.h'
--- plugins/unityshell/src/unityshell.h 2014-03-11 14:11:14 +0000
+++ plugins/unityshell/src/unityshell.h 2014-03-11 14:11:15 +0000
@@ -67,6 +67,7 @@
67#include "ScreenIntrospection.h"67#include "ScreenIntrospection.h"
68#include "SwitcherController.h"68#include "SwitcherController.h"
69#include "SessionController.h"69#include "SessionController.h"
70#include "SessionDBusManager.h"
70#include "SpreadFilter.h"71#include "SpreadFilter.h"
71#include "UBusWrapper.h"72#include "UBusWrapper.h"
72#include "UnityshellPrivate.h"73#include "UnityshellPrivate.h"
@@ -299,6 +300,7 @@
299 unsigned XModifiersToNux(unsigned input) const;300 unsigned XModifiersToNux(unsigned input) const;
300301
301 void UpdateCloseWindowKey(CompAction::KeyBinding const&);302 void UpdateCloseWindowKey(CompAction::KeyBinding const&);
303 void UpdateActivateIndicatorsKey();
302304
303 bool getMipmap () override { return false; }305 bool getMipmap () override { return false; }
304306
@@ -329,6 +331,7 @@
329 switcher::Controller::Ptr switcher_controller_;331 switcher::Controller::Ptr switcher_controller_;
330 hud::Controller::Ptr hud_controller_;332 hud::Controller::Ptr hud_controller_;
331 shortcut::Controller::Ptr shortcut_controller_;333 shortcut::Controller::Ptr shortcut_controller_;
334 session::DBusManager::Ptr session_dbus_manager_;
332 session::Controller::Ptr session_controller_;335 session::Controller::Ptr session_controller_;
333 std::shared_ptr<lockscreen::Controller> lockscreen_controller_;336 std::shared_ptr<lockscreen::Controller> lockscreen_controller_;
334 debug::DebugDBusInterface debugger_;337 debug::DebugDBusInterface debugger_;
335338
=== modified file 'services/panel-service.c'
--- services/panel-service.c 2014-03-11 14:11:14 +0000
+++ services/panel-service.c 2014-03-11 14:11:15 +0000
@@ -1327,7 +1327,7 @@
1327 IndicatorNg *indicator;1327 IndicatorNg *indicator;
13281328
1329 filename = g_build_filename (INDICATOR_SERVICE_DIR, name, NULL);1329 filename = g_build_filename (INDICATOR_SERVICE_DIR, name, NULL);
1330 indicator = indicator_ng_new_for_profile (filename, !lockscreen_mode ? "desktop" : "desktop_greeter", &error);1330 indicator = indicator_ng_new_for_profile (filename, !lockscreen_mode ? "desktop" : "desktop_lockscreen", &error);
1331 if (indicator)1331 if (indicator)
1332 {1332 {
1333 load_indicator (self, INDICATOR_OBJECT (indicator), name);1333 load_indicator (self, INDICATOR_OBJECT (indicator), name);
13341334
=== modified file 'shutdown/CMakeLists.txt'
--- shutdown/CMakeLists.txt 2013-02-17 23:55:54 +0000
+++ shutdown/CMakeLists.txt 2014-03-11 14:11:15 +0000
@@ -19,6 +19,7 @@
19set (SHUTDOWN_SOURCES19set (SHUTDOWN_SOURCES
20 SessionButton.cpp20 SessionButton.cpp
21 SessionController.cpp21 SessionController.cpp
22 SessionDBusManager.cpp
22 SessionView.cpp23 SessionView.cpp
23 )24 )
2425
2526
=== added file 'shutdown/SessionDBusManager.cpp'
--- shutdown/SessionDBusManager.cpp 1970-01-01 00:00:00 +0000
+++ shutdown/SessionDBusManager.cpp 2014-03-11 14:11:15 +0000
@@ -0,0 +1,180 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3 * Copyright (C) 2014 Canonical Ltd
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authored by: Marco Trevisan <marco.trevisan@canonical.com>
18 */
19
20#include "SessionDBusManager.h"
21
22namespace unity
23{
24namespace session
25{
26namespace dbus
27{
28const std::string NAME = "com.canonical.Unity";
29const std::string INTERFACE = "com.canonical.Unity.Session";
30const std::string OBJECT_PATH = "/com/canonical/Unity/Session";
31const std::string INTROSPECTION_XML =
32R"(<node>
33 <interface name="com.canonical.Unity.Session">
34 <method name="RealName">
35 <arg type="s" direction="out" name="realname" />
36 </method>
37 <method name="UserName">
38 <arg type="s" direction="out" name="username" />
39 </method>
40 <method name="HostName">
41 <arg type="s" direction="out" name="hostname" />
42 </method>
43 <method name="Lock" />
44 <method name="Logout" />
45 <method name="RequestLogout" />
46 <method name="Reboot" />
47 <method name="RequestReboot" />
48 <method name="Shutdown" />
49 <method name="RequestShutdown" />
50 <method name="Suspend" />
51 <method name="Hibernate" />
52 <method name="CancelAction" />
53 <method name="CanShutdown">
54 <arg type="b" direction="out" name="canshutdown" />
55 </method>
56 <method name="CanSuspend">
57 <arg type="b" direction="out" name="cansuspend" />
58 </method>
59 <method name="CanHibernate">
60 <arg type="b" direction="out" name="canhibernate" />
61 </method>
62
63 <signal name="LockRequested" />
64 <signal name="Locked" />
65 <signal name="UnlockRequested" />
66 <signal name="Unlocked" />
67 <signal name="LogoutRequested">
68 <arg type="b" name="have_inhibitors" />
69 </signal>
70 <signal name="RebootRequested">
71 <arg type="b" name="have_inhibitors" />
72 </signal>
73 <signal name="ShutdownRequested">
74 <arg type="b" name="have_inhibitors" />
75 </signal>
76 </interface>
77</node>)";
78}
79
80DBusManager::DBusManager(session::Manager::Ptr const& session)
81 : session_(session)
82 , server_(dbus::NAME)
83{
84 server_.AddObjects(dbus::INTROSPECTION_XML, dbus::OBJECT_PATH);
85 object_ = server_.GetObject(dbus::INTERFACE);
86 object_->SetMethodsCallsHandler([this] (std::string const& method, GVariant*) -> GVariant* {
87 if (method == "RealName")
88 {
89 return g_variant_new("(s)", session_->RealName().c_str());
90 }
91 else if (method == "UserName")
92 {
93 return g_variant_new("(s)", session_->UserName().c_str());
94 }
95 else if (method == "HostName")
96 {
97 return g_variant_new("(s)", session_->HostName().c_str());
98 }
99 else if (method == "Lock")
100 {
101 session_->LockScreen();
102 }
103 else if (method == "Logout")
104 {
105 session_->Logout();
106 }
107 else if (method == "RequestLogout")
108 {
109 session_->logout_requested.emit(false);
110 }
111 else if (method == "Reboot")
112 {
113 session_->Reboot();
114 }
115 else if (method == "RequestReboot")
116 {
117 session_->reboot_requested.emit(false);
118 }
119 else if (method == "Shutdown")
120 {
121 session_->Shutdown();
122 }
123 else if (method == "RequestShutdown")
124 {
125 session_->shutdown_requested.emit(false);
126 }
127 else if (method == "Suspend")
128 {
129 session_->Suspend();
130 }
131 else if (method == "Hibernate")
132 {
133 session_->Hibernate();
134 }
135 else if (method == "CancelAction")
136 {
137 session_->CancelAction();
138 session_->cancel_requested.emit();
139 }
140 else if (method == "CanShutdown")
141 {
142 return g_variant_new("(b)", session_->CanShutdown() != FALSE);
143 }
144 else if (method == "CanSuspend")
145 {
146 return g_variant_new("(b)", session_->CanSuspend() != FALSE);
147 }
148 else if (method == "CanHibernate")
149 {
150 return g_variant_new("(b)", session_->CanHibernate() != FALSE);
151 }
152
153 return nullptr;
154 });
155
156 connections_.Add(session_->lock_requested.connect([this] {
157 object_->EmitSignal("LockRequested");
158 }));
159 connections_.Add(session_->locked.connect([this] {
160 object_->EmitSignal("Locked");
161 }));
162 connections_.Add(session_->unlock_requested.connect([this] {
163 object_->EmitSignal("UnlockRequested");
164 }));
165 connections_.Add(session_->unlocked.connect([this] {
166 object_->EmitSignal("Unlocked");
167 }));
168 connections_.Add(session_->logout_requested.connect([this] (bool inhibitors) {
169 object_->EmitSignal("LogoutRequested", g_variant_new("(b)", inhibitors));
170 }));
171 connections_.Add(session_->reboot_requested.connect([this] (bool inhibitors) {
172 object_->EmitSignal("RebootRequested", g_variant_new("(b)", inhibitors));
173 }));
174 connections_.Add(session_->shutdown_requested.connect([this] (bool inhibitors) {
175 object_->EmitSignal("ShutdownRequested", g_variant_new("(b)", inhibitors));
176 }));
177}
178
179} // session
180} // unity
0181
=== added file 'shutdown/SessionDBusManager.h'
--- shutdown/SessionDBusManager.h 1970-01-01 00:00:00 +0000
+++ shutdown/SessionDBusManager.h 2014-03-11 14:11:15 +0000
@@ -0,0 +1,50 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3 * Copyright (C) 2014 Canonical Ltd
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authored by: Marco Trevisan <marco.trevisan@canonical.com>
18 */
19
20#ifndef UNITYSHELL_SESSION_DBUS_MANAGER_H
21#define UNITYSHELL_SESSION_DBUS_MANAGER_H
22
23#include <UnityCore/ConnectionManager.h>
24#include <UnityCore/GLibDBusServer.h>
25#include <UnityCore/SessionManager.h>
26
27namespace unity
28{
29namespace session
30{
31
32class DBusManager
33{
34public:
35 typedef std::shared_ptr<DBusManager> Ptr;
36
37 DBusManager(session::Manager::Ptr const& manager);
38 virtual ~DBusManager() = default;
39
40private:
41 session::Manager::Ptr session_;
42 glib::DBusServer server_;
43 glib::DBusObject::Ptr object_;
44 connection::Manager connections_;
45};
46
47} // session
48} // unity
49
50#endif
051
=== modified file 'shutdown/StandaloneSession.cpp'
--- shutdown/StandaloneSession.cpp 2013-03-07 22:30:02 +0000
+++ shutdown/StandaloneSession.cpp 2014-03-11 14:11:15 +0000
@@ -38,6 +38,7 @@
3838
39 std::string RealName() const { return "Marco Trevisan"; }39 std::string RealName() const { return "Marco Trevisan"; }
40 std::string UserName() const { return "marco"; }40 std::string UserName() const { return "marco"; }
41 std::string HostName() const { return "tricky"; }
4142
42 void LockScreen() { std::cout << "LockScreen" << std::endl; }43 void LockScreen() { std::cout << "LockScreen" << std::endl; }
43 void Logout() { std::cout << "Logout" << std::endl; }44 void Logout() { std::cout << "Logout" << std::endl; }
4445
=== modified file 'tests/data/external.gschema.xml'
--- tests/data/external.gschema.xml 2014-03-11 14:11:14 +0000
+++ tests/data/external.gschema.xml 2014-03-11 14:11:15 +0000
@@ -57,6 +57,9 @@
57 <key type="s" name="logo">57 <key type="s" name="logo">
58 <default>'/usr/share/unity-greeter/logo.png'</default>58 <default>'/usr/share/unity-greeter/logo.png'</default>
59 </key>59 </key>
60 <key type="s" name="font-name">
61 <default>'Ubuntu 11'</default>
62 </key>
60 <key type="s" name="background">63 <key type="s" name="background">
61 <default>'/usr/share/backgrounds/warty-final-ubuntu.png'</default>64 <default>'/usr/share/backgrounds/warty-final-ubuntu.png'</default>
62 </key>65 </key>
@@ -69,5 +72,8 @@
69 <key type="b" name="draw-grid">72 <key type="b" name="draw-grid">
70 <default>true</default>73 <default>true</default>
71 </key>74 </key>
75 <key type="b" name="show-hostname">
76 <default>true</default>
77 </key>
72 </schema>78 </schema>
73</schemalist>79</schemalist>
7480
=== modified file 'tests/test_lockscreen_controller.cpp'
--- tests/test_lockscreen_controller.cpp 2014-03-11 14:11:14 +0000
+++ tests/test_lockscreen_controller.cpp 2014-03-11 14:11:15 +0000
@@ -62,11 +62,20 @@
6262
63}63}
6464
65struct MockShield : AbstractShield
66{
67 MockShield()
68 : AbstractShield(nullptr, nullptr, 0, false)
69 {}
70
71 MOCK_CONST_METHOD0(IsIndicatorOpen, bool());
72};
73
65struct ShieldFactoryMock : ShieldFactoryInterface74struct ShieldFactoryMock : ShieldFactoryInterface
66{75{
67 nux::ObjectPtr<AbstractShield> CreateShield(session::Manager::Ptr const&, int, bool) override76 nux::ObjectPtr<AbstractShield> CreateShield(session::Manager::Ptr const&, indicator::Indicators::Ptr const&, int, bool) override
68 {77 {
69 return nux::ObjectPtr<AbstractShield>(new AbstractShield(nullptr, 0, false));78 return nux::ObjectPtr<AbstractShield>(new MockShield());
70 }79 }
71};80};
7281
7382
=== modified file 'tests/test_mock_session_manager.h'
--- tests/test_mock_session_manager.h 2013-03-07 21:26:57 +0000
+++ tests/test_mock_session_manager.h 2014-03-11 14:11:15 +0000
@@ -31,6 +31,7 @@
3131
32 MOCK_CONST_METHOD0(RealName, std::string());32 MOCK_CONST_METHOD0(RealName, std::string());
33 MOCK_CONST_METHOD0(UserName, std::string());33 MOCK_CONST_METHOD0(UserName, std::string());
34 MOCK_CONST_METHOD0(HostName, std::string());
3435
35 MOCK_METHOD0(LockScreen, void());36 MOCK_METHOD0(LockScreen, void());
36 MOCK_METHOD0(Logout, void());37 MOCK_METHOD0(Logout, void());
3738
=== modified file 'unity-shared/WindowManager.h'
--- unity-shared/WindowManager.h 2014-02-17 21:17:51 +0000
+++ unity-shared/WindowManager.h 2014-03-11 14:11:15 +0000
@@ -166,6 +166,7 @@
166166
167 // Nux Modifiers, Nux Keycode (= X11 KeySym)167 // Nux Modifiers, Nux Keycode (= X11 KeySym)
168 nux::Property<std::pair<unsigned, unsigned>> close_window_key;168 nux::Property<std::pair<unsigned, unsigned>> close_window_key;
169 nux::Property<std::pair<unsigned, unsigned>> activate_indicators_key;
169 nux::Property<nux::Color> average_color;170 nux::Property<nux::Color> average_color;
170171
171 // Signals172 // Signals