Merge lp:~3v1n0/unity/expo-dnd-removal 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: 3148
Proposed branch: lp:~3v1n0/unity/expo-dnd-removal
Merge into: lp:unity
Prerequisite: lp:~3v1n0/unity/favorites-migration-hardcoded
Diff against target: 170 lines (+46/-6)
8 files modified
launcher/ExpoLauncherIcon.cpp (+5/-0)
launcher/ExpoLauncherIcon.h (+1/-0)
tests/test_expo_launcher_icon.cpp (+13/-4)
unity-shared/PluginAdapter.cpp (+20/-0)
unity-shared/PluginAdapter.h (+1/-0)
unity-shared/StandaloneWindowManager.cpp (+4/-1)
unity-shared/StandaloneWindowManager.h (+1/-1)
unity-shared/WindowManager.h (+1/-0)
To merge this branch: bzr merge lp:~3v1n0/unity/expo-dnd-removal
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+147724@code.launchpad.net

Commit message

ExpoLauncherIcon: Set the viewport size to 1,1 (i.e. diable workspaces) on icon Removal

Like when dragged to trash!

Description of the change

This is the last part of the so awaited saga "Launcher - Workspace switcher should not be in the Launcher by default".

Now dragging the WS icon to the trash, disables the workspaces.

It requires the compiz fix lp:~3v1n0/compiz/ccp-core-options-save-fix/+merge/147716 in order to work after a compiz reboot (i.e. to actually save the setting)

