Merge lp:~brandontschaefer/unity/panel-height-dynamic-dpi-over-decorations-branch into lp:unity

Proposed by Brandon Schaefer
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 3670
Proposed branch: lp:~brandontschaefer/unity/panel-height-dynamic-dpi-over-decorations-branch
Merge into: lp:unity
Prerequisite: lp:~3v1n0/unity/unity-decorations
Diff against target: 1708 lines (+401/-128)
44 files modified
dash/DashController.cpp (+1/-1)
dash/DashView.cpp (+17/-12)
hud/HudController.cpp (+6/-4)
launcher/Launcher.cpp (+5/-3)
launcher/LauncherController.cpp (+17/-0)
panel/PanelController.cpp (+15/-2)
panel/PanelController.h (+1/-0)
panel/PanelIndicatorEntryDropdownView.cpp (+1/-1)
panel/PanelIndicatorEntryView.cpp (+73/-14)
panel/PanelIndicatorEntryView.h (+16/-3)
panel/PanelIndicatorsView.cpp (+23/-11)
panel/PanelIndicatorsView.h (+4/-0)
panel/PanelMenuView.cpp (+16/-10)
panel/PanelMenuView.h (+3/-2)
panel/PanelTray.cpp (+6/-4)
panel/PanelTray.h (+3/-1)
panel/PanelView.cpp (+17/-3)
panel/PanelView.h (+2/-0)
panel/StandalonePanel.cpp (+1/-1)
plugins/unityshell/src/unityshell.cpp (+9/-4)
tests/test_em_converter.cpp (+1/-1)
tests/test_launcher_controller.cpp (+6/-6)
tests/test_panel_controller.cpp (+3/-3)
tests/test_panel_indicator_entry_dropdown_view.cpp (+2/-2)
tests/test_panel_menu_view.cpp (+1/-1)
tests/test_panel_style.cpp (+12/-0)
tests/test_raw_pixel.cpp (+3/-3)
unity-shared/EMConverter.cpp (+1/-1)
unity-shared/EMConverter.h (+5/-1)
unity-shared/OverlayWindowButtons.cpp (+1/-1)
unity-shared/PanelStyle.cpp (+20/-13)
unity-shared/PanelStyle.h (+11/-3)
unity-shared/PluginAdapter.cpp (+15/-0)
unity-shared/PluginAdapter.h (+1/-0)
unity-shared/RawPixel.cpp (+2/-2)
unity-shared/RawPixel.h (+1/-1)
unity-shared/StandaloneWindowManager.cpp (+6/-0)
unity-shared/StandaloneWindowManager.h (+1/-0)
unity-shared/UnitySettings.cpp (+23/-8)
unity-shared/UnitySettings.h (+2/-1)
unity-shared/WindowButtonPriv.h (+11/-1)
unity-shared/WindowButtons.cpp (+34/-4)
unity-shared/WindowButtons.h (+2/-0)
unity-shared/WindowManager.h (+1/-0)
To merge this branch: bzr merge lp:~brandontschaefer/unity/panel-height-dynamic-dpi-over-decorations-branch
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Marco Trevisan (Treviño) Needs Fixing
Eleni Maria Stea (community) Approve
Review via email: mp+202960@code.launchpad.net

Commit message

Remove the nux::Property panel_height; Replace it with a function.

Now PanelStyle holds up to monitors::MAX panel_height. Now to get the panel height for the monitor you just use PanelHeight(int monitor).

Added a signal panel_height_changed() that will emit the new panel height, and the monitor that was changed. Its not currently used.

Description of the change

Remove the nux::Property panel_height; Replace it with a function.

Now PanelStyle holds up to monitors::MAX panel_height. Now to get the panel height for the monitor you just use PanelHeight(int monitor).

Added a signal panel_height_changed() that will emit the new panel height, and the monitor that was changed. Its not currently used, but when we get the back end for specific monitor DPI changes, this signal will be useful when dynamically updating the panel height else where. (Such as the panel it self and launcher).

** NOTE **
Not all the PanelHeights() take into account the monitor. Things will need to be refactored to get the correct monitor. For now, I did all the easy ones I found and will go back and slowly get them all into place. Some will not be easy.

Taken from these 2 branches:
https://code.launchpad.net/~brandontschaefer/unity/multimonitor-dpi-panel-height
https://code.launchpad.net/~brandontschaefer/unity/panel-height-dynamic-resize

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Eleni Maria Stea (hikiko) wrote :

Nice job! Just a small suggestion: in some files where you need the height or other sizes too many times you could use a variable to store it to avoid too many calls for the same value in one file (for example you could store panel_style.PanelHeight()). Apart from that it looks good! +1 :)

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

813 + WindowManager& wm = WindowManager::Default();

It doesn't change much, but why defining it at this level, instead that when you actually use it?

206 + panels_[i]->SetMaximumHeight(panel::Style::Instance().PanelHeight(i));
230 + panel_ptr->SetMaximumHeight(height);

This won't probably happen since the children of the panel will request to be bigger, but why not setting the MinimumWidth as well to the same value?
In this way we ensure it will scale both up and down.

Anyuway the first call is quite useless since the same it will done inside PanelView::SetMonitor anyway, so I'd just fix that instead that redoing the same in PanelController.

