Merge lp:~aacid/unity-2d/unity-2d_backport_shell_r934 into lp:unity-2d

Proposed by Albert Astals Cid
Status: Merged
Approved by: Gerry Boland
Approved revision: 890
Merged at revision: 894
Proposed branch: lp:~aacid/unity-2d/unity-2d_backport_shell_r934
Merge into: lp:unity-2d
Diff against target: 574 lines (+409/-4)
9 files modified
launcher/LauncherItem.qml (+1/-1)
launcher/LauncherList.qml (+22/-1)
libunity-2d-private/src/launcherapplication.cpp (+56/-2)
libunity-2d-private/src/launcherapplication.h (+4/-0)
libunity-2d-private/src/launcheritem.cpp (+6/-0)
libunity-2d-private/src/launcheritem.h (+2/-0)
libunity-2d-private/src/unity2ddeclarativeview.cpp (+1/-0)
libunity-2d-private/src/unity2ddeclarativeview.h (+1/-0)
tests/launcher/update_pips_tests.rb (+316/-0)
To merge this branch: bzr merge lp:~aacid/unity-2d/unity-2d_backport_shell_r934
Reviewer Review Type Date Requested Status
Michał Sawicz Needs Fixing
Review via email: mp+91425@code.launchpad.net

Description of the change

[launcher] launcher pips indicate whether application windows belongs to current workspace or not

Backport from r934 of unity-2d-shell

To post a comment you must log in.
Revision history for this message
Albert Astals Cid (aacid) wrote :
Revision history for this message
Michał Sawicz (saviq) wrote :

We're missing "launcher/artwork/launcher_arrow_outline_ltr.png" here

review: Needs Fixing
Revision history for this message
Albert Astals Cid (aacid) wrote :

Added

Revision history for this message
Michał Sawicz (saviq) wrote :

Please fix the paths to the images in both LauncherList.qml and the tests, and also please add a FIXME about converting these tests to visual ones.

review: Needs Fixing
Revision history for this message
Albert Astals Cid (aacid) wrote :

Done

Revision history for this message
Unity Merger (unity-merger) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Revision history for this message
Unity Merger (unity-merger) wrote :

Attempt to merge into lp:unity-2d failed due to conflicts:

text conflict in libunity-2d-private/src/unity2ddeclarativeview.h

890. By Albert Astals Cid

