summaryrefslogtreecommitdiff
path: root/dash
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 /dash
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 'dash')
-rw-r--r--dash/DashView.cpp16
-rw-r--r--dash/DashView.h3
-rw-r--r--dash/ResultViewGrid.cpp20
-rw-r--r--dash/ResultViewGrid.h1
4 files changed, 7 insertions, 33 deletions
diff --git a/dash/DashView.cpp b/dash/DashView.cpp
index 89ecab3ab..289ea1630 100644
--- a/dash/DashView.cpp
+++ b/dash/DashView.cpp
@@ -144,12 +144,6 @@ DashView::DashView(Scopes::Ptr const& scopes, ApplicationStarter::Ptr const& app
preview_state_machine_.PreviewActivated.connect(sigc::mem_fun(this, &DashView::BuildPreview));
Relayout();
- // We are interested in the color of the desktop background.
- ubus_manager_.RegisterInterest(UBUS_BACKGROUND_COLOR_CHANGED, sigc::mem_fun(this, &DashView::OnBGColorChanged));
-
- // request the latest colour from bghash
- ubus_manager_.SendMessage(UBUS_BACKGROUND_REQUEST_COLOUR_EMIT);
-
if (scopes_)
{
scopes_->scope_added.connect(sigc::mem_fun(this, &DashView::OnScopeAdded));
@@ -170,15 +164,6 @@ DashView::~DashView()
RemoveLayout();
}
-void DashView::OnBGColorChanged(GVariant *data)
-{
- double red = 0.0f, green = 0.0f, blue = 0.0f, alpha = 0.0f;
-
- g_variant_get(data, "(dddd)", &red, &green, &blue, &alpha);
- background_color_ = nux::Color(red, green, blue, alpha);
- QueueDraw();
-}
-
void DashView::SetMonitorOffset(int x, int y)
{
renderer_.x_offset = x;
@@ -469,7 +454,6 @@ void DashView::OnPreviewAnimationFinished()
void DashView::AboutToShow()
{
- ubus_manager_.SendMessage(UBUS_BACKGROUND_REQUEST_COLOUR_EMIT);
visible_ = true;
search_bar_->text_entry()->SelectAll();
diff --git a/dash/DashView.h b/dash/DashView.h
index 6abf56b1a..621099f4c 100644
--- a/dash/DashView.h
+++ b/dash/DashView.h
@@ -88,7 +88,6 @@ protected:
private:
void SetupViews();
void SetupUBusConnections();
- void OnBGColorChanged(GVariant *data);
nux::Geometry GetBestFitGeometry(nux::Geometry const& for_geo);
void Draw(nux::GraphicsEngine& gfx_context, bool force_draw);
@@ -178,8 +177,6 @@ private:
int opening_column_width_;
int opening_row_height_;
- nux::Color background_color_;
-
std::unique_ptr<na::AnimateValue<float>> split_animation_;
float animate_split_value_;
diff --git a/dash/ResultViewGrid.cpp b/dash/ResultViewGrid.cpp
index e1d2a68be..c1a218179 100644
--- a/dash/ResultViewGrid.cpp
+++ b/dash/ResultViewGrid.cpp
@@ -35,6 +35,7 @@
#include "unity-shared/UBusMessages.h"
#include "unity-shared/GraphicsUtils.h"
#include "unity-shared/UnitySettings.h"
+#include "unity-shared/WindowManager.h"
#include "ResultViewGrid.h"
#include "math.h"
@@ -114,22 +115,14 @@ ResultViewGrid::ResultViewGrid(NUX_FILE_LINE_DECL)
NeedRedraw();
});
+ WindowManager::Default().average_color.changed.connect(sigc::hide(sigc::mem_fun(this, &View::QueueDraw)));
+
ubus_.RegisterInterest(UBUS_DASH_SIZE_CHANGED, [this] (GVariant* data) {
// on dash size changed, we update our stored values, this sucks
//FIXME in P - make dash size the size of our dash not the entire screen
g_variant_get (data, "(ii)", &recorded_dash_width_, &recorded_dash_height_);
});
- // We are interested in the color of the desktop background.
- ubus_.RegisterInterest(UBUS_BACKGROUND_COLOR_CHANGED, [this] (GVariant* data) {
- double red = 0.0f, green = 0.0f, blue = 0.0f, alpha = 0.0f;
-
- g_variant_get(data, "(dddd)", &red, &green, &blue, &alpha);
- background_color_ = nux::Color(red, green, blue, alpha);
- QueueDraw();
- });
- ubus_.SendMessage(UBUS_BACKGROUND_REQUEST_COLOUR_EMIT);
-
ubus_.RegisterInterest(UBUS_DASH_PREVIEW_NAVIGATION_REQUEST, [&] (GVariant* data) {
int nav_mode = 0;
GVariant* local_result_variant = NULL;
@@ -741,9 +734,10 @@ void ResultViewGrid::DrawRow(nux::GraphicsEngine& GfxContext, ResultListBounds c
saturation = saturation_progress + (1.0-saturation_progress) * UNFOCUSED_ICON_SATURATION_REF;
opacity = saturation_progress + (1.0-saturation_progress) * UNFOCUSED_GHOST_ICON_OPACITY_REF;
}
- nux::Color tint(opacity + (1.0f-opacity) * background_color_.red,
- opacity + (1.0f-opacity) * background_color_.green,
- opacity + (1.0f-opacity) * background_color_.blue,
+ auto const& bg_color = WindowManager::Default().average_color();
+ nux::Color tint(opacity + (1.0f-opacity) * bg_color.red,
+ opacity + (1.0f-opacity) * bg_color.green,
+ opacity + (1.0f-opacity) * bg_color.blue,
opacity);
nux::Geometry render_geo(x_position, y_position, renderer_->width, renderer_->height);
diff --git a/dash/ResultViewGrid.h b/dash/ResultViewGrid.h
index 04ee41952..bba997c0d 100644
--- a/dash/ResultViewGrid.h
+++ b/dash/ResultViewGrid.h
@@ -130,7 +130,6 @@ private:
UBusManager ubus_;
glib::Source::UniquePtr lazy_load_source_;
glib::Source::UniquePtr results_changed_idle_;
- nux::Color background_color_;
glib::Source::UniquePtr activate_timer_;
};