summaryrefslogtreecommitdiff
path: root/hud
diff options
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2014-07-11 03:45:49 +0200
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2014-07-11 03:45:49 +0200
commite7816079c6a26b8a84f6c35a1d34fe8b87d03475 (patch)
treef75a50b0b10700686e68af07ed1b9d334517b1be /hud
parentc1c17f4f86d90192085778be6e6723ff14f274d6 (diff)
HudController: set HudView scale to match current scaling factor for monitor and listen changes
(bzr r3830.6.5)
Diffstat (limited to 'hud')
-rw-r--r--hud/HudController.cpp16
-rw-r--r--hud/HudController.h6
2 files changed, 19 insertions, 3 deletions
diff --git a/hud/HudController.cpp b/hud/HudController.cpp
index aefe40f63..3e858229b 100644
--- a/hud/HudController.cpp
+++ b/hud/HudController.cpp
@@ -107,6 +107,8 @@ Controller::Controller(Controller::ViewCreator const& create_view,
hud_service_.queries_updated.connect(sigc::mem_fun(this, &Controller::OnQueriesFinished));
timeline_animator_.updated.connect(sigc::mem_fun(this, &Controller::OnViewShowHideFrame));
+ Settings::Instance().dpi_changed.connect(sigc::mem_fun(this, &Controller::OnDPIChanged));
+
EnsureHud();
}
@@ -140,6 +142,7 @@ void Controller::SetupHudView()
{
LOG_DEBUG(logger) << "SetupHudView called";
view_ = create_view_();
+ view_->scale = Settings::Instance().em(monitor_index_)->DPIScale();
layout_ = new nux::VLayout(NUX_TRACKER_LOCATION);
layout_->AddView(view_, 1, nux::MINOR_POSITION_START);
@@ -206,7 +209,11 @@ void Controller::SetIcon(std::string const& icon_name)
int launcher_width = unity::Settings::Instance().LauncherWidth(monitor_index_);
if (view_)
- view_->SetIcon(icon_name, tile_size, icon_size, launcher_width - tile_size);
+ {
+ double scale = view_->scale();
+ int tsize = tile_size().CP(scale);
+ view_->SetIcon(icon_name, tsize, icon_size().CP(scale), launcher_width - tsize);
+ }
ubus.SendMessage(UBUS_HUD_ICON_CHANGED, g_variant_new_string(icon_name.c_str()));
}
@@ -344,6 +351,7 @@ void Controller::ShowHud()
{
Relayout();
monitor_index_ = ideal_monitor;
+ view_->scale = Settings::Instance().em(monitor_index_)->DPIScale();
}
view_->ShowEmbeddedIcon(!IsLockedToLauncher(monitor_index_));
@@ -508,6 +516,12 @@ void Controller::OnQueriesFinished(Hud::Queries queries)
view_->SearchFinished();
}
+void Controller::OnDPIChanged()
+{
+ if (view_)
+ view_->scale = Settings::Instance().em(monitor_index_)->DPIScale();
+}
+
// Introspectable
std::string Controller::GetName() const
{
diff --git a/hud/HudController.h b/hud/HudController.h
index c9ebf4e86..559da31e1 100644
--- a/hud/HudController.h
+++ b/hud/HudController.h
@@ -32,6 +32,7 @@
#include <Nux/Nux.h>
#include "unity-shared/UBusWrapper.h"
+#include "unity-shared/RawPixel.h"
#include "unity-shared/ResizingBaseWindow.h"
#include "HudView.h"
@@ -53,8 +54,8 @@ public:
nux::ObjectPtr<AbstractView> HudView() const;
nux::BaseWindow* window() const;
- nux::Property<int> icon_size;
- nux::Property<int> tile_size;
+ nux::Property<RawPixel> icon_size;
+ nux::Property<RawPixel> tile_size;
nux::Property<bool> launcher_locked_out;
nux::Property<bool> multiple_launchers;
@@ -88,6 +89,7 @@ private:
void OnMouseDownOutsideWindow(int x, int y, unsigned long bflags, unsigned long kflags);
void OnScreenUngrabbed();
+ void OnDPIChanged();
void OnExternalShowHud(GVariant* variant);
void OnExternalHideHud(GVariant* variant);
void OnActivateRequest(GVariant* variant);