Merge lp:~3v1n0/unity/launchers-resize-new into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 3051
Proposed branch: lp:~3v1n0/unity/launchers-resize-new
Merge into: lp:unity
Prerequisite: lp:~3v1n0/unity/new-launcher-assets
Diff against target: 539 lines (+146/-75)
10 files modified
launcher/EdgeBarrierController.h (+1/-2)
launcher/Launcher.cpp (+26/-34)
launcher/Launcher.h (+2/-2)
launcher/LauncherController.cpp (+24/-10)
launcher/LauncherControllerPrivate.h (+1/-1)
launcher/LauncherOptions.cpp (+3/-1)
launcher/LauncherOptions.h (+2/-1)
launcher/StandaloneLauncher.cpp (+58/-18)
tests/test_launcher_controller.cpp (+24/-2)
tests/test_uscreen_mock.h (+5/-4)
To merge this branch: bzr merge lp:~3v1n0/unity/launchers-resize-new
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Andrea Azzarone (community) Approve
Review via email: mp+135816@code.launchpad.net

Commit message

Launcher: improve the monitor resizing and background color management, tune the standalone version.

Description of the change

Misc cleanup in Launcher, added a single property in options to manage the launcher background color, using the monitor property to handle monitor changes.

Improved the launcher standalone, so that the view now matches the window size.

Added new tests.

To post a comment you must log in.
Revision history for this message
Andrea Azzarone (azzar1) wrote :

LGTM. Can't see any regression here and all tests pass.

review: Approve
Revision history for this message
Andrea Azzarone (azzar1) wrote :

*regressions :)

Revision history for this message
MC Return (mc-return) wrote :

Approved on 2012-11-29.
Will this ever land ?
I guess something's wrong here :)

Revision history for this message
Martin Mrazik (mrazik) wrote :

This is weird as I have a watchdog which is looking for approved but unmerged MPs. The watchdog noticed this MP only after you made the comment so I assume there was something wrong on the launchpad side.

Revision history for this message
Martin Mrazik (mrazik) wrote :

Oh, now I actually see it. It didn't merge previously because the prerequisite was merged only a while ago.

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

