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
=== modified file 'dash/DashController.cpp'
--- dash/DashController.cpp 2013-11-21 19:38:45 +0000
+++ dash/DashController.cpp 2014-02-19 01:47:39 +0000
@@ -250,7 +250,7 @@
250 view_->Relayout();250 view_->Relayout();
251 window_->SetGeometry(geo);251 window_->SetGeometry(geo);
252 panel::Style &panel_style = panel::Style::Instance();252 panel::Style &panel_style = panel::Style::Instance();
253 view_->SetMonitorOffset(launcher_width, panel_style.panel_height);253 view_->SetMonitorOffset(launcher_width, panel_style.PanelHeight(monitor_));
254}254}
255255
256void Controller::OnMouseDownOutsideWindow(int x, int y,256void Controller::OnMouseDownOutsideWindow(int x, int y,
257257
=== modified file 'dash/DashView.cpp'
--- dash/DashView.cpp 2014-02-10 15:31:44 +0000
+++ dash/DashView.cpp 2014-02-19 01:47:39 +0000
@@ -519,12 +519,13 @@
519{519{
520 dash::Style& style = dash::Style::Instance();520 dash::Style& style = dash::Style::Instance();
521 panel::Style &panel_style = panel::Style::Instance();521 panel::Style &panel_style = panel::Style::Instance();
522 int panel_height = panel_style.PanelHeight();
522523
523 layout_ = new nux::VLayout();524 layout_ = new nux::VLayout();
524 layout_->SetLeftAndRightPadding(style.GetVSeparatorSize(), 0);525 layout_->SetLeftAndRightPadding(style.GetVSeparatorSize(), 0);
525 layout_->SetTopAndBottomPadding(style.GetHSeparatorSize(), 0);526 layout_->SetTopAndBottomPadding(style.GetHSeparatorSize(), 0);
526 SetLayout(layout_);527 SetLayout(layout_);
527 layout_->AddLayout(new nux::SpaceLayout(0, 0, panel_style.panel_height, panel_style.panel_height), 0);528 layout_->AddLayout(new nux::SpaceLayout(0, 0, panel_height, panel_height), 0);
528529
529 content_layout_ = new DashLayout(NUX_TRACKER_LOCATION);530 content_layout_ = new DashLayout(NUX_TRACKER_LOCATION);
530 content_layout_->SetTopAndBottomPadding(style.GetDashViewTopPadding(), 0);531 content_layout_->SetTopAndBottomPadding(style.GetDashViewTopPadding(), 0);
@@ -611,6 +612,7 @@
611{612{
612 dash::Style& style = dash::Style::Instance();613 dash::Style& style = dash::Style::Instance();
613 panel::Style &panel_style = panel::Style::Instance();614 panel::Style &panel_style = panel::Style::Instance();
615 int panel_height = panel_style.PanelHeight();
614616
615 int width = 0, height = 0;617 int width = 0, height = 0;
616 int tile_width = style.GetTileWidth();618 int tile_width = style.GetTileWidth();
@@ -635,14 +637,14 @@
635637
636 // width/height shouldn't be bigger than the geo available.638 // width/height shouldn't be bigger than the geo available.
637 width = std::min(width, for_geo.width); // launcher width is taken into account in for_geo.639 width = std::min(width, for_geo.width); // launcher width is taken into account in for_geo.
638 height = std::min(height, for_geo.height - panel_style.panel_height); // panel height is not taken into account in for_geo.640 height = std::min(height, for_geo.height - panel_height); // panel height is not taken into account in for_geo.
639641
640 if (style.always_maximised)642 if (style.always_maximised)
641 {643 {
642 width = std::max(0, for_geo.width);644 width = std::max(0, for_geo.width);
643 height = std::max(0, for_geo.height - panel_style.panel_height);645 height = std::max(0, for_geo.height - panel_height);
644 }646 }
645 return nux::Geometry(0, panel_style.panel_height, width, height);647 return nux::Geometry(0, panel_height, width, height);
646}648}
647649
648void DashView::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw)650void DashView::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw)
@@ -650,9 +652,10 @@
650 panel::Style &panel_style = panel::Style::Instance();652 panel::Style &panel_style = panel::Style::Instance();
651 nux::Geometry const& renderer_geo_abs(GetRenderAbsoluteGeometry());653 nux::Geometry const& renderer_geo_abs(GetRenderAbsoluteGeometry());
652 nux::Geometry renderer_geo(GetGeometry());654 nux::Geometry renderer_geo(GetGeometry());
655 int panel_height = panel_style.PanelHeight();
653656
654 renderer_geo.y += panel_style.panel_height;657 renderer_geo.y += panel_height;
655 renderer_geo.height += panel_style.panel_height;658 renderer_geo.height += panel_height;
656659
657 renderer_.DrawFull(graphics_engine, content_geo_, renderer_geo_abs, renderer_geo, false);660 renderer_.DrawFull(graphics_engine, content_geo_, renderer_geo_abs, renderer_geo, false);
658}661}
@@ -660,14 +663,15 @@
660void DashView::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw)663void DashView::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw)
661{664{
662 panel::Style& panel_style = panel::Style::Instance();665 panel::Style& panel_style = panel::Style::Instance();
666 int panel_height = panel_style.PanelHeight();
663667
664 nux::Geometry renderer_geo_abs(GetAbsoluteGeometry());668 nux::Geometry renderer_geo_abs(GetAbsoluteGeometry());
665 renderer_geo_abs.y += panel_style.panel_height;669 renderer_geo_abs.y += panel_height;
666 renderer_geo_abs.height -= panel_style.panel_height;670 renderer_geo_abs.height -= panel_height;
667671
668 nux::Geometry renderer_geo(GetGeometry());672 nux::Geometry renderer_geo(GetGeometry());
669 renderer_geo.y += panel_style.panel_height;673 renderer_geo.y += panel_height;
670 renderer_geo.height += panel_style.panel_height;674 renderer_geo.height += panel_height;
671675
672 renderer_.DrawInner(graphics_engine, content_geo_, renderer_geo_abs, renderer_geo);676 renderer_.DrawInner(graphics_engine, content_geo_, renderer_geo_abs, renderer_geo);
673677
@@ -1689,10 +1693,11 @@
1689nux::Geometry DashView::GetRenderAbsoluteGeometry() const1693nux::Geometry DashView::GetRenderAbsoluteGeometry() const
1690{1694{
1691 panel::Style &panel_style = panel::Style::Instance();1695 panel::Style &panel_style = panel::Style::Instance();
1696 int panel_height = panel_style.PanelHeight();
16921697
1693 nux::Geometry renderer_geo_abs(GetAbsoluteGeometry());1698 nux::Geometry renderer_geo_abs(GetAbsoluteGeometry());
1694 renderer_geo_abs.y += panel_style.panel_height;1699 renderer_geo_abs.y += panel_height;
1695 renderer_geo_abs.height -= panel_style.panel_height;1700 renderer_geo_abs.height -= panel_height;
1696 return renderer_geo_abs;1701 return renderer_geo_abs;
1697}1702}
16981703
16991704
=== modified file 'hud/HudController.cpp'
--- hud/HudController.cpp 2014-02-05 15:49:03 +0000
+++ hud/HudController.cpp 2014-02-19 01:47:39 +0000
@@ -231,13 +231,15 @@
231 int ideal_monitor = GetIdealMonitor();231 int ideal_monitor = GetIdealMonitor();
232 auto monitor_geo = UScreen::GetDefault()->GetMonitorGeometry(ideal_monitor);232 auto monitor_geo = UScreen::GetDefault()->GetMonitorGeometry(ideal_monitor);
233233
234 panel::Style &panel_style = panel::Style::Instance();
235 int panel_height = panel_style.PanelHeight(ideal_monitor);
236
234 // We want to cover as much of the screen as possible to grab any mouse events237 // We want to cover as much of the screen as possible to grab any mouse events
235 // outside of our window238 // outside of our window
236 panel::Style &panel_style = panel::Style::Instance();
237 nux::Geometry geo(monitor_geo.x,239 nux::Geometry geo(monitor_geo.x,
238 monitor_geo.y + panel_style.panel_height,240 monitor_geo.y + panel_height,
239 monitor_geo.width,241 monitor_geo.width,
240 monitor_geo.height - panel_style.panel_height);242 monitor_geo.height - panel_height);
241243
242 if (IsLockedToLauncher(ideal_monitor))244 if (IsLockedToLauncher(ideal_monitor))
243 {245 {
@@ -261,7 +263,7 @@
261 view_->QueueDraw();263 view_->QueueDraw();
262 window_->SetGeometry(geo);264 window_->SetGeometry(geo);
263 panel::Style &panel_style = panel::Style::Instance();265 panel::Style &panel_style = panel::Style::Instance();
264 view_->SetMonitorOffset(launcher_width, panel_style.panel_height);266 view_->SetMonitorOffset(launcher_width, panel_style.PanelHeight(monitor_index_));
265}267}
266268
267void Controller::OnMouseDownOutsideWindow(int x, int y,269void Controller::OnMouseDownOutsideWindow(int x, int y,
268270
=== modified file 'launcher/Launcher.cpp'
--- launcher/Launcher.cpp 2014-02-15 14:36:33 +0000
+++ launcher/Launcher.cpp 2014-02-19 01:47:39 +0000
@@ -1183,8 +1183,10 @@
1183 UScreen* uscreen = UScreen::GetDefault();1183 UScreen* uscreen = UScreen::GetDefault();
1184 auto monitor_geo = uscreen->GetMonitorGeometry(new_monitor);1184 auto monitor_geo = uscreen->GetMonitorGeometry(new_monitor);
1185 unity::panel::Style &panel_style = panel::Style::Instance();1185 unity::panel::Style &panel_style = panel::Style::Instance();
1186 Resize(nux::Point(monitor_geo.x, monitor_geo.y + panel_style.panel_height),1186 int panel_height = panel_style.PanelHeight(new_monitor);
1187 monitor_geo.height - panel_style.panel_height);1187
1188 Resize(nux::Point(monitor_geo.x, monitor_geo.y + panel_height),
1189 monitor_geo.height - panel_height);
1188 icon_renderer_->monitor = new_monitor;1190 icon_renderer_->monitor = new_monitor;
1189}1191}
11901192
@@ -1748,7 +1750,7 @@
1748 texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);1750 texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
1749 texxform.SetWrap(nux::TEXWRAP_CLAMP, nux::TEXWRAP_CLAMP);1751 texxform.SetWrap(nux::TEXWRAP_CLAMP, nux::TEXWRAP_CLAMP);
1750 texxform.uoffset = (1.0f / launcher_sheen_->GetWidth()); // TODO (gord) don't use absolute values here1752 texxform.uoffset = (1.0f / launcher_sheen_->GetWidth()); // TODO (gord) don't use absolute values here
1751 texxform.voffset = (1.0f / launcher_sheen_->GetHeight()) * panel::Style::Instance().panel_height;1753 texxform.voffset = (1.0f / launcher_sheen_->GetHeight()) * panel::Style::Instance().PanelHeight(icon_renderer_->monitor);
1752 GfxContext.QRP_1Tex(base.x, base.y, base.width, base.height,1754 GfxContext.QRP_1Tex(base.x, base.y, base.width, base.height,
1753 launcher_sheen_->GetDeviceTexture(),1755 launcher_sheen_->GetDeviceTexture(),
1754 texxform,1756 texxform,
17551757
=== modified file 'launcher/LauncherController.cpp'
--- launcher/LauncherController.cpp 2014-01-31 16:19:39 +0000
+++ launcher/LauncherController.cpp 2014-02-19 01:47:39 +0000
@@ -43,6 +43,8 @@
43#include "unity-shared/UScreen.h"43#include "unity-shared/UScreen.h"
44#include "unity-shared/UBusMessages.h"44#include "unity-shared/UBusMessages.h"
45#include "unity-shared/TimeUtil.h"45#include "unity-shared/TimeUtil.h"
46#include "unity-shared/PanelStyle.h"
47#include "unity-shared/UnitySettings.h"
4648
47namespace unity49namespace unity
48{50{
@@ -169,6 +171,21 @@
169 }171 }
170 });172 });
171173
174 unity::Settings::Instance().dpi_changed.connect([this] {
175 for (auto const& launcher_ptr : launchers)
176 {
177 if (launcher_ptr)
178 {
179 nux::Geometry const& parent_geo = launcher_ptr->GetParent()->GetGeometry();
180 int monitor = launcher_ptr->monitor();
181 int height = panel::Style::Instance().PanelHeight(monitor);
182 int diff = height - parent_geo.y;
183
184 launcher_ptr->Resize(nux::Point(parent_geo.x, parent_geo.y + diff), parent_geo.height - diff);
185 }
186 }
187 });
188
172 parent_->AddChild(model_.get());189 parent_->AddChild(model_.get());
173190
174 xdnd_manager_->dnd_started.connect(sigc::mem_fun(this, &Impl::OnDndStarted));191 xdnd_manager_->dnd_started.connect(sigc::mem_fun(this, &Impl::OnDndStarted));
175192
=== modified file 'panel/PanelController.cpp'
--- panel/PanelController.cpp 2014-02-12 07:45:21 +0000
+++ panel/PanelController.cpp 2014-02-19 01:47:39 +0000
@@ -26,7 +26,6 @@
2626
27#include "unity-shared/UScreen.h"27#include "unity-shared/UScreen.h"
28#include "PanelView.h"28#include "PanelView.h"
29#include "unity-shared/PanelStyle.h"
3029
31namespace unity30namespace unity
32{31{
@@ -190,7 +189,6 @@
190 nux::HLayout* layout = new nux::HLayout(NUX_TRACKER_LOCATION);189 nux::HLayout* layout = new nux::HLayout(NUX_TRACKER_LOCATION);
191190
192 PanelView* view = new PanelView(panel_window, indicators_);191 PanelView* view = new PanelView(panel_window, indicators_);
193 view->SetMaximumHeight(panel::Style::Instance().panel_height);
194 view->SetOpacity(opacity_);192 view->SetOpacity(opacity_);
195 view->SetOpacityMaximizedToggle(opacity_maximized_toggle_);193 view->SetOpacityMaximizedToggle(opacity_maximized_toggle_);
196194
@@ -236,6 +234,8 @@
236 screen->changed.connect(sigc::mem_fun(this, &Controller::OnScreenChanged));234 screen->changed.connect(sigc::mem_fun(this, &Controller::OnScreenChanged));
237 OnScreenChanged(screen->GetPrimaryMonitor(), screen->GetMonitors());235 OnScreenChanged(screen->GetPrimaryMonitor(), screen->GetMonitors());
238236
237 unity::Settings::Instance().dpi_changed.connect(sigc::mem_fun(this, &Controller::OnDPIChanged));
238
239 launcher_width.changed.connect([this] (int width)239 launcher_width.changed.connect([this] (int width)
240 {240 {
241 pimpl->SetLauncherWidth(width);241 pimpl->SetLauncherWidth(width);
@@ -245,6 +245,19 @@
245Controller::~Controller()245Controller::~Controller()
246{}246{}
247247
248void Controller::OnDPIChanged()
249{
250 for (auto& panel_ptr : pimpl->panels_)
251 {
252 if (panel_ptr)
253 {
254 int monitor = panel_ptr->GetMonitor();
255
256 panel_ptr->SetMonitor(monitor);
257 }
258 }
259}
260
248void Controller::SetOpacity(float opacity)261void Controller::SetOpacity(float opacity)
249{262{
250 pimpl->SetOpacity(opacity);263 pimpl->SetOpacity(opacity);
251264
=== modified file 'panel/PanelController.h'
--- panel/PanelController.h 2014-02-12 07:45:21 +0000
+++ panel/PanelController.h 2014-02-19 01:47:39 +0000
@@ -62,6 +62,7 @@
6262
63private:63private:
64 void OnScreenChanged(int primary_monitor, std::vector<nux::Geometry>& monitors);64 void OnScreenChanged(int primary_monitor, std::vector<nux::Geometry>& monitors);
65 void OnDPIChanged();
6566
66 class Impl;67 class Impl;
67 std::unique_ptr<Impl> pimpl;68 std::unique_ptr<Impl> pimpl;
6869
=== modified file 'panel/PanelIndicatorEntryDropdownView.cpp'
--- panel/PanelIndicatorEntryDropdownView.cpp 2014-02-16 19:44:54 +0000
+++ panel/PanelIndicatorEntryDropdownView.cpp 2014-02-19 01:47:39 +0000
@@ -125,7 +125,7 @@
125 entries.push_back(entry->GetEntry());125 entries.push_back(entry->GetEntry());
126126
127 auto const& geo = GetAbsoluteGeometry();127 auto const& geo = GetAbsoluteGeometry();
128 indicators_->ShowEntriesDropdown(entries, active_entry_, 0, geo.x, geo.y + Style::Instance().panel_height);128 indicators_->ShowEntriesDropdown(entries, active_entry_, 0, geo.x, geo.y + Style::Instance().PanelHeight(monitor_));
129}129}
130130
131bool PanelIndicatorEntryDropdownView::ActivateChild(PanelIndicatorEntryView::Ptr const& child)131bool PanelIndicatorEntryDropdownView::ActivateChild(PanelIndicatorEntryView::Ptr const& child)
132132
=== modified file 'panel/PanelIndicatorEntryView.cpp'
--- panel/PanelIndicatorEntryView.cpp 2014-02-16 19:44:54 +0000
+++ panel/PanelIndicatorEntryView.cpp 2014-02-19 01:47:39 +0000
@@ -30,13 +30,16 @@
30#include "unity-shared/CairoTexture.h"30#include "unity-shared/CairoTexture.h"
31#include "unity-shared/PanelStyle.h"31#include "unity-shared/PanelStyle.h"
32#include "unity-shared/WindowManager.h"32#include "unity-shared/WindowManager.h"
33#include "unity-shared/UnitySettings.h"
3334
34namespace unity35namespace unity
35{36{
3637
37namespace38namespace
38{39{
39const int DEFAULT_SPACING = 3;40const RawPixel DEFAULT_SPACING = 3_em;
41
42const int SCALED_IMAGE_Y = 1;
40}43}
4144
42using namespace indicator;45using namespace indicator;
@@ -49,6 +52,7 @@
49 , spacing_(DEFAULT_SPACING)52 , spacing_(DEFAULT_SPACING)
50 , left_padding_(padding < 0 ? 0 : padding)53 , left_padding_(padding < 0 ? 0 : padding)
51 , right_padding_(left_padding_)54 , right_padding_(left_padding_)
55 , monitor_(0)
52 , type_(type)56 , type_(type)
53 , entry_texture_(nullptr)57 , entry_texture_(nullptr)
54 , opacity_(1.0f)58 , opacity_(1.0f)
@@ -56,6 +60,7 @@
56 , overlay_showing_(false)60 , overlay_showing_(false)
57 , disabled_(false)61 , disabled_(false)
58 , focused_(true)62 , focused_(true)
63 , cv_(unity::Settings::Instance().em(monitor_))
59{64{
60 proxy_->active_changed.connect(sigc::mem_fun(this, &PanelIndicatorEntryView::OnActiveChanged));65 proxy_->active_changed.connect(sigc::mem_fun(this, &PanelIndicatorEntryView::OnActiveChanged));
61 proxy_->updated.connect(sigc::mem_fun(this, &PanelIndicatorEntryView::Refresh));66 proxy_->updated.connect(sigc::mem_fun(this, &PanelIndicatorEntryView::Refresh));
@@ -70,6 +75,7 @@
70 }75 }
7176
72 panel::Style::Instance().changed.connect(sigc::mem_fun(this, &PanelIndicatorEntryView::Refresh));77 panel::Style::Instance().changed.connect(sigc::mem_fun(this, &PanelIndicatorEntryView::Refresh));
78 unity::Settings::Instance().dpi_changed.connect(sigc::mem_fun(this, &PanelIndicatorEntryView::Refresh));
7379
74 Refresh();80 Refresh();
75}81}
@@ -104,14 +110,13 @@
104 });110 });
105111
106 wm.TerminateExpo();112 wm.TerminateExpo();
107 return;
108 }113 }
109114
110 if (wm.IsScaleActive())115 if (wm.IsScaleActive())
111 wm.TerminateScale();116 wm.TerminateScale();
112117
113 auto const& abs_geo = GetAbsoluteGeometry();118 auto const& abs_geo = GetAbsoluteGeometry();
114 proxy_->ShowMenu(abs_geo.x, abs_geo.y + panel::Style::Instance().panel_height, button);119 proxy_->ShowMenu(abs_geo.x, abs_geo.y + panel::Style::Instance().PanelHeight(monitor_), button);
115}120}
116121
117void PanelIndicatorEntryView::OnMouseDown(int x, int y, long button_flags, long key_flags)122void PanelIndicatorEntryView::OnMouseDown(int x, int y, long button_flags, long key_flags)
@@ -195,7 +200,7 @@
195 glib::Object<GdkPixbuf> pixbuf;200 glib::Object<GdkPixbuf> pixbuf;
196 GtkIconTheme* theme = gtk_icon_theme_get_default();201 GtkIconTheme* theme = gtk_icon_theme_get_default();
197 int image_type = proxy_->image_type();202 int image_type = proxy_->image_type();
198 int size = (type_ != DROP_DOWN) ? 24 : 16;203 RawPixel size = (type_ != DROP_DOWN) ? 24_em : 16_em;
199204
200 if (image_type == GTK_IMAGE_PIXBUF)205 if (image_type == GTK_IMAGE_PIXBUF)
201 {206 {
@@ -214,14 +219,14 @@
214 else if (image_type == GTK_IMAGE_STOCK ||219 else if (image_type == GTK_IMAGE_STOCK ||
215 image_type == GTK_IMAGE_ICON_NAME)220 image_type == GTK_IMAGE_ICON_NAME)
216 {221 {
217 pixbuf = gtk_icon_theme_load_icon(theme, proxy_->image_data().c_str(), size,222 pixbuf = gtk_icon_theme_load_icon(theme, proxy_->image_data().c_str(), size.CP(cv_),
218 (GtkIconLookupFlags)0, nullptr);223 (GtkIconLookupFlags)0, nullptr);
219 }224 }
220 else if (image_type == GTK_IMAGE_GICON)225 else if (image_type == GTK_IMAGE_GICON)
221 {226 {
222 glib::Object<GIcon> icon(g_icon_new_for_string(proxy_->image_data().c_str(), nullptr));227 glib::Object<GIcon> icon(g_icon_new_for_string(proxy_->image_data().c_str(), nullptr));
223228
224 gtk::IconInfo info(gtk_icon_theme_lookup_by_gicon(theme, icon, size,229 gtk::IconInfo info(gtk_icon_theme_lookup_by_gicon(theme, icon, size.CP(cv_),
225 (GtkIconLookupFlags)0));230 (GtkIconLookupFlags)0));
226 if (info)231 if (info)
227 pixbuf = gtk_icon_info_load_icon(info, nullptr);232 pixbuf = gtk_icon_info_load_icon(info, nullptr);
@@ -230,6 +235,33 @@
230 return pixbuf;235 return pixbuf;
231}236}
232237
238int PanelIndicatorEntryView::PixbufWidth(glib::Object<GdkPixbuf> const& pixbuf) const
239{
240 int image_type = proxy_->image_type();
241 if (image_type == GTK_IMAGE_PIXBUF)
242 {
243 return RawPixel(gdk_pixbuf_get_width(pixbuf)).CP(cv_);
244 }
245 else
246 {
247 return gdk_pixbuf_get_width(pixbuf);
248 }
249}
250
251int PanelIndicatorEntryView::PixbufHeight(glib::Object<GdkPixbuf> const& pixbuf) const
252{
253 int image_type = proxy_->image_type();
254 if (image_type == GTK_IMAGE_PIXBUF)
255 {
256 return RawPixel(gdk_pixbuf_get_height(pixbuf)).CP(cv_);
257 }
258 else
259 {
260 return gdk_pixbuf_get_height(pixbuf);
261 }
262
263}
264
233void PanelIndicatorEntryView::DrawEntryPrelight(cairo_t* cr, unsigned int width, unsigned int height)265void PanelIndicatorEntryView::DrawEntryPrelight(cairo_t* cr, unsigned int width, unsigned int height)
234{266{
235 GtkStyleContext* style_context = panel::Style::Instance().GetStyleContext();267 GtkStyleContext* style_context = panel::Style::Instance().GetStyleContext();
@@ -254,9 +286,22 @@
254 gtk_style_context_restore(style_context);286 gtk_style_context_restore(style_context);
255}287}
256288
289// FIXME Remove me when icons for the indicators aren't stuck as 22x22 images...
290void PanelIndicatorEntryView::ScaleImageIcons(cairo_t* cr, int* x, int* y)
291{
292 int image_type = proxy_->image_type();
293 if (image_type == GTK_IMAGE_PIXBUF)
294 {
295 float aspect = cv_->DPIScale();
296 *x = left_padding_;
297 *y = SCALED_IMAGE_Y;
298 cairo_scale(cr, aspect, aspect);
299 }
300}
301
257void PanelIndicatorEntryView::DrawEntryContent(cairo_t *cr, unsigned int width, unsigned int height, glib::Object<GdkPixbuf> const& pixbuf, glib::Object<PangoLayout> const& layout)302void PanelIndicatorEntryView::DrawEntryContent(cairo_t *cr, unsigned int width, unsigned int height, glib::Object<GdkPixbuf> const& pixbuf, glib::Object<PangoLayout> const& layout)
258{303{
259 int x = left_padding_;304 int x = left_padding_.CP(cv_);
260305
261 if (IsActive())306 if (IsActive())
262 DrawEntryPrelight(cr, width, height);307 DrawEntryPrelight(cr, width, height);
@@ -264,7 +309,7 @@
264 if (pixbuf && IsIconVisible())309 if (pixbuf && IsIconVisible())
265 {310 {
266 GtkStyleContext* style_context = panel::Style::Instance().GetStyleContext();311 GtkStyleContext* style_context = panel::Style::Instance().GetStyleContext();
267 unsigned int icon_width = gdk_pixbuf_get_width(pixbuf);312 unsigned int icon_width = PixbufWidth(pixbuf);
268313
269 gtk_style_context_save(style_context);314 gtk_style_context_save(style_context);
270315
@@ -286,7 +331,8 @@
286 gtk_style_context_set_state(style_context, GTK_STATE_FLAG_PRELIGHT);331 gtk_style_context_set_state(style_context, GTK_STATE_FLAG_PRELIGHT);
287 }332 }
288333
289 int y = (int)((height - gdk_pixbuf_get_height(pixbuf)) / 2);334 int y = (int)((height - PixbufHeight(pixbuf)) / 2);
335
290 if (overlay_showing_ && !IsActive())336 if (overlay_showing_ && !IsActive())
291 {337 {
292 /* Most of the images we get are straight pixbufs (annoyingly), so when338 /* Most of the images we get are straight pixbufs (annoyingly), so when
@@ -295,6 +341,7 @@
295 * icon themes/icons.341 * icon themes/icons.
296 */342 */
297 cairo_save(cr);343 cairo_save(cr);
344 ScaleImageIcons(cr, &x, &y);
298345
299 cairo_push_group(cr);346 cairo_push_group(cr);
300 gdk_cairo_set_source_pixbuf(cr, pixbuf, x, y);347 gdk_cairo_set_source_pixbuf(cr, pixbuf, x, y);
@@ -311,17 +358,22 @@
311 }358 }
312 else359 else
313 {360 {
361 cairo_save(cr);
362 ScaleImageIcons(cr, &x, &y);
363
314 cairo_push_group(cr);364 cairo_push_group(cr);
315 gtk_render_icon(style_context, cr, pixbuf, x, y);365 gtk_render_icon(style_context, cr, pixbuf, x, y);
316 cairo_pop_group_to_source(cr);366 cairo_pop_group_to_source(cr);
317 cairo_paint_with_alpha(cr, (IsIconSensitive() && IsFocused()) ? 1.0 : 0.5);367 cairo_paint_with_alpha(cr, (IsIconSensitive() && IsFocused()) ? 1.0 : 0.5);
368
369 cairo_restore(cr);
318 }370 }
319371
320 gtk_widget_path_free(widget_path);372 gtk_widget_path_free(widget_path);
321373
322 gtk_style_context_restore(style_context);374 gtk_style_context_restore(style_context);
323375
324 x += icon_width + spacing_;376 x += icon_width + spacing_.CP(cv_);
325 }377 }
326378
327 if (layout)379 if (layout)
@@ -399,12 +451,12 @@
399451
400 unsigned int width = 0;452 unsigned int width = 0;
401 unsigned int icon_width = 0;453 unsigned int icon_width = 0;
402 unsigned int height = panel::Style::Instance().panel_height;454 unsigned int height = panel::Style::Instance().PanelHeight(monitor_);
403455
404 // First lets figure out our size456 // First lets figure out our size
405 if (pixbuf && IsIconVisible())457 if (pixbuf && IsIconVisible())
406 {458 {
407 width = gdk_pixbuf_get_width(pixbuf);459 width = PixbufWidth(pixbuf);
408 icon_width = width;460 icon_width = width;
409 }461 }
410462
@@ -457,14 +509,14 @@
457 unsigned int text_width = log_rect.width / PANGO_SCALE;509 unsigned int text_width = log_rect.width / PANGO_SCALE;
458510
459 if (icon_width)511 if (icon_width)
460 width += spacing_;512 width += spacing_.CP(cv_);
461 width += text_width;513 width += text_width;
462514
463 pango_font_description_free(desc);515 pango_font_description_free(desc);
464 }516 }
465517
466 if (width)518 if (width)
467 width += left_padding_ + right_padding_;519 width += left_padding_.CP(cv_) + right_padding_.CP(cv_);
468520
469 SetMinimumWidth(width);521 SetMinimumWidth(width);
470 SetMaximumWidth(width);522 SetMaximumWidth(width);
@@ -529,6 +581,13 @@
529 Refresh();581 Refresh();
530}582}
531583
584void PanelIndicatorEntryView::SetMonitor(int monitor)
585{
586 monitor_ = monitor;
587
588 cv_ = unity::Settings::Instance().em(monitor);
589}
590
532void PanelIndicatorEntryView::SetOpacity(double opacity)591void PanelIndicatorEntryView::SetOpacity(double opacity)
533{592{
534 opacity = CLAMP(opacity, 0.0f, 1.0f);593 opacity = CLAMP(opacity, 0.0f, 1.0f);
535594
=== modified file 'panel/PanelIndicatorEntryView.h'
--- panel/PanelIndicatorEntryView.h 2014-02-05 10:36:28 +0000
+++ panel/PanelIndicatorEntryView.h 2014-02-19 01:47:39 +0000
@@ -32,7 +32,9 @@
3232
33#include <gtk/gtk.h>33#include <gtk/gtk.h>
3434
35#include "unity-shared/EMConverter.h"
35#include "unity-shared/Introspectable.h"36#include "unity-shared/Introspectable.h"
37#include "unity-shared/RawPixel.h"
3638
3739
38namespace unity40namespace unity
@@ -90,6 +92,8 @@
90 void OverlayShown();92 void OverlayShown();
91 void OverlayHidden();93 void OverlayHidden();
9294
95 virtual void SetMonitor(int monitor);
96
93 sigc::signal<void, PanelIndicatorEntryView*, bool> active_changed;97 sigc::signal<void, PanelIndicatorEntryView*, bool> active_changed;
94 sigc::signal<void, PanelIndicatorEntryView*> refreshed;98 sigc::signal<void, PanelIndicatorEntryView*> refreshed;
9599
@@ -108,9 +112,11 @@
108 virtual void ShowMenu(int button = 1);112 virtual void ShowMenu(int button = 1);
109113
110 indicator::Entry::Ptr proxy_;114 indicator::Entry::Ptr proxy_;
111 unsigned int spacing_;115 RawPixel spacing_;
112 unsigned int left_padding_;116 RawPixel left_padding_;
113 unsigned int right_padding_;117 RawPixel right_padding_;
118
119 int monitor_;
114120
115private:121private:
116 void OnMouseDown(int x, int y, long button_flags, long key_flags);122 void OnMouseDown(int x, int y, long button_flags, long key_flags);
@@ -118,6 +124,11 @@
118 void OnMouseWheel(int x, int y, int delta, unsigned long mouse_state, unsigned long key_state);124 void OnMouseWheel(int x, int y, int delta, unsigned long mouse_state, unsigned long key_state);
119 void OnActiveChanged(bool is_active);125 void OnActiveChanged(bool is_active);
120126
127 int PixbufWidth(glib::Object<GdkPixbuf> const& pixbuf) const;
128 int PixbufHeight(glib::Object<GdkPixbuf> const& pixbuf) const;
129
130 void ScaleImageIcons(cairo_t* cr, int* x, int* y);
131
121 glib::Object<GdkPixbuf> MakePixbuf();132 glib::Object<GdkPixbuf> MakePixbuf();
122133
123 IndicatorEntryType type_;134 IndicatorEntryType type_;
@@ -128,6 +139,8 @@
128 bool overlay_showing_;139 bool overlay_showing_;
129 bool disabled_;140 bool disabled_;
130 bool focused_;141 bool focused_;
142
143 EMConverter::Ptr cv_;
131};144};
132145
133}146}
134147
=== modified file 'panel/PanelIndicatorsView.cpp'
--- panel/PanelIndicatorsView.cpp 2014-02-06 22:12:59 +0000
+++ panel/PanelIndicatorsView.cpp 2014-02-19 01:47:39 +0000
@@ -41,6 +41,7 @@
41: View(NUX_TRACKER_LOCATION)41: View(NUX_TRACKER_LOCATION)
42, opacity(1.0f, sigc::mem_fun(this, &PanelIndicatorsView::SetOpacity))42, opacity(1.0f, sigc::mem_fun(this, &PanelIndicatorsView::SetOpacity))
43, layout_(new nux::HLayout("", NUX_TRACKER_LOCATION))43, layout_(new nux::HLayout("", NUX_TRACKER_LOCATION))
44, monitor_(0)
44{45{
45 opacity.DisableNotifications();46 opacity.DisableNotifications();
46 layout_->SetContentDistribution(nux::MAJOR_POSITION_END);47 layout_->SetContentDistribution(nux::MAJOR_POSITION_END);
@@ -265,23 +266,27 @@
265 if (!view)266 if (!view)
266 return;267 return;
267268
269 auto const& entry_id = view->GetEntryID();
268 int entry_pos = pos;270 int entry_pos = pos;
269 auto const& entry_id = view->GetEntryID();271 bool known_entry = (entries_.find(entry_id) != entries_.end());
270 view->SetOpacity(opacity());272 view->SetOpacity(opacity());
271273
272 if (entry_pos == IndicatorEntryPosition::AUTO)274 if (!known_entry && dropdown_ && !dropdown_->Empty())
273 {275 {
274 entry_pos = nux::NUX_LAYOUT_BEGIN;276 if (entry_pos == IndicatorEntryPosition::AUTO)
275
276 if (view->GetEntryPriority() > -1)
277 {277 {
278 for (auto area : layout_->GetChildren())278 entry_pos = nux::NUX_LAYOUT_BEGIN;
279
280 if (view->GetEntryPriority() > -1)
279 {281 {
280 auto en = static_cast<PanelIndicatorEntryView*>(area);282 for (auto area : layout_->GetChildren())
281 if (view->GetEntryPriority() <= en->GetEntryPriority())283 {
282 break;284 auto en = static_cast<PanelIndicatorEntryView*>(area);
285 if (view->GetEntryPriority() <= en->GetEntryPriority())
286 break;
283287
284 ++entry_pos;288 ++entry_pos;
289 }
285 }290 }
286 }291 }
287 }292 }
@@ -292,7 +297,7 @@
292 QueueRelayout();297 QueueRelayout();
293 QueueDraw();298 QueueDraw();
294299
295 if (entries_.find(entry_id) == entries_.end())300 if (!known_entry)
296 {301 {
297 view->refreshed.connect(sigc::mem_fun(this, &PanelIndicatorsView::OnEntryRefreshed));302 view->refreshed.connect(sigc::mem_fun(this, &PanelIndicatorsView::OnEntryRefreshed));
298 entries_.insert({entry_id, view});303 entries_.insert({entry_id, view});
@@ -306,6 +311,8 @@
306 auto view = new PanelIndicatorEntryView(entry, padding, type);311 auto view = new PanelIndicatorEntryView(entry, padding, type);
307 AddEntryView(view, pos);312 AddEntryView(view, pos);
308313
314 view->SetMonitor(monitor_);
315
309 return view;316 return view;
310}317}
311318
@@ -357,6 +364,11 @@
357 entry.second->OverlayHidden();364 entry.second->OverlayHidden();
358}365}
359366
367void PanelIndicatorsView::SetMonitor(int monitor)
368{
369 monitor_ = monitor;
370}
371
360bool PanelIndicatorsView::SetOpacity(double& target, double const& new_value)372bool PanelIndicatorsView::SetOpacity(double& target, double const& new_value)
361{373{
362 double opacity = CLAMP(new_value, 0.0f, 1.0f);374 double opacity = CLAMP(new_value, 0.0f, 1.0f);
363375
=== modified file 'panel/PanelIndicatorsView.h'
--- panel/PanelIndicatorsView.h 2014-02-06 22:12:59 +0000
+++ panel/PanelIndicatorsView.h 2014-02-19 01:47:39 +0000
@@ -69,6 +69,8 @@
6969
70 void EnableDropdownMenu(bool, indicator::Indicators::Ptr const& i = nullptr);70 void EnableDropdownMenu(bool, indicator::Indicators::Ptr const& i = nullptr);
7171
72 virtual void SetMonitor(int monitor);
73
72 nux::Property<double> opacity;74 nux::Property<double> opacity;
7375
74 sigc::signal<void> on_indicator_updated;76 sigc::signal<void> on_indicator_updated;
@@ -95,6 +97,8 @@
95 typedef std::map<std::string, PanelIndicatorEntryView*> Entries;97 typedef std::map<std::string, PanelIndicatorEntryView*> Entries;
96 Entries entries_;98 Entries entries_;
9799
100 int monitor_;
101
98private:102private:
99 bool SetOpacity(double& target, double const& new_value);103 bool SetOpacity(double& target, double const& new_value);
100104
101105
=== modified file 'panel/PanelMenuView.cpp'
--- panel/PanelMenuView.cpp 2014-02-15 18:10:14 +0000
+++ panel/PanelMenuView.cpp 2014-02-19 01:47:39 +0000
@@ -68,7 +68,6 @@
68 , show_now_activated_(false)68 , show_now_activated_(false)
69 , we_control_active_(false)69 , we_control_active_(false)
70 , new_app_menu_shown_(false)70 , new_app_menu_shown_(false)
71 , monitor_(0)
72 , active_xid_(0)71 , active_xid_(0)
73 , desktop_name_(_("Ubuntu Desktop"))72 , desktop_name_(_("Ubuntu Desktop"))
74{73{
@@ -83,13 +82,7 @@
83 SetupWindowManagerSignals();82 SetupWindowManagerSignals();
84 SetupUBusManagerInterests();83 SetupUBusManagerInterests();
8584
86 style_changed_connection_ = panel::Style::Instance().changed.connect([this] {85 style_changed_connection_ = panel::Style::Instance().changed.connect(sigc::mem_fun(this, &PanelMenuView::OnDPIChanged));
87 window_buttons_->ComputeContentSize();
88 layout_->SetLeftAndRightPadding(window_buttons_->GetContentWidth(), 0);
89
90 Refresh(true);
91 FullRedraw();
92 });
9386
94 opacity = 0.0f;87 opacity = 0.0f;
9588
@@ -103,6 +96,19 @@
103 titlebar_grab_area_->UnParentObject();96 titlebar_grab_area_->UnParentObject();
104}97}
10598
99void PanelMenuView::OnDPIChanged()
100{
101 int height = panel::Style::Instance().PanelHeight(monitor_);
102 window_buttons_->SetMaximumHeight(height);
103 window_buttons_->UpdateDPIChanged();
104
105 window_buttons_->ComputeContentSize();
106 layout_->SetLeftAndRightPadding(window_buttons_->GetContentWidth(), 0);
107
108 Refresh(true);
109 FullRedraw();
110}
111
106void PanelMenuView::SetupPanelMenuViewSignals()112void PanelMenuView::SetupPanelMenuViewSignals()
107{113{
108 active_win_changed_signal_.Connect(matcher_, "active-window-changed",114 active_win_changed_signal_.Connect(matcher_, "active-window-changed",
@@ -129,7 +135,7 @@
129 window_buttons_->controlled_window = active_xid_;135 window_buttons_->controlled_window = active_xid_;
130 window_buttons_->opacity = 0.0f;136 window_buttons_->opacity = 0.0f;
131 window_buttons_->SetLeftAndRightPadding(MAIN_LEFT_PADDING, MENUBAR_PADDING);137 window_buttons_->SetLeftAndRightPadding(MAIN_LEFT_PADDING, MENUBAR_PADDING);
132 window_buttons_->SetMaximumHeight(panel::Style::Instance().panel_height);138 window_buttons_->SetMaximumHeight(panel::Style::Instance().PanelHeight(monitor_));
133 window_buttons_->ComputeContentSize();139 window_buttons_->ComputeContentSize();
134140
135 window_buttons_->mouse_enter.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseEnter));141 window_buttons_->mouse_enter.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseEnter));
@@ -145,7 +151,7 @@
145{151{
146 layout_->SetContentDistribution(nux::MAJOR_POSITION_START);152 layout_->SetContentDistribution(nux::MAJOR_POSITION_START);
147 layout_->SetLeftAndRightPadding(window_buttons_->GetContentWidth(), 0);153 layout_->SetLeftAndRightPadding(window_buttons_->GetContentWidth(), 0);
148 layout_->SetBaseHeight(panel::Style::Instance().panel_height);154 layout_->SetBaseHeight(panel::Style::Instance().PanelHeight(monitor_));
149}155}
150156
151void PanelMenuView::SetupTitlebarGrabArea()157void PanelMenuView::SetupTitlebarGrabArea()
152158
=== modified file 'panel/PanelMenuView.h'
--- panel/PanelMenuView.h 2014-02-15 18:10:14 +0000
+++ panel/PanelMenuView.h 2014-02-19 01:47:39 +0000
@@ -45,7 +45,7 @@
45 ~PanelMenuView();45 ~PanelMenuView();
4646
47 void SetMousePosition(int x, int y);47 void SetMousePosition(int x, int y);
48 void SetMonitor(int monitor);48 void SetMonitor(int monitor) override;
4949
50 Window GetTopWindow() const;50 Window GetTopWindow() const;
51 Window GetMaximizedWindow() const;51 Window GetMaximizedWindow() const;
@@ -58,6 +58,8 @@
58 virtual void OverlayShown();58 virtual void OverlayShown();
59 virtual void OverlayHidden();59 virtual void OverlayHidden();
6060
61 void OnDPIChanged();
62
61protected:63protected:
62 std::string GetName() const;64 std::string GetName() const;
63 void AddProperties(debug::IntrospectionData&);65 void AddProperties(debug::IntrospectionData&);
@@ -177,7 +179,6 @@
177 bool we_control_active_;179 bool we_control_active_;
178 bool new_app_menu_shown_;180 bool new_app_menu_shown_;
179181
180 int monitor_;
181 Window active_xid_;182 Window active_xid_;
182 nux::Geometry monitor_geo_;183 nux::Geometry monitor_geo_;
183 const std::string desktop_name_;184 const std::string desktop_name_;
184185
=== modified file 'panel/PanelTray.cpp'
--- panel/PanelTray.cpp 2013-09-19 16:44:03 +0000
+++ panel/PanelTray.cpp 2014-02-19 01:47:39 +0000
@@ -21,6 +21,7 @@
2121
22#include "PanelTray.h"22#include "PanelTray.h"
23#include "unity-shared/PanelStyle.h"23#include "unity-shared/PanelStyle.h"
24#include "unity-shared/UnitySettings.h"
2425
25#include <NuxCore/Logger.h>26#include <NuxCore/Logger.h>
2627
@@ -35,11 +36,12 @@
35namespace unity36namespace unity
36{37{
3738
38PanelTray::PanelTray()39PanelTray::PanelTray(int monitor)
39 : View(NUX_TRACKER_LOCATION)40 : View(NUX_TRACKER_LOCATION)
40 , window_(gtk_window_new(GTK_WINDOW_TOPLEVEL))41 , window_(gtk_window_new(GTK_WINDOW_TOPLEVEL))
42 , monitor_(monitor)
41{43{
42 int panel_height = panel::Style::Instance().panel_height;44 int panel_height = panel::Style::Instance().PanelHeight(monitor_);
4345
44 auto gtkwindow = glib::object_cast<GtkWindow>(window_);46 auto gtkwindow = glib::object_cast<GtkWindow>(window_);
45 gtk_window_set_type_hint(gtkwindow, GDK_WINDOW_TYPE_HINT_DOCK);47 gtk_window_set_type_hint(gtkwindow, GDK_WINDOW_TYPE_HINT_DOCK);
@@ -113,7 +115,7 @@
113{115{
114 if (tray_)116 if (tray_)
115 {117 {
116 SetMinMaxSize(WidthOfTray() + (PADDING * 2), panel::Style::Instance().panel_height);118 SetMinMaxSize(WidthOfTray() + (PADDING * 2), panel::Style::Instance().PanelHeight(monitor_));
117 QueueRelayout();119 QueueRelayout();
118 QueueDraw();120 QueueDraw();
119121
@@ -176,7 +178,7 @@
176bool PanelTray::IdleSync()178bool PanelTray::IdleSync()
177{179{
178 int width = WidthOfTray();180 int width = WidthOfTray();
179 gtk_window_resize(GTK_WINDOW(window_.RawPtr()), width, panel::Style::Instance().panel_height);181 gtk_window_resize(GTK_WINDOW(window_.RawPtr()), width, panel::Style::Instance().PanelHeight(monitor_));
180 Sync();182 Sync();
181183
182 return false;184 return false;
183185
=== modified file 'panel/PanelTray.h'
--- panel/PanelTray.h 2013-09-19 16:44:03 +0000
+++ panel/PanelTray.h 2014-02-19 01:47:39 +0000
@@ -40,7 +40,7 @@
40class PanelTray : public nux::View, public unity::debug::Introspectable40class PanelTray : public nux::View, public unity::debug::Introspectable
41{41{
42public:42public:
43 PanelTray();43 PanelTray(int monitor);
44 ~PanelTray();44 ~PanelTray();
4545
46 void Sync();46 void Sync();
@@ -70,6 +70,8 @@
70 glib::Source::UniquePtr sync_idle_;70 glib::Source::UniquePtr sync_idle_;
71 std::list<NaTrayChild*> children_;71 std::list<NaTrayChild*> children_;
72 nux::Geometry last_geo_;72 nux::Geometry last_geo_;
73
74 int monitor_;
73};75};
7476
75}77}
7678
=== modified file 'panel/PanelView.cpp'
--- panel/PanelView.cpp 2014-02-17 13:43:43 +0000
+++ panel/PanelView.cpp 2014-02-19 01:47:39 +0000
@@ -73,6 +73,8 @@
73{73{
74 auto& wm = WindowManager::Default();74 auto& wm = WindowManager::Default();
75 panel::Style::Instance().changed.connect(sigc::mem_fun(this, &PanelView::ForceUpdateBackground));75 panel::Style::Instance().changed.connect(sigc::mem_fun(this, &PanelView::ForceUpdateBackground));
76 unity::Settings::Instance().dpi_changed.connect(sigc::mem_fun(this, &PanelView::OnDPIChanged));
77
76 wm.average_color.changed.connect(sigc::mem_fun(this, &PanelView::OnBackgroundUpdate));78 wm.average_color.changed.connect(sigc::mem_fun(this, &PanelView::OnBackgroundUpdate));
77 wm.initiate_spread.connect(sigc::mem_fun(this, &PanelView::OnSpreadInitiate));79 wm.initiate_spread.connect(sigc::mem_fun(this, &PanelView::OnSpreadInitiate));
78 wm.terminate_spread.connect(sigc::mem_fun(this, &PanelView::OnSpreadTerminate));80 wm.terminate_spread.connect(sigc::mem_fun(this, &PanelView::OnSpreadTerminate));
@@ -107,11 +109,12 @@
107109
108 SetCompositionLayout(layout_);110 SetCompositionLayout(layout_);
109111
110 tray_ = new PanelTray();112 tray_ = new PanelTray(monitor_);
111 layout_->AddView(tray_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);113 layout_->AddView(tray_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
112 AddChild(tray_);114 AddChild(tray_);
113115
114 indicators_ = new PanelIndicatorsView();116 indicators_ = new PanelIndicatorsView();
117 indicators_->SetMonitor(monitor_);
115 AddPanelView(indicators_, 0);118 AddPanelView(indicators_, 0);
116119
117 for (auto const& object : remote_->GetIndicators())120 for (auto const& object : remote_->GetIndicators())
@@ -168,6 +171,13 @@
168 return tray_->xid();171 return tray_->xid();
169}172}
170173
174void PanelView::OnDPIChanged()
175{
176 int height = panel::Style::Instance().PanelHeight(monitor_);
177 tray_->SetMinMaxSize(1, height);
178 menu_view_->OnDPIChanged();
179}
180
171void PanelView::SetLauncherWidth(int width)181void PanelView::SetLauncherWidth(int width)
172{182{
173 launcher_width_ = width;183 launcher_width_ = width;
@@ -774,7 +784,11 @@
774{784{
775 monitor_ = monitor;785 monitor_ = monitor;
776 menu_view_->SetMonitor(monitor);786 menu_view_->SetMonitor(monitor);
787 indicators_->SetMonitor(monitor);
777788
789 int height = panel::Style::Instance().PanelHeight(monitor_);
790 SetMinMaxSize(height, height);
791
778 UScreen* uscreen = UScreen::GetDefault();792 UScreen* uscreen = UScreen::GetDefault();
779 auto monitor_geo = uscreen->GetMonitorGeometry(monitor);793 auto monitor_geo = uscreen->GetMonitorGeometry(monitor);
780 Resize(nux::Point(monitor_geo.x, monitor_geo.y), monitor_geo.width);794 Resize(nux::Point(monitor_geo.x, monitor_geo.y), monitor_geo.width);
@@ -784,8 +798,8 @@
784{798{
785 unity::panel::Style &panel_style = panel::Style::Instance();799 unity::panel::Style &panel_style = panel::Style::Instance();
786 SetMaximumWidth(width);800 SetMaximumWidth(width);
787 SetGeometry(nux::Geometry(0, 0, width, panel_style.panel_height));801 SetGeometry(nux::Geometry(0, 0, width, panel_style.PanelHeight(monitor_)));
788 parent_->SetGeometry(nux::Geometry(offset.x, offset.y, width, panel_style.panel_height));802 parent_->SetGeometry(nux::Geometry(offset.x, offset.y, width, panel_style.PanelHeight(monitor_)));
789}803}
790804
791int PanelView::GetMonitor() const805int PanelView::GetMonitor() const
792806
=== modified file 'panel/PanelView.h'
--- panel/PanelView.h 2014-02-17 14:09:15 +0000
+++ panel/PanelView.h 2014-02-19 01:47:39 +0000
@@ -110,6 +110,8 @@
110 bool TrackMenuPointer();110 bool TrackMenuPointer();
111 void SyncGeometries();111 void SyncGeometries();
112 void AddPanelView(PanelIndicatorsView* child, unsigned int stretchFactor);112 void AddPanelView(PanelIndicatorsView* child, unsigned int stretchFactor);
113
114 void OnDPIChanged();
113115
114 MockableBaseWindow* parent_;116 MockableBaseWindow* parent_;
115 indicator::Indicators::Ptr remote_;117 indicator::Indicators::Ptr remote_;
116118
=== modified file 'panel/StandalonePanel.cpp'
--- panel/StandalonePanel.cpp 2014-02-12 07:13:01 +0000
+++ panel/StandalonePanel.cpp 2014-02-19 01:47:39 +0000
@@ -89,7 +89,7 @@
89 panel_window->ShowWindow(true);89 panel_window->ShowWindow(true);
90 panel_window->SetWidth(1024);90 panel_window->SetWidth(1024);
91 panel_window->SetXY(0, 0);91 panel_window->SetXY(0, 0);
92 panel_window->SetMaximumHeight(panel_style.panel_height());92 panel_window->SetMaximumHeight(panel_style.PanelHeight());
9393
94 wt->window_configuration.connect([this] (int x, int y, int w, int h) {94 wt->window_configuration.connect([this] (int x, int y, int w, int h) {
95 panel_window->SetWidth(w);95 panel_window->SetWidth(w);
9696
=== modified file 'plugins/unityshell/src/unityshell.cpp'
--- plugins/unityshell/src/unityshell.cpp 2014-02-17 23:31:02 +0000
+++ plugins/unityshell/src/unityshell.cpp 2014-02-19 01:47:39 +0000
@@ -628,7 +628,8 @@
628 if (_shadow_texture.empty ())628 if (_shadow_texture.empty ())
629 return;629 return;
630630
631 float panel_h = static_cast<float>(panel_style_.panel_height);631 int monitor = PluginAdapter::Default().MonitorGeometryIn(NuxGeometryFromCompRect(output));
632 float panel_h = static_cast<float>(panel_style_.PanelHeight(monitor));
632 float shadowX = output.x();633 float shadowX = output.x();
633 float shadowY = output.y() + panel_h;634 float shadowY = output.y() + panel_h;
634 float shadowWidth = output.width();635 float shadowWidth = output.width();
@@ -907,7 +908,9 @@
907908
908 nux::TexCoordXForm texxform;909 nux::TexCoordXForm texxform;
909 texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_CLAMP);910 texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_CLAMP);
910 int panel_height = panel_style_.panel_height;911
912 // FIXME Change to paint per monitor vs all at once
913 int panel_height = panel_style_.PanelHeight();
911 auto const& texture = panel_style_.GetBackground()->GetDeviceTexture();914 auto const& texture = panel_style_.GetBackground()->GetDeviceTexture();
912 graphics_engine->QRP_GLSL_1Tex(0, 0, screen->width(), panel_height, texture, texxform, nux::color::White);915 graphics_engine->QRP_GLSL_1Tex(0, 0, screen->width(), panel_height, texture, texxform, nux::color::White);
913}916}
@@ -2907,9 +2910,11 @@
2907 !(window->state() & CompWindowStateFullscreenMask) &&2910 !(window->state() & CompWindowStateFullscreenMask) &&
2908 !(window->type() & CompWindowTypeFullscreenMask))2911 !(window->type() & CompWindowTypeFullscreenMask))
2909 {2912 {
2913 WindowManager& wm = WindowManager::Default();
2910 auto const& output = uScreen->screen->currentOutputDev();2914 auto const& output = uScreen->screen->currentOutputDev();
2915 int monitor = wm.MonitorGeometryIn(NuxGeometryFromCompRect(output));
29112916
2912 if (window->y() - window->border().top < output.y() + uScreen->panel_style_.panel_height)2917 if (window->y() - window->border().top < output.y() + uScreen->panel_style_.PanelHeight(monitor))
2913 {2918 {
2914 draw_panel_shadow = DrawPanelShadow::OVER_WINDOW;2919 draw_panel_shadow = DrawPanelShadow::OVER_WINDOW;
2915 }2920 }
@@ -3622,7 +3627,7 @@
3622 hud_controller_->launcher_width = launcher_width;3627 hud_controller_->launcher_width = launcher_width;
3623 dash_controller_->launcher_width = launcher_width;3628 dash_controller_->launcher_width = launcher_width;
3624 panel_controller_->launcher_width = launcher_width;3629 panel_controller_->launcher_width = launcher_width;
3625 shortcut_controller_->SetAdjustment(launcher_width, panel_style_.panel_height);3630 shortcut_controller_->SetAdjustment(launcher_width, panel_style_.PanelHeight());
36263631
3627 CompOption::Value v(launcher_width);3632 CompOption::Value v(launcher_width);
3628 screen->setOptionForPlugin("expo", "x_offset", v);3633 screen->setOptionForPlugin("expo", "x_offset", v);
36293634
=== modified file 'tests/test_em_converter.cpp'
--- tests/test_em_converter.cpp 2014-01-29 22:40:20 +0000
+++ tests/test_em_converter.cpp 2014-02-19 01:47:39 +0000
@@ -64,7 +64,7 @@
6464
65TEST_F(TestEMConverter, TestConvertPixel)65TEST_F(TestEMConverter, TestConvertPixel)
66{66{
67 EXPECT_EQ(PIXEL_SIZE, em_converter.ConvertPixels(PIXEL_SIZE));67 EXPECT_EQ(PIXEL_SIZE, em_converter.CP(PIXEL_SIZE));
68}68}
6969
70TEST_F(TestEMConverter, TestDPIScale)70TEST_F(TestEMConverter, TestDPIScale)
7171
=== modified file 'tests/test_launcher_controller.cpp'
--- tests/test_launcher_controller.cpp 2013-11-06 11:21:43 +0000
+++ tests/test_launcher_controller.cpp 2014-02-19 01:47:39 +0000
@@ -464,8 +464,8 @@
464 auto const& monitor_geo = uscreen.GetMonitorGeometry(i);464 auto const& monitor_geo = uscreen.GetMonitorGeometry(i);
465 auto const& launcher_geo = lc.launchers()[i]->GetAbsoluteGeometry();465 auto const& launcher_geo = lc.launchers()[i]->GetAbsoluteGeometry();
466 ASSERT_EQ(launcher_geo.x, monitor_geo.x);466 ASSERT_EQ(launcher_geo.x, monitor_geo.x);
467 ASSERT_EQ(launcher_geo.y, monitor_geo.y + panel_style.panel_height);467 ASSERT_EQ(launcher_geo.y, monitor_geo.y + panel_style.PanelHeight(i));
468 ASSERT_EQ(launcher_geo.height, monitor_geo.height - panel_style.panel_height);468 ASSERT_EQ(launcher_geo.height, monitor_geo.height - panel_style.PanelHeight(i));
469 }469 }
470}470}
471471
@@ -476,15 +476,15 @@
476 uscreen.SetMonitors({monitor_geo});476 uscreen.SetMonitors({monitor_geo});
477 nux::Geometry launcher_geo = lc.launcher().GetAbsoluteGeometry();477 nux::Geometry launcher_geo = lc.launcher().GetAbsoluteGeometry();
478 ASSERT_EQ(launcher_geo.x, monitor_geo.x);478 ASSERT_EQ(launcher_geo.x, monitor_geo.x);
479 ASSERT_EQ(launcher_geo.y, monitor_geo.y + panel_style.panel_height);479 ASSERT_EQ(launcher_geo.y, monitor_geo.y + panel_style.PanelHeight());
480 ASSERT_EQ(launcher_geo.height, monitor_geo.height - panel_style.panel_height);480 ASSERT_EQ(launcher_geo.height, monitor_geo.height - panel_style.PanelHeight());
481481
482 uscreen.Reset();482 uscreen.Reset();
483 monitor_geo = uscreen.GetMonitorGeometry(0);483 monitor_geo = uscreen.GetMonitorGeometry(0);
484 launcher_geo = lc.launcher().GetAbsoluteGeometry();484 launcher_geo = lc.launcher().GetAbsoluteGeometry();
485 ASSERT_EQ(launcher_geo.x, monitor_geo.x);485 ASSERT_EQ(launcher_geo.x, monitor_geo.x);
486 ASSERT_EQ(launcher_geo.y, monitor_geo.y + panel_style.panel_height);486 ASSERT_EQ(launcher_geo.y, monitor_geo.y + panel_style.PanelHeight());
487 ASSERT_EQ(launcher_geo.height, monitor_geo.height - panel_style.panel_height);487 ASSERT_EQ(launcher_geo.height, monitor_geo.height - panel_style.PanelHeight());
488}488}
489489
490TEST_F(TestLauncherController, IconCentersResetsOnMonitorsUpdated)490TEST_F(TestLauncherController, IconCentersResetsOnMonitorsUpdated)
491491
=== modified file 'tests/test_panel_controller.cpp'
--- tests/test_panel_controller.cpp 2014-02-12 07:13:01 +0000
+++ tests/test_panel_controller.cpp 2014-02-19 01:47:39 +0000
@@ -148,7 +148,7 @@
148 ASSERT_EQ(panel_geo.x, monitor_geo.x);148 ASSERT_EQ(panel_geo.x, monitor_geo.x);
149 ASSERT_EQ(panel_geo.y, monitor_geo.y);149 ASSERT_EQ(panel_geo.y, monitor_geo.y);
150 ASSERT_EQ(panel_geo.width, monitor_geo.width);150 ASSERT_EQ(panel_geo.width, monitor_geo.width);
151 ASSERT_EQ(panel_geo.height, panel_style.panel_height);151 ASSERT_EQ(panel_geo.height, panel_style.PanelHeight(i));
152 }152 }
153 }153 }
154}154}
@@ -164,7 +164,7 @@
164 ASSERT_EQ(panel_geo.x, monitor_geo.x);164 ASSERT_EQ(panel_geo.x, monitor_geo.x);
165 ASSERT_EQ(panel_geo.y, monitor_geo.y);165 ASSERT_EQ(panel_geo.y, monitor_geo.y);
166 ASSERT_EQ(panel_geo.width, monitor_geo.width);166 ASSERT_EQ(panel_geo.width, monitor_geo.width);
167 ASSERT_EQ(panel_geo.height, panel_style.panel_height);167 ASSERT_EQ(panel_geo.height, panel_style.PanelHeight());
168168
169 uscreen.Reset();169 uscreen.Reset();
170 monitor_geo = uscreen.GetMonitorGeometry(0);170 monitor_geo = uscreen.GetMonitorGeometry(0);
@@ -172,7 +172,7 @@
172 ASSERT_EQ(panel_geo.x, monitor_geo.x);172 ASSERT_EQ(panel_geo.x, monitor_geo.x);
173 ASSERT_EQ(panel_geo.y, monitor_geo.y);173 ASSERT_EQ(panel_geo.y, monitor_geo.y);
174 ASSERT_EQ(panel_geo.width, monitor_geo.width);174 ASSERT_EQ(panel_geo.width, monitor_geo.width);
175 ASSERT_EQ(panel_geo.height, panel_style.panel_height);175 ASSERT_EQ(panel_geo.height, panel_style.PanelHeight());
176}176}
177177
178TEST_F(TestPanelController, MultiMonitorEdgeBarrierSubscriptions)178TEST_F(TestPanelController, MultiMonitorEdgeBarrierSubscriptions)
179179
=== modified file 'tests/test_panel_indicator_entry_dropdown_view.cpp'
--- tests/test_panel_indicator_entry_dropdown_view.cpp 2014-01-30 19:46:58 +0000
+++ tests/test_panel_indicator_entry_dropdown_view.cpp 2014-02-19 01:47:39 +0000
@@ -230,7 +230,7 @@
230 }230 }
231231
232 auto const& geo = dropdown.GetGeometry();232 auto const& geo = dropdown.GetGeometry();
233 EXPECT_CALL(*indicators_, ShowEntriesDropdown(entries, Entry::Ptr(), 0, geo.x, geo.y + Style::Instance().panel_height));233 EXPECT_CALL(*indicators_, ShowEntriesDropdown(entries, Entry::Ptr(), 0, geo.x, geo.y + Style::Instance().PanelHeight()));
234 dropdown.ShowMenu();234 dropdown.ShowMenu();
235}235}
236236
@@ -249,7 +249,7 @@
249 auto active = views[g_random_int() % views.size()];249 auto active = views[g_random_int() % views.size()];
250 auto const& geo = dropdown.GetGeometry();250 auto const& geo = dropdown.GetGeometry();
251251
252 EXPECT_CALL(*indicators_, ShowEntriesDropdown(entries, active->GetEntry(), 0, geo.x, geo.y + Style::Instance().panel_height));252 EXPECT_CALL(*indicators_, ShowEntriesDropdown(entries, active->GetEntry(), 0, geo.x, geo.y + Style::Instance().PanelHeight()));
253 dropdown.ActivateChild(active);253 dropdown.ActivateChild(active);
254}254}
255255
256256
=== modified file 'tests/test_panel_menu_view.cpp'
--- tests/test_panel_menu_view.cpp 2014-02-17 15:36:53 +0000
+++ tests/test_panel_menu_view.cpp 2014-02-19 01:47:39 +0000
@@ -61,7 +61,7 @@
61 nux::ObjectPtr<nux::BaseWindow> panel_win(new nux::BaseWindow());61 nux::ObjectPtr<nux::BaseWindow> panel_win(new nux::BaseWindow());
62 auto const& monitor_geo = uscreen.GetMonitorGeometry(monitor);62 auto const& monitor_geo = uscreen.GetMonitorGeometry(monitor);
63 panel_win->SetGeometry(monitor_geo);63 panel_win->SetGeometry(monitor_geo);
64 panel_win->SetMaximumHeight(panelStyle.panel_height());64 panel_win->SetMaximumHeight(panelStyle.PanelHeight(monitor));
65 panel_win->SetLayout(new nux::HLayout(NUX_TRACKER_LOCATION));65 panel_win->SetLayout(new nux::HLayout(NUX_TRACKER_LOCATION));
66 panel_win->GetLayout()->AddView(&menu_view, 1);66 panel_win->GetLayout()->AddView(&menu_view, 1);
67 panel_win->GetLayout()->SetContentDistribution(nux::MAJOR_POSITION_START);67 panel_win->GetLayout()->SetContentDistribution(nux::MAJOR_POSITION_START);
6868
=== modified file 'tests/test_panel_style.cpp'
--- tests/test_panel_style.cpp 2013-07-09 04:29:25 +0000
+++ tests/test_panel_style.cpp 2014-02-19 01:47:39 +0000
@@ -27,6 +27,8 @@
27#include "unity-shared/UnitySettings.h"27#include "unity-shared/UnitySettings.h"
28#include "test_utils.h"28#include "test_utils.h"
2929
30#include "MultiMonitor.h"
31
30using namespace unity;32using namespace unity;
31using namespace testing;33using namespace testing;
3234
@@ -83,4 +85,14 @@
83 g_free (old_font);85 g_free (old_font);
84}86}
8587
88TEST_F(TestPanelStyle, TestPanelHeightUnderBounds)
89{
90 ASSERT_EQ(panel_style_instance->PanelHeight(-1), 0);
91}
92
93TEST_F(TestPanelStyle, TestPanelHeightOverBounds)
94{
95 ASSERT_EQ(panel_style_instance->PanelHeight(monitors::MAX), 0);
96}
97
86}98}
8799
=== modified file 'tests/test_raw_pixel.cpp'
--- tests/test_raw_pixel.cpp 2014-02-07 21:50:15 +0000
+++ tests/test_raw_pixel.cpp 2014-02-19 01:47:39 +0000
@@ -32,13 +32,13 @@
32{32{
33public:33public:
34 TestRawPixel()34 TestRawPixel()
35 : cv(FONT_SIZE, DPI)35 : cv(std::make_shared<EMConverter>(FONT_SIZE, DPI))
36 , p_i(10_em)36 , p_i(10_em)
37 , p_f(10.0_em)37 , p_f(10.0_em)
38 {38 {
39 }39 }
4040
41 EMConverter cv;41 EMConverter::Ptr cv;
42 RawPixel p_i;42 RawPixel p_i;
43 RawPixel p_f;43 RawPixel p_f;
44};44};
@@ -67,7 +67,7 @@
6767
68TEST_F(TestRawPixel, TestConverterTimesTwo)68TEST_F(TestRawPixel, TestConverterTimesTwo)
69{69{
70 cv.SetDPI(DPI * 2);70 cv->SetDPI(DPI * 2);
71 ASSERT_EQ(p_i.CP(cv), 20);71 ASSERT_EQ(p_i.CP(cv), 20);
72}72}
7373
7474
=== modified file 'unity-shared/EMConverter.cpp'
--- unity-shared/EMConverter.cpp 2014-02-07 21:50:15 +0000
+++ unity-shared/EMConverter.cpp 2014-02-19 01:47:39 +0000
@@ -96,7 +96,7 @@
96 return (pixels / base_pixels_per_em_);96 return (pixels / base_pixels_per_em_);
97}97}
9898
99double EMConverter::ConvertPixels(int pixels) const99double EMConverter::CP(int pixels) const
100{100{
101 double pixels_em = PixelsToBaseEM(pixels);101 double pixels_em = PixelsToBaseEM(pixels);
102 return EMToPixels(pixels_em);102 return EMToPixels(pixels_em);
103103
=== modified file 'unity-shared/EMConverter.h'
--- unity-shared/EMConverter.h 2014-02-07 21:50:15 +0000
+++ unity-shared/EMConverter.h 2014-02-19 01:47:39 +0000
@@ -20,12 +20,16 @@
20#ifndef EM_CONVERTER_H20#ifndef EM_CONVERTER_H
21#define EM_CONVERTER_H21#define EM_CONVERTER_H
2222
23#include <memory>
24
23namespace unity25namespace unity
24{26{
2527
26class EMConverter28class EMConverter
27{29{
28public:30public:
31 typedef std::shared_ptr<EMConverter> Ptr;
32
29 EMConverter(int font_size = 0, double dpi = 96.0);33 EMConverter(int font_size = 0, double dpi = 96.0);
3034
31 void SetFontSize(int font_size);35 void SetFontSize(int font_size);
@@ -34,7 +38,7 @@
34 int GetFontSize() const;38 int GetFontSize() const;
35 double GetDPI() const;39 double GetDPI() const;
3640
37 double ConvertPixels(int pixels) const;41 double CP(int pixels) const;
38 double DPIScale() const;42 double DPIScale() const;
3943
40 double PtToPx(int pt);44 double PtToPx(int pt);
4145
=== modified file 'unity-shared/OverlayWindowButtons.cpp'
--- unity-shared/OverlayWindowButtons.cpp 2014-02-10 15:31:44 +0000
+++ unity-shared/OverlayWindowButtons.cpp 2014-02-19 01:47:39 +0000
@@ -60,7 +60,7 @@
6060
61 SetX(geo.x + MAIN_LEFT_PADDING);61 SetX(geo.x + MAIN_LEFT_PADDING);
62 SetY(geo.y + MENUBAR_PADDING);62 SetY(geo.y + MENUBAR_PADDING);
63 SetHeight(panel::Style::Instance().panel_height);63 SetHeight(panel::Style::Instance().PanelHeight(monitor));
6464
65 window_buttons_->monitor = monitor;65 window_buttons_->monitor = monitor;
66}66}
6767
=== modified file 'unity-shared/PanelStyle.cpp'
--- unity-shared/PanelStyle.cpp 2014-01-16 13:20:16 +0000
+++ unity-shared/PanelStyle.cpp 2014-02-19 01:47:39 +0000
@@ -27,6 +27,8 @@
27#include "unity-shared/TextureCache.h"27#include "unity-shared/TextureCache.h"
28#include "unity-shared/UnitySettings.h"28#include "unity-shared/UnitySettings.h"
2929
30#include "MultiMonitor.h"
31
30namespace unity32namespace unity
31{33{
32namespace panel34namespace panel
@@ -38,6 +40,7 @@
38DECLARE_LOGGER(logger, "unity.panel.style");40DECLARE_LOGGER(logger, "unity.panel.style");
39const int BUTTONS_SIZE = 16;41const int BUTTONS_SIZE = 16;
40const int BUTTONS_PADDING = 1;42const int BUTTONS_PADDING = 1;
43const int BASE_PANEL_HEIGHT = 24;
4144
42std::string button_id(WindowButtonType type, WindowState ws)45std::string button_id(WindowButtonType type, WindowState ws)
43{46{
@@ -50,8 +53,8 @@
50}53}
5154
52Style::Style()55Style::Style()
53 : panel_height(24)56 : style_context_(gtk_style_context_new())
54 , style_context_(gtk_style_context_new())57 , panel_heights_(monitors::MAX, BASE_PANEL_HEIGHT)
55{58{
56 if (style_instance)59 if (style_instance)
57 {60 {
@@ -62,15 +65,6 @@
62 style_instance = this;65 style_instance = this;
63 }66 }
6467
65 if (Settings::Instance().form_factor() == FormFactor::TV)
66 panel_height = 0;
67
68 Settings::Instance().form_factor.changed.connect([this](FormFactor form_factor)
69 {
70 if (form_factor == FormFactor::TV)
71 panel_height = 0;
72 });
73
74 GtkWidgetPath* widget_path = gtk_widget_path_new();68 GtkWidgetPath* widget_path = gtk_widget_path_new();
75 gint pos = gtk_widget_path_append_type(widget_path, GTK_TYPE_WINDOW);69 gint pos = gtk_widget_path_append_type(widget_path, GTK_TYPE_WINDOW);
76 gtk_widget_path_iter_set_name(widget_path, pos, "UnityPanelWidget");70 gtk_widget_path_iter_set_name(widget_path, pos, "UnityPanelWidget");
@@ -115,10 +109,23 @@
115 RefreshContext();109 RefreshContext();
116}110}
117111
112int Style::PanelHeight(int monitor) const
113{
114 if (monitor < 0 || monitor >= (int)monitors::MAX)
115 {
116 LOG_ERROR(logger) << "Invalid monitor index: " << monitor;
117 return 0;
118 }
119
120 EMConverter::Ptr const& cv = unity::Settings::Instance().em(monitor);
121 return panel_heights_[monitor].CP(cv);
122}
123
118void Style::RefreshContext()124void Style::RefreshContext()
119{125{
120 gtk_style_context_invalidate(style_context_);126 gtk_style_context_invalidate(style_context_);
121 bg_texture_.Release();127 bg_texture_.Release();
128
122 changed.emit();129 changed.emit();
123}130}
124131
@@ -127,13 +134,13 @@
127 return style_context_;134 return style_context_;
128}135}
129136
130BaseTexturePtr Style::GetBackground()137BaseTexturePtr Style::GetBackground(int monitor)
131{138{
132 if (bg_texture_)139 if (bg_texture_)
133 return bg_texture_;140 return bg_texture_;
134141
135 int width = 1;142 int width = 1;
136 int height = panel_height();143 int height = PanelHeight(monitor);
137144
138 nux::CairoGraphics context(CAIRO_FORMAT_ARGB32, width, height);145 nux::CairoGraphics context(CAIRO_FORMAT_ARGB32, width, height);
139146
140147
=== modified file 'unity-shared/PanelStyle.h'
--- unity-shared/PanelStyle.h 2014-01-14 17:18:17 +0000
+++ unity-shared/PanelStyle.h 2014-02-19 01:47:39 +0000
@@ -28,6 +28,9 @@
28#include <gtk/gtk.h>28#include <gtk/gtk.h>
29#include <UnityCore/GLibWrapper.h>29#include <UnityCore/GLibWrapper.h>
3030
31#include "unity-shared/EMConverter.h"
32#include "unity-shared/RawPixel.h"
33
31namespace unity34namespace unity
32{35{
33namespace decoration36namespace decoration
@@ -57,23 +60,28 @@
5760
58 static Style& Instance();61 static Style& Instance();
5962
60 nux::Property<int> panel_height;
61
62 GtkStyleContext* GetStyleContext();63 GtkStyleContext* GetStyleContext();
63 BaseTexturePtr GetBackground();64 BaseTexturePtr GetBackground(int monitor = 0);
64 BaseTexturePtr GetWindowButton(WindowButtonType type, WindowState state);65 BaseTexturePtr GetWindowButton(WindowButtonType type, WindowState state);
65 BaseTexturePtr GetFallbackWindowButton(WindowButtonType type, WindowState state);66 BaseTexturePtr GetFallbackWindowButton(WindowButtonType type, WindowState state);
66 std::string GetFontDescription(PanelItem item);67 std::string GetFontDescription(PanelItem item);
67 int GetTextDPI();68 int GetTextDPI();
6869
70 int PanelHeight(int monitor = 0) const;
71
69 sigc::signal<void> changed;72 sigc::signal<void> changed;
7073
71private:74private:
72 void OnThemeChanged(std::string const&);75 void OnThemeChanged(std::string const&);
73 void RefreshContext();76 void RefreshContext();
7477
78 void UpdateFontSize();
79 void UpdatePanelHeight();
80
75 glib::Object<GtkStyleContext> style_context_;81 glib::Object<GtkStyleContext> style_context_;
76 BaseTexturePtr bg_texture_;82 BaseTexturePtr bg_texture_;
83
84 std::vector<RawPixel> panel_heights_;
77};85};
7886
79}87}
8088
=== modified file 'unity-shared/PluginAdapter.cpp'
--- unity-shared/PluginAdapter.cpp 2014-02-18 00:59:30 +0000
+++ unity-shared/PluginAdapter.cpp 2014-02-19 01:47:39 +0000
@@ -23,6 +23,7 @@
23#include "DecorationStyle.h"23#include "DecorationStyle.h"
24#include "PluginAdapter.h"24#include "PluginAdapter.h"
25#include "CompizUtils.h"25#include "CompizUtils.h"
26#include "MultiMonitor.h"
2627
27#include <scale/scale.h>28#include <scale/scale.h>
28#include <NuxCore/Logger.h>29#include <NuxCore/Logger.h>
@@ -411,6 +412,20 @@
411 return ret;412 return ret;
412}413}
413414
415int PluginAdapter::MonitorGeometryIn(nux::Geometry const& geo) const
416{
417 std::vector<nux::Geometry> const& monitors = unity::UScreen::GetDefault()->GetMonitors();
418 for (unsigned i = 0; i < monitors.size(); ++i)
419 {
420 nux::Geometry const& i_g = geo.Intersect(monitors[i]);
421
422 if (i_g.width > 0 && i_g.height > 0)
423 return i;
424 }
425
426 return 0;
427}
428
414bool PluginAdapter::IsTopWindowFullscreenOnMonitorWithMouse() const429bool PluginAdapter::IsTopWindowFullscreenOnMonitorWithMouse() const
415{430{
416 int monitor = unity::UScreen::GetDefault()->GetMonitorWithMouse();431 int monitor = unity::UScreen::GetDefault()->GetMonitorWithMouse();
417432
=== modified file 'unity-shared/PluginAdapter.h'
--- unity-shared/PluginAdapter.h 2014-02-15 14:46:47 +0000
+++ unity-shared/PluginAdapter.h 2014-02-19 01:47:39 +0000
@@ -115,6 +115,7 @@
115 Window GetActiveWindow() const;115 Window GetActiveWindow() const;
116 std::vector<Window> GetWindowsInStackingOrder() const override;116 std::vector<Window> GetWindowsInStackingOrder() const override;
117117
118 int MonitorGeometryIn(nux::Geometry const& geo) const override;
118 bool IsTopWindowFullscreenOnMonitorWithMouse() const override;119 bool IsTopWindowFullscreenOnMonitorWithMouse() const override;
119120
120 // WindowManager implementation121 // WindowManager implementation
121122
=== modified file 'unity-shared/RawPixel.cpp'
--- unity-shared/RawPixel.cpp 2014-02-07 21:50:15 +0000
+++ unity-shared/RawPixel.cpp 2014-02-19 01:47:39 +0000
@@ -37,9 +37,9 @@
37{37{
38}38}
3939
40float RawPixel::CP(EMConverter const& converter) const40float RawPixel::CP(EMConverter::Ptr const& converter) const
41{41{
42 return converter.ConvertPixels(raw_pixel_);42 return converter->CP(raw_pixel_);
43}43}
4444
45RawPixel::operator float() const45RawPixel::operator float() const
4646
=== modified file 'unity-shared/RawPixel.h'
--- unity-shared/RawPixel.h 2014-02-07 21:50:15 +0000
+++ unity-shared/RawPixel.h 2014-02-19 01:47:39 +0000
@@ -30,7 +30,7 @@
30public:30public:
31 RawPixel(float raw_pixel);31 RawPixel(float raw_pixel);
3232
33 float CP(EMConverter const& converter) const;33 float CP(EMConverter::Ptr const& converter) const;
3434
35 operator float() const;35 operator float() const;
3636
3737
=== modified file 'unity-shared/StandaloneWindowManager.cpp'
--- unity-shared/StandaloneWindowManager.cpp 2014-02-17 15:22:39 +0000
+++ unity-shared/StandaloneWindowManager.cpp 2014-02-19 01:47:39 +0000
@@ -129,6 +129,12 @@
129129
130 return ret;130 return ret;
131}131}
132
133int StandaloneWindowManager::MonitorGeometryIn(nux::Geometry const& geo) const
134{
135 // TODO
136 return 0;
137}
132138
133bool StandaloneWindowManager::IsTopWindowFullscreenOnMonitorWithMouse() const139bool StandaloneWindowManager::IsTopWindowFullscreenOnMonitorWithMouse() const
134{140{
135141
=== modified file 'unity-shared/StandaloneWindowManager.h'
--- unity-shared/StandaloneWindowManager.h 2014-02-14 03:05:02 +0000
+++ unity-shared/StandaloneWindowManager.h 2014-02-19 01:47:39 +0000
@@ -71,6 +71,7 @@
71 virtual Window GetActiveWindow() const;71 virtual Window GetActiveWindow() const;
72 std::vector<Window> GetWindowsInStackingOrder() const override;72 std::vector<Window> GetWindowsInStackingOrder() const override;
7373
74 virtual int MonitorGeometryIn(nux::Geometry const& geo) const override;
74 virtual bool IsTopWindowFullscreenOnMonitorWithMouse() const override;75 virtual bool IsTopWindowFullscreenOnMonitorWithMouse() const override;
7576
76 virtual bool IsWindowMaximized(Window window_id) const;77 virtual bool IsWindowMaximized(Window window_id) const;
7778
=== modified file 'unity-shared/UnitySettings.cpp'
--- unity-shared/UnitySettings.cpp 2014-01-31 21:20:30 +0000
+++ unity-shared/UnitySettings.cpp 2014-02-19 01:47:39 +0000
@@ -39,6 +39,10 @@
39const std::string SETTINGS_NAME = "com.canonical.Unity";39const std::string SETTINGS_NAME = "com.canonical.Unity";
40const std::string FORM_FACTOR = "form-factor";40const std::string FORM_FACTOR = "form-factor";
41const std::string DOUBLE_CLICK_ACTIVATE = "double-click-activate";41const std::string DOUBLE_CLICK_ACTIVATE = "double-click-activate";
42
43// FIXME Remove me when hikikos settings changes land in unity
44const std::string GNOME_SETTINGS = "org.gnome.desktop.interface";
45const std::string TEXT_SCALING_FACTOR = "text-scaling-factor";
42}46}
4347
44//48//
@@ -50,11 +54,14 @@
50 Impl(Settings* owner)54 Impl(Settings* owner)
51 : parent_(owner)55 : parent_(owner)
52 , gsettings_(g_settings_new(SETTINGS_NAME.c_str()))56 , gsettings_(g_settings_new(SETTINGS_NAME.c_str()))
57 , gnome_settings_(g_settings_new(GNOME_SETTINGS.c_str()))
53 , cached_form_factor_(FormFactor::DESKTOP)58 , cached_form_factor_(FormFactor::DESKTOP)
54 , cached_double_click_activate_(true)59 , cached_double_click_activate_(true)
55 , lowGfx_(false)60 , lowGfx_(false)
56 , em_converters_(monitors::MAX)
57 {61 {
62 for (int i = 0; i < (int)monitors::MAX; i++)
63 em_converters_.push_back(std::make_shared<EMConverter>());
64
58 CacheFormFactor();65 CacheFormFactor();
59 CacheDoubleClickActivate();66 CacheDoubleClickActivate();
6067
@@ -67,6 +74,10 @@
67 parent_->double_click_activate.changed.emit(cached_double_click_activate_);74 parent_->double_click_activate.changed.emit(cached_double_click_activate_);
68 });75 });
6976
77 signals_.Add<void, GSettings*, const gchar*>(gnome_settings_, "changed::" + TEXT_SCALING_FACTOR, [this] (GSettings*, const gchar* t) {
78 UpdateEMConverter();
79 });
80
70 UpdateEMConverter();81 UpdateEMConverter();
71 }82 }
7283
@@ -124,10 +135,10 @@
124 // FIXME Add in getting the specific dpi scale from each monitor135 // FIXME Add in getting the specific dpi scale from each monitor
125 int GetDPI(int monitor = 0) const136 int GetDPI(int monitor = 0) const
126 {137 {
127 int dpi = 0;138 int dpi = 96;
128 g_object_get(gtk_settings_get_default(), "gtk-xft-dpi", &dpi, nullptr);139 float scale = g_settings_get_double(gnome_settings_, TEXT_SCALING_FACTOR.c_str());
129140
130 return dpi / 1024;141 return dpi * scale;
131 }142 }
132143
133 void UpdateFontSize()144 void UpdateFontSize()
@@ -135,7 +146,7 @@
135 int font_size = GetFontSize();146 int font_size = GetFontSize();
136147
137 for (auto& em : em_converters_)148 for (auto& em : em_converters_)
138 em.SetFontSize(font_size);149 em->SetFontSize(font_size);
139 }150 }
140151
141 void UpdateDPI()152 void UpdateDPI()
@@ -143,8 +154,10 @@
143 for (int i = 0; i < (int)em_converters_.size(); ++i)154 for (int i = 0; i < (int)em_converters_.size(); ++i)
144 {155 {
145 int dpi = GetDPI(i);156 int dpi = GetDPI(i);
146 em_converters_[i].SetDPI(dpi);157 em_converters_[i]->SetDPI(dpi);
147 }158 }
159
160 parent_->dpi_changed.emit();
148 }161 }
149162
150 void UpdateEMConverter()163 void UpdateEMConverter()
@@ -155,6 +168,7 @@
155168
156 Settings* parent_;169 Settings* parent_;
157 glib::Object<GSettings> gsettings_;170 glib::Object<GSettings> gsettings_;
171 glib::Object<GSettings> gnome_settings_;
158 FormFactor cached_form_factor_;172 FormFactor cached_form_factor_;
159 bool cached_double_click_activate_;173 bool cached_double_click_activate_;
160 bool lowGfx_;174 bool lowGfx_;
@@ -162,7 +176,8 @@
162 glib::Signal<void, GSettings*, gchar* > form_factor_changed_;176 glib::Signal<void, GSettings*, gchar* > form_factor_changed_;
163 glib::Signal<void, GSettings*, gchar* > double_click_activate_changed_;177 glib::Signal<void, GSettings*, gchar* > double_click_activate_changed_;
164178
165 std::vector<EMConverter> em_converters_;179 glib::SignalManager signals_;
180 std::vector<EMConverter::Ptr> em_converters_;
166};181};
167182
168//183//
@@ -215,7 +230,7 @@
215 pimpl->lowGfx_ = low_gfx;230 pimpl->lowGfx_ = low_gfx;
216}231}
217232
218EMConverter const& Settings::em(int monitor) const233EMConverter::Ptr const& Settings::em(int monitor) const
219{234{
220 if (monitor < 0 || monitor >= (int)monitors::MAX)235 if (monitor < 0 || monitor >= (int)monitors::MAX)
221 {236 {
222237
=== modified file 'unity-shared/UnitySettings.h'
--- unity-shared/UnitySettings.h 2014-01-31 21:01:53 +0000
+++ unity-shared/UnitySettings.h 2014-02-19 01:47:39 +0000
@@ -51,7 +51,8 @@
51 nux::Property<bool> is_standalone;51 nux::Property<bool> is_standalone;
52 nux::ROProperty<bool> double_click_activate;52 nux::ROProperty<bool> double_click_activate;
5353
54 EMConverter const& em(int monitor = 0) const;54 sigc::signal<void> dpi_changed;
55 EMConverter::Ptr const& em(int monitor = 0) const;
5556
56private:57private:
57 class Impl;58 class Impl;
5859
=== modified file 'unity-shared/WindowButtonPriv.h'
--- unity-shared/WindowButtonPriv.h 2014-01-14 13:13:11 +0000
+++ unity-shared/WindowButtonPriv.h 2014-02-19 01:47:39 +0000
@@ -24,9 +24,11 @@
24#include <Nux/Button.h>24#include <Nux/Button.h>
2525
26#include "unity-shared/DecorationStyle.h"26#include "unity-shared/DecorationStyle.h"
27#include "unity-shared/Introspectable.h"
27#include "unity-shared/PanelStyle.h"28#include "unity-shared/PanelStyle.h"
29#include "unity-shared/RawPixel.h"
28#include "unity-shared/UBusWrapper.h"30#include "unity-shared/UBusWrapper.h"
29#include "unity-shared/Introspectable.h"31#include "unity-shared/UnitySettings.h"
3032
31namespace unity33namespace unity
32{34{
@@ -44,6 +46,9 @@
44 panel::WindowButtonType GetType() const;46 panel::WindowButtonType GetType() const;
45 void SetVisualState(nux::ButtonVisualState new_state);47 void SetVisualState(nux::ButtonVisualState new_state);
4648
49 void OnMonitorChanged(int monitor);
50 void UpdateDPIChanged();
51
47 nux::RWProperty<bool> enabled;52 nux::RWProperty<bool> enabled;
48 nux::Property<bool> overlay_mode;53 nux::Property<bool> overlay_mode;
4954
@@ -58,6 +63,8 @@
58 bool EnabledSetter(bool enabled);63 bool EnabledSetter(bool enabled);
59 static nux::ObjectPtr<nux::BaseTexture> GetDashWindowButton(panel::WindowButtonType type, panel::WindowState state);64 static nux::ObjectPtr<nux::BaseTexture> GetDashWindowButton(panel::WindowButtonType type, panel::WindowState state);
6065
66 void UpdateGeometry();
67
61 inline WindowButtons* Parent() const68 inline WindowButtons* Parent() const
62 {69 {
63 return static_cast<WindowButtons*>(GetParentObject());70 return static_cast<WindowButtons*>(GetParentObject());
@@ -66,6 +73,9 @@
66private:73private:
67 panel::WindowButtonType type_;74 panel::WindowButtonType type_;
6875
76 int monitor_;
77 EMConverter::Ptr cv_;
78
69 nux::ObjectPtr<nux::BaseTexture> normal_tex_;79 nux::ObjectPtr<nux::BaseTexture> normal_tex_;
70 nux::ObjectPtr<nux::BaseTexture> prelight_tex_;80 nux::ObjectPtr<nux::BaseTexture> prelight_tex_;
71 nux::ObjectPtr<nux::BaseTexture> pressed_tex_;81 nux::ObjectPtr<nux::BaseTexture> pressed_tex_;
7282
=== modified file 'unity-shared/WindowButtons.cpp'
--- unity-shared/WindowButtons.cpp 2014-02-15 17:33:02 +0000
+++ unity-shared/WindowButtons.cpp 2014-02-19 01:47:39 +0000
@@ -43,11 +43,25 @@
43 sigc::mem_fun(this, &WindowButton::EnabledSetter))43 sigc::mem_fun(this, &WindowButton::EnabledSetter))
44 , overlay_mode(false)44 , overlay_mode(false)
45 , type_(type)45 , type_(type)
46 , monitor_(0)
47 , cv_(unity::Settings::Instance().em(0))
46{48{
47 overlay_mode.changed.connect([this] (bool) { UpdateSize(); QueueDraw(); });49 overlay_mode.changed.connect([this] (bool) { UpdateSize(); QueueDraw(); });
48 SetAcceptKeyNavFocusOnMouseDown(false);50 SetAcceptKeyNavFocusOnMouseDown(false);
49 panel::Style::Instance().changed.connect(sigc::mem_fun(this, &WindowButton::LoadImages));51 panel::Style::Instance().changed.connect(sigc::mem_fun(this, &WindowButton::LoadImages));
50 LoadImages();52
53 LoadImages();
54}
55
56void WindowButton::UpdateDPIChanged()
57{
58 LoadImages();
59}
60
61void WindowButton::OnMonitorChanged(int monitor)
62{
63 monitor_ = monitor;
64 cv_ = unity::Settings::Instance().em(monitor);
51}65}
5266
53void WindowButton::SetVisualState(nux::ButtonVisualState new_state)67void WindowButton::SetVisualState(nux::ButtonVisualState new_state)
@@ -133,7 +147,7 @@
133147
134void WindowButton::UpdateSize()148void WindowButton::UpdateSize()
135{149{
136 int panel_height = panel::Style::Instance().panel_height;150 int panel_height = panel::Style::Instance().PanelHeight(monitor_);
137 nux::BaseTexture* tex;151 nux::BaseTexture* tex;
138 tex = (overlay_mode()) ? normal_dash_tex_.GetPointer() : normal_tex_.GetPointer();152 tex = (overlay_mode()) ? normal_dash_tex_.GetPointer() : normal_tex_.GetPointer();
139 int width = 0;153 int width = 0;
@@ -141,8 +155,10 @@
141155
142 if (tex)156 if (tex)
143 {157 {
144 width = std::min(panel_height, tex->GetWidth());158 int tex_w = RawPixel(tex->GetWidth()).CP(cv_);
145 height = std::min(panel_height, tex->GetHeight());159 int tex_h = RawPixel(tex->GetHeight()).CP(cv_);
160 width = std::min(panel_height, tex_w);
161 height = std::min(panel_height, tex_h);
146 }162 }
147163
148 SetMinMaxSize(width, height);164 SetMinMaxSize(width, height);
@@ -321,6 +337,20 @@
321 WindowManager::Default().terminate_spread.connect(sigc::mem_fun(this, &WindowButtons::OnSpreadTerminate));337 WindowManager::Default().terminate_spread.connect(sigc::mem_fun(this, &WindowButtons::OnSpreadTerminate));
322}338}
323339
340
341void WindowButtons::UpdateDPIChanged()
342{
343 for (auto area : GetChildren())
344 static_cast<internal::WindowButton*>(area)->UpdateDPIChanged();
345}
346
347void WindowButtons::OnMonitorChanged(int monitor)
348{
349 // Need to update the EMConverter in each window button if the monitor changes
350 for (auto area : GetChildren())
351 static_cast<internal::WindowButton*>(area)->OnMonitorChanged(monitor);
352}
353
324nux::Area* WindowButtons::FindAreaUnderMouse(const nux::Point& mouse, nux::NuxEventType event_type)354nux::Area* WindowButtons::FindAreaUnderMouse(const nux::Point& mouse, nux::NuxEventType event_type)
325{355{
326 if (!GetInputEventSensitivity())356 if (!GetInputEventSensitivity())
327357
=== modified file 'unity-shared/WindowButtons.h'
--- unity-shared/WindowButtons.h 2014-02-15 17:33:02 +0000
+++ unity-shared/WindowButtons.h 2014-02-19 01:47:39 +0000
@@ -44,6 +44,7 @@
44 nux::Property<bool> focused;44 nux::Property<bool> focused;
4545
46 bool IsMouseOwner();46 bool IsMouseOwner();
47 void UpdateDPIChanged();
47 virtual nux::Area* FindAreaUnderMouse(const nux::Point& mouse_pos, nux::NuxEventType event_type);48 virtual nux::Area* FindAreaUnderMouse(const nux::Point& mouse_pos, nux::NuxEventType event_type);
4849
49 sigc::signal<void> close_clicked;50 sigc::signal<void> close_clicked;
@@ -71,6 +72,7 @@
71 void OnControlledWindowChanged(Window xid);72 void OnControlledWindowChanged(Window xid);
72 void ResetNormalButtonState();73 void ResetNormalButtonState();
73 bool OpacitySetter(double& target, double new_value);74 bool OpacitySetter(double& target, double new_value);
75 void OnMonitorChanged(int monitor);
7476
75 std::string active_overlay_;77 std::string active_overlay_;
76 UBusManager ubus_manager_;78 UBusManager ubus_manager_;
7779
=== modified file 'unity-shared/WindowManager.h'
--- unity-shared/WindowManager.h 2014-02-14 03:05:02 +0000
+++ unity-shared/WindowManager.h 2014-02-19 01:47:39 +0000
@@ -77,6 +77,7 @@
77 virtual Window GetActiveWindow() const = 0;77 virtual Window GetActiveWindow() const = 0;
78 virtual std::vector<Window> GetWindowsInStackingOrder() const = 0;78 virtual std::vector<Window> GetWindowsInStackingOrder() const = 0;
7979
80 virtual int MonitorGeometryIn(nux::Geometry const& geo) const = 0;
80 virtual bool IsTopWindowFullscreenOnMonitorWithMouse() const = 0;81 virtual bool IsTopWindowFullscreenOnMonitorWithMouse() const = 0;
8182
82 virtual bool IsWindowMaximized(Window window_id) const = 0;83 virtual bool IsWindowMaximized(Window window_id) const = 0;