merge

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/LauncherItem.qml'
2--- launcher/LauncherItem.qml 2011-12-21 09:52:15 +0000
3+++ launcher/LauncherItem.qml 2012-02-03 21:02:20 +0000
4@@ -156,7 +156,7 @@
5 Repeater {
6 model: item.pips
7 delegate: Image {
8- objectName: "pips"
9+ objectName: "pips-" + index
10 /* FIXME: It seems that when the image is created (or re-used) by the Repeater
11 for a moment it doesn't have any parent, and therefore warnings are
12 printed for the following two anchor assignements. This fixes the
13
14=== modified file 'launcher/LauncherList.qml'
15--- launcher/LauncherList.qml 2011-12-21 09:52:15 +0000
16+++ launcher/LauncherList.qml 2012-02-03 21:02:20 +0000
17@@ -89,6 +89,16 @@
18 }
19 }
20
21+ function updatePips() {
22+ if (item.belongsToDifferentWorkspace()) {
23+ launcherItem.pips = 1
24+ launcherItem.pipSource = "artwork/launcher_arrow_outline_ltr.png";
25+ } else {
26+ launcherItem.pips = Math.min(item.windowCount, 3)
27+ launcherItem.pipSource = ("artwork/launcher_" + ((pips <= 1) ? "arrow" : "pip") + "_ltr.png")
28+ }
29+ }
30+
31 Accessible.name: accessibleDescription()
32 name: item.name
33
34@@ -275,7 +285,10 @@
35 PropertyAction { target: launcherItem; property: "ListView.delayRemove"; value: false }
36 }
37
38- onRunningChanged: setIconGeometry()
39+ onRunningChanged: {
40+ setIconGeometry()
41+ item.connectWindowSignals()
42+ }
43 /* Note: this doesn’t work as expected for the first favorite
44 application in the list if it is already running when the
45 launcher is started, because its y property doesn’t change.
46@@ -286,6 +299,8 @@
47 Connections {
48 target: item
49 onWindowAdded: item.setIconGeometry(x + panel.x, y + panel.y, width, height, xid)
50+ onWindowCountChanged: updatePips()
51+ onWindowWorkspaceChanged: updatePips()
52 /* Not all items are applications. */
53 ignoreUnknownSignals: true
54 }
55@@ -328,5 +343,11 @@
56 }
57 }
58 }
59+
60+ Connections {
61+ target: declarativeView
62+ onActiveWorkspaceChanged: updatePips()
63+ }
64+ Component.onCompleted: updatePips()
65 }
66 }
67
68=== added file 'launcher/artwork/launcher_arrow_outline_ltr.png'
69Binary files launcher/artwork/launcher_arrow_outline_ltr.png 1970-01-01 00:00:00 +0000 and launcher/artwork/launcher_arrow_outline_ltr.png 2012-02-03 21:02:20 +0000 differ
70=== modified file 'libunity-2d-private/src/launcherapplication.cpp'
71--- libunity-2d-private/src/launcherapplication.cpp 2012-02-01 13:13:07 +0000
72+++ libunity-2d-private/src/launcherapplication.cpp 2012-02-03 21:02:20 +0000
73@@ -507,10 +507,36 @@
74 }
75
76 void
77+LauncherApplication::connectWindowSignals()
78+{
79+ if (m_application == NULL || m_application->running() == false) {
80+ return;
81+ }
82+
83+ QScopedPointer<BamfUintList> xids(m_application->xids());
84+ int size = xids->size();
85+ if (size < 1) {
86+ return;
87+ }
88+
89+ WnckScreen* screen = wnck_screen_get_default();
90+ wnck_screen_force_update(screen);
91+
92+ for (int i = 0; i < size; ++i) {
93+ WnckWindow* window = wnck_window_get(xids->at(i));
94+ g_signal_connect(G_OBJECT(window), "workspace-changed",
95+ G_CALLBACK(LauncherApplication::onWindowWorkspaceChanged), this);
96+ }
97+}
98+
99+void
100 LauncherApplication::onWindowAdded(BamfWindow* window)
101 {
102 if (window != NULL) {
103 windowAdded(window->xid());
104+ WnckWindow* wnck_window = wnck_window_get(window->xid());
105+ g_signal_connect(G_OBJECT(wnck_window), "workspace-changed",
106+ G_CALLBACK(LauncherApplication::onWindowWorkspaceChanged), this);
107 }
108 }
109
110@@ -601,6 +627,11 @@
111 LauncherApplication::windowCountOnCurrentWorkspace()
112 {
113 int windowCount = 0;
114+
115+ if (!m_application) {
116+ return windowCount;
117+ }
118+
119 WnckWorkspace *current = wnck_screen_get_active_workspace(wnck_screen_get_default());
120
121 QScopedPointer<BamfWindowList> windows(m_application->windows());
122@@ -622,9 +653,13 @@
123 }
124 }
125
126- WnckWorkspace *workspace = wnck_window_get_workspace(wnck_window);
127- if (workspace == current) {
128+ if (wnck_window_is_pinned(wnck_window)) {
129 windowCount++;
130+ } else {
131+ WnckWorkspace *workspace = wnck_window_get_workspace(wnck_window);
132+ if (workspace == current) {
133+ windowCount++;
134+ }
135 }
136 }
137 return windowCount;
138@@ -939,6 +974,18 @@
139 }
140 }
141
142+bool
143+LauncherApplication::belongsToDifferentWorkspace()
144+{
145+ int totalWindows = windowCount();
146+ int windowsInCurrentWorkspace = windowCountOnCurrentWorkspace();
147+ if (totalWindows > 0 && windowsInCurrentWorkspace == 0) {
148+ return true;
149+ }
150+
151+ return false;
152+}
153+
154 void
155 LauncherApplication::onIndicatorMenuUpdated()
156 {
157@@ -1056,6 +1103,13 @@
158 }
159
160 void
161+LauncherApplication::onWindowWorkspaceChanged(WnckWindow *window, gpointer user_data)
162+{
163+ Q_UNUSED(window);
164+ ((LauncherApplication*)user_data)->windowWorkspaceChanged();
165+}
166+
167+void
168 LauncherApplication::onDragEnter(DeclarativeDragDropEvent* event)
169 {
170 QList<QUrl> urls = validateUrisForLaunch(event->mimeData());
171
172=== modified file 'libunity-2d-private/src/launcherapplication.h'
173--- libunity-2d-private/src/launcherapplication.h 2012-01-27 06:26:14 +0000
174+++ libunity-2d-private/src/launcherapplication.h 2012-02-03 21:02:20 +0000
175@@ -104,6 +104,8 @@
176 Q_INVOKABLE virtual void launchNewInstance();
177
178 Q_INVOKABLE virtual void createMenuActions();
179+ Q_INVOKABLE virtual bool belongsToDifferentWorkspace();
180+ Q_INVOKABLE void connectWindowSignals();
181
182 void updateOverlaysState(const QString& sender, const QMap<QString, QVariant>& properties);
183
184@@ -179,6 +181,8 @@
185 QList<QUrl> validateUrisForLaunch(DeclarativeMimeData* mimedata);
186 QStringList supportedTypes();
187
188+ static void onWindowWorkspaceChanged(WnckWindow *window, gpointer user_data);
189+
190 QString m_dynamicQuicklistPath;
191 QScopedPointer<DBusMenuImporter> m_dynamicQuicklistImporter;
192 QDBusServiceWatcher* m_dynamicQuicklistServiceWatcher;
193
194=== modified file 'libunity-2d-private/src/launcheritem.cpp'
195--- libunity-2d-private/src/launcheritem.cpp 2011-07-29 13:49:34 +0000
196+++ libunity-2d-private/src/launcheritem.cpp 2012-02-03 21:02:20 +0000
197@@ -87,6 +87,12 @@
198 }
199
200 bool
201+LauncherItem::belongsToDifferentWorkspace()
202+{
203+ return false;
204+}
205+
206+bool
207 LauncherItem::progressBarVisible() const
208 {
209 return false;
210
211=== modified file 'libunity-2d-private/src/launcheritem.h'
212--- libunity-2d-private/src/launcheritem.h 2011-07-29 13:49:34 +0000
213+++ libunity-2d-private/src/launcheritem.h 2012-02-03 21:02:20 +0000
214@@ -79,6 +79,7 @@
215 Q_INVOKABLE virtual void activate() = 0;
216 Q_INVOKABLE virtual void createMenuActions() = 0;
217 Q_INVOKABLE virtual void launchNewInstance();
218+ Q_INVOKABLE virtual bool belongsToDifferentWorkspace();
219
220 protected:
221 LauncherContextualMenu* m_menu;
222@@ -100,6 +101,7 @@
223 void counterChanged(int);
224 void emblemVisibleChanged(bool);
225 void emblemChanged(QString);
226+ void windowWorkspaceChanged();
227
228 public Q_SLOTS:
229 /* Default implementation of drag’n’drop handling, should be overridden in
230
231=== modified file 'libunity-2d-private/src/unity2ddeclarativeview.cpp'
232--- libunity-2d-private/src/unity2ddeclarativeview.cpp 2012-02-03 12:09:19 +0000
233+++ libunity-2d-private/src/unity2ddeclarativeview.cpp 2012-02-03 21:02:20 +0000
234@@ -275,6 +275,7 @@
235 void Unity2DDeclarativeView::onActiveWorkspaceChanged()
236 {
237 m_last_focused_window = None;
238+ Q_EMIT activeWorkspaceChanged();
239 }
240
241 #include <unity2ddeclarativeview.moc>
242
243=== modified file 'libunity-2d-private/src/unity2ddeclarativeview.h'
244--- libunity-2d-private/src/unity2ddeclarativeview.h 2012-02-03 12:09:19 +0000
245+++ libunity-2d-private/src/unity2ddeclarativeview.h 2012-02-03 21:02:20 +0000
246@@ -46,6 +46,7 @@
247 void transparentBackgroundChanged(bool);
248 void globalPositionChanged(QPoint);
249 void visibleChanged(bool);
250+ void activeWorkspaceChanged();
251
252 protected:
253 void setupViewport();
254
255=== added file 'tests/launcher/update_pips_tests.rb'
256--- tests/launcher/update_pips_tests.rb 1970-01-01 00:00:00 +0000
257+++ tests/launcher/update_pips_tests.rb 2012-02-03 21:02:20 +0000
258@@ -0,0 +1,316 @@
259+#!/usr/bin/env ruby1.8
260+=begin
261+/*
262+ * This file is part of unity-2d
263+ *
264+ * Copyright 2011 Canonical Ltd.
265+ *
266+ * Authors:
267+ * - Lohith DS <lohith.shivamurthy@canonical.com>
268+ *
269+ * This program is free software; you can redistribute it and/or modify
270+ * it under the terms of the GNU General Public License as published by
271+ * the Free Software Foundation; version 3.
272+ *
273+ * This program is distributed in the hope that it will be useful,
274+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
275+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
276+ * GNU General Public License for more details.
277+ *
278+ * You should have received a copy of the GNU General Public License
279+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
280+ */
281+=end
282+
283+require '../run-tests.rb' unless $INIT_COMPLETED
284+require 'xdo/xwindow'
285+require 'xdo/keyboard'
286+require 'xdo/mouse'
287+require 'timeout'
288+require 'tmpdir'
289+
290+def open_window()
291+ # FIXME : Need to choose a better test application in future?
292+ window_id = -1
293+ o = [('a'..'z'),('A'..'Z')].map{|i| i.to_a}.flatten;
294+ title_string = (0..50).map{ o[rand(o.length)] }.join;
295+ if (@@title_string.empty?)
296+ @@title_string = title_string
297+ end
298+ # Open xman with random title
299+ $SUT.execute_shell_command("xman -geometry 300x90+100+100 -title #{title_string}", :detached => true)
300+ Timeout.timeout(30){ window_id = XDo::XWindow.wait_for_window(title_string)}
301+ Kernel.raise(SystemCallError, "Unable to open xman") if window_id == -1
302+ return XDo::XWindow.new(window_id)
303+end
304+
305+def change_window_workspace(xid)
306+ new_workspace = 0
307+ if xid.desktop > 0
308+ new_workspace=0
309+ else
310+ new_workspace=1
311+ end
312+
313+ xid.desktop=new_workspace
314+ verify_true(3, 'Change window workspace failed') {
315+ xid.desktop==new_workspace
316+ }
317+end
318+
319+def reset_current_workspace
320+ XDo::XWindow.desktop=@@current_workspace
321+ verify_true(TIMEOUT, 'Reset active workspace failed') {
322+ XDo::XWindow.desktop==@@current_workspace
323+ }
324+end
325+
326+def change_user_workspace
327+ new_workspace = 0
328+ if @@current_workspace > 0
329+ new_workspace = 0
330+ else
331+ new_workspace = 1
332+ end
333+
334+ XDo::XWindow.desktop=new_workspace
335+ verify_true(TIMEOUT, 'Change user workspace failed') {
336+ XDo::XWindow.desktop==new_workspace
337+ }
338+end
339+
340+def close_all_test_windows
341+ @@xid_list.each {
342+ |xid|
343+ if (xid.exists?)
344+ xid.close!
345+ end
346+ }
347+end
348+
349+############################# Test Suite #############################
350+context "Launcher pips tests" do
351+ # Run once at the beginning of this test suite
352+ startup do
353+ $SUT.execute_shell_command 'killall unity-2d-launcher'
354+ $SUT.execute_shell_command 'killall unity-2d-launcher'
355+
356+ # Minimize all windows
357+ XDo::XWindow.toggle_minimize_all
358+
359+ @number_of_workspaces = XDo::XWindow.desktop_num
360+ @reset_num_workspaces = false
361+ if @number_of_workspaces < 2
362+ # Setting number of workspaces to minimum(two) to enable the test suite
363+ XDo::XWindow.desktop_num = 2
364+ @reset_num_workspaces = true
365+ end
366+
367+ $SUT.execute_shell_command 'killall xman'
368+ @@current_workspace = XDo::XWindow.desktop
369+ @@xid_list=Array.new
370+
371+ end
372+
373+ # Run once at the end of this test suite
374+ shutdown do
375+ if @reset_num_workspaces == true
376+ # Resetting number of workspaces to " + @number_of_workspaces.to_s
377+ XDo::XWindow.desktop_num=@number_of_workspaces
378+ end
379+ end
380+
381+ # Run before each test case begins
382+ setup do
383+ # Execute the application
384+ @app = $SUT.run( :name => UNITY_2D_LAUNCHER,
385+ :arguments => "-testability",
386+ :sleeptime => 2 )
387+ @@title_string = ""
388+ end
389+
390+ # Run after each test case completes
391+ teardown do
392+ close_all_test_windows
393+ reset_current_workspace
394+ system "pkill -nf unity-2d-launcher"
395+ end
396+
397+ #####################################################################################
398+ # Test cases
399+
400+ # FIXME We need some visual tests for this too
401+
402+ # Test case objectives:
403+ # * Check pips are updated properly when the app is in current workspace
404+ # Pre-conditions
405+ # * This test case assumes that the test app will have only one window
406+ # * For eg, xman is choosen
407+ # * To ensure there is no xman windows running, kill all the xman windows if any
408+ # Test steps
409+ # * Open a xman window
410+ # * Verify the launcher tile pip image matches with the expected one
411+ # Post-conditions
412+ # * None
413+ # References
414+ # * lp:#883172
415+ test "Check pips are updated properly when the app is in current workspace" do
416+ xid = open_window()
417+ @@xid_list << xid
418+
419+ expected_pip_image = 'image://blended/artwork/launcher_arrow_ltr.pngcolor=lightgreyalpha=1'
420+
421+ verify_equal(expected_pip_image, TIMEOUT, 'pip not matching with launcher_arrow_ltr.png'){
422+ @app.Unity2dPanel() \
423+ .LauncherList( :name => 'main' ) \
424+ .QDeclarativeItem( :name => @@title_string ) \
425+ .QDeclarativeImage( :name => 'pips-0')['source']
426+ }
427+ end
428+
429+
430+ # Test case objectives:
431+ # * Check pips are updated properly when the app is moved to different workspace
432+ # Pre-conditions
433+ # * None
434+ # Test steps
435+ # * Move the window to a different workspace
436+ # * Verify the launcher tile pip image matches with the expected one
437+ # Post-conditions
438+ # * None
439+ # References
440+ # * lp:#883172
441+ test "Check pips are updated properly when the app is moved to different workspace" do
442+ xid = open_window()
443+ @@xid_list << xid
444+
445+ change_window_workspace(xid)
446+
447+ expected_pip_image = 'image://blended/artwork/launcher_arrow_outline_ltr.pngcolor=lightgreyalpha=1'
448+
449+ verify_equal(expected_pip_image, TIMEOUT, 'pip not matching with launcher_arrow_outline_ltr.png'){
450+ @app.Unity2dPanel() \
451+ .LauncherList( :name => 'main' ) \
452+ .QDeclarativeItem( :name => @@title_string ) \
453+ .QDeclarativeImage( :name => 'pips-0')['source']
454+ }
455+ end
456+
457+
458+ # Test case objectives:
459+ # * Check launcher pips to indicate an app with two windows each on two different workspaces
460+ # Pre-conditions
461+ # * None
462+ # Test steps
463+ # * Open another window along with first window from the first testcase.
464+ # * Verify the launcher tile pip images matches with the expected one
465+ # Post-conditions
466+ # * None
467+ # References
468+ # * lp:#883172
469+ test "Check launcher pips to indicate an app with two windows each on two different workspaces" do
470+ xid = open_window()
471+ @@xid_list << xid
472+ xid = open_window()
473+ @@xid_list << xid
474+
475+ expected_pip_image = 'image://blended/artwork/launcher_pip_ltr.pngcolor=lightgreyalpha=1'
476+
477+ verify_equal(expected_pip_image, TIMEOUT, 'Pip not matching expected image launcher_pip_ltr.png'){
478+ @app.Unity2dPanel() \
479+ .LauncherList( :name => 'main' ) \
480+ .QDeclarativeItem( :name => @@title_string ) \
481+ .QDeclarativeImage( :name => 'pips-0')['source']
482+ }
483+ end
484+
485+
486+ # Test case objectives:
487+ # * Check launcher pips to indicate an app completely belonging to different workspace
488+ # Pre-conditions
489+ # * None
490+ # Test steps
491+ # * Move the second window too to a different workspace
492+ # * Verify the launcher tile pip image matches with the expected one
493+ # Post-conditions
494+ # * None
495+ # References
496+ # * lp:#883172
497+ test "Check launcher pips to indicate an app completely belonging to different workspace" do
498+ xid = open_window()
499+ @@xid_list << xid
500+ change_window_workspace(xid)
501+
502+ xid = open_window()
503+ @@xid_list << xid
504+ change_window_workspace(xid)
505+
506+ expected_pip_image = 'image://blended/artwork/launcher_arrow_outline_ltr.pngcolor=lightgreyalpha=1'
507+
508+ verify_equal(expected_pip_image, TIMEOUT, 'pip not matching expected image launcher_arrow_outline_ltr.png'){
509+ @app.Unity2dPanel() \
510+ .LauncherList( :name => 'main' ) \
511+ .QDeclarativeItem( :name => @@title_string ) \
512+ .QDeclarativeImage( :name => 'pips-0')['source']
513+ }
514+ end
515+
516+
517+ # Test case objectives:
518+ # * Check launcher pips when an app window is closed.
519+ # Pre-conditions
520+ # * None
521+ # Test steps
522+ # * Close one of the app windows and move the last window back to its original workspace
523+ # * Verify the launcher tile pip image matches with the expected one
524+ # Post-conditions
525+ # * None
526+ # References
527+ # * lp:#883172
528+ test "Check launcher pips when an app window is closed" do
529+ xid = open_window()
530+ @@xid_list << xid
531+ xid = open_window()
532+ @@xid_list << xid
533+
534+ xid.close!
535+ change_window_workspace(@@xid_list[0])
536+
537+ expected_pip_image = 'image://blended/artwork/launcher_arrow_outline_ltr.pngcolor=lightgreyalpha=1'
538+
539+ verify_equal(expected_pip_image, TIMEOUT, 'pip not matching expected image launcher_arrow_outline_ltr.png'){
540+ @app.Unity2dPanel() \
541+ .LauncherList( :name => 'main' ) \
542+ .QDeclarativeItem( :name => @@title_string ) \
543+ .QDeclarativeImage( :name => 'pips-0')['source']
544+ }
545+ end
546+
547+
548+ # Test case objectives:
549+ # * Check launcher pips to indicate when the user workspace changed
550+ # Pre-conditions
551+ # * None
552+ # Test steps
553+ # * Change the user workspace to other than app workspace
554+ # * Verify that the pips are updated properly
555+ # Post-conditions
556+ # * None
557+ # References
558+ # * lp:#883172
559+ test "Check launcher pips to indicate when the user workspace changed" do
560+ xid = open_window()
561+ @@xid_list << xid
562+
563+ change_user_workspace
564+
565+ expected_pip_image = 'image://blended/artwork/launcher_arrow_outline_ltr.pngcolor=lightgreyalpha=1'
566+
567+ verify_equal(expected_pip_image, TIMEOUT, 'pip not matching expected image launcher_arrow_outline_ltr.png'){
568+ @app.Unity2dPanel() \
569+ .LauncherList( :name => 'main' ) \
570+ .QDeclarativeItem( :name => @@title_string ) \
571+ .QDeclarativeImage( :name => 'pips-0')['source']
572+ }
573+ end
574+end

Subscribers

People subscribed via source and target branches