Merge lp:~3v1n0/unity/switcher-activenumber-overflow-fix-7.0 into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Superseded
Proposed branch: lp:~3v1n0/unity/switcher-activenumber-overflow-fix-7.0
Merge into: lp:unity
Diff against target: 437 lines (+151/-30) (has conflicts)
10 files modified
debian/changelog (+49/-0)
launcher/SwitcherController.cpp (+6/-10)
tests/test_application_launcher_icon.cpp (+0/-1)
tests/test_switcher_controller.cpp (+27/-2)
tests/test_switcher_controller.h (+16/-2)
tests/test_switcher_controller_class.cpp (+18/-6)
tests/test_switcher_controller_slow.cpp (+12/-7)
unity-shared/PreviewStyle.cpp (+16/-0)
unity-shared/StandaloneWindowManager.cpp (+5/-0)
unity-shared/StandaloneWindowManager.h (+2/-2)
Text conflict in debian/changelog
Text conflict in tests/test_switcher_controller.h
Text conflict in tests/test_switcher_controller_class.cpp
Text conflict in unity-shared/PreviewStyle.cpp
To merge this branch: bzr merge lp:~3v1n0/unity/switcher-activenumber-overflow-fix-7.0
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Unity Team Pending
Review via email: mp+164550@code.launchpad.net

This proposal has been superseded by a proposal from 2013-05-18.

Commit message

SwitcherController: use proper long long types for WindowActiveNumber

Otherwise an overflow can cause bad window selection after long uptime.