Tests added.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/ExpoLauncherIcon.cpp'
2--- launcher/ExpoLauncherIcon.cpp 2012-12-03 16:09:51 +0000
3+++ launcher/ExpoLauncherIcon.cpp 2013-02-11 17:32:24 +0000
4@@ -66,6 +66,11 @@
5 }
6 }
7
8+void ExpoLauncherIcon::AboutToRemove()
9+{
10+ WindowManager::Default().SetViewportSize(1, 1);
11+}
12+
13 void ExpoLauncherIcon::UpdateIcon()
14 {
15 auto const& vp = WindowManager::Default().GetCurrentViewport();
16
17=== modified file 'launcher/ExpoLauncherIcon.h'
18--- launcher/ExpoLauncherIcon.h 2012-12-03 15:34:23 +0000
19+++ launcher/ExpoLauncherIcon.h 2013-02-11 17:32:24 +0000
20@@ -32,6 +32,7 @@
21 public:
22 ExpoLauncherIcon();
23 void Stick(bool save);
24+ void AboutToRemove();
25
26 protected:
27 void ActivateLauncherIcon(ActionArg arg);
28
29=== modified file 'tests/test_expo_launcher_icon.cpp'
30--- tests/test_expo_launcher_icon.cpp 2012-12-03 16:09:51 +0000
31+++ tests/test_expo_launcher_icon.cpp 2013-02-11 17:32:24 +0000
32@@ -71,14 +71,14 @@
33 wm->SetCurrentViewport(nux::Point(0, 1));
34 wm->screen_viewport_switch_ended.emit();
35 EXPECT_EQ(icon.icon_name, "workspace-switcher-left-bottom");
36-
37+
38 wm->SetCurrentViewport(nux::Point(1, 1));
39 wm->screen_viewport_switch_ended.emit();
40 EXPECT_EQ(icon.icon_name, "workspace-switcher-right-bottom");
41
42 wm->SetCurrentViewport(nux::Point(0, 0));
43 wm->screen_viewport_switch_ended.emit();
44- EXPECT_EQ(icon.icon_name, "workspace-switcher-top-left");
45+ EXPECT_EQ(icon.icon_name, "workspace-switcher-top-left");
46 }
47
48 TEST_F(TestExpoLauncherIcon, Icon2x2Layout_Expo)
49@@ -92,14 +92,14 @@
50 wm->SetCurrentViewport(nux::Point(0, 1));
51 wm->terminate_expo.emit();
52 EXPECT_EQ(icon.icon_name, "workspace-switcher-left-bottom");
53-
54+
55 wm->SetCurrentViewport(nux::Point(1, 1));
56 wm->terminate_expo.emit();
57 EXPECT_EQ(icon.icon_name, "workspace-switcher-right-bottom");
58
59 wm->SetCurrentViewport(nux::Point(0, 0));
60 wm->terminate_expo.emit();
61- EXPECT_EQ(icon.icon_name, "workspace-switcher-top-left");
62+ EXPECT_EQ(icon.icon_name, "workspace-switcher-top-left");
63 }
64
65 TEST_F(TestExpoLauncherIcon, IconNot2x2Layout)
66@@ -116,4 +116,13 @@
67 EXPECT_EQ(icon.icon_name, "workspace-switcher-top-left");
68 }
69
70+TEST_F(TestExpoLauncherIcon, AboutToRemoveDisablesViewport)
71+{
72+ wm->SetViewportSize(2, 2);
73+
74+ icon.AboutToRemove();
75+ EXPECT_EQ(wm->GetViewportHSize(), 1);
76+ EXPECT_EQ(wm->GetViewportVSize(), 1);
77+}
78+
79 }
80
81=== modified file 'unity-shared/PluginAdapter.cpp'
82--- unity-shared/PluginAdapter.cpp 2013-02-04 23:09:24 +0000
83+++ unity-shared/PluginAdapter.cpp 2013-02-11 17:32:24 +0000
84@@ -1113,6 +1113,26 @@
85 return nux::Point(vp.x(), vp.y());
86 }
87
88+void PluginAdapter::SetViewportSize(int horizontal, int vertical)
89+{
90+ if (horizontal < 1 || vertical < 1)
91+ {
92+ LOG_ERROR(logger) << "Impossible to set viewport to invalid values "
93+ << horizontal << "x" << vertical;
94+ return;
95+ }
96+
97+ CompOption::Value hsize;
98+ hsize.set<int>(horizontal);
99+ m_Screen->setOptionForPlugin("core", "hsize", hsize);
100+
101+ CompOption::Value vsize(vertical);
102+ vsize.set<int>(vertical);
103+ m_Screen->setOptionForPlugin("core", "vsize", vsize);
104+
105+ LOG_INFO(logger) << "Setting viewport size to " << hsize.i() << "x" << vsize.i();
106+}
107+
108 int PluginAdapter::GetViewportHSize() const
109 {
110 return m_Screen->vpSize().width();
111
112=== modified file 'unity-shared/PluginAdapter.h'
113--- unity-shared/PluginAdapter.h 2013-02-04 23:09:24 +0000
114+++ unity-shared/PluginAdapter.h 2013-02-11 17:32:24 +0000
115@@ -180,6 +180,7 @@
116 int WorkspaceCount() const;
117
118 nux::Point GetCurrentViewport() const override;
119+ void SetViewportSize(int horizontal, int vertical) override;
120 int GetViewportHSize() const override;
121 int GetViewportVSize() const override;
122
123
124=== modified file 'unity-shared/StandaloneWindowManager.cpp'
125--- unity-shared/StandaloneWindowManager.cpp 2013-02-05 21:12:51 +0000
126+++ unity-shared/StandaloneWindowManager.cpp 2013-02-11 17:32:24 +0000
127@@ -492,8 +492,11 @@
128 {
129 }
130
131-void StandaloneWindowManager::SetViewportSize(unsigned horizontal, unsigned vertical)
132+void StandaloneWindowManager::SetViewportSize(int horizontal, int vertical)
133 {
134+ if (horizontal < 1 || vertical < 1)
135+ return;
136+
137 nux::Size new_size(horizontal, vertical);
138
139 if (viewport_size_ == new_size)
140
141=== modified file 'unity-shared/StandaloneWindowManager.h'
142--- unity-shared/StandaloneWindowManager.h 2013-02-04 23:15:07 +0000
143+++ unity-shared/StandaloneWindowManager.h 2013-02-11 17:32:24 +0000
144@@ -136,6 +136,7 @@
145 virtual int WorkspaceCount() const;
146
147 nux::Point GetCurrentViewport() const override;
148+ void SetViewportSize(int horizontal, int vertical);
149 int GetViewportHSize() const override;
150 int GetViewportVSize() const override;
151
152@@ -152,7 +153,6 @@
153 void SetScaleActiveForGroup(bool scale_active_for_group);
154 void SetCurrentDesktop(unsigned desktop_id);
155
156- void SetViewportSize(unsigned horizontal, unsigned vertical);
157 void SetCurrentViewport(nux::Point const& vp);
158 void SetWorkareaGeometry(nux::Geometry const& geo);
159
160
161=== modified file 'unity-shared/WindowManager.h'
162--- unity-shared/WindowManager.h 2013-02-04 23:09:24 +0000
163+++ unity-shared/WindowManager.h 2013-02-11 17:32:24 +0000
164@@ -145,6 +145,7 @@
165 virtual int WorkspaceCount() const = 0;
166
167 virtual nux::Point GetCurrentViewport() const = 0;
168+ virtual void SetViewportSize(int horizontal, int vertical) = 0;
169 virtual int GetViewportHSize() const = 0;
170 virtual int GetViewportVSize() const = 0;
171