Merge lp:~ruben-verweij/unity/fix-677594-workspaces into lp:unity

Proposed by Ruben Verweij
Status: Superseded
Proposed branch: lp:~ruben-verweij/unity/fix-677594-workspaces
Merge into: lp:unity
Diff against target: 171 lines (+77/-21) (has conflicts)
4 files modified
src/LauncherController.cpp (+38/-13)
src/LauncherController.h (+13/-8)
src/unity.cpp (+21/-0)
src/unity.h (+5/-0)
Text conflict in src/unity.cpp
To merge this branch: bzr merge lp:~ruben-verweij/unity/fix-677594-workspaces
Reviewer Review Type Date Requested Status
Neil J. Patel (community) Needs Fixing
Review via email: mp+43060@code.launchpad.net

This proposal has been superseded by a proposal from 2010-12-09.

Description of the change

Fix launchpad bug 677594 so the Workspace switcher is not shown when there is only one workspace. This uses GConf to check if the number of workspaces Compiz uses is greater than 1.

To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Hi,

You don't need to use gconf to do this, you can just ask compiz directly for the number of workspaces with screen->vpSize ().width ();

Also if you want to be notified when this number changes you can implement a

bool
UnityScreen::setOptionForPlugin (const char *plugin, const char *name, CompOption::Value &v) and make sure that UnityScreen inherits ScreenInterface (and that we call ScreenInterface::setHandler (screen) in the UnityScreen construtor) and then check for plugin == "core" and name == "hsize" and react on that change.

See git.compiz.org/compiz/core/plugins/cube/src/cube.cpp:1622 for some ideas on this.

Remind me that this method is full of suck and I need to change it.

Revision history for this message
Neil J. Patel (njpatel) wrote :

