summaryrefslogtreecommitdiff
path: root/lockscreen
diff options
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2015-12-03 15:13:10 +0100
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2015-12-03 15:13:10 +0100
commitbbbfdc89681093f0a28f6efb942aad4cb0e4e7b0 (patch)
treee4faa26ad652a1c0738b676c7705a0a969147ff5 /lockscreen
parent9995e7f3389a2cf5cf8c9317db1da4a52011f229 (diff)
LockScreenBaseShield: add new base shield with common features for Ubuntu and Kylin
(bzr r4016.3.1)
Diffstat (limited to 'lockscreen')
-rw-r--r--lockscreen/CMakeLists.txt1
-rw-r--r--lockscreen/KylinLockScreenShield.cpp62
-rw-r--r--lockscreen/KylinLockScreenShield.h14
-rw-r--r--lockscreen/LockScreenAbstractShield.h146
-rw-r--r--lockscreen/LockScreenBaseShield.cpp173
-rw-r--r--lockscreen/LockScreenBaseShield.h88
-rw-r--r--lockscreen/LockScreenController.h5
-rw-r--r--lockscreen/LockScreenShield.cpp59
-rw-r--r--lockscreen/LockScreenShield.h14
-rw-r--r--lockscreen/LockScreenShieldFactory.cpp18
-rw-r--r--lockscreen/LockScreenShieldFactory.h24
11 files changed, 295 insertions, 309 deletions
diff --git a/lockscreen/CMakeLists.txt b/lockscreen/CMakeLists.txt
index 3ccd322aa..97857a36a 100644
--- a/lockscreen/CMakeLists.txt
+++ b/lockscreen/CMakeLists.txt
@@ -22,6 +22,7 @@ set (LOCKSCREEN_SOURCES
KylinUserPromptView.cpp
KylinLockScreenShield.cpp
LockScreenController.cpp
+ LockScreenBaseShield.cpp
LockScreenSettings.cpp
LockScreenShield.cpp
LockScreenShieldFactory.cpp
diff --git a/lockscreen/KylinLockScreenShield.cpp b/lockscreen/KylinLockScreenShield.cpp
index 5b1246889..5adf08263 100644
--- a/lockscreen/KylinLockScreenShield.cpp
+++ b/lockscreen/KylinLockScreenShield.cpp
@@ -21,12 +21,10 @@
#include <Nux/VLayout.h>
#include <Nux/HLayout.h>
-#include <Nux/PaintLayer.h>
#include "CofView.h"
#include "LockScreenSettings.h"
#include "LockScreenAbstractPromptView.h"
-#include "unity-shared/UnitySettings.h"
namespace unity
{
@@ -37,47 +35,10 @@ KylinShield::KylinShield(session::Manager::Ptr const& session_manager,
Accelerators::Ptr const& accelerators,
nux::ObjectPtr<AbstractUserPromptView> const& prompt_view,
int monitor_num, bool is_primary)
- : AbstractShield(session_manager, nullptr, accelerators, prompt_view, monitor_num, is_primary)
- , cof_view_(nullptr)
+ : BaseShield(session_manager, nullptr, accelerators, prompt_view, monitor_num, is_primary)
{
- UpdateScale();
is_primary ? ShowPrimaryView() : ShowSecondaryView();
-
EnableInputWindow(true);
-
- unity::Settings::Instance().dpi_changed.connect(sigc::mem_fun(this, &KylinShield::UpdateScale));
- geometry_changed.connect([this] (nux::Area*, nux::Geometry&) { UpdateBackgroundTexture();});
-
- monitor.changed.connect([this] (int) {
- UpdateScale();
- UpdateBackgroundTexture();
- });
-
- primary.changed.connect([this] (bool is_primary) {
- regrab_conn_->disconnect();
- is_primary ? ShowPrimaryView() : ShowSecondaryView();
- QueueRelayout();
- QueueDraw();
- });
-
- scale.changed.connect([this] (double scale) {
- if (prompt_view_ && primary())
- prompt_view_->scale = scale;
-
- if (cof_view_)
- cof_view_->scale = scale;
-
- if (prompt_layout_)
- prompt_layout_->SetLeftAndRightPadding(2 * Settings::GRID_SIZE.CP(scale));
-
- background_layer_.reset();
- UpdateBackgroundTexture();
- });
-
- mouse_move.connect([this] (int x, int y, int, int, unsigned long, unsigned long) {
- auto const& abs_geo = GetAbsoluteGeometry();
- grab_motion.emit(abs_geo.x + x, abs_geo.y + y);
- });
}
void KylinShield::ShowPrimaryView()
@@ -114,27 +75,6 @@ void KylinShield::ShowPrimaryView()
main_layout->AddSpace(0, 10);
}
-void KylinShield::ShowSecondaryView()
-{
- if (prompt_layout_)
- prompt_layout_->RemoveChildObject(prompt_view_.GetPointer());
-
- if (cof_layout_)
- {
- SetLayout(cof_layout_.GetPointer());
- return;
- }
-
- nux::Layout* main_layout = new nux::VLayout();
- cof_layout_ = main_layout;
- SetLayout(cof_layout_.GetPointer());
-
- // The circle of friends
- cof_view_ = new CofView();
- cof_view_->scale = scale();
- main_layout->AddView(cof_view_);
-}
-
nux::Area* KylinShield::FindKeyFocusArea(unsigned etype, unsigned long keysym, unsigned long modifiers)
{
if (primary)
diff --git a/lockscreen/KylinLockScreenShield.h b/lockscreen/KylinLockScreenShield.h
index f75ec3894..cdabaf5db 100644
--- a/lockscreen/KylinLockScreenShield.h
+++ b/lockscreen/KylinLockScreenShield.h
@@ -22,18 +22,16 @@
#include <UnityCore/ConnectionManager.h>
#include <UnityCore/GLibSource.h>
-#include "LockScreenAbstractShield.h"
+#include "LockScreenBaseShield.h"
namespace unity
{
namespace lockscreen
{
-class UserAuthenticator;
class AbstractUserPromptView;
-class CofView;
-class KylinShield : public AbstractShield
+class KylinShield : public BaseShield
{
public:
KylinShield(session::Manager::Ptr const&,
@@ -45,13 +43,7 @@ protected:
nux::Area* FindKeyFocusArea(unsigned int, unsigned long, unsigned long) override;
private:
- void ShowPrimaryView();
- void ShowSecondaryView();
-
- nux::ObjectPtr<nux::Layout> primary_layout_;
- nux::ObjectPtr<nux::Layout> prompt_layout_;
- nux::ObjectPtr<nux::Layout> cof_layout_;
- CofView* cof_view_;
+ void ShowPrimaryView() override;
};
}
diff --git a/lockscreen/LockScreenAbstractShield.h b/lockscreen/LockScreenAbstractShield.h
deleted file mode 100644
index 386e68586..000000000
--- a/lockscreen/LockScreenAbstractShield.h
+++ /dev/null
@@ -1,146 +0,0 @@
-// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
-/*
- * Copyright (C) 2014 Canonical Ltd
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 3 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * Authored by: Marco Trevisan <marco.trevisan@canonical.com>
- */
-
-#ifndef UNITY_LOCKSCREEN_ABSTRACT_SHIELD_H
-#define UNITY_LOCKSCREEN_ABSTRACT_SHIELD_H
-
-#include <NuxCore/Property.h>
-#include <UnityCore/SessionManager.h>
-#include <UnityCore/Indicators.h>
-
-#include "BackgroundSettings.h"
-#include "unity-shared/MockableBaseWindow.h"
-#include "unity-shared/UnitySettings.h"
-#include "unity-shared/UScreen.h"
-#include "unity-shared/WindowManager.h"
-#include "LockScreenAccelerators.h"
-
-namespace unity
-{
-namespace lockscreen
-{
-namespace
-{
-const unsigned MAX_GRAB_WAIT = 100;
-}
-
-class AbstractUserPromptView;
-
-class AbstractShield : public MockableBaseWindow
-{
-public:
- AbstractShield(session::Manager::Ptr const& session,
- indicator::Indicators::Ptr const& indicators,
- Accelerators::Ptr const& accelerators,
- nux::ObjectPtr<AbstractUserPromptView> const& prompt_view,
- int monitor_num, bool is_primary)
- : MockableBaseWindow("Unity Lockscreen")
- , primary(is_primary)
- , monitor(monitor_num)
- , scale(1.0)
- , session_manager_(session)
- , indicators_(indicators)
- , accelerators_(accelerators)
- , prompt_view_(prompt_view)
- , bg_settings_(std::make_shared<BackgroundSettings>())
- {}
-
- nux::Property<bool> primary;
- nux::Property<int> monitor;
- nux::Property<double> scale;
-
- using MockableBaseWindow::RemoveLayout;
- virtual bool HasGrab() const
- {
- auto& wc = nux::GetWindowCompositor();
- return (wc.GetPointerGrabArea() == this && wc.GetKeyboardGrabArea() == this);
- }
- virtual bool IsIndicatorOpen() const { return false; }
- virtual void ActivatePanel() {}
-
- sigc::signal<void> grabbed;
- sigc::signal<void> grab_failed;
- sigc::signal<void, int, int> grab_motion;
- sigc::signal<void, unsigned long, unsigned long> grab_key;
-
-protected:
- virtual bool AcceptKeyNavFocus() { return false; }
- virtual nux::Area* FindAreaUnderMouse(nux::Point const& mouse, nux::NuxEventType event_type)
- {
- nux::Area* area = BaseWindow::FindAreaUnderMouse(mouse, event_type);
-
- if (!area && primary)
- return this;
-
- return area;
- }
- virtual void GrabScreen(bool cancel_on_failure)
- {
- auto& wc = nux::GetWindowCompositor();
-
- if (wc.GrabPointerAdd(this) && wc.GrabKeyboardAdd(this))
- {
- regrab_conn_->disconnect();
- regrab_timeout_.reset();
- grabbed.emit();
- }
- else
- {
- auto const& retry_cb = sigc::bind(sigc::mem_fun(this, &AbstractShield::GrabScreen), false);
- regrab_conn_ = WindowManager::Default().screen_ungrabbed.connect(retry_cb);
-
- if (cancel_on_failure)
- {
- regrab_timeout_.reset(new glib::Timeout(MAX_GRAB_WAIT, [this] {
- grab_failed.emit();
- return false;
- }));
- }
- }
- }
- virtual void UpdateBackgroundTexture()
- {
- auto const& monitor_geo = UScreen::GetDefault()->GetMonitorGeometry(monitor);
-
- if (!background_layer_ || monitor_geo != background_layer_->GetGeometry())
- {
- auto background_texture = bg_settings_->GetBackgroundTexture(monitor);
- background_layer_.reset(new nux::TextureLayer(background_texture->GetDeviceTexture(), nux::TexCoordXForm(), nux::color::White, true));
- SetBackgroundLayer(background_layer_.get());
- }
- }
- virtual void UpdateScale()
- {
- scale = Settings::Instance().em(monitor)->DPIScale();
- }
-
- session::Manager::Ptr session_manager_;
- indicator::Indicators::Ptr indicators_;
- Accelerators::Ptr accelerators_;
- nux::ObjectPtr<AbstractUserPromptView> prompt_view_;
- std::shared_ptr<BackgroundSettings> bg_settings_;
- std::unique_ptr<nux::AbstractPaintLayer> background_layer_;
- connection::Wrapper regrab_conn_;
- glib::Source::UniquePtr regrab_timeout_;
-};
-
-} // lockscreen
-} // unity
-
-#endif // UNITY_LOCKSCREEN_ABSTRACT_SHIELD_H
diff --git a/lockscreen/LockScreenBaseShield.cpp b/lockscreen/LockScreenBaseShield.cpp
new file mode 100644
index 000000000..0d65550c3
--- /dev/null
+++ b/lockscreen/LockScreenBaseShield.cpp
@@ -0,0 +1,173 @@
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
+/*
+ * Copyright (C) 2015 Canonical Ltd
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authored by: Marco Trevisan <marco.trevisan@canonical.com>
+ */
+
+#include "LockScreenBaseShield.h"
+
+#include "BackgroundSettings.h"
+#include "CofView.h"
+#include "LockScreenAbstractPromptView.h"
+#include "LockScreenSettings.h"
+#include "unity-shared/MockableBaseWindow.h"
+#include "unity-shared/UnitySettings.h"
+#include "unity-shared/UScreen.h"
+#include "unity-shared/WindowManager.h"
+
+namespace unity
+{
+namespace lockscreen
+{
+namespace
+{
+const unsigned MAX_GRAB_WAIT = 100;
+}
+
+BaseShield::BaseShield(session::Manager::Ptr const& session,
+ indicator::Indicators::Ptr const& indicators,
+ Accelerators::Ptr const& accelerators,
+ nux::ObjectPtr<AbstractUserPromptView> const& prompt_view,
+ int monitor_num, bool is_primary)
+ : MockableBaseWindow("Unity Lockscreen")
+ , primary(is_primary)
+ , monitor(monitor_num)
+ , scale(1.0)
+ , session_manager_(session)
+ , indicators_(indicators)
+ , accelerators_(accelerators)
+ , prompt_view_(prompt_view)
+ , bg_settings_(std::make_shared<BackgroundSettings>())
+ , cof_view_(nullptr)
+{
+ UpdateScale();
+
+ unity::Settings::Instance().dpi_changed.connect(sigc::mem_fun(this, &BaseShield::UpdateScale));
+ geometry_changed.connect([this] (nux::Area*, nux::Geometry&) { UpdateBackgroundTexture();});
+
+ monitor.changed.connect([this] (int monitor) {
+ UpdateScale();
+ UpdateBackgroundTexture();
+ });
+
+ primary.changed.connect([this] (bool is_primary) {
+ regrab_conn_->disconnect();
+ is_primary ? ShowPrimaryView() : ShowSecondaryView();
+ QueueRelayout();
+ QueueDraw();
+ });
+
+ scale.changed.connect([this] (double scale) {
+ if (prompt_view_ && primary())
+ prompt_view_->scale = scale;
+
+ if (cof_view_)
+ cof_view_->scale = scale;
+
+ if (prompt_layout_)
+ prompt_layout_->SetLeftAndRightPadding(2 * Settings::GRID_SIZE.CP(scale));
+
+ background_layer_.reset();
+ UpdateBackgroundTexture();
+ });
+
+ mouse_move.connect([this] (int x, int y, int, int, unsigned long, unsigned long) {
+ auto const& abs_geo = GetAbsoluteGeometry();
+ grab_motion.emit(abs_geo.x + x, abs_geo.y + y);
+ });
+}
+
+bool BaseShield::HasGrab() const
+{
+ auto& wc = nux::GetWindowCompositor();
+ return (wc.GetPointerGrabArea() == this && wc.GetKeyboardGrabArea() == this);
+}
+
+nux::Area* BaseShield::FindAreaUnderMouse(nux::Point const& mouse, nux::NuxEventType event_type)
+{
+ nux::Area* area = BaseWindow::FindAreaUnderMouse(mouse, event_type);
+
+ if (!area && primary)
+ return this;
+
+ return area;
+}
+
+void BaseShield::GrabScreen(bool cancel_on_failure)
+{
+ auto& wc = nux::GetWindowCompositor();
+
+ if (wc.GrabPointerAdd(this) && wc.GrabKeyboardAdd(this))
+ {
+ regrab_conn_->disconnect();
+ regrab_timeout_.reset();
+ grabbed.emit();
+ }
+ else
+ {
+ auto const& retry_cb = sigc::bind(sigc::mem_fun(this, &BaseShield::GrabScreen), false);
+ regrab_conn_ = WindowManager::Default().screen_ungrabbed.connect(retry_cb);
+
+ if (cancel_on_failure)
+ {
+ regrab_timeout_.reset(new glib::Timeout(MAX_GRAB_WAIT, [this] {
+ grab_failed.emit();
+ return false;
+ }));
+ }
+ }
+}
+
+void BaseShield::UpdateBackgroundTexture()
+{
+ auto const& monitor_geo = UScreen::GetDefault()->GetMonitorGeometry(monitor);
+
+ if (!background_layer_ || monitor_geo != background_layer_->GetGeometry())
+ {
+ auto background_texture = bg_settings_->GetBackgroundTexture(monitor);
+ background_layer_.reset(new nux::TextureLayer(background_texture->GetDeviceTexture(), nux::TexCoordXForm(), nux::color::White, true));
+ SetBackgroundLayer(background_layer_.get());
+ }
+}
+
+void BaseShield::UpdateScale()
+{
+ scale = unity::Settings::Instance().em(monitor)->DPIScale();
+}
+
+void BaseShield::ShowSecondaryView()
+{
+ if (prompt_layout_)
+ prompt_layout_->RemoveChildObject(prompt_view_.GetPointer());
+
+ if (cof_layout_)
+ {
+ SetLayout(cof_layout_.GetPointer());
+ return;
+ }
+
+ nux::Layout* main_layout = new nux::VLayout();
+ cof_layout_ = main_layout;
+ SetLayout(cof_layout_.GetPointer());
+
+ // The circle of friends
+ cof_view_ = new CofView();
+ cof_view_->scale = scale();
+ main_layout->AddView(cof_view_);
+}
+
+} // lockscreen
+} // unity
diff --git a/lockscreen/LockScreenBaseShield.h b/lockscreen/LockScreenBaseShield.h
new file mode 100644
index 000000000..d45d26872
--- /dev/null
+++ b/lockscreen/LockScreenBaseShield.h
@@ -0,0 +1,88 @@
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
+/*
+ * Copyright (C) 2014-2015 Canonical Ltd
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authored by: Marco Trevisan <marco.trevisan@canonical.com>
+ */
+
+#ifndef UNITY_LOCKSCREEN_BASE_SHIELD_H
+#define UNITY_LOCKSCREEN_BASE_SHIELD_H
+
+#include <NuxCore/Property.h>
+#include <UnityCore/SessionManager.h>
+#include <UnityCore/Indicators.h>
+#include <UnityCore/GLibSource.h>
+#include "unity-shared/MockableBaseWindow.h"
+
+#include "LockScreenAccelerators.h"
+
+namespace unity
+{
+namespace lockscreen
+{
+class BackgroundSettings;
+class AbstractUserPromptView;
+class CofView;
+
+class BaseShield : public MockableBaseWindow
+{
+public:
+ BaseShield(session::Manager::Ptr const&, indicator::Indicators::Ptr const&,
+ Accelerators::Ptr const&, nux::ObjectPtr<AbstractUserPromptView> const&,
+ int monitor_num, bool is_primary);
+
+ nux::Property<bool> primary;
+ nux::Property<int> monitor;
+ nux::Property<double> scale;
+
+ bool HasGrab() const;
+ virtual bool IsIndicatorOpen() const { return false; };
+ virtual void ActivatePanel() {}
+ using MockableBaseWindow::RemoveLayout;
+
+ sigc::signal<void> grabbed;
+ sigc::signal<void> grab_failed;
+ sigc::signal<void, int, int> grab_motion;
+ sigc::signal<void, unsigned long, unsigned long> grab_key;
+
+protected:
+ virtual bool AcceptKeyNavFocus() { return false; }
+ virtual void ShowPrimaryView() = 0;
+ virtual void ShowSecondaryView();
+
+ nux::Area* FindAreaUnderMouse(nux::Point const& mouse, nux::NuxEventType event_type) override;
+
+ void GrabScreen(bool cancel_on_failure);
+ void UpdateBackgroundTexture();
+ void UpdateScale();
+
+ session::Manager::Ptr session_manager_;
+ indicator::Indicators::Ptr indicators_;
+ Accelerators::Ptr accelerators_;
+ nux::ObjectPtr<AbstractUserPromptView> prompt_view_;
+ std::shared_ptr<BackgroundSettings> bg_settings_;
+ std::unique_ptr<nux::AbstractPaintLayer> background_layer_;
+ nux::ObjectPtr<nux::Layout> primary_layout_;
+ nux::ObjectPtr<nux::Layout> prompt_layout_;
+ nux::ObjectPtr<nux::Layout> cof_layout_;
+ CofView* cof_view_;
+ connection::Wrapper regrab_conn_;
+ glib::Source::UniquePtr regrab_timeout_;
+};
+
+} // lockscreen
+} // unity
+
+#endif // UNITY_LOCKSCREEN_BASE_SHIELD_H
diff --git a/lockscreen/LockScreenController.h b/lockscreen/LockScreenController.h
index f0550e89e..1aacdb9b0 100644
--- a/lockscreen/LockScreenController.h
+++ b/lockscreen/LockScreenController.h
@@ -24,7 +24,6 @@
#include <UnityCore/ConnectionManager.h>
#include <UnityCore/GLibSource.h>
-#include "LockScreenAbstractPromptView.h"
#include "LockScreenShieldFactory.h"
#include "LockScreenAcceleratorController.h"
#include "ScreenSaverDBusManager.h"
@@ -77,8 +76,8 @@ private:
void OnScreenSaverActivationRequest(bool activate);
void OnPrimaryShieldMotion(int x, int y);
- std::vector<nux::ObjectPtr<AbstractShield>> shields_;
- nux::ObjectWeakPtr<AbstractShield> primary_shield_;
+ std::vector<nux::ObjectPtr<BaseShield>> shields_;
+ nux::ObjectWeakPtr<BaseShield> primary_shield_;
nux::ObjectWeakPtr<AbstractUserPromptView> prompt_view_;
nux::ObjectPtr<nux::BaseWindow> blank_window_;
diff --git a/lockscreen/LockScreenShield.cpp b/lockscreen/LockScreenShield.cpp
index ff31e3e7f..264cf7132 100644
--- a/lockscreen/LockScreenShield.cpp
+++ b/lockscreen/LockScreenShield.cpp
@@ -21,13 +21,10 @@
#include <Nux/VLayout.h>
#include <Nux/HLayout.h>
-#include <Nux/PaintLayer.h>
-#include "CofView.h"
#include "LockScreenPanel.h"
#include "LockScreenSettings.h"
#include "LockScreenAbstractPromptView.h"
-#include "unity-shared/UnitySettings.h"
namespace unity
{
@@ -39,52 +36,19 @@ Shield::Shield(session::Manager::Ptr const& session_manager,
Accelerators::Ptr const& accelerators,
nux::ObjectPtr<AbstractUserPromptView> const& prompt_view,
int monitor_num, bool is_primary)
- : AbstractShield(session_manager, indicators, accelerators, prompt_view, monitor_num, is_primary)
+ : BaseShield(session_manager, indicators, accelerators, prompt_view, monitor_num, is_primary)
, panel_view_(nullptr)
- , cof_view_(nullptr)
{
- UpdateScale();
is_primary ? ShowPrimaryView() : ShowSecondaryView();
-
EnableInputWindow(true);
- unity::Settings::Instance().dpi_changed.connect(sigc::mem_fun(this, &Shield::UpdateScale));
- geometry_changed.connect([this] (nux::Area*, nux::Geometry&) { UpdateBackgroundTexture();});
-
monitor.changed.connect([this] (int monitor) {
- UpdateScale();
-
if (panel_view_)
panel_view_->monitor = monitor;
-
- UpdateBackgroundTexture();
});
primary.changed.connect([this] (bool is_primary) {
- regrab_conn_->disconnect();
- is_primary ? ShowPrimaryView() : ShowSecondaryView();
if (panel_view_) panel_view_->SetInputEventSensitivity(is_primary);
- QueueRelayout();
- QueueDraw();
- });
-
- scale.changed.connect([this] (double scale) {
- if (prompt_view_ && primary())
- prompt_view_->scale = scale;
-
- if (cof_view_)
- cof_view_->scale = scale;
-
- if (prompt_layout_)
- prompt_layout_->SetLeftAndRightPadding(2 * Settings::GRID_SIZE.CP(scale));
-
- background_layer_.reset();
- UpdateBackgroundTexture();
- });
-
- mouse_move.connect([this] (int x, int y, int, int, unsigned long, unsigned long) {
- auto const& abs_geo = GetAbsoluteGeometry();
- grab_motion.emit(abs_geo.x + x, abs_geo.y + y);
});
}
@@ -125,27 +89,6 @@ void Shield::ShowPrimaryView()
main_layout->AddSpace(0, 10);
}
-void Shield::ShowSecondaryView()
-{
- if (prompt_layout_)
- prompt_layout_->RemoveChildObject(prompt_view_.GetPointer());
-
- if (cof_layout_)
- {
- SetLayout(cof_layout_.GetPointer());
- return;
- }
-
- nux::Layout* main_layout = new nux::VLayout();
- cof_layout_ = main_layout;
- SetLayout(cof_layout_.GetPointer());
-
- // The circle of friends
- cof_view_ = new CofView();
- cof_view_->scale = scale();
- main_layout->AddView(cof_view_);
-}
-
Panel* Shield::CreatePanel()
{
if (!indicators_ || !session_manager_)
diff --git a/lockscreen/LockScreenShield.h b/lockscreen/LockScreenShield.h
index 7cc99bcee..053e0102f 100644
--- a/lockscreen/LockScreenShield.h
+++ b/lockscreen/LockScreenShield.h
@@ -21,20 +21,17 @@
#define UNITY_LOCKSCREEN_SHIELD_H
#include <UnityCore/ConnectionManager.h>
-#include <UnityCore/GLibSource.h>
-#include "LockScreenAbstractShield.h"
+#include "LockScreenBaseShield.h"
namespace unity
{
namespace lockscreen
{
-class UserAuthenticator;
class AbstractUserPromptView;
class Panel;
-class CofView;
-class Shield : public AbstractShield
+class Shield : public BaseShield
{
public:
Shield(session::Manager::Ptr const&,
@@ -50,16 +47,11 @@ protected:
nux::Area* FindKeyFocusArea(unsigned int, unsigned long, unsigned long) override;
private:
- void ShowPrimaryView();
- void ShowSecondaryView();
+ void ShowPrimaryView() override;
Panel* CreatePanel();
- nux::ObjectPtr<nux::Layout> primary_layout_;
- nux::ObjectPtr<nux::Layout> prompt_layout_;
- nux::ObjectPtr<nux::Layout> cof_layout_;
connection::Wrapper panel_active_conn_;
Panel* panel_view_;
- CofView* cof_view_;
};
}
diff --git a/lockscreen/LockScreenShieldFactory.cpp b/lockscreen/LockScreenShieldFactory.cpp
index 74bc77c9b..1583e67e0 100644
--- a/lockscreen/LockScreenShieldFactory.cpp
+++ b/lockscreen/LockScreenShieldFactory.cpp
@@ -28,16 +28,20 @@ namespace unity
namespace lockscreen
{
-nux::ObjectPtr<AbstractShield> ShieldFactory::CreateShield(session::Manager::Ptr const& session_manager,
- indicator::Indicators::Ptr const& indicators,
- Accelerators::Ptr const& accelerators,
- nux::ObjectPtr<AbstractUserPromptView> const& prompt_view,
- int monitor, bool is_primary)
+nux::ObjectPtr<BaseShield> ShieldFactory::CreateShield(session::Manager::Ptr const& session_manager,
+ indicator::Indicators::Ptr const& indicators,
+ Accelerators::Ptr const& accelerators,
+ nux::ObjectPtr<AbstractUserPromptView> const& prompt_view,
+ int monitor, bool is_primary)
{
+ nux::ObjectPtr<BaseShield> shield;
+
if (Settings::Instance().desktop_type() == DesktopType::UBUNTUKYLIN)
- return nux::ObjectPtr<KylinShield>(new KylinShield(session_manager, accelerators, prompt_view, monitor, is_primary));
+ shield = new KylinShield(session_manager, accelerators, prompt_view, monitor, is_primary);
else
- return nux::ObjectPtr<Shield>(new Shield(session_manager, indicators, accelerators, prompt_view, monitor, is_primary));
+ shield = new Shield(session_manager, indicators, accelerators, prompt_view, monitor, is_primary);
+
+ return shield;
}
}
diff --git a/lockscreen/LockScreenShieldFactory.h b/lockscreen/LockScreenShieldFactory.h
index b841e1288..aa7e21700 100644
--- a/lockscreen/LockScreenShieldFactory.h
+++ b/lockscreen/LockScreenShieldFactory.h
@@ -21,7 +21,7 @@
#define UNITY_LOCKSCREEN_SHIELD_FACTORY
#include <Nux/Nux.h>
-#include "LockScreenAbstractShield.h"
+#include "LockScreenBaseShield.h"
namespace unity
{
@@ -39,23 +39,23 @@ struct ShieldFactoryInterface
virtual ~ShieldFactoryInterface() = default;
- virtual nux::ObjectPtr<AbstractShield> CreateShield(session::Manager::Ptr const&,
- indicator::Indicators::Ptr const&,
- Accelerators::Ptr const&,
- nux::ObjectPtr<AbstractUserPromptView> const&,
- int monitor, bool is_primary) = 0;
+ virtual nux::ObjectPtr<BaseShield> CreateShield(session::Manager::Ptr const&,
+ indicator::Indicators::Ptr const&,
+ Accelerators::Ptr const&,
+ nux::ObjectPtr<AbstractUserPromptView> const&,
+ int monitor, bool is_primary) = 0;
};
struct ShieldFactory : ShieldFactoryInterface
{
- nux::ObjectPtr<AbstractShield> CreateShield(session::Manager::Ptr const&,
- indicator::Indicators::Ptr const&,
- Accelerators::Ptr const&,
- nux::ObjectPtr<AbstractUserPromptView> const&,
- int monitor, bool is_primary) override;
+ nux::ObjectPtr<BaseShield> CreateShield(session::Manager::Ptr const&,
+ indicator::Indicators::Ptr const&,
+ Accelerators::Ptr const&,
+ nux::ObjectPtr<AbstractUserPromptView> const&,
+ int monitor, bool is_primary) override;
};
}
}
-#endif
+#endif // UNITY_LOCKSCREEN_SHIELD_FACTORY