summaryrefslogtreecommitdiff
path: root/shortcuts
diff options
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2013-09-24 22:18:42 +0200
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2013-09-24 22:18:42 +0200
commitbc7056c056ffe1d8a5ca2d5ad35506dbfa9f2925 (patch)
tree9bf133ef9862f577837f9e7492990bf65739851d /shortcuts
parente7c8f39ed851678c09cdcf4bdd1274d7ebb269e8 (diff)
Unity: Use WindowManager average_color property for getting the desktop color
Having to deal with UBus here was a mess and caused us to re-store the same value too many times. Using a nux property gives us all the features we need easily while WindowManager is already enough shared to be used for this task. (bzr r3530.1.3)
Diffstat (limited to 'shortcuts')
-rw-r--r--shortcuts/ShortcutController.cpp17
-rw-r--r--shortcuts/ShortcutController.h3
2 files changed, 6 insertions, 14 deletions
diff --git a/shortcuts/ShortcutController.cpp b/shortcuts/ShortcutController.cpp
index 117517ccd..609544b49 100644
--- a/shortcuts/ShortcutController.cpp
+++ b/shortcuts/ShortcutController.cpp
@@ -23,6 +23,7 @@
#include "unity-shared/AnimationUtils.h"
#include "unity-shared/UBusMessages.h"
#include "unity-shared/UScreen.h"
+#include "unity-shared/WindowManager.h"
namespace unity
{
@@ -40,11 +41,8 @@ Controller::Controller(BaseWindowRaiser::Ptr const& base_window_raiser,
, base_window_raiser_(base_window_raiser)
, visible_(false)
, enabled_(true)
- , bg_color_(0.0, 0.0, 0.0, 0.5)
, fade_animator_(FADE_DURATION)
{
- ubus_manager_.RegisterInterest(UBUS_BACKGROUND_COLOR_CHANGED,
- sigc::mem_fun(this, &Controller::OnBackgroundUpdate));
ubus_manager_.RegisterInterest(UBUS_LAUNCHER_START_KEY_SWITCHER, [this] (GVariant*)
{ SetEnabled(false); });
ubus_manager_.RegisterInterest(UBUS_LAUNCHER_END_KEY_SWITCHER, [this] (GVariant*)
@@ -52,8 +50,7 @@ Controller::Controller(BaseWindowRaiser::Ptr const& base_window_raiser,
ubus_manager_.RegisterInterest(UBUS_OVERLAY_SHOWN,
sigc::hide(sigc::mem_fun(this, &Controller::Hide)));
- ubus_manager_.SendMessage(UBUS_BACKGROUND_REQUEST_COLOUR_EMIT);
-
+ WindowManager::Default().average_color.changed.connect(sigc::mem_fun(this, &Controller::OnBackgroundUpdate));
fade_animator_.updated.connect(sigc::mem_fun(this, &Controller::SetOpacity));
modeller_->model_changed.connect(sigc::mem_fun(this, &Controller::OnModelUpdated));
}
@@ -61,14 +58,10 @@ Controller::Controller(BaseWindowRaiser::Ptr const& base_window_raiser,
Controller::~Controller()
{}
-void Controller::OnBackgroundUpdate(GVariant* data)
+void Controller::OnBackgroundUpdate(nux::Color const& new_color)
{
- gdouble red, green, blue, alpha;
- g_variant_get(data, "(dddd)", &red, &green, &blue, &alpha);
- bg_color_ = nux::Color(red, green, blue, alpha);
-
if (view_)
- view_->background_color = bg_color_;
+ view_->background_color = new_color;
}
void Controller::OnModelUpdated(Model::Ptr const& model)
@@ -161,7 +154,7 @@ void Controller::ConstructView()
view_ = View::Ptr(new View());
AddChild(view_.GetPointer());
view_->SetModel(modeller_->GetCurrentModel());
- view_->background_color = bg_color_;
+ view_->background_color = WindowManager::Default().average_color();
if (!view_window_)
{
diff --git a/shortcuts/ShortcutController.h b/shortcuts/ShortcutController.h
index 18ca21bd3..c506c2df0 100644
--- a/shortcuts/ShortcutController.h
+++ b/shortcuts/ShortcutController.h
@@ -67,7 +67,7 @@ protected:
private:
void ConstructView();
void EnsureView();
- void OnBackgroundUpdate(GVariant* data);
+ void OnBackgroundUpdate(nux::Color const&);
void OnModelUpdated(Model::Ptr const&);
bool OnShowTimer();
@@ -82,7 +82,6 @@ private:
bool visible_;
bool enabled_;
- nux::Color bg_color_;
nux::animation::AnimateValue<double> fade_animator_;