This branch needs re-merging with trunk.

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)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'launcher/EdgeBarrierController.h'
--- launcher/EdgeBarrierController.h 2012-07-25 23:18:17 +0000
+++ launcher/EdgeBarrierController.h 2013-01-18 18:26:28 +0000
@@ -26,9 +26,8 @@
26namespace unity {26namespace unity {
27namespace ui {27namespace ui {
2828
29class EdgeBarrierSubscriber29struct EdgeBarrierSubscriber
30{30{
31public:
32 virtual bool HandleBarrierEvent(PointerBarrierWrapper* owner, BarrierEvent::Ptr event) = 0;31 virtual bool HandleBarrierEvent(PointerBarrierWrapper* owner, BarrierEvent::Ptr event) = 0;
33};32};
3433
3534
=== modified file 'launcher/Launcher.cpp'
--- launcher/Launcher.cpp 2013-01-17 23:44:13 +0000
+++ launcher/Launcher.cpp 2013-01-18 18:26:28 +0000
@@ -144,7 +144,7 @@
144 , _drag_gesture_ongoing(false)144 , _drag_gesture_ongoing(false)
145 , _last_reveal_progress(0.0f)145 , _last_reveal_progress(0.0f)
146 , _selection_atom(0)146 , _selection_atom(0)
147 , _background_color(nux::color::DimGray)147 , icon_renderer(std::make_shared<ui::IconRenderer>())
148{148{
149 m_Layout = new nux::HLayout(NUX_TRACKER_LOCATION);149 m_Layout = new nux::HLayout(NUX_TRACKER_LOCATION);
150150
@@ -190,13 +190,8 @@
190190
191 ubus_.RegisterInterest(UBUS_OVERLAY_SHOWN, sigc::mem_fun(this, &Launcher::OnOverlayShown));191 ubus_.RegisterInterest(UBUS_OVERLAY_SHOWN, sigc::mem_fun(this, &Launcher::OnOverlayShown));
192 ubus_.RegisterInterest(UBUS_OVERLAY_HIDDEN, sigc::mem_fun(this, &Launcher::OnOverlayHidden));192 ubus_.RegisterInterest(UBUS_OVERLAY_HIDDEN, sigc::mem_fun(this, &Launcher::OnOverlayHidden));
193 ubus_.RegisterInterest(UBUS_BACKGROUND_COLOR_CHANGED, sigc::mem_fun(this, &Launcher::OnBGColorChanged));
194 ubus_.RegisterInterest(UBUS_LAUNCHER_LOCK_HIDE, sigc::mem_fun(this, &Launcher::OnLockHideChanged));193 ubus_.RegisterInterest(UBUS_LAUNCHER_LOCK_HIDE, sigc::mem_fun(this, &Launcher::OnLockHideChanged));
195194
196 // request the latest colour from bghash
197 ubus_.SendMessage(UBUS_BACKGROUND_REQUEST_COLOUR_EMIT);
198
199 icon_renderer = ui::AbstractIconRenderer::Ptr(new ui::IconRenderer());
200 icon_renderer->SetTargetSize(_icon_size, _icon_image_size, _space_between_icons);195 icon_renderer->SetTargetSize(_icon_size, _icon_image_size, _space_between_icons);
201196
202 TextureCache& cache = TextureCache::GetDefault();197 TextureCache& cache = TextureCache::GetDefault();
@@ -208,6 +203,7 @@
208 launcher_pressure_effect_ = cache.FindTexture("launcher_pressure_effect", 0, 0, cb);203 launcher_pressure_effect_ = cache.FindTexture("launcher_pressure_effect", 0, 0, cb);
209204
210 options.changed.connect(sigc::mem_fun(this, &Launcher::OnOptionsChanged));205 options.changed.connect(sigc::mem_fun(this, &Launcher::OnOptionsChanged));
206 monitor.changed.connect(sigc::mem_fun(this, &Launcher::OnMonitorChanged));
211}207}
212208
213/* Introspection */209/* Introspection */
@@ -989,7 +985,7 @@
989 struct timespec current;985 struct timespec current;
990 clock_gettime(CLOCK_MONOTONIC, &current);986 clock_gettime(CLOCK_MONOTONIC, &current);
991987
992 nux::Color colorify = FullySaturateColor(_background_color);988 nux::Color const& colorify = FullySaturateColor(options()->background_color);
993989
994 float hover_progress = GetHoverProgress(current);990 float hover_progress = GetHoverProgress(current);
995 float folded_z_distance = _folded_z_distance * (1.0f - hover_progress);991 float folded_z_distance = _folded_z_distance * (1.0f - hover_progress);
@@ -1171,17 +1167,6 @@
1171 EnsureAnimation();1167 EnsureAnimation();
1172}1168}
11731169
1174void Launcher::OnBGColorChanged(GVariant *data)
1175{
1176 ui::IconRenderer::DestroyShortcutTextures();
1177
1178 double red = 0.0f, green = 0.0f, blue = 0.0f, alpha = 0.0f;
1179
1180 g_variant_get(data, "(dddd)", &red, &green, &blue, &alpha);
1181 _background_color = nux::Color(red, green, blue, alpha);
1182 QueueDraw();
1183}
1184
1185void Launcher::OnLockHideChanged(GVariant *data)1170void Launcher::OnLockHideChanged(GVariant *data)
1186{1171{
1187 gboolean enable_lock = FALSE;1172 gboolean enable_lock = FALSE;
@@ -1390,6 +1375,16 @@
1390 UpdateOptions(options());1375 UpdateOptions(options());
1391}1376}
13921377
1378void Launcher::OnMonitorChanged(int new_monitor)
1379{
1380 UScreen* uscreen = UScreen::GetDefault();
1381 auto monitor_geo = uscreen->GetMonitorGeometry(new_monitor);
1382 unity::panel::Style &panel_style = panel::Style::Instance();
1383
1384 Resize(nux::Point(monitor_geo.x, monitor_geo.y + panel_style.panel_height),
1385 monitor_geo.height - panel_style.panel_height);
1386}
1387
1393void Launcher::UpdateOptions(Options::Ptr options)1388void Launcher::UpdateOptions(Options::Ptr options)
1394{1389{
1395 SetIconSize(options->tile_size, options->icon_size);1390 SetIconSize(options->tile_size, options->icon_size);
@@ -1574,24 +1569,21 @@
15741569
1575 icon_renderer->SetTargetSize(_icon_size, _icon_image_size, _space_between_icons);1570 icon_renderer->SetTargetSize(_icon_size, _icon_image_size, _space_between_icons);
15761571
1577 Resize();1572 nux::Geometry const& parent_geo = _parent->GetGeometry();
1573 Resize(nux::Point(parent_geo.x, parent_geo.y), parent_geo.height);
1578}1574}
15791575
1580int Launcher::GetIconSize() const1576int Launcher::GetIconSize() const
1581{1577{
1582 return _icon_size;1578 return _icon_size;
1583}1579}
15841580
1585void Launcher::Resize()1581void Launcher::Resize(nux::Point const& offset, int height)
1586{1582{
1587 UScreen* uscreen = UScreen::GetDefault();1583 unsigned width = _icon_size + ICON_PADDING * 2 + RIGHT_LINE_WIDTH - 2;
1588 auto geo = uscreen->GetMonitorGeometry(monitor());1584 _parent->SetGeometry(nux::Geometry(offset.x, offset.y, width, height));
1589 unity::panel::Style &panel_style = panel::Style::Instance();1585 SetGeometry(nux::Geometry(0, 0, width, height));
1590 int width = _icon_size + ICON_PADDING*2 + RIGHT_LINE_WIDTH - 2;1586 SetMaximumHeight(height);
1591 nux::Geometry new_geometry(geo.x, geo.y + panel_style.panel_height, width, geo.height - panel_style.panel_height);
1592 SetMaximumHeight(new_geometry.height);
1593 _parent->SetGeometry(new_geometry);
1594 SetGeometry(nux::Geometry(0, 0, new_geometry.width, new_geometry.height));
15951587
1596 ConfigureBarrier();1588 ConfigureBarrier();
1597}1589}
@@ -1722,7 +1714,7 @@
1722 1714
1723 if (Settings::Instance().GetLowGfxMode())1715 if (Settings::Instance().GetLowGfxMode())
1724 {1716 {
1725 clear_colour = _background_color;1717 clear_colour = options()->background_color;
1726 clear_colour.alpha = 1.0f;1718 clear_colour.alpha = 1.0f;
1727 }1719 }
17281720
@@ -1796,7 +1788,7 @@
1796 blur_texture,1788 blur_texture,
1797 texxform_blur_bg,1789 texxform_blur_bg,
1798 nux::color::White,1790 nux::color::White,
1799 _background_color, nux::LAYER_BLEND_MODE_OVERLAY,1791 options()->background_color, nux::LAYER_BLEND_MODE_OVERLAY,
1800 true, ROP);1792 true, ROP);
1801 else1793 else
1802 gPainter.PushDrawTextureLayer(GfxContext, base,1794 gPainter.PushDrawTextureLayer(GfxContext, base,
@@ -1810,7 +1802,7 @@
1810 blur_texture,1802 blur_texture,
1811 texxform_blur_bg,1803 texxform_blur_bg,
1812 nux::color::White,1804 nux::color::White,
1813 _background_color, nux::LAYER_BLEND_MODE_OVERLAY,1805 options()->background_color, nux::LAYER_BLEND_MODE_OVERLAY,
1814 true, ROP);1806 true, ROP);
1815#endif1807#endif
1816 GfxContext.PopClippingRectangle();1808 GfxContext.PopClippingRectangle();
@@ -1829,7 +1821,7 @@
1829 // apply the bg colour1821 // apply the bg colour
1830#ifndef NUX_OPENGLES_201822#ifndef NUX_OPENGLES_20
1831 if (GfxContext.UsingGLSLCodePath() == false)1823 if (GfxContext.UsingGLSLCodePath() == false)
1832 gPainter.Paint2DQuadColor(GfxContext, bkg_box, _background_color);1824 gPainter.Paint2DQuadColor(GfxContext, bkg_box, options()->background_color);
1833#endif1825#endif
18341826
1835 // apply the shine1827 // apply the shine
@@ -1849,7 +1841,7 @@
1849 }1841 }
1850 else1842 else
1851 {1843 {
1852 nux::Color color = _background_color;1844 nux::Color color = options()->background_color;
1853 color.alpha = options()->background_alpha;1845 color.alpha = options()->background_alpha;
1854 gPainter.Paint2DQuadColor(GfxContext, bkg_box, color);1846 gPainter.Paint2DQuadColor(GfxContext, bkg_box, color);
1855 }1847 }
18561848
=== modified file 'launcher/Launcher.h'
--- launcher/Launcher.h 2012-11-15 19:46:04 +0000
+++ launcher/Launcher.h 2013-01-18 18:26:28 +0000
@@ -121,7 +121,7 @@
121 int GetMouseX() const;121 int GetMouseX() const;
122 int GetMouseY() const;122 int GetMouseY() const;
123123
124 void Resize();124 void Resize(nux::Point const& offset, int height);
125125
126 int GetDragDelta() const;126 int GetDragDelta() const;
127 void SetHover(bool hovered);127 void SetHover(bool hovered);
@@ -196,6 +196,7 @@
196196
197 void ConfigureBarrier();197 void ConfigureBarrier();
198198
199 void OnMonitorChanged(int monitor);
199 void OnOptionsChanged(Options::Ptr options);200 void OnOptionsChanged(Options::Ptr options);
200 void OnOptionChanged();201 void OnOptionChanged();
201 void UpdateOptions(Options::Ptr options);202 void UpdateOptions(Options::Ptr options);
@@ -392,7 +393,6 @@
392393
393 struct timespec _times[TIME_LAST];394 struct timespec _times[TIME_LAST];
394395
395 nux::Color _background_color;
396 BaseTexturePtr launcher_sheen_;396 BaseTexturePtr launcher_sheen_;
397 BaseTexturePtr launcher_pressure_effect_;397 BaseTexturePtr launcher_pressure_effect_;
398398
399399
=== modified file 'launcher/LauncherController.cpp'
--- launcher/LauncherController.cpp 2013-01-08 11:47:00 +0000
+++ launcher/LauncherController.cpp 2013-01-18 18:26:28 +0000
@@ -40,6 +40,7 @@
40#include "ExpoLauncherIcon.h"40#include "ExpoLauncherIcon.h"
41#include "TrashLauncherIcon.h"41#include "TrashLauncherIcon.h"
42#include "BFBLauncherIcon.h"42#include "BFBLauncherIcon.h"
43#include "unity-shared/IconRenderer.h"
43#include "unity-shared/UScreen.h"44#include "unity-shared/UScreen.h"
44#include "unity-shared/UBusMessages.h"45#include "unity-shared/UBusMessages.h"
45#include "unity-shared/TimeUtil.h"46#include "unity-shared/TimeUtil.h"
@@ -119,6 +120,17 @@
119 edge_barriers_.options = parent_->options();120 edge_barriers_.options = parent_->options();
120#endif121#endif
121122
123 ubus.RegisterInterest(UBUS_BACKGROUND_COLOR_CHANGED, [this](GVariant * data) {
124 ui::IconRenderer::DestroyShortcutTextures();
125
126 double red = 0.0f, green = 0.0f, blue = 0.0f, alpha = 0.0f;
127 g_variant_get(data, "(dddd)", &red, &green, &blue, &alpha);
128 parent_->options()->background_color = nux::Color(red, green, blue, alpha);
129 });
130
131 // request the latest color from bghash
132 ubus.SendMessage(UBUS_BACKGROUND_REQUEST_COLOUR_EMIT);
133
122 UScreen* uscreen = UScreen::GetDefault();134 UScreen* uscreen = UScreen::GetDefault();
123 EnsureLaunchers(uscreen->GetPrimaryMonitor(), uscreen->GetMonitors());135 EnsureLaunchers(uscreen->GetPrimaryMonitor(), uscreen->GetMonitors());
124136
@@ -148,7 +160,7 @@
148 wm.window_focus_changed.connect(sigc::mem_fun(this, &Controller::Impl::OnWindowFocusChanged));160 wm.window_focus_changed.connect(sigc::mem_fun(this, &Controller::Impl::OnWindowFocusChanged));
149 wm.viewport_layout_changed.connect(sigc::group(sigc::mem_fun(this, &Controller::Impl::UpdateNumWorkspaces), sigc::_1 * sigc::_2));161 wm.viewport_layout_changed.connect(sigc::group(sigc::mem_fun(this, &Controller::Impl::UpdateNumWorkspaces), sigc::_1 * sigc::_2));
150162
151 ubus.RegisterInterest(UBUS_QUICKLIST_END_KEY_NAV, [&](GVariant * args) {163 ubus.RegisterInterest(UBUS_QUICKLIST_END_KEY_NAV, [this](GVariant * args) {
152 if (reactivate_keynav)164 if (reactivate_keynav)
153 parent_->KeyNavGrab();165 parent_->KeyNavGrab();
154166
@@ -197,24 +209,27 @@
197 {209 {
198 if (i >= launchers_size)210 if (i >= launchers_size)
199 {211 {
200 launchers.push_back(nux::ObjectPtr<Launcher>(CreateLauncher(i)));212 launchers.push_back(nux::ObjectPtr<Launcher>(CreateLauncher()));
201 }213 }
202 else if (!launchers[i])214 else if (!launchers[i])
203 {215 {
204 launchers[i] = nux::ObjectPtr<Launcher>(CreateLauncher(i));216 launchers[i] = nux::ObjectPtr<Launcher>(CreateLauncher());
205 }217 }
206218
207 int monitor = (num_launchers == 1) ? primary : i;219 int monitor = (num_launchers == 1) ? primary : i;
208220
209#ifdef USE_X11
210 if (launchers[i]->monitor() != monitor)221 if (launchers[i]->monitor() != monitor)
211 {222 {
223#ifdef USE_X11
212 edge_barriers_.Unsubscribe(launchers[i].GetPointer(), launchers[i]->monitor);224 edge_barriers_.Unsubscribe(launchers[i].GetPointer(), launchers[i]->monitor);
213 }
214#endif225#endif
226 launchers[i]->monitor = monitor;
227 }
228 else
229 {
230 launchers[i]->monitor.changed(monitor);
231 }
215232
216 launchers[i]->monitor(monitor);
217 launchers[i]->Resize();
218#ifdef USE_X11233#ifdef USE_X11
219 edge_barriers_.Subscribe(launchers[i].GetPointer(), launchers[i]->monitor);234 edge_barriers_.Subscribe(launchers[i].GetPointer(), launchers[i]->monitor);
220#endif235#endif
@@ -222,7 +237,7 @@
222237
223 for (unsigned int i = last_launcher; i < launchers_size; ++i)238 for (unsigned int i = last_launcher; i < launchers_size; ++i)
224 {239 {
225 auto launcher = launchers[i];240 auto const& launcher = launchers[i];
226 if (launcher)241 if (launcher)
227 {242 {
228 parent_->RemoveChild(launcher.GetPointer());243 parent_->RemoveChild(launcher.GetPointer());
@@ -297,12 +312,11 @@
297 }312 }
298}313}
299314
300Launcher* Controller::Impl::CreateLauncher(int monitor)315Launcher* Controller::Impl::CreateLauncher()
301{316{
302 nux::BaseWindow* launcher_window = new nux::BaseWindow(TEXT("LauncherWindow"));317 nux::BaseWindow* launcher_window = new nux::BaseWindow(TEXT("LauncherWindow"));
303318
304 Launcher* launcher = new Launcher(launcher_window);319 Launcher* launcher = new Launcher(launcher_window);
305 launcher->monitor = monitor;
306 launcher->options = parent_->options();320 launcher->options = parent_->options();
307 launcher->SetModel(model_);321 launcher->SetModel(model_);
308322
309323
=== modified file 'launcher/LauncherControllerPrivate.h'
--- launcher/LauncherControllerPrivate.h 2012-12-07 04:21:35 +0000
+++ launcher/LauncherControllerPrivate.h 2013-01-18 18:26:28 +0000
@@ -54,7 +54,7 @@
5454
55 void UpdateNumWorkspaces(int workspaces);55 void UpdateNumWorkspaces(int workspaces);
5656
57 Launcher* CreateLauncher(int monitor);57 Launcher* CreateLauncher();
5858
59 void SaveIconsOrder();59 void SaveIconsOrder();
60 void SortAndUpdate();60 void SortAndUpdate();
6161
=== modified file 'launcher/LauncherOptions.cpp'
--- launcher/LauncherOptions.cpp 2012-12-14 18:12:52 +0000
+++ launcher/LauncherOptions.cpp 2013-01-18 18:26:28 +0000
@@ -33,9 +33,10 @@
33 , auto_hide_animation(FADE_AND_SLIDE)33 , auto_hide_animation(FADE_AND_SLIDE)
34 , backlight_mode(BACKLIGHT_NORMAL)34 , backlight_mode(BACKLIGHT_NORMAL)
35 , reveal_trigger(RevealTrigger::EDGE)35 , reveal_trigger(RevealTrigger::EDGE)
36 , background_color(nux::Color(95, 18, 45))
37 , background_alpha(0.6667)
36 , icon_size(48)38 , icon_size(48)
37 , tile_size(54)39 , tile_size(54)
38 , background_alpha(0.6667)
39 , edge_decay_rate(1500)40 , edge_decay_rate(1500)
40 , edge_overcome_pressure(2000)41 , edge_overcome_pressure(2000)
41 , edge_stop_velocity(6500)42 , edge_stop_velocity(6500)
@@ -51,6 +52,7 @@
5152
52 auto_hide_animation.changed.connect(sigc::hide(changed_lambda));53 auto_hide_animation.changed.connect(sigc::hide(changed_lambda));
53 background_alpha.changed.connect(sigc::hide(changed_lambda));54 background_alpha.changed.connect(sigc::hide(changed_lambda));
55 background_color.changed.connect(sigc::hide(changed_lambda));
54 backlight_mode.changed.connect(sigc::hide(changed_lambda));56 backlight_mode.changed.connect(sigc::hide(changed_lambda));
55 edge_decay_rate.changed.connect(sigc::hide(changed_lambda));57 edge_decay_rate.changed.connect(sigc::hide(changed_lambda));
56 edge_overcome_pressure.changed.connect(sigc::hide(changed_lambda));58 edge_overcome_pressure.changed.connect(sigc::hide(changed_lambda));
5759
=== modified file 'launcher/LauncherOptions.h'
--- launcher/LauncherOptions.h 2012-12-14 18:12:52 +0000
+++ launcher/LauncherOptions.h 2013-01-18 18:26:28 +0000
@@ -89,9 +89,10 @@
89 nux::Property<AutoHideAnimation> auto_hide_animation;89 nux::Property<AutoHideAnimation> auto_hide_animation;
90 nux::Property<BacklightMode> backlight_mode;90 nux::Property<BacklightMode> backlight_mode;
91 nux::Property<RevealTrigger> reveal_trigger;91 nux::Property<RevealTrigger> reveal_trigger;
92 nux::Property<nux::Color> background_color;
93 nux::Property<float> background_alpha;
92 nux::Property<int> icon_size;94 nux::Property<int> icon_size;
93 nux::Property<int> tile_size;95 nux::Property<int> tile_size;
94 nux::Property<float> background_alpha;
95 nux::Property<int> edge_decay_rate;96 nux::Property<int> edge_decay_rate;
96 nux::Property<int> edge_overcome_pressure;97 nux::Property<int> edge_overcome_pressure;
97 nux::Property<int> edge_stop_velocity;98 nux::Property<int> edge_stop_velocity;
9899
=== modified file 'launcher/StandaloneLauncher.cpp'
--- launcher/StandaloneLauncher.cpp 2013-01-17 14:09:35 +0000
+++ launcher/StandaloneLauncher.cpp 2013-01-18 18:26:28 +0000
@@ -27,35 +27,75 @@
27#include "Launcher.h"27#include "Launcher.h"
28#include "unity-shared/IconRenderer.h"28#include "unity-shared/IconRenderer.h"
29#include "unity-shared/PanelStyle.h"29#include "unity-shared/PanelStyle.h"
30#include "unity-shared/UBusMessages.h"
30#include "unity-shared/UnitySettings.h"31#include "unity-shared/UnitySettings.h"
32#include "unity-shared/UScreen.h"
3133
32using namespace unity;34using namespace unity;
3335
34static launcher::Controller::Ptr controller;36namespace
35
36void ThreadWidgetInit(nux::NThread* thread, void* InitData)
37{37{
38 auto xdnd_manager = std::make_shared<XdndManager>();38const nux::Size win_size(1024, 768);
39 controller = std::make_shared<launcher::Controller>(xdnd_manager);39const nux::Color bg_color(95/255.0f, 18/255.0f, 45/255.0f, 1.0f);
40}40}
4141
42struct LauncherWindow
43{
44 LauncherWindow()
45 : wt(nux::CreateGUIThread("Unity Launcher", win_size.width, win_size.height, 0, &LauncherWindow::ThreadWidgetInit, this))
46 {}
47
48 void Show()
49 {
50 wt->Run(nullptr);
51 }
52
53private:
54 void SetupBackground()
55 {
56 nux::ObjectPtr<nux::BaseTexture> background_tex;
57 background_tex.Adopt(nux::CreateTextureFromFile("/usr/share/backgrounds/warty-final-ubuntu.png"));
58 nux::TexCoordXForm texxform;
59 auto tex_layer = std::make_shared<nux::TextureLayer>(background_tex->GetDeviceTexture(), texxform, nux::color::White);
60 wt->SetWindowBackgroundPaintLayer(tex_layer.get());
61 }
62
63 void Init()
64 {
65 SetupBackground();
66 controller.reset(new launcher::Controller(std::make_shared<XdndManager>()));
67 controller->launcher().GetParent()->EnableInputWindow(false);
68
69 UScreen* uscreen = UScreen::GetDefault();
70 std::vector<nux::Geometry> fake_monitor({nux::Geometry(0, 0, win_size.width, win_size.height)});
71 uscreen->changed.emit(0, fake_monitor);
72 uscreen->changed.clear();
73 controller->launcher().Resize(nux::Point(), win_size.height);
74
75 wt->window_configuration.connect([this] (int x, int y, int w, int h) {
76 controller->launcher().Resize(nux::Point(), h);
77 });
78 }
79
80 static void ThreadWidgetInit(nux::NThread* thread, void* self)
81 {
82 static_cast<LauncherWindow*>(self)->Init();
83 }
84
85 internal::FavoriteStoreGSettings favorite_store;
86 unity::Settings settings;
87 panel::Style panel_style;
88 std::shared_ptr<nux::WindowThread> wt;
89 launcher::Controller::Ptr controller;
90};
91
42int main(int argc, char** argv)92int main(int argc, char** argv)
43{93{
44 gtk_init(&argc, &argv);94 gtk_init(&argc, &argv);
45 nux::NuxInitialize(0);95 nux::NuxInitialize(0);
4696
47 unity::Settings settings;97 LauncherWindow lc;
48 panel::Style panel_style;98 lc.Show();
49 internal::FavoriteStoreGSettings favorite_store;99
50
51 BackgroundEffectHelper::blur_type = BLUR_NONE;
52 nux::WindowThread* wt = nux::CreateGUIThread(TEXT("Unity Switcher"), 300, 800, 0, &ThreadWidgetInit, 0);
53
54 wt->Run(NULL);
55 // Make sure the controller is destroyed before the window thread.
56 controller.reset();
57 ::unity::ui::IconRenderer::DestroyTextures();
58
59 delete wt;
60 return 0;100 return 0;
61}101}
62102
=== modified file 'tests/test_launcher_controller.cpp'
--- tests/test_launcher_controller.cpp 2013-01-14 23:11:05 +0000
+++ tests/test_launcher_controller.cpp 2013-01-18 18:26:28 +0000
@@ -327,7 +327,7 @@
327327
328 for (int i = 0; i < max_num_monitors; ++i)328 for (int i = 0; i < max_num_monitors; ++i)
329 {329 {
330 EXPECT_EQ(lc.launchers()[i]->monitor(), i);330 ASSERT_EQ(lc.launchers()[i]->monitor(), i);
331 }331 }
332}332}
333333
@@ -389,7 +389,7 @@
389 ASSERT_EQ(lc.launchers().size(), max_num_monitors - 1);389 ASSERT_EQ(lc.launchers().size(), max_num_monitors - 1);
390390
391 for (int i = 0; i < max_num_monitors - 1; ++i)391 for (int i = 0; i < max_num_monitors - 1; ++i)
392 EXPECT_EQ(lc.launchers()[i]->monitor(), i);392 ASSERT_EQ(lc.launchers()[i]->monitor(), i);
393}393}
394394
395TEST_F(TestLauncherController, SingleMonitorSwitchToMultimonitor)395TEST_F(TestLauncherController, SingleMonitorSwitchToMultimonitor)
@@ -436,6 +436,20 @@
436436
437#endif437#endif
438438
439TEST_F(TestLauncherController, MultimonitorGeometries)
440{
441 uscreen.SetupFakeMultiMonitor();
442
443 for (int i = 0; i < max_num_monitors; ++i)
444 {
445 auto const& monitor_geo = uscreen.GetMonitorGeometry(i);
446 auto const& launcher_geo = lc.launchers()[i]->GetAbsoluteGeometry();
447 ASSERT_EQ(launcher_geo.x, monitor_geo.x);
448 ASSERT_EQ(launcher_geo.y, monitor_geo.y + panel_style.panel_height);
449 ASSERT_EQ(launcher_geo.height, monitor_geo.height - panel_style.panel_height);
450 }
451}
452
439TEST_F(TestLauncherController, OnlyUnstickIconOnFavoriteRemoval)453TEST_F(TestLauncherController, OnlyUnstickIconOnFavoriteRemoval)
440{454{
441 const std::string desktop = app::BZR_HANDLE_PATCH;455 const std::string desktop = app::BZR_HANDLE_PATCH;
@@ -1555,6 +1569,14 @@
1555 ASSERT_EQ(lc.Impl()->model_->Selection()->tooltip_text(), last_selection_change);1569 ASSERT_EQ(lc.Impl()->model_->Selection()->tooltip_text(), last_selection_change);
1556}1570}
15571571
1572TEST_F(TestLauncherController, UpdateLaunchersBackgroundColor)
1573{
1574 UBusManager().SendMessage(UBUS_BACKGROUND_COLOR_CHANGED,
1575 g_variant_new("(dddd)", 11/255.0f, 22/255.0f, 33/255.0f, 1.0f));
1576
1577 Utils::WaitUntil([this] { return lc.options()->background_color == nux::Color(11, 22, 33); });
1578}
1579
1558// thumper: 2012-11-28 disabling the drag and drop tests as they are taking over 20s1580// thumper: 2012-11-28 disabling the drag and drop tests as they are taking over 20s
1559// each, and that is not acceptable for unit tests. These sound more like functional1581// each, and that is not acceptable for unit tests. These sound more like functional
1560// tests.1582// tests.
15611583
=== modified file 'tests/test_uscreen_mock.h'
--- tests/test_uscreen_mock.h 2012-07-24 20:22:08 +0000
+++ tests/test_uscreen_mock.h 2013-01-18 18:26:28 +0000
@@ -44,16 +44,17 @@
44 default_screen_ = nullptr;44 default_screen_ = nullptr;
45 }45 }
4646
47 void Reset(bool emit = true)47 void Reset(bool emit_change = true)
48 {48 {
49 default_screen_ = this;49 default_screen_ = this;
50 primary_ = 0;50 primary_ = 0;
51 monitors_ = {nux::Geometry(0, 0, MONITOR_WIDTH, MONITOR_HEIGHT)};51 monitors_ = {nux::Geometry(0, 0, MONITOR_WIDTH, MONITOR_HEIGHT)};
5252
53 changed.emit(primary_, monitors_);53 if (emit_change)
54 changed.emit(primary_, monitors_);
54 }55 }
5556
56 void SetupFakeMultiMonitor(int primary = 0, bool emit_update = true)57 void SetupFakeMultiMonitor(int primary = 0, bool emit_change = true)
57 {58 {
58 SetPrimary(primary, false);59 SetPrimary(primary, false);
59 monitors_.clear();60 monitors_.clear();
@@ -63,7 +64,7 @@
63 monitors_.push_back(nux::Geometry(MONITOR_WIDTH, MONITOR_HEIGHT, total_width, 0));64 monitors_.push_back(nux::Geometry(MONITOR_WIDTH, MONITOR_HEIGHT, total_width, 0));
64 total_width += MONITOR_WIDTH;65 total_width += MONITOR_WIDTH;
6566
66 if (emit_update)67 if (emit_change)
67 changed.emit(GetPrimaryMonitor(), GetMonitors());68 changed.emit(GetPrimaryMonitor(), GetMonitors());
68 }69 }
69 }70 }