Description of the change

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dash/previews/MusicPreview.cpp'
2=== modified file 'dash/previews/MusicPreview.h'
3=== modified file 'debian/changelog'
4--- debian/changelog 2013-05-09 16:26:04 +0000
5+++ debian/changelog 2013-05-17 22:08:29 +0000
6@@ -1,3 +1,4 @@
7+<<<<<<< TREE
8 unity (7.0.0daily13.05.08ubuntu.unity.experimental.certified-0ubuntu1) raring; urgency=low
9
10 [ Nick Dedekind ]
11@@ -138,6 +139,54 @@
12
13 -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Wed, 10 Apr 2013 07:16:02 +0000
14
15+=======
16+unity (7.0.0daily13.05.08~13.04-0ubuntu1) raring; urgency=low
17+
18+ [ Sebastien Bacher ]
19+ * Some untranslatable and wrong strings in the previews (LP: #1074038)
20+
21+ [ Andrea Azzarone ]
22+ * [alt-tab] Disable detail view for webapp icons. (LP: #1169340)
23+
24+ [ Marco Trevisan (Treviño) ]
25+ * Launcher - count label pops out in auto-hide mode (LP: #1171476)
26+ * Panel shadow is drawn above full-screen windows when notifications
27+ are shown (LP: #1171934)
28+ * [regression] Icon count is not shown if the icon is not transformed
29+ (LP: #1171663)
30+
31+ [ Ubuntu daily release ]
32+ * Automatic snapshot from revision 3314
33+
34+ -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Wed, 08 May 2013 04:37:10 +0000
35+
36+unity (7.0.0daily13.04.18~13.04-0ubuntu1) raring; urgency=low
37+
38+ [ Manuel de la Pena ]
39+ * Purchased songs won't download when not logged to U1 (LP: #1168674)
40+
41+ [ Ubuntu daily release ]
42+ * Automatic snapshot from revision 3309
43+
44+ -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Thu, 18 Apr 2013 05:43:34 +0000
45+
46+unity (7.0.0daily13.04.17~13.04-0ubuntu1) raring; urgency=low
47+
48+ [ Marco Trevisan (Treviño) ]
49+ * Top Bar, window managment - top bar shadow not falling on restored
50+ windows that are partially off the top edge of the screen (LP:
51+ #871758)
52+
53+ [ Matthieu James ]
54+ * [UIFe] BFB icon swirl should run clockwise not anti-clockwise (LP:
55+ #1169238)
56+
57+ [ Ubuntu daily release ]
58+ * Automatic snapshot from revision 3305
59+
60+ -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Wed, 17 Apr 2013 04:07:04 +0000
61+
62+>>>>>>> MERGE-SOURCE
63 unity (7.0.0daily13.04.15-0ubuntu1) raring; urgency=low
64
65 [ Brandon Schaefer ]
66
67=== modified file 'launcher/ApplicationLauncherIcon.cpp'
68=== modified file 'launcher/LauncherIcon.cpp'
69=== modified file 'launcher/MockLauncherIcon.h'
70=== modified file 'launcher/SwitcherController.cpp'
71--- launcher/SwitcherController.cpp 2013-04-18 14:04:10 +0000
72+++ launcher/SwitcherController.cpp 2013-05-17 22:08:29 +0000
73@@ -649,15 +649,15 @@
74 return;
75 }
76
77- unsigned int first_highest = 0;
78- unsigned int first_second = 0; // first icons second highest active
79- unsigned int second_first = 0; // second icons first highest active
80+ unsigned long long first_highest = 0;
81+ unsigned long long first_second = 0; // first icons second highest active
82+ unsigned long long second_first = 0; // second icons first highest active
83
84 WindowManager& wm = WindowManager::Default();
85 for (auto& window : first->Windows())
86 {
87- guint32 xid = window->window_id();
88- unsigned int num = wm.GetWindowActiveNumber(xid);
89+ Window xid = window->window_id();
90+ unsigned long long num = wm.GetWindowActiveNumber(xid);
91
92 if (num > first_highest)
93 {
94@@ -670,11 +670,7 @@
95 }
96 }
97
98- for (auto& window : second->Windows())
99- {
100- guint32 xid = window->window_id();
101- second_first = std::max<unsigned long long>(wm.GetWindowActiveNumber(xid), second_first);
102- }
103+ second_first = second->SwitcherPriority();
104
105 if (first_second > second_first)
106 model_->Select(first);
107
108=== modified file 'plugins/unityshell/src/unityshell.cpp'
109=== modified file 'po/POTFILES.in'
110=== modified file 'tests/autopilot/unity/tests/__init__.py'
111=== modified file 'tests/autopilot/unity/tests/test_panel.py'
112=== modified file 'tests/test_application_launcher_icon.cpp'
113--- tests/test_application_launcher_icon.cpp 2013-04-17 19:16:54 +0000
114+++ tests/test_application_launcher_icon.cpp 2013-05-17 22:08:29 +0000
115@@ -29,7 +29,6 @@
116 #include "FavoriteStore.h"
117 #include "StandaloneWindowManager.h"
118 #include "mock-application.h"
119-#include "StandaloneWindowManager.h"
120 #include "test_utils.h"
121
122 using namespace testing;
123
124=== modified file 'tests/test_switcher_controller.cpp'
125--- tests/test_switcher_controller.cpp 2013-04-17 19:16:54 +0000
126+++ tests/test_switcher_controller.cpp 2013-05-17 22:08:29 +0000
127@@ -84,7 +84,7 @@
128 EXPECT_CALL(*mock_window_, ShowWindow(true, _)).Times(AtLeast(1));
129
130 controller_->Show(ShowMode::ALL, SortMode::LAUNCHER_ORDER, icons_);
131- Utils::WaitForTimeoutMSec(200);
132+ Utils::WaitUntilMSec([this] { return controller_->Visible(); });
133 EXPECT_TRUE(controller_->Visible());
134 EXPECT_TRUE(controller_->StartIndex() == 1);
135 }
136@@ -97,7 +97,7 @@
137 ASSERT_TRUE(controller_->IsShowDesktopDisabled());
138
139 controller_->Show(ShowMode::ALL, SortMode::LAUNCHER_ORDER, icons_);
140- Utils::WaitForTimeoutMSec(200);
141+ Utils::WaitUntilMSec([this] { return controller_->Visible(); });
142 ASSERT_TRUE(controller_->StartIndex() == 0);
143 Selection selection = controller_->GetCurrentSelection();
144 EXPECT_NE(selection.application_->tooltip_text(), "Show Desktop");
145@@ -120,6 +120,31 @@
146 EXPECT_FALSE(selection.application_);
147 }
148
149+TEST_F(TestSwitcherController, ShowSwitcherSelectsWindowOfActiveApp)
150+{
151+ // Making the first application active
152+ auto const& first_app = icons_[1];
153+ first_app->SetQuirk(launcher::AbstractLauncherIcon::Quirk::ACTIVE, true);
154+
155+ // Raising the priority of the second window of the first app
156+ auto first_app_windows = first_app->Windows();
157+ auto first_app_last_window = first_app_windows.back();
158+ auto standalone = WM->GetWindowByXid(first_app_last_window->window_id());
159+ standalone->active_number = WM->GetWindowActiveNumber(first_app_windows.front()->window_id()) - 1;
160+
161+ // Setting the active number of the first window of the second app to max uint
162+ auto second_app_first_window = icons_[2]->Windows().front();
163+ standalone = WM->GetWindowByXid(second_app_first_window->window_id());
164+ standalone->active_number = std::numeric_limits<unsigned>::max();
165+
166+ controller_->Show(ShowMode::CURRENT_VIEWPORT, SortMode::FOCUS_ORDER, icons_);
167+ Utils::WaitUntilMSec([this] { return controller_->Visible(); });
168+
169+ Selection selection = controller_->GetCurrentSelection();
170+ ASSERT_EQ(selection.application_, first_app);
171+ EXPECT_EQ(selection.window_, first_app_last_window->window_id());
172+}
173+
174 TEST_F(TestSwitcherController, Opacity)
175 {
176 EXPECT_EQ(controller_->Opacity(), 0.0f);
177
178=== modified file 'tests/test_switcher_controller.h'
179--- tests/test_switcher_controller.h 2013-04-17 19:16:54 +0000
180+++ tests/test_switcher_controller.h 2013-05-17 22:08:29 +0000
181@@ -28,6 +28,7 @@
182 #include "test_utils.h"
183 #include "DesktopLauncherIcon.h"
184 #include "SimpleLauncherIcon.h"
185+#include "StandaloneWindowManager.h"
186 #include "SwitcherController.h"
187 #include "SwitcherView.h"
188 #include "TimeUtil.h"
189@@ -51,7 +52,7 @@
190 class FakeApplicationWindow : public unity::ApplicationWindow
191 {
192 public:
193- FakeApplicationWindow(Window xid);
194+ FakeApplicationWindow(Window xid, unsigned long long active_number = 0);
195
196 std::string title() const;
197 virtual std::string icon() const;
198@@ -62,6 +63,7 @@
199 virtual unity::ApplicationPtr application() const;
200 virtual bool Focus() const;
201 virtual void Quit() const;
202+
203 private:
204 Window xid_;
205 };
206@@ -69,8 +71,9 @@
207 /**
208 * A fake LauncherIcon for verifying selection operations of the switcher.
209 */
210-class FakeLauncherIcon : public unity::launcher::SimpleLauncherIcon
211+struct FakeLauncherIcon : unity::launcher::SimpleLauncherIcon
212 {
213+<<<<<<< TREE
214 public:
215 FakeLauncherIcon(std::string const& app_name, bool allow_detail_view, unsigned priority);
216
217@@ -81,6 +84,16 @@
218 private:
219 bool allow_detail_view_;
220 unsigned priority_;
221+=======
222+ FakeLauncherIcon(std::string const& app_name, bool allow_detail_view, unsigned long long priority);
223+
224+ unity::WindowList Windows() override;
225+ bool AllowDetailViewInSwitcher() const override;
226+ unsigned long long SwitcherPriority() override;
227+
228+ bool allow_detail_view_;
229+ unsigned long long priority_;
230+>>>>>>> MERGE-SOURCE
231 unity::WindowList window_list;
232 };
233
234@@ -96,6 +109,7 @@
235 // required to create hidden secret global variables before test objects
236 unity::Settings unity_settings_;
237
238+ unity::StandaloneWindowManager* WM;
239 nux::animation::TickSource tick_source_;
240 nux::animation::AnimationController animation_controller_;
241 unity::testmocks::MockBaseWindow::Ptr mock_window_;
242
243=== modified file 'tests/test_switcher_controller_class.cpp'
244--- tests/test_switcher_controller_class.cpp 2013-04-17 19:16:54 +0000
245+++ tests/test_switcher_controller_class.cpp 2013-05-17 22:08:29 +0000
246@@ -25,7 +25,14 @@
247 using namespace unity::switcher;
248 using namespace std::chrono;
249
250-FakeApplicationWindow::FakeApplicationWindow(Window xid) : xid_(xid) {}
251+FakeApplicationWindow::FakeApplicationWindow(Window xid, unsigned long long active_number)
252+ : xid_(xid)
253+{
254+ auto WM = dynamic_cast<StandaloneWindowManager*>(&WindowManager::Default());
255+ auto standalone_window = std::make_shared<StandaloneWindow>(xid_);
256+ standalone_window->active_number = active_number;
257+ WM->AddStandaloneWindow(standalone_window);
258+}
259
260 std::string FakeApplicationWindow::title() const { return "FakeApplicationWindow"; }
261 std::string FakeApplicationWindow::icon() const { return ""; }
262@@ -35,14 +42,18 @@
263 int FakeApplicationWindow::monitor() const { return -1; }
264 ApplicationPtr FakeApplicationWindow::application() const { return ApplicationPtr(); }
265 bool FakeApplicationWindow::Focus() const { return false; }
266-void FakeApplicationWindow::Quit() const {}
267+void FakeApplicationWindow::Quit() const { WindowManager::Default().Close(xid_); }
268
269+<<<<<<< TREE
270 FakeLauncherIcon::FakeLauncherIcon(std::string const& app_name, bool allow_detail_view, unsigned priority)
271+=======
272+FakeLauncherIcon::FakeLauncherIcon(std::string const& app_name, bool allow_detail_view, unsigned long long priority)
273+>>>>>>> MERGE-SOURCE
274 : launcher::SimpleLauncherIcon(IconType::APPLICATION)
275 , allow_detail_view_(allow_detail_view)
276 , priority_(priority)
277- , window_list{ std::make_shared<FakeApplicationWindow>(priority_ | 0x0001),
278- std::make_shared<FakeApplicationWindow>(priority_ | 0x0002) }
279+ , window_list{ std::make_shared<FakeApplicationWindow>(priority_ | 0x0001, SwitcherPriority()),
280+ std::make_shared<FakeApplicationWindow>(priority_ | 0x0002, priority_) }
281 {
282 tooltip_text = app_name;
283 }
284@@ -59,7 +70,7 @@
285
286 unsigned long long FakeLauncherIcon::SwitcherPriority()
287 {
288- return 0xffffffff - priority_;
289+ return std::numeric_limits<unsigned long long>::max() - priority_;
290 }
291
292 /**
293@@ -67,7 +78,8 @@
294 */
295 //class TestSwitcherController : public testing::Test
296 TestSwitcherController::TestSwitcherController()
297- : animation_controller_(tick_source_)
298+ : WM(dynamic_cast<StandaloneWindowManager*>(&WindowManager::Default()))
299+ , animation_controller_(tick_source_)
300 , mock_window_(new NiceMock<testmocks::MockBaseWindow>())
301 {
302 ON_CALL(*mock_window_, SetOpacity(_))
303
304=== modified file 'tests/test_switcher_controller_slow.cpp'
305--- tests/test_switcher_controller_slow.cpp 2013-03-19 01:13:43 +0000
306+++ tests/test_switcher_controller_slow.cpp 2013-05-17 22:08:29 +0000
307@@ -69,17 +69,22 @@
308
309 controller_->Next();
310 selection = controller_->GetCurrentSelection();
311- EXPECT_EQ(selection.application_->tooltip_text(), "Show Desktop");
312- EXPECT_EQ(selection.window_, 0);
313-
314- controller_->Next();
315- selection = controller_->GetCurrentSelection();
316- EXPECT_EQ(selection.application_->tooltip_text(), "First");
317+ ASSERT_EQ(selection.application_->tooltip_text(), "Third");
318+ EXPECT_EQ(selection.window_, 0);
319+
320+ controller_->Next();
321+ selection = controller_->GetCurrentSelection();
322+ ASSERT_EQ(selection.application_->tooltip_text(), "Show Desktop");
323+ EXPECT_EQ(selection.window_, 0);
324+
325+ controller_->Next();
326+ selection = controller_->GetCurrentSelection();
327+ ASSERT_EQ(selection.application_->tooltip_text(), "First");
328 EXPECT_EQ(selection.window_, 0);
329
330 Utils::WaitForTimeoutMSec(details_timeout * 1.1);
331 selection = controller_->GetCurrentSelection();
332- EXPECT_EQ(selection.application_->tooltip_text(), "First");
333+ ASSERT_EQ(selection.application_->tooltip_text(), "First");
334 EXPECT_EQ(selection.window_, 0x0101);
335
336
337
338=== modified file 'unity-shared/PreviewStyle.cpp'
339--- unity-shared/PreviewStyle.cpp 2013-05-09 16:26:04 +0000
340+++ unity-shared/PreviewStyle.cpp 2013-05-17 22:08:29 +0000
341@@ -294,6 +294,7 @@
342 return 12;
343 }
344
345+<<<<<<< TREE
346 std::string Style::payment_title_font() const
347 {
348 return "Ubuntu 22";
349@@ -383,6 +384,13 @@
350 return "Ubuntu Bold 11.5";
351 }
352
353+=======
354+std::string Style::u1_warning_font() const
355+{
356+ return "Ubuntu Bold 11.5";
357+}
358+
359+>>>>>>> MERGE-SOURCE
360 float Style::GetVideoImageAspectRatio() const
361 {
362 return float(540)/380;
363@@ -492,6 +500,7 @@
364 return pimpl->preview_pause_texture_.texture();
365 }
366
367+<<<<<<< TREE
368 nux::BaseTexture* Style::GetLockIcon()
369 {
370 return nux::CreateTexture2DFromFile(
371@@ -503,6 +512,13 @@
372 return pimpl->warning_icon_texture_.texture();
373 }
374
375+=======
376+nux::BaseTexture* Style::GetWarningIcon()
377+{
378+ return pimpl->warning_icon_texture_.texture();
379+}
380+
381+>>>>>>> MERGE-SOURCE
382 nux::BaseTexture* Style::GetSearchSpinIcon(int size)
383 {
384 return pimpl->preview_spin_texture_.texture(size);
385
386=== modified file 'unity-shared/PreviewStyle.h'
387=== modified file 'unity-shared/StandaloneWindowManager.cpp'
388--- unity-shared/StandaloneWindowManager.cpp 2013-02-21 13:43:48 +0000
389+++ unity-shared/StandaloneWindowManager.cpp 2013-05-17 22:08:29 +0000
390@@ -39,6 +39,7 @@
391 , geo(nux::Geometry(0, 0, 10, 10))
392 , current_desktop(0)
393 , monitor(0)
394+ , active_number(0)
395 , active(false)
396 , mapped(true)
397 , visible(true)
398@@ -480,6 +481,10 @@
399
400 unsigned long long StandaloneWindowManager::GetWindowActiveNumber(Window window_id) const
401 {
402+ auto window = GetWindowByXid(window_id);
403+ if (window)
404+ return window->active_number;
405+
406 return 0;
407 }
408
409
410=== modified file 'unity-shared/StandaloneWindowManager.h'
411--- unity-shared/StandaloneWindowManager.h 2013-02-09 16:06:56 +0000
412+++ unity-shared/StandaloneWindowManager.h 2013-05-17 22:08:29 +0000
413@@ -44,6 +44,7 @@
414 nux::Size deco_sizes[4];
415 unsigned current_desktop;
416 unsigned monitor;
417+ unsigned long long active_number;
418 nux::Property<bool> active;
419 nux::Property<bool> mapped;
420 nux::Property<bool> visible;
421@@ -146,6 +147,7 @@
422 virtual std::string GetWindowName(Window window_id) const;
423
424 // Mock functions
425+ StandaloneWindow::Ptr GetWindowByXid(Window window_id) const;
426 void AddStandaloneWindow(StandaloneWindow::Ptr const& window);
427 std::list<StandaloneWindow::Ptr> GetStandaloneWindows() const;
428
429@@ -160,8 +162,6 @@
430 virtual void AddProperties(GVariantBuilder* builder);
431
432 private:
433- StandaloneWindow::Ptr GetWindowByXid(Window window_id) const;
434-
435 bool expo_state_;
436 bool in_show_desktop_;
437 bool scale_active_;