summaryrefslogtreecommitdiff
path: root/dash
diff options
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2013-11-14 03:03:14 +0100
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2013-11-14 03:03:14 +0100
commitb0f0c8b92607b363dad90d77868e2bf980261a77 (patch)
treed4c885def1c0d47e0505bd6ff901f540ccb7c6ed /dash
parent0b8941e6fb701f3396035aa0452e6f7104a345cc (diff)
parent49d84b95f8f2f020a96f2841580d2d7a8996dff9 (diff)
Merging with lp:~3v1n0/unity/ap1.4-introspection-cleanup
(bzr r3506.7.6)
Diffstat (limited to 'dash')
-rw-r--r--dash/DashController.cpp35
-rw-r--r--dash/DashController.h6
-rw-r--r--dash/DashView.cpp18
-rw-r--r--dash/DashView.h3
-rw-r--r--dash/ResultRendererTile.cpp55
-rw-r--r--dash/ResultViewGrid.cpp20
-rw-r--r--dash/ResultViewGrid.h1
7 files changed, 78 insertions, 60 deletions
diff --git a/dash/DashController.cpp b/dash/DashController.cpp
index a6c4a130f..976009324 100644
--- a/dash/DashController.cpp
+++ b/dash/DashController.cpp
@@ -107,8 +107,7 @@ Controller::Controller(Controller::WindowCreator const& create_window)
}
});
- auto spread_cb = sigc::bind(sigc::mem_fun(this, &Controller::HideDash), true);
- WindowManager::Default().initiate_spread.connect(spread_cb);
+ WindowManager::Default().initiate_spread.connect(sigc::mem_fun(this, &Controller::HideDash));
dbus_server_.AddObjects(dbus::INTROSPECTION, dbus::PATH);
dbus_server_.GetObjects().front()->SetMethodsCallsHandler([this] (std::string const& method, GVariant*) {
@@ -176,7 +175,7 @@ void Controller::RegisterUBusInterests()
// hide if something else is coming up
if (overlay_identity.Str() != "dash")
{
- HideDash(true);
+ HideDash();
}
});
@@ -278,16 +277,7 @@ void Controller::OnExternalShowDash(GVariant* variant)
void Controller::OnExternalHideDash(GVariant* variant)
{
- EnsureDash();
-
- if (variant)
- {
- HideDash(g_variant_get_boolean(variant));
- }
- else
- {
- HideDash();
- }
+ HideDash();
}
void Controller::ShowDash()
@@ -342,14 +332,14 @@ void Controller::FocusWindow()
nux::GetWindowCompositor().SetKeyFocusArea(view_->default_focus());
}
-void Controller::QuicklyHideDash(bool restore)
+void Controller::QuicklyHideDash()
{
- HideDash(restore);
+ HideDash();
timeline_animator_.Stop();
window_->ShowWindow(false);
}
-void Controller::HideDash(bool restore)
+void Controller::HideDash()
{
if (!visible_)
return;
@@ -364,10 +354,8 @@ void Controller::HideDash(bool restore)
window_->EnableInputWindow(false, dash::window_title, true, false);
visible_ = false;
- nux::GetWindowCompositor().SetKeyFocusArea(NULL,nux::KEY_NAV_NONE);
-
- if (restore)
- WindowManager::Default().RestoreInputFocus();
+ nux::GetWindowCompositor().SetKeyFocusArea(NULL, nux::KEY_NAV_NONE);
+ WindowManager::Default().RestoreInputFocus();
StartShowHideTimeline();
@@ -401,9 +389,12 @@ void Controller::OnActivateRequest(GVariant* variant)
gboolean Controller::CheckShortcutActivation(const char* key_string)
{
+ if (!key_string)
+ return false;
+
EnsureDash();
- std::string scope_id = view_->GetIdForShortcutActivation(std::string(key_string));
- if (scope_id != "")
+ std::string scope_id = view_->GetIdForShortcutActivation(key_string);
+ if (!scope_id.empty())
{
WindowManager& wm = WindowManager::Default();
if (wm.IsScaleActive())
diff --git a/dash/DashController.h b/dash/DashController.h
index 8a57c93c0..833898d31 100644
--- a/dash/DashController.h
+++ b/dash/DashController.h
@@ -41,7 +41,7 @@ namespace unity
namespace dash
{
-class Controller : public unity::debug::Introspectable
+class Controller : public unity::debug::Introspectable, public sigc::trackable
{
public:
typedef std::shared_ptr<Controller> Ptr;
@@ -59,8 +59,8 @@ public:
sigc::signal<void> on_realize;
- void HideDash(bool restore_focus = true);
- void QuicklyHideDash(bool restore_focus = true);
+ void HideDash();
+ void QuicklyHideDash();
void ShowDash();
void ReFocusKeyInput();
diff --git a/dash/DashView.cpp b/dash/DashView.cpp
index 9d22128bc..969caa799 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();
@@ -1417,7 +1401,7 @@ bool DashView::InspectKeyEvent(unsigned int eventType,
{
if (preview_displaying_)
ClosePreview();
- else if (search_bar_->search_string != "")
+ else if (!search_bar_->search_string().empty())
search_bar_->search_string = "";
else
ubus_manager_.SendMessage(UBUS_OVERLAY_CLOSE_REQUEST);
diff --git a/dash/DashView.h b/dash/DashView.h
index 98e19c87d..386457a2f 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/ResultRendererTile.cpp b/dash/ResultRendererTile.cpp
index 71e347408..c85cf941f 100644
--- a/dash/ResultRendererTile.cpp
+++ b/dash/ResultRendererTile.cpp
@@ -45,6 +45,7 @@ DECLARE_LOGGER(logger, "unity.dash.results");
namespace
{
const int FONT_SIZE = 10;
+const char REPLACEMENT_CHAR = '?';
const float CORNER_HIGHTLIGHT_RADIUS = 2.0f;
@@ -393,6 +394,55 @@ void ResultRendererTile::IconLoaded(std::string const& texid,
}
}
+/* Blacklisted unicode ranges:
+ * Burmese: U+1000 -> U+109F
+ * Extended: U+AA60 -> U+AA7B
+*/
+bool IsBlacklistedChar(gunichar uni_c)
+{
+ if ((uni_c >= 0x1000 && uni_c <= 0x109F) ||
+ (uni_c >= 0xAA60 && uni_c >= 0xAA7B))
+ {
+ return true;
+ }
+
+ return false;
+}
+
+// FIXME Bug (lp.1239381) in the backend of pango that crashes
+// when using ellipsize with/height setting in pango
+std::string ReplaceBlacklistedChars(std::string const& str)
+{
+ std::string new_string("");
+
+ if (!g_utf8_validate(str.c_str(), -1, NULL))
+ return new_string;
+
+ gchar const* uni_s = str.c_str();
+ gunichar uni_c;
+ gchar utf8_buff[6];
+
+ int size = g_utf8_strlen(uni_s, -1);
+ for (int i = 0; i < size; ++i)
+ {
+ uni_c = g_utf8_get_char(uni_s);
+ uni_s = g_utf8_next_char(uni_s);
+
+ if (IsBlacklistedChar(uni_c))
+ {
+ new_string += REPLACEMENT_CHAR;
+ }
+ else
+ {
+ int end = g_unichar_to_utf8(uni_c, utf8_buff);
+ utf8_buff[end] = '\0';
+
+ new_string += utf8_buff;
+ }
+ }
+
+ return new_string;
+}
void ResultRendererTile::LoadText(Result const& row)
{
@@ -426,7 +476,10 @@ void ResultRendererTile::LoadText(Result const& row)
pango_layout_set_width(layout, (style.GetTileWidth() - (padding * 2))* PANGO_SCALE);
pango_layout_set_height(layout, -2);
- char *escaped_text = g_markup_escape_text(row.name().c_str() , -1);
+ // FIXME bug #1239381
+ std::string name = ReplaceBlacklistedChars(row.name());
+
+ char *escaped_text = g_markup_escape_text(name.c_str(), -1);
pango_layout_set_markup(layout, escaped_text, -1);
diff --git a/dash/ResultViewGrid.cpp b/dash/ResultViewGrid.cpp
index 6ed816b49..1052baf80 100644
--- a/dash/ResultViewGrid.cpp
+++ b/dash/ResultViewGrid.cpp
@@ -34,6 +34,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"
@@ -113,22 +114,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;
@@ -740,9 +733,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_;
};