Merge lp:~3v1n0/unity/launchers-setup-struts 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: 2643
Proposed branch: lp:~3v1n0/unity/launchers-setup-struts
Merge into: lp:unity
Diff against target: 181 lines (+69/-38)
3 files modified
launcher/Launcher.cpp (+4/-34)
launcher/LauncherController.cpp (+1/-1)
tests/test_launcher_controller.cpp (+64/-3)
To merge this branch: bzr merge lp:~3v1n0/unity/launchers-setup-struts
Reviewer Review Type Date Requested Status
Brandon Schaefer (community) Approve
Review via email: mp+122152@code.launchpad.net

Commit message

LauncherController: make the controller enable the launcher struts, based on hide-mode option

Description of the change

Launcher struts should be set on each constructed launcher, depending on the auto-hide option.
Fixed launcher controller to always do that. At this point the launcher struts hack is really no more needed.

Unit tests added.

To post a comment you must log in.
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Looks good, and confirmed working. +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/Launcher.cpp'
2--- launcher/Launcher.cpp 2012-08-25 15:54:29 +0000
3+++ launcher/Launcher.cpp 2012-08-30 21:15:25 +0000
4@@ -92,7 +92,6 @@
5 const float DRAG_OUT_PIXELS = 300.0f;
6
7 const std::string DND_CHECK_TIMEOUT = "dnd-check-timeout";
8-const std::string STRUT_HACK_TIMEOUT = "strut-hack-timeout";
9 const std::string START_DRAGICON_TIMEOUT = "start-dragicon-timeout";
10 const std::string SCROLL_TIMEOUT = "scroll-timeout";
11 const std::string ANIMATION_IDLE = "animation-idle";
12@@ -215,7 +214,7 @@
13 launcher_sheen_ = cache.FindTexture("dash_sheen", 0, 0, cb);
14 launcher_pressure_effect_ = cache.FindTexture("launcher_pressure_effect", 0, 0, cb);
15
16- options.changed.connect(sigc::mem_fun (this, &Launcher::OnOptionsChanged));
17+ options.changed.connect(sigc::mem_fun(this, &Launcher::OnOptionsChanged));
18 }
19
20 /* Introspection */
21@@ -1428,21 +1427,9 @@
22
23 /* End Launcher Show/Hide logic */
24
25-// Hacks around compiz failing to see the struts because the window was just mapped.
26-bool Launcher::StrutHack()
27-{
28- _parent->InputWindowEnableStruts(false);
29-
30- if (options()->hide_mode == LAUNCHER_HIDE_NEVER)
31- _parent->InputWindowEnableStruts(true);
32-
33- return false;
34-}
35-
36 void Launcher::OnOptionsChanged(Options::Ptr options)
37 {
38 UpdateOptions(options);
39-
40 options->option_changed.connect(sigc::mem_fun(this, &Launcher::OnOptionChanged));
41 }
42
43@@ -1473,26 +1460,9 @@
44
45 void Launcher::SetHideMode(LauncherHideMode hidemode)
46 {
47- if (hidemode != LAUNCHER_HIDE_NEVER)
48- {
49- _parent->InputWindowEnableStruts(false);
50- }
51- else
52- {
53- static bool first_time = true;
54-
55- _parent->EnableInputWindow(true, launcher::window_title, false, false);
56-
57- if (first_time && !sources_.GetSource(STRUT_HACK_TIMEOUT))
58- {
59- sources_.AddTimeout(1000, sigc::mem_fun(this, &Launcher::StrutHack), STRUT_HACK_TIMEOUT);
60- first_time = false;
61- }
62-
63- _parent->InputWindowEnableStruts(true);
64- }
65-
66- _hide_machine.SetMode((LauncherHideMachine::HideMode) hidemode);
67+ bool fixed_launcher = (hidemode == LAUNCHER_HIDE_NEVER);
68+ _parent->InputWindowEnableStruts(fixed_launcher);
69+ _hide_machine.SetMode(static_cast<LauncherHideMachine::HideMode>(hidemode));
70 EnsureAnimation();
71 }
72
73
74=== modified file 'launcher/LauncherController.cpp'
75--- launcher/LauncherController.cpp 2012-08-29 08:16:08 +0000
76+++ launcher/LauncherController.cpp 2012-08-30 21:15:25 +0000
77@@ -280,7 +280,7 @@
78 launcher_window->SetBackgroundColor(nux::color::Transparent);
79 launcher_window->ShowWindow(true);
80 launcher_window->EnableInputWindow(true, launcher::window_title, false, false);
81- launcher_window->InputWindowEnableStruts(false);
82+ launcher_window->InputWindowEnableStruts(parent_->options()->hide_mode == LAUNCHER_HIDE_NEVER);
83 launcher_window->SetEnterFocusInputArea(launcher);
84
85 launcher->launcher_addrequest.connect(sigc::mem_fun(this, &Impl::OnLauncherAddRequest));
86
87=== modified file 'tests/test_launcher_controller.cpp'
88--- tests/test_launcher_controller.cpp 2012-08-10 09:58:49 +0000
89+++ tests/test_launcher_controller.cpp 2012-08-30 21:15:25 +0000
90@@ -52,7 +52,6 @@
91 class MockBamfLauncherIcon : public BamfLauncherIcon
92 {
93 public:
94- //typedef nux::ObjectPtr<MockMockLauncherIcon> Ptr;
95 MockBamfLauncherIcon(BamfApplication* app)
96 : BamfLauncherIcon(app) {}
97
98@@ -71,7 +70,6 @@
99
100 virtual void SetUp()
101 {
102- lc.options = std::make_shared<Options>();
103 lc.multiple_launchers = true;
104 }
105
106@@ -98,6 +96,8 @@
107 {
108 EXPECT_NE(lc.options(), nullptr);
109 EXPECT_TRUE(lc.multiple_launchers());
110+ ASSERT_EQ(lc.launchers().size(), 1);
111+ EXPECT_EQ(lc.launcher().monitor(), 0);
112 }
113
114 TEST_F(TestLauncherController, MultimonitorMultipleLaunchers)
115@@ -230,4 +230,65 @@
116 favorite_store.favorite_removed.emit(USC_DESKTOP);
117 }
118
119-}
120+TEST_F(TestLauncherController, EnabledStrutsByDefault)
121+{
122+ EXPECT_EQ(lc.launcher().options()->hide_mode, LAUNCHER_HIDE_NEVER);
123+ EXPECT_TRUE(lc.launcher().GetParent()->InputWindowStrutsEnabled());
124+}
125+
126+TEST_F(TestLauncherController, EnabledStrutsOnNeverHide)
127+{
128+ lc.multiple_launchers = true;
129+ uscreen.SetupFakeMultiMonitor();
130+ lc.options()->hide_mode = LAUNCHER_HIDE_NEVER;
131+
132+ for (int i = 0; i < max_num_monitors; ++i)
133+ ASSERT_TRUE(lc.launchers()[i]->GetParent()->InputWindowStrutsEnabled());
134+}
135+
136+TEST_F(TestLauncherController, DisabledStrutsOnAutoHide)
137+{
138+ lc.multiple_launchers = true;
139+ uscreen.SetupFakeMultiMonitor();
140+ lc.options()->hide_mode = LAUNCHER_HIDE_AUTOHIDE;
141+
142+ for (int i = 0; i < max_num_monitors; ++i)
143+ ASSERT_FALSE(lc.launchers()[i]->GetParent()->InputWindowStrutsEnabled());
144+}
145+
146+TEST_F(TestLauncherController, EnabledStrutsAddingNewLaunchersOnAutoHide)
147+{
148+ // This makes the controller to add multiple launchers
149+ lc.multiple_launchers = true;
150+ lc.options()->hide_mode = LAUNCHER_HIDE_NEVER;
151+ uscreen.SetupFakeMultiMonitor();
152+
153+ // This makes the controller to remove unneeded launchers
154+ lc.multiple_launchers = false;
155+
156+ // This makes the controller to add again new launchers
157+ lc.multiple_launchers = true;
158+
159+ for (int i = 0; i < max_num_monitors; ++i)
160+ ASSERT_TRUE(lc.launchers()[i]->GetParent()->InputWindowStrutsEnabled());
161+}
162+
163+TEST_F(TestLauncherController, DisabledStrutsAddingNewLaunchersOnNeverHide)
164+{
165+ // This makes the controller to add multiple launchers
166+ lc.multiple_launchers = true;
167+ lc.options()->hide_mode = LAUNCHER_HIDE_AUTOHIDE;
168+ uscreen.SetupFakeMultiMonitor();
169+
170+ // This makes the controller to remove unneeded launchers
171+ lc.multiple_launchers = false;
172+
173+ // This makes the controller to add again new launchers
174+ lc.multiple_launchers = true;
175+
176+ for (int i = 0; i < max_num_monitors; ++i)
177+ ASSERT_FALSE(lc.launchers()[i]->GetParent()->InputWindowStrutsEnabled());
178+}
179+
180+}
181+