As for PanelIndicatorEntryView we might have just used new cairo features instead of dealing with the EMConverter (to it would make changes much smaller), but it arrived late for us. :(

610 + unity::Settings::Instance().dpi_changed.connect([this] {

Get rid of this lambda from PanelMenuView and PanelTray at least... Or you use a connection::Wrapper/Manager to handle it or you should use sigc::mem_fun in order to make sure we disconnect from it when the views gets removed (otherwise we'd get a crash if you change the setting after removing a monitor)

Anyway consider the case where you can just do this once in PanelView (or even in PanelController) applying then this down to its children.

WindowButtons: see if you can share the same cv_ instead of passing down the same monitor for every children (probably something to be done in other places as well), but we leave it for the next steps.

805 + int panel_height = panel_style_.PanelHeight();
806 auto const& texture = panel_style_.GetBackground()->GetDeviceTexture();
807 graphics_engine->QRP_GLSL_1Tex(0, 0, screen->width(), panel_height, texture, texxform, nux::color::White);

In theory here you only to paint each time for every outputdevice, with different size. But if you can't fix it now, please tag it with a FIXME for later (not that I like it, but at least we can track it :P).

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dash/DashController.cpp'
2--- dash/DashController.cpp 2013-11-21 19:38:45 +0000
3+++ dash/DashController.cpp 2014-02-19 01:47:39 +0000
4@@ -250,7 +250,7 @@
5 view_->Relayout();
6 window_->SetGeometry(geo);
7 panel::Style &panel_style = panel::Style::Instance();
8- view_->SetMonitorOffset(launcher_width, panel_style.panel_height);
9+ view_->SetMonitorOffset(launcher_width, panel_style.PanelHeight(monitor_));
10 }
11
12 void Controller::OnMouseDownOutsideWindow(int x, int y,
13
14=== modified file 'dash/DashView.cpp'
15--- dash/DashView.cpp 2014-02-10 15:31:44 +0000
16+++ dash/DashView.cpp 2014-02-19 01:47:39 +0000
17@@ -519,12 +519,13 @@
18 {
19 dash::Style& style = dash::Style::Instance();
20 panel::Style &panel_style = panel::Style::Instance();
21+ int panel_height = panel_style.PanelHeight();
22
23 layout_ = new nux::VLayout();
24 layout_->SetLeftAndRightPadding(style.GetVSeparatorSize(), 0);
25 layout_->SetTopAndBottomPadding(style.GetHSeparatorSize(), 0);
26 SetLayout(layout_);
27- layout_->AddLayout(new nux::SpaceLayout(0, 0, panel_style.panel_height, panel_style.panel_height), 0);
28+ layout_->AddLayout(new nux::SpaceLayout(0, 0, panel_height, panel_height), 0);
29
30 content_layout_ = new DashLayout(NUX_TRACKER_LOCATION);
31 content_layout_->SetTopAndBottomPadding(style.GetDashViewTopPadding(), 0);
32@@ -611,6 +612,7 @@
33 {
34 dash::Style& style = dash::Style::Instance();
35 panel::Style &panel_style = panel::Style::Instance();
36+ int panel_height = panel_style.PanelHeight();
37
38 int width = 0, height = 0;
39 int tile_width = style.GetTileWidth();
40@@ -635,14 +637,14 @@
41
42 // width/height shouldn't be bigger than the geo available.
43 width = std::min(width, for_geo.width); // launcher width is taken into account in for_geo.
44- height = std::min(height, for_geo.height - panel_style.panel_height); // panel height is not taken into account in for_geo.
45+ height = std::min(height, for_geo.height - panel_height); // panel height is not taken into account in for_geo.
46
47 if (style.always_maximised)
48 {
49 width = std::max(0, for_geo.width);
50- height = std::max(0, for_geo.height - panel_style.panel_height);
51+ height = std::max(0, for_geo.height - panel_height);
52 }
53- return nux::Geometry(0, panel_style.panel_height, width, height);
54+ return nux::Geometry(0, panel_height, width, height);
55 }
56
57 void DashView::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw)
58@@ -650,9 +652,10 @@
59 panel::Style &panel_style = panel::Style::Instance();
60 nux::Geometry const& renderer_geo_abs(GetRenderAbsoluteGeometry());
61 nux::Geometry renderer_geo(GetGeometry());
62+ int panel_height = panel_style.PanelHeight();
63
64- renderer_geo.y += panel_style.panel_height;
65- renderer_geo.height += panel_style.panel_height;
66+ renderer_geo.y += panel_height;
67+ renderer_geo.height += panel_height;
68
69 renderer_.DrawFull(graphics_engine, content_geo_, renderer_geo_abs, renderer_geo, false);
70 }
71@@ -660,14 +663,15 @@
72 void DashView::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw)
73 {
74 panel::Style& panel_style = panel::Style::Instance();
75+ int panel_height = panel_style.PanelHeight();
76
77 nux::Geometry renderer_geo_abs(GetAbsoluteGeometry());
78- renderer_geo_abs.y += panel_style.panel_height;
79- renderer_geo_abs.height -= panel_style.panel_height;
80+ renderer_geo_abs.y += panel_height;
81+ renderer_geo_abs.height -= panel_height;
82
83 nux::Geometry renderer_geo(GetGeometry());
84- renderer_geo.y += panel_style.panel_height;
85- renderer_geo.height += panel_style.panel_height;
86+ renderer_geo.y += panel_height;
87+ renderer_geo.height += panel_height;
88
89 renderer_.DrawInner(graphics_engine, content_geo_, renderer_geo_abs, renderer_geo);
90
91@@ -1689,10 +1693,11 @@
92 nux::Geometry DashView::GetRenderAbsoluteGeometry() const
93 {
94 panel::Style &panel_style = panel::Style::Instance();
95+ int panel_height = panel_style.PanelHeight();
96
97 nux::Geometry renderer_geo_abs(GetAbsoluteGeometry());
98- renderer_geo_abs.y += panel_style.panel_height;
99- renderer_geo_abs.height -= panel_style.panel_height;
100+ renderer_geo_abs.y += panel_height;
101+ renderer_geo_abs.height -= panel_height;
102 return renderer_geo_abs;
103 }
104
105
106=== modified file 'hud/HudController.cpp'
107--- hud/HudController.cpp 2014-02-05 15:49:03 +0000
108+++ hud/HudController.cpp 2014-02-19 01:47:39 +0000
109@@ -231,13 +231,15 @@
110 int ideal_monitor = GetIdealMonitor();
111 auto monitor_geo = UScreen::GetDefault()->GetMonitorGeometry(ideal_monitor);
112
113+ panel::Style &panel_style = panel::Style::Instance();
114+ int panel_height = panel_style.PanelHeight(ideal_monitor);
115+
116 // We want to cover as much of the screen as possible to grab any mouse events
117 // outside of our window
118- panel::Style &panel_style = panel::Style::Instance();
119 nux::Geometry geo(monitor_geo.x,
120- monitor_geo.y + panel_style.panel_height,
121+ monitor_geo.y + panel_height,
122 monitor_geo.width,
123- monitor_geo.height - panel_style.panel_height);
124+ monitor_geo.height - panel_height);
125
126 if (IsLockedToLauncher(ideal_monitor))
127 {
128@@ -261,7 +263,7 @@
129 view_->QueueDraw();
130 window_->SetGeometry(geo);
131 panel::Style &panel_style = panel::Style::Instance();
132- view_->SetMonitorOffset(launcher_width, panel_style.panel_height);
133+ view_->SetMonitorOffset(launcher_width, panel_style.PanelHeight(monitor_index_));
134 }
135
136 void Controller::OnMouseDownOutsideWindow(int x, int y,
137
138=== modified file 'launcher/Launcher.cpp'
139--- launcher/Launcher.cpp 2014-02-15 14:36:33 +0000
140+++ launcher/Launcher.cpp 2014-02-19 01:47:39 +0000
141@@ -1183,8 +1183,10 @@
142 UScreen* uscreen = UScreen::GetDefault();
143 auto monitor_geo = uscreen->GetMonitorGeometry(new_monitor);
144 unity::panel::Style &panel_style = panel::Style::Instance();
145- Resize(nux::Point(monitor_geo.x, monitor_geo.y + panel_style.panel_height),
146- monitor_geo.height - panel_style.panel_height);
147+ int panel_height = panel_style.PanelHeight(new_monitor);
148+
149+ Resize(nux::Point(monitor_geo.x, monitor_geo.y + panel_height),
150+ monitor_geo.height - panel_height);
151 icon_renderer_->monitor = new_monitor;
152 }
153
154@@ -1748,7 +1750,7 @@
155 texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
156 texxform.SetWrap(nux::TEXWRAP_CLAMP, nux::TEXWRAP_CLAMP);
157 texxform.uoffset = (1.0f / launcher_sheen_->GetWidth()); // TODO (gord) don't use absolute values here
158- texxform.voffset = (1.0f / launcher_sheen_->GetHeight()) * panel::Style::Instance().panel_height;
159+ texxform.voffset = (1.0f / launcher_sheen_->GetHeight()) * panel::Style::Instance().PanelHeight(icon_renderer_->monitor);
160 GfxContext.QRP_1Tex(base.x, base.y, base.width, base.height,
161 launcher_sheen_->GetDeviceTexture(),
162 texxform,
163
164=== modified file 'launcher/LauncherController.cpp'
165--- launcher/LauncherController.cpp 2014-01-31 16:19:39 +0000
166+++ launcher/LauncherController.cpp 2014-02-19 01:47:39 +0000
167@@ -43,6 +43,8 @@
168 #include "unity-shared/UScreen.h"
169 #include "unity-shared/UBusMessages.h"
170 #include "unity-shared/TimeUtil.h"
171+#include "unity-shared/PanelStyle.h"
172+#include "unity-shared/UnitySettings.h"
173
174 namespace unity
175 {
176@@ -169,6 +171,21 @@
177 }
178 });
179
180+ unity::Settings::Instance().dpi_changed.connect([this] {
181+ for (auto const& launcher_ptr : launchers)
182+ {
183+ if (launcher_ptr)
184+ {
185+ nux::Geometry const& parent_geo = launcher_ptr->GetParent()->GetGeometry();
186+ int monitor = launcher_ptr->monitor();
187+ int height = panel::Style::Instance().PanelHeight(monitor);
188+ int diff = height - parent_geo.y;
189+
190+ launcher_ptr->Resize(nux::Point(parent_geo.x, parent_geo.y + diff), parent_geo.height - diff);
191+ }
192+ }
193+ });
194+
195 parent_->AddChild(model_.get());
196
197 xdnd_manager_->dnd_started.connect(sigc::mem_fun(this, &Impl::OnDndStarted));
198
199=== modified file 'panel/PanelController.cpp'
200--- panel/PanelController.cpp 2014-02-12 07:45:21 +0000
201+++ panel/PanelController.cpp 2014-02-19 01:47:39 +0000
202@@ -26,7 +26,6 @@
203
204 #include "unity-shared/UScreen.h"
205 #include "PanelView.h"
206-#include "unity-shared/PanelStyle.h"
207
208 namespace unity
209 {
210@@ -190,7 +189,6 @@
211 nux::HLayout* layout = new nux::HLayout(NUX_TRACKER_LOCATION);
212
213 PanelView* view = new PanelView(panel_window, indicators_);
214- view->SetMaximumHeight(panel::Style::Instance().panel_height);
215 view->SetOpacity(opacity_);
216 view->SetOpacityMaximizedToggle(opacity_maximized_toggle_);
217
218@@ -236,6 +234,8 @@
219 screen->changed.connect(sigc::mem_fun(this, &Controller::OnScreenChanged));
220 OnScreenChanged(screen->GetPrimaryMonitor(), screen->GetMonitors());
221
222+ unity::Settings::Instance().dpi_changed.connect(sigc::mem_fun(this, &Controller::OnDPIChanged));
223+
224 launcher_width.changed.connect([this] (int width)
225 {
226 pimpl->SetLauncherWidth(width);
227@@ -245,6 +245,19 @@
228 Controller::~Controller()
229 {}
230
231+void Controller::OnDPIChanged()
232+{
233+ for (auto& panel_ptr : pimpl->panels_)
234+ {
235+ if (panel_ptr)
236+ {
237+ int monitor = panel_ptr->GetMonitor();
238+
239+ panel_ptr->SetMonitor(monitor);
240+ }
241+ }
242+}
243+
244 void Controller::SetOpacity(float opacity)
245 {
246 pimpl->SetOpacity(opacity);
247
248=== modified file 'panel/PanelController.h'
249--- panel/PanelController.h 2014-02-12 07:45:21 +0000
250+++ panel/PanelController.h 2014-02-19 01:47:39 +0000
251@@ -62,6 +62,7 @@
252
253 private:
254 void OnScreenChanged(int primary_monitor, std::vector<nux::Geometry>& monitors);
255+ void OnDPIChanged();
256
257 class Impl;
258 std::unique_ptr<Impl> pimpl;
259
260=== modified file 'panel/PanelIndicatorEntryDropdownView.cpp'
261--- panel/PanelIndicatorEntryDropdownView.cpp 2014-02-16 19:44:54 +0000
262+++ panel/PanelIndicatorEntryDropdownView.cpp 2014-02-19 01:47:39 +0000
263@@ -125,7 +125,7 @@
264 entries.push_back(entry->GetEntry());
265
266 auto const& geo = GetAbsoluteGeometry();
267- indicators_->ShowEntriesDropdown(entries, active_entry_, 0, geo.x, geo.y + Style::Instance().panel_height);
268+ indicators_->ShowEntriesDropdown(entries, active_entry_, 0, geo.x, geo.y + Style::Instance().PanelHeight(monitor_));
269 }
270
271 bool PanelIndicatorEntryDropdownView::ActivateChild(PanelIndicatorEntryView::Ptr const& child)
272
273=== modified file 'panel/PanelIndicatorEntryView.cpp'
274--- panel/PanelIndicatorEntryView.cpp 2014-02-16 19:44:54 +0000
275+++ panel/PanelIndicatorEntryView.cpp 2014-02-19 01:47:39 +0000
276@@ -30,13 +30,16 @@
277 #include "unity-shared/CairoTexture.h"
278 #include "unity-shared/PanelStyle.h"
279 #include "unity-shared/WindowManager.h"
280+#include "unity-shared/UnitySettings.h"
281
282 namespace unity
283 {
284
285 namespace
286 {
287-const int DEFAULT_SPACING = 3;
288+const RawPixel DEFAULT_SPACING = 3_em;
289+
290+const int SCALED_IMAGE_Y = 1;
291 }
292
293 using namespace indicator;
294@@ -49,6 +52,7 @@
295 , spacing_(DEFAULT_SPACING)
296 , left_padding_(padding < 0 ? 0 : padding)
297 , right_padding_(left_padding_)
298+ , monitor_(0)
299 , type_(type)
300 , entry_texture_(nullptr)
301 , opacity_(1.0f)
302@@ -56,6 +60,7 @@
303 , overlay_showing_(false)
304 , disabled_(false)
305 , focused_(true)
306+ , cv_(unity::Settings::Instance().em(monitor_))
307 {
308 proxy_->active_changed.connect(sigc::mem_fun(this, &PanelIndicatorEntryView::OnActiveChanged));
309 proxy_->updated.connect(sigc::mem_fun(this, &PanelIndicatorEntryView::Refresh));
310@@ -70,6 +75,7 @@
311 }
312
313 panel::Style::Instance().changed.connect(sigc::mem_fun(this, &PanelIndicatorEntryView::Refresh));
314+ unity::Settings::Instance().dpi_changed.connect(sigc::mem_fun(this, &PanelIndicatorEntryView::Refresh));
315
316 Refresh();
317 }
318@@ -104,14 +110,13 @@
319 });
320
321 wm.TerminateExpo();
322- return;
323 }
324
325 if (wm.IsScaleActive())
326 wm.TerminateScale();
327
328 auto const& abs_geo = GetAbsoluteGeometry();
329- proxy_->ShowMenu(abs_geo.x, abs_geo.y + panel::Style::Instance().panel_height, button);
330+ proxy_->ShowMenu(abs_geo.x, abs_geo.y + panel::Style::Instance().PanelHeight(monitor_), button);
331 }
332
333 void PanelIndicatorEntryView::OnMouseDown(int x, int y, long button_flags, long key_flags)
334@@ -195,7 +200,7 @@
335 glib::Object<GdkPixbuf> pixbuf;
336 GtkIconTheme* theme = gtk_icon_theme_get_default();
337 int image_type = proxy_->image_type();
338- int size = (type_ != DROP_DOWN) ? 24 : 16;
339+ RawPixel size = (type_ != DROP_DOWN) ? 24_em : 16_em;
340
341 if (image_type == GTK_IMAGE_PIXBUF)
342 {
343@@ -214,14 +219,14 @@
344 else if (image_type == GTK_IMAGE_STOCK ||
345 image_type == GTK_IMAGE_ICON_NAME)
346 {
347- pixbuf = gtk_icon_theme_load_icon(theme, proxy_->image_data().c_str(), size,
348+ pixbuf = gtk_icon_theme_load_icon(theme, proxy_->image_data().c_str(), size.CP(cv_),
349 (GtkIconLookupFlags)0, nullptr);
350 }
351 else if (image_type == GTK_IMAGE_GICON)
352 {
353 glib::Object<GIcon> icon(g_icon_new_for_string(proxy_->image_data().c_str(), nullptr));
354
355- gtk::IconInfo info(gtk_icon_theme_lookup_by_gicon(theme, icon, size,
356+ gtk::IconInfo info(gtk_icon_theme_lookup_by_gicon(theme, icon, size.CP(cv_),
357 (GtkIconLookupFlags)0));
358 if (info)
359 pixbuf = gtk_icon_info_load_icon(info, nullptr);
360@@ -230,6 +235,33 @@
361 return pixbuf;
362 }
363
364+int PanelIndicatorEntryView::PixbufWidth(glib::Object<GdkPixbuf> const& pixbuf) const
365+{
366+ int image_type = proxy_->image_type();
367+ if (image_type == GTK_IMAGE_PIXBUF)
368+ {
369+ return RawPixel(gdk_pixbuf_get_width(pixbuf)).CP(cv_);
370+ }
371+ else
372+ {
373+ return gdk_pixbuf_get_width(pixbuf);
374+ }
375+}
376+
377+int PanelIndicatorEntryView::PixbufHeight(glib::Object<GdkPixbuf> const& pixbuf) const
378+{
379+ int image_type = proxy_->image_type();
380+ if (image_type == GTK_IMAGE_PIXBUF)
381+ {
382+ return RawPixel(gdk_pixbuf_get_height(pixbuf)).CP(cv_);
383+ }
384+ else
385+ {
386+ return gdk_pixbuf_get_height(pixbuf);
387+ }
388+
389+}
390+
391 void PanelIndicatorEntryView::DrawEntryPrelight(cairo_t* cr, unsigned int width, unsigned int height)
392 {
393 GtkStyleContext* style_context = panel::Style::Instance().GetStyleContext();
394@@ -254,9 +286,22 @@
395 gtk_style_context_restore(style_context);
396 }
397
398+// FIXME Remove me when icons for the indicators aren't stuck as 22x22 images...
399+void PanelIndicatorEntryView::ScaleImageIcons(cairo_t* cr, int* x, int* y)
400+{
401+ int image_type = proxy_->image_type();
402+ if (image_type == GTK_IMAGE_PIXBUF)
403+ {
404+ float aspect = cv_->DPIScale();
405+ *x = left_padding_;
406+ *y = SCALED_IMAGE_Y;
407+ cairo_scale(cr, aspect, aspect);
408+ }
409+}
410+
411 void PanelIndicatorEntryView::DrawEntryContent(cairo_t *cr, unsigned int width, unsigned int height, glib::Object<GdkPixbuf> const& pixbuf, glib::Object<PangoLayout> const& layout)
412 {
413- int x = left_padding_;
414+ int x = left_padding_.CP(cv_);
415
416 if (IsActive())
417 DrawEntryPrelight(cr, width, height);
418@@ -264,7 +309,7 @@
419 if (pixbuf && IsIconVisible())
420 {
421 GtkStyleContext* style_context = panel::Style::Instance().GetStyleContext();
422- unsigned int icon_width = gdk_pixbuf_get_width(pixbuf);
423+ unsigned int icon_width = PixbufWidth(pixbuf);
424
425 gtk_style_context_save(style_context);
426
427@@ -286,7 +331,8 @@
428 gtk_style_context_set_state(style_context, GTK_STATE_FLAG_PRELIGHT);
429 }
430
431- int y = (int)((height - gdk_pixbuf_get_height(pixbuf)) / 2);
432+ int y = (int)((height - PixbufHeight(pixbuf)) / 2);
433+
434 if (overlay_showing_ && !IsActive())
435 {
436 /* Most of the images we get are straight pixbufs (annoyingly), so when
437@@ -295,6 +341,7 @@
438 * icon themes/icons.
439 */
440 cairo_save(cr);
441+ ScaleImageIcons(cr, &x, &y);
442
443 cairo_push_group(cr);
444 gdk_cairo_set_source_pixbuf(cr, pixbuf, x, y);
445@@ -311,17 +358,22 @@
446 }
447 else
448 {
449+ cairo_save(cr);
450+ ScaleImageIcons(cr, &x, &y);
451+
452 cairo_push_group(cr);
453 gtk_render_icon(style_context, cr, pixbuf, x, y);
454 cairo_pop_group_to_source(cr);
455 cairo_paint_with_alpha(cr, (IsIconSensitive() && IsFocused()) ? 1.0 : 0.5);
456+
457+ cairo_restore(cr);
458 }
459
460 gtk_widget_path_free(widget_path);
461
462 gtk_style_context_restore(style_context);
463
464- x += icon_width + spacing_;
465+ x += icon_width + spacing_.CP(cv_);
466 }
467
468 if (layout)
469@@ -399,12 +451,12 @@
470
471 unsigned int width = 0;
472 unsigned int icon_width = 0;
473- unsigned int height = panel::Style::Instance().panel_height;
474+ unsigned int height = panel::Style::Instance().PanelHeight(monitor_);
475
476 // First lets figure out our size
477 if (pixbuf && IsIconVisible())
478 {
479- width = gdk_pixbuf_get_width(pixbuf);
480+ width = PixbufWidth(pixbuf);
481 icon_width = width;
482 }
483
484@@ -457,14 +509,14 @@
485 unsigned int text_width = log_rect.width / PANGO_SCALE;
486
487 if (icon_width)
488- width += spacing_;
489+ width += spacing_.CP(cv_);
490 width += text_width;
491
492 pango_font_description_free(desc);
493 }
494
495 if (width)
496- width += left_padding_ + right_padding_;
497+ width += left_padding_.CP(cv_) + right_padding_.CP(cv_);
498
499 SetMinimumWidth(width);
500 SetMaximumWidth(width);
501@@ -529,6 +581,13 @@
502 Refresh();
503 }
504
505+void PanelIndicatorEntryView::SetMonitor(int monitor)
506+{
507+ monitor_ = monitor;
508+
509+ cv_ = unity::Settings::Instance().em(monitor);
510+}
511+
512 void PanelIndicatorEntryView::SetOpacity(double opacity)
513 {
514 opacity = CLAMP(opacity, 0.0f, 1.0f);
515
516=== modified file 'panel/PanelIndicatorEntryView.h'
517--- panel/PanelIndicatorEntryView.h 2014-02-05 10:36:28 +0000
518+++ panel/PanelIndicatorEntryView.h 2014-02-19 01:47:39 +0000
519@@ -32,7 +32,9 @@
520
521 #include <gtk/gtk.h>
522
523+#include "unity-shared/EMConverter.h"
524 #include "unity-shared/Introspectable.h"
525+#include "unity-shared/RawPixel.h"
526
527
528 namespace unity
529@@ -90,6 +92,8 @@
530 void OverlayShown();
531 void OverlayHidden();
532
533+ virtual void SetMonitor(int monitor);
534+
535 sigc::signal<void, PanelIndicatorEntryView*, bool> active_changed;
536 sigc::signal<void, PanelIndicatorEntryView*> refreshed;
537
538@@ -108,9 +112,11 @@
539 virtual void ShowMenu(int button = 1);
540
541 indicator::Entry::Ptr proxy_;
542- unsigned int spacing_;
543- unsigned int left_padding_;
544- unsigned int right_padding_;
545+ RawPixel spacing_;
546+ RawPixel left_padding_;
547+ RawPixel right_padding_;
548+
549+ int monitor_;
550
551 private:
552 void OnMouseDown(int x, int y, long button_flags, long key_flags);
553@@ -118,6 +124,11 @@
554 void OnMouseWheel(int x, int y, int delta, unsigned long mouse_state, unsigned long key_state);
555 void OnActiveChanged(bool is_active);
556
557+ int PixbufWidth(glib::Object<GdkPixbuf> const& pixbuf) const;
558+ int PixbufHeight(glib::Object<GdkPixbuf> const& pixbuf) const;
559+
560+ void ScaleImageIcons(cairo_t* cr, int* x, int* y);
561+
562 glib::Object<GdkPixbuf> MakePixbuf();
563
564 IndicatorEntryType type_;
565@@ -128,6 +139,8 @@
566 bool overlay_showing_;
567 bool disabled_;
568 bool focused_;
569+
570+ EMConverter::Ptr cv_;
571 };
572
573 }
574
575=== modified file 'panel/PanelIndicatorsView.cpp'
576--- panel/PanelIndicatorsView.cpp 2014-02-06 22:12:59 +0000
577+++ panel/PanelIndicatorsView.cpp 2014-02-19 01:47:39 +0000
578@@ -41,6 +41,7 @@
579 : View(NUX_TRACKER_LOCATION)
580 , opacity(1.0f, sigc::mem_fun(this, &PanelIndicatorsView::SetOpacity))
581 , layout_(new nux::HLayout("", NUX_TRACKER_LOCATION))
582+, monitor_(0)
583 {
584 opacity.DisableNotifications();
585 layout_->SetContentDistribution(nux::MAJOR_POSITION_END);
586@@ -265,23 +266,27 @@
587 if (!view)
588 return;
589
590+ auto const& entry_id = view->GetEntryID();
591 int entry_pos = pos;
592- auto const& entry_id = view->GetEntryID();
593+ bool known_entry = (entries_.find(entry_id) != entries_.end());
594 view->SetOpacity(opacity());
595
596- if (entry_pos == IndicatorEntryPosition::AUTO)
597+ if (!known_entry && dropdown_ && !dropdown_->Empty())
598 {
599- entry_pos = nux::NUX_LAYOUT_BEGIN;
600-
601- if (view->GetEntryPriority() > -1)
602+ if (entry_pos == IndicatorEntryPosition::AUTO)
603 {
604- for (auto area : layout_->GetChildren())
605+ entry_pos = nux::NUX_LAYOUT_BEGIN;
606+
607+ if (view->GetEntryPriority() > -1)
608 {
609- auto en = static_cast<PanelIndicatorEntryView*>(area);
610- if (view->GetEntryPriority() <= en->GetEntryPriority())
611- break;
612+ for (auto area : layout_->GetChildren())
613+ {
614+ auto en = static_cast<PanelIndicatorEntryView*>(area);
615+ if (view->GetEntryPriority() <= en->GetEntryPriority())
616+ break;
617
618- ++entry_pos;
619+ ++entry_pos;
620+ }
621 }
622 }
623 }
624@@ -292,7 +297,7 @@
625 QueueRelayout();
626 QueueDraw();
627
628- if (entries_.find(entry_id) == entries_.end())
629+ if (!known_entry)
630 {
631 view->refreshed.connect(sigc::mem_fun(this, &PanelIndicatorsView::OnEntryRefreshed));
632 entries_.insert({entry_id, view});
633@@ -306,6 +311,8 @@
634 auto view = new PanelIndicatorEntryView(entry, padding, type);
635 AddEntryView(view, pos);
636
637+ view->SetMonitor(monitor_);
638+
639 return view;
640 }
641
642@@ -357,6 +364,11 @@
643 entry.second->OverlayHidden();
644 }
645
646+void PanelIndicatorsView::SetMonitor(int monitor)
647+{
648+ monitor_ = monitor;
649+}
650+
651 bool PanelIndicatorsView::SetOpacity(double& target, double const& new_value)
652 {
653 double opacity = CLAMP(new_value, 0.0f, 1.0f);
654
655=== modified file 'panel/PanelIndicatorsView.h'
656--- panel/PanelIndicatorsView.h 2014-02-06 22:12:59 +0000
657+++ panel/PanelIndicatorsView.h 2014-02-19 01:47:39 +0000
658@@ -69,6 +69,8 @@
659
660 void EnableDropdownMenu(bool, indicator::Indicators::Ptr const& i = nullptr);
661
662+ virtual void SetMonitor(int monitor);
663+
664 nux::Property<double> opacity;
665
666 sigc::signal<void> on_indicator_updated;
667@@ -95,6 +97,8 @@
668 typedef std::map<std::string, PanelIndicatorEntryView*> Entries;
669 Entries entries_;
670
671+ int monitor_;
672+
673 private:
674 bool SetOpacity(double& target, double const& new_value);
675
676
677=== modified file 'panel/PanelMenuView.cpp'
678--- panel/PanelMenuView.cpp 2014-02-15 18:10:14 +0000
679+++ panel/PanelMenuView.cpp 2014-02-19 01:47:39 +0000
680@@ -68,7 +68,6 @@
681 , show_now_activated_(false)
682 , we_control_active_(false)
683 , new_app_menu_shown_(false)
684- , monitor_(0)
685 , active_xid_(0)
686 , desktop_name_(_("Ubuntu Desktop"))
687 {
688@@ -83,13 +82,7 @@
689 SetupWindowManagerSignals();
690 SetupUBusManagerInterests();
691
692- style_changed_connection_ = panel::Style::Instance().changed.connect([this] {
693- window_buttons_->ComputeContentSize();
694- layout_->SetLeftAndRightPadding(window_buttons_->GetContentWidth(), 0);
695-
696- Refresh(true);
697- FullRedraw();
698- });
699+ style_changed_connection_ = panel::Style::Instance().changed.connect(sigc::mem_fun(this, &PanelMenuView::OnDPIChanged));
700
701 opacity = 0.0f;
702
703@@ -103,6 +96,19 @@
704 titlebar_grab_area_->UnParentObject();
705 }
706
707+void PanelMenuView::OnDPIChanged()
708+{
709+ int height = panel::Style::Instance().PanelHeight(monitor_);
710+ window_buttons_->SetMaximumHeight(height);
711+ window_buttons_->UpdateDPIChanged();
712+
713+ window_buttons_->ComputeContentSize();
714+ layout_->SetLeftAndRightPadding(window_buttons_->GetContentWidth(), 0);
715+
716+ Refresh(true);
717+ FullRedraw();
718+}
719+
720 void PanelMenuView::SetupPanelMenuViewSignals()
721 {
722 active_win_changed_signal_.Connect(matcher_, "active-window-changed",
723@@ -129,7 +135,7 @@
724 window_buttons_->controlled_window = active_xid_;
725 window_buttons_->opacity = 0.0f;
726 window_buttons_->SetLeftAndRightPadding(MAIN_LEFT_PADDING, MENUBAR_PADDING);
727- window_buttons_->SetMaximumHeight(panel::Style::Instance().panel_height);
728+ window_buttons_->SetMaximumHeight(panel::Style::Instance().PanelHeight(monitor_));
729 window_buttons_->ComputeContentSize();
730
731 window_buttons_->mouse_enter.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseEnter));
732@@ -145,7 +151,7 @@
733 {
734 layout_->SetContentDistribution(nux::MAJOR_POSITION_START);
735 layout_->SetLeftAndRightPadding(window_buttons_->GetContentWidth(), 0);
736- layout_->SetBaseHeight(panel::Style::Instance().panel_height);
737+ layout_->SetBaseHeight(panel::Style::Instance().PanelHeight(monitor_));
738 }
739
740 void PanelMenuView::SetupTitlebarGrabArea()
741
742=== modified file 'panel/PanelMenuView.h'
743--- panel/PanelMenuView.h 2014-02-15 18:10:14 +0000
744+++ panel/PanelMenuView.h 2014-02-19 01:47:39 +0000
745@@ -45,7 +45,7 @@
746 ~PanelMenuView();
747
748 void SetMousePosition(int x, int y);
749- void SetMonitor(int monitor);
750+ void SetMonitor(int monitor) override;
751
752 Window GetTopWindow() const;
753 Window GetMaximizedWindow() const;
754@@ -58,6 +58,8 @@
755 virtual void OverlayShown();
756 virtual void OverlayHidden();
757
758+ void OnDPIChanged();
759+
760 protected:
761 std::string GetName() const;
762 void AddProperties(debug::IntrospectionData&);
763@@ -177,7 +179,6 @@
764 bool we_control_active_;
765 bool new_app_menu_shown_;
766
767- int monitor_;
768 Window active_xid_;
769 nux::Geometry monitor_geo_;
770 const std::string desktop_name_;
771
772=== modified file 'panel/PanelTray.cpp'
773--- panel/PanelTray.cpp 2013-09-19 16:44:03 +0000
774+++ panel/PanelTray.cpp 2014-02-19 01:47:39 +0000
775@@ -21,6 +21,7 @@
776
777 #include "PanelTray.h"
778 #include "unity-shared/PanelStyle.h"
779+#include "unity-shared/UnitySettings.h"
780
781 #include <NuxCore/Logger.h>
782
783@@ -35,11 +36,12 @@
784 namespace unity
785 {
786
787-PanelTray::PanelTray()
788+PanelTray::PanelTray(int monitor)
789 : View(NUX_TRACKER_LOCATION)
790 , window_(gtk_window_new(GTK_WINDOW_TOPLEVEL))
791+ , monitor_(monitor)
792 {
793- int panel_height = panel::Style::Instance().panel_height;
794+ int panel_height = panel::Style::Instance().PanelHeight(monitor_);
795
796 auto gtkwindow = glib::object_cast<GtkWindow>(window_);
797 gtk_window_set_type_hint(gtkwindow, GDK_WINDOW_TYPE_HINT_DOCK);
798@@ -113,7 +115,7 @@
799 {
800 if (tray_)
801 {
802- SetMinMaxSize(WidthOfTray() + (PADDING * 2), panel::Style::Instance().panel_height);
803+ SetMinMaxSize(WidthOfTray() + (PADDING * 2), panel::Style::Instance().PanelHeight(monitor_));
804 QueueRelayout();
805 QueueDraw();
806
807@@ -176,7 +178,7 @@
808 bool PanelTray::IdleSync()
809 {
810 int width = WidthOfTray();
811- gtk_window_resize(GTK_WINDOW(window_.RawPtr()), width, panel::Style::Instance().panel_height);
812+ gtk_window_resize(GTK_WINDOW(window_.RawPtr()), width, panel::Style::Instance().PanelHeight(monitor_));
813 Sync();
814
815 return false;
816
817=== modified file 'panel/PanelTray.h'
818--- panel/PanelTray.h 2013-09-19 16:44:03 +0000
819+++ panel/PanelTray.h 2014-02-19 01:47:39 +0000
820@@ -40,7 +40,7 @@
821 class PanelTray : public nux::View, public unity::debug::Introspectable
822 {
823 public:
824- PanelTray();
825+ PanelTray(int monitor);
826 ~PanelTray();
827
828 void Sync();
829@@ -70,6 +70,8 @@
830 glib::Source::UniquePtr sync_idle_;
831 std::list<NaTrayChild*> children_;
832 nux::Geometry last_geo_;
833+
834+ int monitor_;
835 };
836
837 }
838
839=== modified file 'panel/PanelView.cpp'
840--- panel/PanelView.cpp 2014-02-17 13:43:43 +0000
841+++ panel/PanelView.cpp 2014-02-19 01:47:39 +0000
842@@ -73,6 +73,8 @@
843 {
844 auto& wm = WindowManager::Default();
845 panel::Style::Instance().changed.connect(sigc::mem_fun(this, &PanelView::ForceUpdateBackground));
846+ unity::Settings::Instance().dpi_changed.connect(sigc::mem_fun(this, &PanelView::OnDPIChanged));
847+
848 wm.average_color.changed.connect(sigc::mem_fun(this, &PanelView::OnBackgroundUpdate));
849 wm.initiate_spread.connect(sigc::mem_fun(this, &PanelView::OnSpreadInitiate));
850 wm.terminate_spread.connect(sigc::mem_fun(this, &PanelView::OnSpreadTerminate));
851@@ -107,11 +109,12 @@
852
853 SetCompositionLayout(layout_);
854
855- tray_ = new PanelTray();
856+ tray_ = new PanelTray(monitor_);
857 layout_->AddView(tray_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
858 AddChild(tray_);
859
860 indicators_ = new PanelIndicatorsView();
861+ indicators_->SetMonitor(monitor_);
862 AddPanelView(indicators_, 0);
863
864 for (auto const& object : remote_->GetIndicators())
865@@ -168,6 +171,13 @@
866 return tray_->xid();
867 }
868
869+void PanelView::OnDPIChanged()
870+{
871+ int height = panel::Style::Instance().PanelHeight(monitor_);
872+ tray_->SetMinMaxSize(1, height);
873+ menu_view_->OnDPIChanged();
874+}
875+
876 void PanelView::SetLauncherWidth(int width)
877 {
878 launcher_width_ = width;
879@@ -774,7 +784,11 @@
880 {
881 monitor_ = monitor;
882 menu_view_->SetMonitor(monitor);
883+ indicators_->SetMonitor(monitor);
884
885+ int height = panel::Style::Instance().PanelHeight(monitor_);
886+ SetMinMaxSize(height, height);
887+
888 UScreen* uscreen = UScreen::GetDefault();
889 auto monitor_geo = uscreen->GetMonitorGeometry(monitor);
890 Resize(nux::Point(monitor_geo.x, monitor_geo.y), monitor_geo.width);
891@@ -784,8 +798,8 @@
892 {
893 unity::panel::Style &panel_style = panel::Style::Instance();
894 SetMaximumWidth(width);
895- SetGeometry(nux::Geometry(0, 0, width, panel_style.panel_height));
896- parent_->SetGeometry(nux::Geometry(offset.x, offset.y, width, panel_style.panel_height));
897+ SetGeometry(nux::Geometry(0, 0, width, panel_style.PanelHeight(monitor_)));
898+ parent_->SetGeometry(nux::Geometry(offset.x, offset.y, width, panel_style.PanelHeight(monitor_)));
899 }
900
901 int PanelView::GetMonitor() const
902
903=== modified file 'panel/PanelView.h'
904--- panel/PanelView.h 2014-02-17 14:09:15 +0000
905+++ panel/PanelView.h 2014-02-19 01:47:39 +0000
906@@ -110,6 +110,8 @@
907 bool TrackMenuPointer();
908 void SyncGeometries();
909 void AddPanelView(PanelIndicatorsView* child, unsigned int stretchFactor);
910+
911+ void OnDPIChanged();
912
913 MockableBaseWindow* parent_;
914 indicator::Indicators::Ptr remote_;
915
916=== modified file 'panel/StandalonePanel.cpp'
917--- panel/StandalonePanel.cpp 2014-02-12 07:13:01 +0000
918+++ panel/StandalonePanel.cpp 2014-02-19 01:47:39 +0000
919@@ -89,7 +89,7 @@
920 panel_window->ShowWindow(true);
921 panel_window->SetWidth(1024);
922 panel_window->SetXY(0, 0);
923- panel_window->SetMaximumHeight(panel_style.panel_height());
924+ panel_window->SetMaximumHeight(panel_style.PanelHeight());
925
926 wt->window_configuration.connect([this] (int x, int y, int w, int h) {
927 panel_window->SetWidth(w);
928
929=== modified file 'plugins/unityshell/src/unityshell.cpp'
930--- plugins/unityshell/src/unityshell.cpp 2014-02-17 23:31:02 +0000
931+++ plugins/unityshell/src/unityshell.cpp 2014-02-19 01:47:39 +0000
932@@ -628,7 +628,8 @@
933 if (_shadow_texture.empty ())
934 return;
935
936- float panel_h = static_cast<float>(panel_style_.panel_height);
937+ int monitor = PluginAdapter::Default().MonitorGeometryIn(NuxGeometryFromCompRect(output));
938+ float panel_h = static_cast<float>(panel_style_.PanelHeight(monitor));
939 float shadowX = output.x();
940 float shadowY = output.y() + panel_h;
941 float shadowWidth = output.width();
942@@ -907,7 +908,9 @@
943
944 nux::TexCoordXForm texxform;
945 texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_CLAMP);
946- int panel_height = panel_style_.panel_height;
947+
948+ // FIXME Change to paint per monitor vs all at once
949+ int panel_height = panel_style_.PanelHeight();
950 auto const& texture = panel_style_.GetBackground()->GetDeviceTexture();
951 graphics_engine->QRP_GLSL_1Tex(0, 0, screen->width(), panel_height, texture, texxform, nux::color::White);
952 }
953@@ -2907,9 +2910,11 @@
954 !(window->state() & CompWindowStateFullscreenMask) &&
955 !(window->type() & CompWindowTypeFullscreenMask))
956 {
957+ WindowManager& wm = WindowManager::Default();
958 auto const& output = uScreen->screen->currentOutputDev();
959+ int monitor = wm.MonitorGeometryIn(NuxGeometryFromCompRect(output));
960
961- if (window->y() - window->border().top < output.y() + uScreen->panel_style_.panel_height)
962+ if (window->y() - window->border().top < output.y() + uScreen->panel_style_.PanelHeight(monitor))
963 {
964 draw_panel_shadow = DrawPanelShadow::OVER_WINDOW;
965 }
966@@ -3622,7 +3627,7 @@
967 hud_controller_->launcher_width = launcher_width;
968 dash_controller_->launcher_width = launcher_width;
969 panel_controller_->launcher_width = launcher_width;
970- shortcut_controller_->SetAdjustment(launcher_width, panel_style_.panel_height);
971+ shortcut_controller_->SetAdjustment(launcher_width, panel_style_.PanelHeight());
972
973 CompOption::Value v(launcher_width);
974 screen->setOptionForPlugin("expo", "x_offset", v);
975
976=== modified file 'tests/test_em_converter.cpp'
977--- tests/test_em_converter.cpp 2014-01-29 22:40:20 +0000
978+++ tests/test_em_converter.cpp 2014-02-19 01:47:39 +0000
979@@ -64,7 +64,7 @@
980
981 TEST_F(TestEMConverter, TestConvertPixel)
982 {
983- EXPECT_EQ(PIXEL_SIZE, em_converter.ConvertPixels(PIXEL_SIZE));
984+ EXPECT_EQ(PIXEL_SIZE, em_converter.CP(PIXEL_SIZE));
985 }
986
987 TEST_F(TestEMConverter, TestDPIScale)
988
989=== modified file 'tests/test_launcher_controller.cpp'
990--- tests/test_launcher_controller.cpp 2013-11-06 11:21:43 +0000
991+++ tests/test_launcher_controller.cpp 2014-02-19 01:47:39 +0000
992@@ -464,8 +464,8 @@
993 auto const& monitor_geo = uscreen.GetMonitorGeometry(i);
994 auto const& launcher_geo = lc.launchers()[i]->GetAbsoluteGeometry();
995 ASSERT_EQ(launcher_geo.x, monitor_geo.x);
996- ASSERT_EQ(launcher_geo.y, monitor_geo.y + panel_style.panel_height);
997- ASSERT_EQ(launcher_geo.height, monitor_geo.height - panel_style.panel_height);
998+ ASSERT_EQ(launcher_geo.y, monitor_geo.y + panel_style.PanelHeight(i));
999+ ASSERT_EQ(launcher_geo.height, monitor_geo.height - panel_style.PanelHeight(i));
1000 }
1001 }
1002
1003@@ -476,15 +476,15 @@
1004 uscreen.SetMonitors({monitor_geo});
1005 nux::Geometry launcher_geo = lc.launcher().GetAbsoluteGeometry();
1006 ASSERT_EQ(launcher_geo.x, monitor_geo.x);
1007- ASSERT_EQ(launcher_geo.y, monitor_geo.y + panel_style.panel_height);
1008- ASSERT_EQ(launcher_geo.height, monitor_geo.height - panel_style.panel_height);
1009+ ASSERT_EQ(launcher_geo.y, monitor_geo.y + panel_style.PanelHeight());
1010+ ASSERT_EQ(launcher_geo.height, monitor_geo.height - panel_style.PanelHeight());
1011
1012 uscreen.Reset();
1013 monitor_geo = uscreen.GetMonitorGeometry(0);
1014 launcher_geo = lc.launcher().GetAbsoluteGeometry();
1015 ASSERT_EQ(launcher_geo.x, monitor_geo.x);
1016- ASSERT_EQ(launcher_geo.y, monitor_geo.y + panel_style.panel_height);
1017- ASSERT_EQ(launcher_geo.height, monitor_geo.height - panel_style.panel_height);
1018+ ASSERT_EQ(launcher_geo.y, monitor_geo.y + panel_style.PanelHeight());
1019+ ASSERT_EQ(launcher_geo.height, monitor_geo.height - panel_style.PanelHeight());
1020 }
1021
1022 TEST_F(TestLauncherController, IconCentersResetsOnMonitorsUpdated)
1023
1024=== modified file 'tests/test_panel_controller.cpp'
1025--- tests/test_panel_controller.cpp 2014-02-12 07:13:01 +0000
1026+++ tests/test_panel_controller.cpp 2014-02-19 01:47:39 +0000
1027@@ -148,7 +148,7 @@
1028 ASSERT_EQ(panel_geo.x, monitor_geo.x);
1029 ASSERT_EQ(panel_geo.y, monitor_geo.y);
1030 ASSERT_EQ(panel_geo.width, monitor_geo.width);
1031- ASSERT_EQ(panel_geo.height, panel_style.panel_height);
1032+ ASSERT_EQ(panel_geo.height, panel_style.PanelHeight(i));
1033 }
1034 }
1035 }
1036@@ -164,7 +164,7 @@
1037 ASSERT_EQ(panel_geo.x, monitor_geo.x);
1038 ASSERT_EQ(panel_geo.y, monitor_geo.y);
1039 ASSERT_EQ(panel_geo.width, monitor_geo.width);
1040- ASSERT_EQ(panel_geo.height, panel_style.panel_height);
1041+ ASSERT_EQ(panel_geo.height, panel_style.PanelHeight());
1042
1043 uscreen.Reset();
1044 monitor_geo = uscreen.GetMonitorGeometry(0);
1045@@ -172,7 +172,7 @@
1046 ASSERT_EQ(panel_geo.x, monitor_geo.x);
1047 ASSERT_EQ(panel_geo.y, monitor_geo.y);
1048 ASSERT_EQ(panel_geo.width, monitor_geo.width);
1049- ASSERT_EQ(panel_geo.height, panel_style.panel_height);
1050+ ASSERT_EQ(panel_geo.height, panel_style.PanelHeight());
1051 }
1052
1053 TEST_F(TestPanelController, MultiMonitorEdgeBarrierSubscriptions)
1054
1055=== modified file 'tests/test_panel_indicator_entry_dropdown_view.cpp'
1056--- tests/test_panel_indicator_entry_dropdown_view.cpp 2014-01-30 19:46:58 +0000
1057+++ tests/test_panel_indicator_entry_dropdown_view.cpp 2014-02-19 01:47:39 +0000
1058@@ -230,7 +230,7 @@
1059 }
1060
1061 auto const& geo = dropdown.GetGeometry();
1062- EXPECT_CALL(*indicators_, ShowEntriesDropdown(entries, Entry::Ptr(), 0, geo.x, geo.y + Style::Instance().panel_height));
1063+ EXPECT_CALL(*indicators_, ShowEntriesDropdown(entries, Entry::Ptr(), 0, geo.x, geo.y + Style::Instance().PanelHeight()));
1064 dropdown.ShowMenu();
1065 }
1066
1067@@ -249,7 +249,7 @@
1068 auto active = views[g_random_int() % views.size()];
1069 auto const& geo = dropdown.GetGeometry();
1070
1071- EXPECT_CALL(*indicators_, ShowEntriesDropdown(entries, active->GetEntry(), 0, geo.x, geo.y + Style::Instance().panel_height));
1072+ EXPECT_CALL(*indicators_, ShowEntriesDropdown(entries, active->GetEntry(), 0, geo.x, geo.y + Style::Instance().PanelHeight()));
1073 dropdown.ActivateChild(active);
1074 }
1075
1076
1077=== modified file 'tests/test_panel_menu_view.cpp'
1078--- tests/test_panel_menu_view.cpp 2014-02-17 15:36:53 +0000
1079+++ tests/test_panel_menu_view.cpp 2014-02-19 01:47:39 +0000
1080@@ -61,7 +61,7 @@
1081 nux::ObjectPtr<nux::BaseWindow> panel_win(new nux::BaseWindow());
1082 auto const& monitor_geo = uscreen.GetMonitorGeometry(monitor);
1083 panel_win->SetGeometry(monitor_geo);
1084- panel_win->SetMaximumHeight(panelStyle.panel_height());
1085+ panel_win->SetMaximumHeight(panelStyle.PanelHeight(monitor));
1086 panel_win->SetLayout(new nux::HLayout(NUX_TRACKER_LOCATION));
1087 panel_win->GetLayout()->AddView(&menu_view, 1);
1088 panel_win->GetLayout()->SetContentDistribution(nux::MAJOR_POSITION_START);
1089
1090=== modified file 'tests/test_panel_style.cpp'
1091--- tests/test_panel_style.cpp 2013-07-09 04:29:25 +0000
1092+++ tests/test_panel_style.cpp 2014-02-19 01:47:39 +0000
1093@@ -27,6 +27,8 @@
1094 #include "unity-shared/UnitySettings.h"
1095 #include "test_utils.h"
1096
1097+#include "MultiMonitor.h"
1098+
1099 using namespace unity;
1100 using namespace testing;
1101
1102@@ -83,4 +85,14 @@
1103 g_free (old_font);
1104 }
1105
1106+TEST_F(TestPanelStyle, TestPanelHeightUnderBounds)
1107+{
1108+ ASSERT_EQ(panel_style_instance->PanelHeight(-1), 0);
1109+}
1110+
1111+TEST_F(TestPanelStyle, TestPanelHeightOverBounds)
1112+{
1113+ ASSERT_EQ(panel_style_instance->PanelHeight(monitors::MAX), 0);
1114+}
1115+
1116 }
1117
1118=== modified file 'tests/test_raw_pixel.cpp'
1119--- tests/test_raw_pixel.cpp 2014-02-07 21:50:15 +0000
1120+++ tests/test_raw_pixel.cpp 2014-02-19 01:47:39 +0000
1121@@ -32,13 +32,13 @@
1122 {
1123 public:
1124 TestRawPixel()
1125- : cv(FONT_SIZE, DPI)
1126+ : cv(std::make_shared<EMConverter>(FONT_SIZE, DPI))
1127 , p_i(10_em)
1128 , p_f(10.0_em)
1129 {
1130 }
1131
1132- EMConverter cv;
1133+ EMConverter::Ptr cv;
1134 RawPixel p_i;
1135 RawPixel p_f;
1136 };
1137@@ -67,7 +67,7 @@
1138
1139 TEST_F(TestRawPixel, TestConverterTimesTwo)
1140 {
1141- cv.SetDPI(DPI * 2);
1142+ cv->SetDPI(DPI * 2);
1143 ASSERT_EQ(p_i.CP(cv), 20);
1144 }
1145
1146
1147=== modified file 'unity-shared/EMConverter.cpp'
1148--- unity-shared/EMConverter.cpp 2014-02-07 21:50:15 +0000
1149+++ unity-shared/EMConverter.cpp 2014-02-19 01:47:39 +0000
1150@@ -96,7 +96,7 @@
1151 return (pixels / base_pixels_per_em_);
1152 }
1153
1154-double EMConverter::ConvertPixels(int pixels) const
1155+double EMConverter::CP(int pixels) const
1156 {
1157 double pixels_em = PixelsToBaseEM(pixels);
1158 return EMToPixels(pixels_em);
1159
1160=== modified file 'unity-shared/EMConverter.h'
1161--- unity-shared/EMConverter.h 2014-02-07 21:50:15 +0000
1162+++ unity-shared/EMConverter.h 2014-02-19 01:47:39 +0000
1163@@ -20,12 +20,16 @@
1164 #ifndef EM_CONVERTER_H
1165 #define EM_CONVERTER_H
1166
1167+#include <memory>
1168+
1169 namespace unity
1170 {
1171
1172 class EMConverter
1173 {
1174 public:
1175+ typedef std::shared_ptr<EMConverter> Ptr;
1176+
1177 EMConverter(int font_size = 0, double dpi = 96.0);
1178
1179 void SetFontSize(int font_size);
1180@@ -34,7 +38,7 @@
1181 int GetFontSize() const;
1182 double GetDPI() const;
1183
1184- double ConvertPixels(int pixels) const;
1185+ double CP(int pixels) const;
1186 double DPIScale() const;
1187
1188 double PtToPx(int pt);
1189
1190=== modified file 'unity-shared/OverlayWindowButtons.cpp'
1191--- unity-shared/OverlayWindowButtons.cpp 2014-02-10 15:31:44 +0000
1192+++ unity-shared/OverlayWindowButtons.cpp 2014-02-19 01:47:39 +0000
1193@@ -60,7 +60,7 @@
1194
1195 SetX(geo.x + MAIN_LEFT_PADDING);
1196 SetY(geo.y + MENUBAR_PADDING);
1197- SetHeight(panel::Style::Instance().panel_height);
1198+ SetHeight(panel::Style::Instance().PanelHeight(monitor));
1199
1200 window_buttons_->monitor = monitor;
1201 }
1202
1203=== modified file 'unity-shared/PanelStyle.cpp'
1204--- unity-shared/PanelStyle.cpp 2014-01-16 13:20:16 +0000
1205+++ unity-shared/PanelStyle.cpp 2014-02-19 01:47:39 +0000
1206@@ -27,6 +27,8 @@
1207 #include "unity-shared/TextureCache.h"
1208 #include "unity-shared/UnitySettings.h"
1209
1210+#include "MultiMonitor.h"
1211+
1212 namespace unity
1213 {
1214 namespace panel
1215@@ -38,6 +40,7 @@
1216 DECLARE_LOGGER(logger, "unity.panel.style");
1217 const int BUTTONS_SIZE = 16;
1218 const int BUTTONS_PADDING = 1;
1219+const int BASE_PANEL_HEIGHT = 24;
1220
1221 std::string button_id(WindowButtonType type, WindowState ws)
1222 {
1223@@ -50,8 +53,8 @@
1224 }
1225
1226 Style::Style()
1227- : panel_height(24)
1228- , style_context_(gtk_style_context_new())
1229+ : style_context_(gtk_style_context_new())
1230+ , panel_heights_(monitors::MAX, BASE_PANEL_HEIGHT)
1231 {
1232 if (style_instance)
1233 {
1234@@ -62,15 +65,6 @@
1235 style_instance = this;
1236 }
1237
1238- if (Settings::Instance().form_factor() == FormFactor::TV)
1239- panel_height = 0;
1240-
1241- Settings::Instance().form_factor.changed.connect([this](FormFactor form_factor)
1242- {
1243- if (form_factor == FormFactor::TV)
1244- panel_height = 0;
1245- });
1246-
1247 GtkWidgetPath* widget_path = gtk_widget_path_new();
1248 gint pos = gtk_widget_path_append_type(widget_path, GTK_TYPE_WINDOW);
1249 gtk_widget_path_iter_set_name(widget_path, pos, "UnityPanelWidget");
1250@@ -115,10 +109,23 @@
1251 RefreshContext();
1252 }
1253
1254+int Style::PanelHeight(int monitor) const
1255+{
1256+ if (monitor < 0 || monitor >= (int)monitors::MAX)
1257+ {
1258+ LOG_ERROR(logger) << "Invalid monitor index: " << monitor;
1259+ return 0;
1260+ }
1261+
1262+ EMConverter::Ptr const& cv = unity::Settings::Instance().em(monitor);
1263+ return panel_heights_[monitor].CP(cv);
1264+}
1265+
1266 void Style::RefreshContext()
1267 {
1268 gtk_style_context_invalidate(style_context_);
1269 bg_texture_.Release();
1270+
1271 changed.emit();
1272 }
1273
1274@@ -127,13 +134,13 @@
1275 return style_context_;
1276 }
1277
1278-BaseTexturePtr Style::GetBackground()
1279+BaseTexturePtr Style::GetBackground(int monitor)
1280 {
1281 if (bg_texture_)
1282 return bg_texture_;
1283
1284 int width = 1;
1285- int height = panel_height();
1286+ int height = PanelHeight(monitor);
1287
1288 nux::CairoGraphics context(CAIRO_FORMAT_ARGB32, width, height);
1289
1290
1291=== modified file 'unity-shared/PanelStyle.h'
1292--- unity-shared/PanelStyle.h 2014-01-14 17:18:17 +0000
1293+++ unity-shared/PanelStyle.h 2014-02-19 01:47:39 +0000
1294@@ -28,6 +28,9 @@
1295 #include <gtk/gtk.h>
1296 #include <UnityCore/GLibWrapper.h>
1297
1298+#include "unity-shared/EMConverter.h"
1299+#include "unity-shared/RawPixel.h"
1300+
1301 namespace unity
1302 {
1303 namespace decoration
1304@@ -57,23 +60,28 @@
1305
1306 static Style& Instance();
1307
1308- nux::Property<int> panel_height;
1309-
1310 GtkStyleContext* GetStyleContext();
1311- BaseTexturePtr GetBackground();
1312+ BaseTexturePtr GetBackground(int monitor = 0);
1313 BaseTexturePtr GetWindowButton(WindowButtonType type, WindowState state);
1314 BaseTexturePtr GetFallbackWindowButton(WindowButtonType type, WindowState state);
1315 std::string GetFontDescription(PanelItem item);
1316 int GetTextDPI();
1317
1318+ int PanelHeight(int monitor = 0) const;
1319+
1320 sigc::signal<void> changed;
1321
1322 private:
1323 void OnThemeChanged(std::string const&);
1324 void RefreshContext();
1325
1326+ void UpdateFontSize();
1327+ void UpdatePanelHeight();
1328+
1329 glib::Object<GtkStyleContext> style_context_;
1330 BaseTexturePtr bg_texture_;
1331+
1332+ std::vector<RawPixel> panel_heights_;
1333 };
1334
1335 }
1336
1337=== modified file 'unity-shared/PluginAdapter.cpp'
1338--- unity-shared/PluginAdapter.cpp 2014-02-18 00:59:30 +0000
1339+++ unity-shared/PluginAdapter.cpp 2014-02-19 01:47:39 +0000
1340@@ -23,6 +23,7 @@
1341 #include "DecorationStyle.h"
1342 #include "PluginAdapter.h"
1343 #include "CompizUtils.h"
1344+#include "MultiMonitor.h"
1345
1346 #include <scale/scale.h>
1347 #include <NuxCore/Logger.h>
1348@@ -411,6 +412,20 @@
1349 return ret;
1350 }
1351
1352+int PluginAdapter::MonitorGeometryIn(nux::Geometry const& geo) const
1353+{
1354+ std::vector<nux::Geometry> const& monitors = unity::UScreen::GetDefault()->GetMonitors();
1355+ for (unsigned i = 0; i < monitors.size(); ++i)
1356+ {
1357+ nux::Geometry const& i_g = geo.Intersect(monitors[i]);
1358+
1359+ if (i_g.width > 0 && i_g.height > 0)
1360+ return i;
1361+ }
1362+
1363+ return 0;
1364+}
1365+
1366 bool PluginAdapter::IsTopWindowFullscreenOnMonitorWithMouse() const
1367 {
1368 int monitor = unity::UScreen::GetDefault()->GetMonitorWithMouse();
1369
1370=== modified file 'unity-shared/PluginAdapter.h'
1371--- unity-shared/PluginAdapter.h 2014-02-15 14:46:47 +0000
1372+++ unity-shared/PluginAdapter.h 2014-02-19 01:47:39 +0000
1373@@ -115,6 +115,7 @@
1374 Window GetActiveWindow() const;
1375 std::vector<Window> GetWindowsInStackingOrder() const override;
1376
1377+ int MonitorGeometryIn(nux::Geometry const& geo) const override;
1378 bool IsTopWindowFullscreenOnMonitorWithMouse() const override;
1379
1380 // WindowManager implementation
1381
1382=== modified file 'unity-shared/RawPixel.cpp'
1383--- unity-shared/RawPixel.cpp 2014-02-07 21:50:15 +0000
1384+++ unity-shared/RawPixel.cpp 2014-02-19 01:47:39 +0000
1385@@ -37,9 +37,9 @@
1386 {
1387 }
1388
1389-float RawPixel::CP(EMConverter const& converter) const
1390+float RawPixel::CP(EMConverter::Ptr const& converter) const
1391 {
1392- return converter.ConvertPixels(raw_pixel_);
1393+ return converter->CP(raw_pixel_);
1394 }
1395
1396 RawPixel::operator float() const
1397
1398=== modified file 'unity-shared/RawPixel.h'
1399--- unity-shared/RawPixel.h 2014-02-07 21:50:15 +0000
1400+++ unity-shared/RawPixel.h 2014-02-19 01:47:39 +0000
1401@@ -30,7 +30,7 @@
1402 public:
1403 RawPixel(float raw_pixel);
1404
1405- float CP(EMConverter const& converter) const;
1406+ float CP(EMConverter::Ptr const& converter) const;
1407
1408 operator float() const;
1409
1410
1411=== modified file 'unity-shared/StandaloneWindowManager.cpp'
1412--- unity-shared/StandaloneWindowManager.cpp 2014-02-17 15:22:39 +0000
1413+++ unity-shared/StandaloneWindowManager.cpp 2014-02-19 01:47:39 +0000
1414@@ -129,6 +129,12 @@
1415
1416 return ret;
1417 }
1418+
1419+int StandaloneWindowManager::MonitorGeometryIn(nux::Geometry const& geo) const
1420+{
1421+ // TODO
1422+ return 0;
1423+}
1424
1425 bool StandaloneWindowManager::IsTopWindowFullscreenOnMonitorWithMouse() const
1426 {
1427
1428=== modified file 'unity-shared/StandaloneWindowManager.h'
1429--- unity-shared/StandaloneWindowManager.h 2014-02-14 03:05:02 +0000
1430+++ unity-shared/StandaloneWindowManager.h 2014-02-19 01:47:39 +0000
1431@@ -71,6 +71,7 @@
1432 virtual Window GetActiveWindow() const;
1433 std::vector<Window> GetWindowsInStackingOrder() const override;
1434
1435+ virtual int MonitorGeometryIn(nux::Geometry const& geo) const override;
1436 virtual bool IsTopWindowFullscreenOnMonitorWithMouse() const override;
1437
1438 virtual bool IsWindowMaximized(Window window_id) const;
1439
1440=== modified file 'unity-shared/UnitySettings.cpp'
1441--- unity-shared/UnitySettings.cpp 2014-01-31 21:20:30 +0000
1442+++ unity-shared/UnitySettings.cpp 2014-02-19 01:47:39 +0000
1443@@ -39,6 +39,10 @@
1444 const std::string SETTINGS_NAME = "com.canonical.Unity";
1445 const std::string FORM_FACTOR = "form-factor";
1446 const std::string DOUBLE_CLICK_ACTIVATE = "double-click-activate";
1447+
1448+// FIXME Remove me when hikikos settings changes land in unity
1449+const std::string GNOME_SETTINGS = "org.gnome.desktop.interface";
1450+const std::string TEXT_SCALING_FACTOR = "text-scaling-factor";
1451 }
1452
1453 //
1454@@ -50,11 +54,14 @@
1455 Impl(Settings* owner)
1456 : parent_(owner)
1457 , gsettings_(g_settings_new(SETTINGS_NAME.c_str()))
1458+ , gnome_settings_(g_settings_new(GNOME_SETTINGS.c_str()))
1459 , cached_form_factor_(FormFactor::DESKTOP)
1460 , cached_double_click_activate_(true)
1461 , lowGfx_(false)
1462- , em_converters_(monitors::MAX)
1463 {
1464+ for (int i = 0; i < (int)monitors::MAX; i++)
1465+ em_converters_.push_back(std::make_shared<EMConverter>());
1466+
1467 CacheFormFactor();
1468 CacheDoubleClickActivate();
1469
1470@@ -67,6 +74,10 @@
1471 parent_->double_click_activate.changed.emit(cached_double_click_activate_);
1472 });
1473
1474+ signals_.Add<void, GSettings*, const gchar*>(gnome_settings_, "changed::" + TEXT_SCALING_FACTOR, [this] (GSettings*, const gchar* t) {
1475+ UpdateEMConverter();
1476+ });
1477+
1478 UpdateEMConverter();
1479 }
1480
1481@@ -124,10 +135,10 @@
1482 // FIXME Add in getting the specific dpi scale from each monitor
1483 int GetDPI(int monitor = 0) const
1484 {
1485- int dpi = 0;
1486- g_object_get(gtk_settings_get_default(), "gtk-xft-dpi", &dpi, nullptr);
1487+ int dpi = 96;
1488+ float scale = g_settings_get_double(gnome_settings_, TEXT_SCALING_FACTOR.c_str());
1489
1490- return dpi / 1024;
1491+ return dpi * scale;
1492 }
1493
1494 void UpdateFontSize()
1495@@ -135,7 +146,7 @@
1496 int font_size = GetFontSize();
1497
1498 for (auto& em : em_converters_)
1499- em.SetFontSize(font_size);
1500+ em->SetFontSize(font_size);
1501 }
1502
1503 void UpdateDPI()
1504@@ -143,8 +154,10 @@
1505 for (int i = 0; i < (int)em_converters_.size(); ++i)
1506 {
1507 int dpi = GetDPI(i);
1508- em_converters_[i].SetDPI(dpi);
1509+ em_converters_[i]->SetDPI(dpi);
1510 }
1511+
1512+ parent_->dpi_changed.emit();
1513 }
1514
1515 void UpdateEMConverter()
1516@@ -155,6 +168,7 @@
1517
1518 Settings* parent_;
1519 glib::Object<GSettings> gsettings_;
1520+ glib::Object<GSettings> gnome_settings_;
1521 FormFactor cached_form_factor_;
1522 bool cached_double_click_activate_;
1523 bool lowGfx_;
1524@@ -162,7 +176,8 @@
1525 glib::Signal<void, GSettings*, gchar* > form_factor_changed_;
1526 glib::Signal<void, GSettings*, gchar* > double_click_activate_changed_;
1527
1528- std::vector<EMConverter> em_converters_;
1529+ glib::SignalManager signals_;
1530+ std::vector<EMConverter::Ptr> em_converters_;
1531 };
1532
1533 //
1534@@ -215,7 +230,7 @@
1535 pimpl->lowGfx_ = low_gfx;
1536 }
1537
1538-EMConverter const& Settings::em(int monitor) const
1539+EMConverter::Ptr const& Settings::em(int monitor) const
1540 {
1541 if (monitor < 0 || monitor >= (int)monitors::MAX)
1542 {
1543
1544=== modified file 'unity-shared/UnitySettings.h'
1545--- unity-shared/UnitySettings.h 2014-01-31 21:01:53 +0000
1546+++ unity-shared/UnitySettings.h 2014-02-19 01:47:39 +0000
1547@@ -51,7 +51,8 @@
1548 nux::Property<bool> is_standalone;
1549 nux::ROProperty<bool> double_click_activate;
1550
1551- EMConverter const& em(int monitor = 0) const;
1552+ sigc::signal<void> dpi_changed;
1553+ EMConverter::Ptr const& em(int monitor = 0) const;
1554
1555 private:
1556 class Impl;
1557
1558=== modified file 'unity-shared/WindowButtonPriv.h'
1559--- unity-shared/WindowButtonPriv.h 2014-01-14 13:13:11 +0000
1560+++ unity-shared/WindowButtonPriv.h 2014-02-19 01:47:39 +0000
1561@@ -24,9 +24,11 @@
1562 #include <Nux/Button.h>
1563
1564 #include "unity-shared/DecorationStyle.h"
1565+#include "unity-shared/Introspectable.h"
1566 #include "unity-shared/PanelStyle.h"
1567+#include "unity-shared/RawPixel.h"
1568 #include "unity-shared/UBusWrapper.h"
1569-#include "unity-shared/Introspectable.h"
1570+#include "unity-shared/UnitySettings.h"
1571
1572 namespace unity
1573 {
1574@@ -44,6 +46,9 @@
1575 panel::WindowButtonType GetType() const;
1576 void SetVisualState(nux::ButtonVisualState new_state);
1577
1578+ void OnMonitorChanged(int monitor);
1579+ void UpdateDPIChanged();
1580+
1581 nux::RWProperty<bool> enabled;
1582 nux::Property<bool> overlay_mode;
1583
1584@@ -58,6 +63,8 @@
1585 bool EnabledSetter(bool enabled);
1586 static nux::ObjectPtr<nux::BaseTexture> GetDashWindowButton(panel::WindowButtonType type, panel::WindowState state);
1587
1588+ void UpdateGeometry();
1589+
1590 inline WindowButtons* Parent() const
1591 {
1592 return static_cast<WindowButtons*>(GetParentObject());
1593@@ -66,6 +73,9 @@
1594 private:
1595 panel::WindowButtonType type_;
1596
1597+ int monitor_;
1598+ EMConverter::Ptr cv_;
1599+
1600 nux::ObjectPtr<nux::BaseTexture> normal_tex_;
1601 nux::ObjectPtr<nux::BaseTexture> prelight_tex_;
1602 nux::ObjectPtr<nux::BaseTexture> pressed_tex_;
1603
1604=== modified file 'unity-shared/WindowButtons.cpp'
1605--- unity-shared/WindowButtons.cpp 2014-02-15 17:33:02 +0000
1606+++ unity-shared/WindowButtons.cpp 2014-02-19 01:47:39 +0000
1607@@ -43,11 +43,25 @@
1608 sigc::mem_fun(this, &WindowButton::EnabledSetter))
1609 , overlay_mode(false)
1610 , type_(type)
1611+ , monitor_(0)
1612+ , cv_(unity::Settings::Instance().em(0))
1613 {
1614 overlay_mode.changed.connect([this] (bool) { UpdateSize(); QueueDraw(); });
1615 SetAcceptKeyNavFocusOnMouseDown(false);
1616 panel::Style::Instance().changed.connect(sigc::mem_fun(this, &WindowButton::LoadImages));
1617- LoadImages();
1618+
1619+ LoadImages();
1620+}
1621+
1622+void WindowButton::UpdateDPIChanged()
1623+{
1624+ LoadImages();
1625+}
1626+
1627+void WindowButton::OnMonitorChanged(int monitor)
1628+{
1629+ monitor_ = monitor;
1630+ cv_ = unity::Settings::Instance().em(monitor);
1631 }
1632
1633 void WindowButton::SetVisualState(nux::ButtonVisualState new_state)
1634@@ -133,7 +147,7 @@
1635
1636 void WindowButton::UpdateSize()
1637 {
1638- int panel_height = panel::Style::Instance().panel_height;
1639+ int panel_height = panel::Style::Instance().PanelHeight(monitor_);
1640 nux::BaseTexture* tex;
1641 tex = (overlay_mode()) ? normal_dash_tex_.GetPointer() : normal_tex_.GetPointer();
1642 int width = 0;
1643@@ -141,8 +155,10 @@
1644
1645 if (tex)
1646 {
1647- width = std::min(panel_height, tex->GetWidth());
1648- height = std::min(panel_height, tex->GetHeight());
1649+ int tex_w = RawPixel(tex->GetWidth()).CP(cv_);
1650+ int tex_h = RawPixel(tex->GetHeight()).CP(cv_);
1651+ width = std::min(panel_height, tex_w);
1652+ height = std::min(panel_height, tex_h);
1653 }
1654
1655 SetMinMaxSize(width, height);
1656@@ -321,6 +337,20 @@
1657 WindowManager::Default().terminate_spread.connect(sigc::mem_fun(this, &WindowButtons::OnSpreadTerminate));
1658 }
1659
1660+
1661+void WindowButtons::UpdateDPIChanged()
1662+{
1663+ for (auto area : GetChildren())
1664+ static_cast<internal::WindowButton*>(area)->UpdateDPIChanged();
1665+}
1666+
1667+void WindowButtons::OnMonitorChanged(int monitor)
1668+{
1669+ // Need to update the EMConverter in each window button if the monitor changes
1670+ for (auto area : GetChildren())
1671+ static_cast<internal::WindowButton*>(area)->OnMonitorChanged(monitor);
1672+}
1673+
1674 nux::Area* WindowButtons::FindAreaUnderMouse(const nux::Point& mouse, nux::NuxEventType event_type)
1675 {
1676 if (!GetInputEventSensitivity())
1677
1678=== modified file 'unity-shared/WindowButtons.h'
1679--- unity-shared/WindowButtons.h 2014-02-15 17:33:02 +0000
1680+++ unity-shared/WindowButtons.h 2014-02-19 01:47:39 +0000
1681@@ -44,6 +44,7 @@
1682 nux::Property<bool> focused;
1683
1684 bool IsMouseOwner();
1685+ void UpdateDPIChanged();
1686 virtual nux::Area* FindAreaUnderMouse(const nux::Point& mouse_pos, nux::NuxEventType event_type);
1687
1688 sigc::signal<void> close_clicked;
1689@@ -71,6 +72,7 @@
1690 void OnControlledWindowChanged(Window xid);
1691 void ResetNormalButtonState();
1692 bool OpacitySetter(double& target, double new_value);
1693+ void OnMonitorChanged(int monitor);
1694
1695 std::string active_overlay_;
1696 UBusManager ubus_manager_;
1697
1698=== modified file 'unity-shared/WindowManager.h'
1699--- unity-shared/WindowManager.h 2014-02-14 03:05:02 +0000
1700+++ unity-shared/WindowManager.h 2014-02-19 01:47:39 +0000
1701@@ -77,6 +77,7 @@
1702 virtual Window GetActiveWindow() const = 0;
1703 virtual std::vector<Window> GetWindowsInStackingOrder() const = 0;
1704
1705+ virtual int MonitorGeometryIn(nux::Geometry const& geo) const = 0;
1706 virtual bool IsTopWindowFullscreenOnMonitorWithMouse() const = 0;
1707
1708 virtual bool IsWindowMaximized(Window window_id) const = 0;