As per sams comment

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/LauncherController.cpp'
2--- src/LauncherController.cpp 2010-12-07 23:19:18 +0000
3+++ src/LauncherController.cpp 2010-12-09 20:02:20 +0000
4@@ -39,7 +39,12 @@
5 _favorite_store = FavoriteStore::GetDefault ();
6
7 g_timeout_add (5000, (GSourceFunc) &LauncherController::BamfTimerCallback, this);
8- InsertExpoAction ();
9+
10+ _num_workspaces = _screen->vpSize ().width ();
11+ if(_num_workspaces > 1)
12+ {
13+ InsertExpoAction ();
14+ }
15 InsertTrash ();
16 }
17
18@@ -86,6 +91,21 @@
19 }
20
21 void
22+LauncherController::UpdateNumWorkspaces (int workspaces)
23+{
24+ if ((_num_workspaces == 0) && (workspaces > 0))
25+ {
26+ InsertExpoAction ();
27+ }
28+ else if((_num_workspaces > 0) && (workspaces == 0))
29+ {
30+ RemoveExpoAction ();
31+ }
32+
33+ _num_workspaces = workspaces;
34+}
35+
36+void
37 LauncherController::InsertTrash ()
38 {
39 TrashLauncherIcon *icon;
40@@ -96,18 +116,23 @@
41 void
42 LauncherController::InsertExpoAction ()
43 {
44- SimpleLauncherIcon *expoIcon;
45- expoIcon = new SimpleLauncherIcon (_launcher);
46-
47- expoIcon->SetTooltipText ("Workspace Switcher");
48- expoIcon->SetIconName ("workspace-switcher");
49- expoIcon->SetQuirk (LAUNCHER_ICON_QUIRK_VISIBLE, true);
50- expoIcon->SetQuirk (LAUNCHER_ICON_QUIRK_RUNNING, false);
51- expoIcon->SetIconType (LAUNCHER_ICON_TYPE_END);
52-
53- expoIcon->MouseClick.connect (sigc::mem_fun (this, &LauncherController::OnExpoClicked));
54-
55- RegisterIcon (expoIcon);
56+ _expoIcon = new SimpleLauncherIcon (_launcher);
57+
58+ _expoIcon->SetTooltipText ("Workspace Switcher");
59+ _expoIcon->SetIconName ("workspace-switcher");
60+ _expoIcon->SetQuirk (LAUNCHER_ICON_QUIRK_VISIBLE, true);
61+ _expoIcon->SetQuirk (LAUNCHER_ICON_QUIRK_RUNNING, false);
62+ _expoIcon->SetIconType (LAUNCHER_ICON_TYPE_END);
63+
64+ _expoIcon->MouseClick.connect (sigc::mem_fun (this, &LauncherController::OnExpoClicked));
65+
66+ RegisterIcon (_expoIcon);
67+}
68+
69+void
70+LauncherController::RemoveExpoAction ()
71+{
72+ _model->RemoveIcon (_expoIcon);
73 }
74
75 bool
76
77=== modified file 'src/LauncherController.h'
78--- src/LauncherController.h 2010-11-25 01:49:19 +0000
79+++ src/LauncherController.h 2010-12-09 20:02:20 +0000
80@@ -46,16 +46,19 @@
81 void PresentIconOwningWindow (Window window);
82
83 private:
84- BamfMatcher* _matcher;
85- CompAction* _expo_action;
86- CompScreen* _screen;
87- Launcher* _launcher;
88- LauncherModel* _model;
89- nux::BaseWindow* _window;
90- FavoriteStore* _favorite_store;
91- int _sort_priority;
92+ BamfMatcher* _matcher;
93+ CompAction* _expo_action;
94+ CompScreen* _screen;
95+ Launcher* _launcher;
96+ LauncherModel* _model;
97+ nux::BaseWindow* _window;
98+ FavoriteStore* _favorite_store;
99+ SimpleLauncherIcon* _expoIcon;
100+ int _sort_priority;
101+ int _num_workspaces;
102
103 void InsertExpoAction ();
104+ void RemoveExpoAction ();
105
106 void InsertTrash ();
107
108@@ -67,6 +70,8 @@
109
110 void OnExpoClicked (int button);
111
112+ void UpdateNumWorkspaces(int workspaces);
113+
114 /* statics */
115
116 static bool CompareIcons (LauncherIcon *first, LauncherIcon *second);
117
118=== modified file 'src/unity.cpp'
119--- src/unity.cpp 2010-12-09 17:56:23 +0000
120+++ src/unity.cpp 2010-12-09 20:02:20 +0000
121@@ -388,6 +388,7 @@
122 }
123 }
124
125+<<<<<<< TREE
126 static gboolean
127 write_logger_data_to_disk (gpointer data)
128 {
129@@ -395,6 +396,26 @@
130 return FALSE;
131 }
132
133+=======
134+/* Handle changes in the number of workspaces by showing the switcher
135+ * or not showing the switcher */
136+bool
137+UnityScreen::setOptionForPlugin(const char *plugin, const char *name,
138+ CompOption::Value &v)
139+{
140+ bool status;
141+ status = screen->setOptionForPlugin (plugin, name, v);
142+ if (status)
143+ {
144+ if (strcmp (plugin, "core") == 0 && strcmp (name, "hsize") == 0)
145+ {
146+ controller->UpdateNumWorkspaces(screen->vpSize ().width ());
147+ }
148+ }
149+ return status;
150+}
151+
152+>>>>>>> MERGE-SOURCE
153 UnityScreen::UnityScreen (CompScreen *screen) :
154 PluginClassHandler <UnityScreen, CompScreen> (screen),
155 screen (screen),
156
157=== modified file 'src/unity.h'
158--- src/unity.h 2010-12-06 23:36:00 +0000
159+++ src/unity.h 2010-12-09 20:02:20 +0000
160@@ -93,6 +93,11 @@
161 /* handle option changes and change settings inside of the
162 * panel and dock views */
163 void optionChanged (CompOption *, Options num);
164+
165+ /* Handle changes in the number of workspaces by showing the switcher
166+ * or not showing the switcher */
167+ bool setOptionForPlugin(const char *plugin, const char *name,
168+ CompOption::Value &v);
169
170 /* init plugin actions for screen */
171 bool initPluginForScreen (CompPlugin *p);