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
=== modified file 'src/LauncherController.cpp'
--- src/LauncherController.cpp 2010-12-07 23:19:18 +0000
+++ src/LauncherController.cpp 2010-12-09 20:02:20 +0000
@@ -39,7 +39,12 @@
39 _favorite_store = FavoriteStore::GetDefault ();39 _favorite_store = FavoriteStore::GetDefault ();
4040
41 g_timeout_add (5000, (GSourceFunc) &LauncherController::BamfTimerCallback, this);41 g_timeout_add (5000, (GSourceFunc) &LauncherController::BamfTimerCallback, this);
42 InsertExpoAction ();42
43 _num_workspaces = _screen->vpSize ().width ();
44 if(_num_workspaces > 1)
45 {
46 InsertExpoAction ();
47 }
43 InsertTrash ();48 InsertTrash ();
44}49}
4550
@@ -86,6 +91,21 @@
86}91}
8792
88void93void
94LauncherController::UpdateNumWorkspaces (int workspaces)
95{
96 if ((_num_workspaces == 0) && (workspaces > 0))
97 {
98 InsertExpoAction ();
99 }
100 else if((_num_workspaces > 0) && (workspaces == 0))
101 {
102 RemoveExpoAction ();
103 }
104
105 _num_workspaces = workspaces;
106}
107
108void
89LauncherController::InsertTrash ()109LauncherController::InsertTrash ()
90{110{
91 TrashLauncherIcon *icon;111 TrashLauncherIcon *icon;
@@ -96,18 +116,23 @@
96void116void
97LauncherController::InsertExpoAction ()117LauncherController::InsertExpoAction ()
98{118{
99 SimpleLauncherIcon *expoIcon;119 _expoIcon = new SimpleLauncherIcon (_launcher);
100 expoIcon = new SimpleLauncherIcon (_launcher);120
101 121 _expoIcon->SetTooltipText ("Workspace Switcher");
102 expoIcon->SetTooltipText ("Workspace Switcher");122 _expoIcon->SetIconName ("workspace-switcher");
103 expoIcon->SetIconName ("workspace-switcher");123 _expoIcon->SetQuirk (LAUNCHER_ICON_QUIRK_VISIBLE, true);
104 expoIcon->SetQuirk (LAUNCHER_ICON_QUIRK_VISIBLE, true);124 _expoIcon->SetQuirk (LAUNCHER_ICON_QUIRK_RUNNING, false);
105 expoIcon->SetQuirk (LAUNCHER_ICON_QUIRK_RUNNING, false);125 _expoIcon->SetIconType (LAUNCHER_ICON_TYPE_END);
106 expoIcon->SetIconType (LAUNCHER_ICON_TYPE_END);126
107 127 _expoIcon->MouseClick.connect (sigc::mem_fun (this, &LauncherController::OnExpoClicked));
108 expoIcon->MouseClick.connect (sigc::mem_fun (this, &LauncherController::OnExpoClicked));128
109 129 RegisterIcon (_expoIcon);
110 RegisterIcon (expoIcon);130}
131
132void
133LauncherController::RemoveExpoAction ()
134{
135 _model->RemoveIcon (_expoIcon);
111}136}
112137
113bool138bool
114139
=== modified file 'src/LauncherController.h'
--- src/LauncherController.h 2010-11-25 01:49:19 +0000
+++ src/LauncherController.h 2010-12-09 20:02:20 +0000
@@ -46,16 +46,19 @@
46 void PresentIconOwningWindow (Window window);46 void PresentIconOwningWindow (Window window);
47 47
48private:48private:
49 BamfMatcher* _matcher;49 BamfMatcher* _matcher;
50 CompAction* _expo_action;50 CompAction* _expo_action;
51 CompScreen* _screen;51 CompScreen* _screen;
52 Launcher* _launcher;52 Launcher* _launcher;
53 LauncherModel* _model;53 LauncherModel* _model;
54 nux::BaseWindow* _window;54 nux::BaseWindow* _window;
55 FavoriteStore* _favorite_store;55 FavoriteStore* _favorite_store;
56 int _sort_priority;56 SimpleLauncherIcon* _expoIcon;
57 int _sort_priority;
58 int _num_workspaces;
5759
58 void InsertExpoAction ();60 void InsertExpoAction ();
61 void RemoveExpoAction ();
59 62
60 void InsertTrash ();63 void InsertTrash ();
6164
@@ -67,6 +70,8 @@
6770
68 void OnExpoClicked (int button);71 void OnExpoClicked (int button);
69 72
73 void UpdateNumWorkspaces(int workspaces);
74
70 /* statics */75 /* statics */
71 76
72 static bool CompareIcons (LauncherIcon *first, LauncherIcon *second);77 static bool CompareIcons (LauncherIcon *first, LauncherIcon *second);
7378
=== modified file 'src/unity.cpp'
--- src/unity.cpp 2010-12-09 17:56:23 +0000
+++ src/unity.cpp 2010-12-09 20:02:20 +0000
@@ -388,6 +388,7 @@
388 }388 }
389}389}
390390
391<<<<<<< TREE
391static gboolean392static gboolean
392write_logger_data_to_disk (gpointer data)393write_logger_data_to_disk (gpointer data)
393{394{
@@ -395,6 +396,26 @@
395 return FALSE;396 return FALSE;
396}397}
397398
399=======
400/* Handle changes in the number of workspaces by showing the switcher
401 * or not showing the switcher */
402bool
403UnityScreen::setOptionForPlugin(const char *plugin, const char *name,
404 CompOption::Value &v)
405{
406 bool status;
407 status = screen->setOptionForPlugin (plugin, name, v);
408 if (status)
409 {
410 if (strcmp (plugin, "core") == 0 && strcmp (name, "hsize") == 0)
411 {
412 controller->UpdateNumWorkspaces(screen->vpSize ().width ());
413 }
414 }
415 return status;
416}
417
418>>>>>>> MERGE-SOURCE
398UnityScreen::UnityScreen (CompScreen *screen) :419UnityScreen::UnityScreen (CompScreen *screen) :
399 PluginClassHandler <UnityScreen, CompScreen> (screen),420 PluginClassHandler <UnityScreen, CompScreen> (screen),
400 screen (screen),421 screen (screen),
401422
=== modified file 'src/unity.h'
--- src/unity.h 2010-12-06 23:36:00 +0000
+++ src/unity.h 2010-12-09 20:02:20 +0000
@@ -93,6 +93,11 @@
93 /* handle option changes and change settings inside of the93 /* handle option changes and change settings inside of the
94 * panel and dock views */94 * panel and dock views */
95 void optionChanged (CompOption *, Options num);95 void optionChanged (CompOption *, Options num);
96
97 /* Handle changes in the number of workspaces by showing the switcher
98 * or not showing the switcher */
99 bool setOptionForPlugin(const char *plugin, const char *name,
100 CompOption::Value &v);
96101
97 /* init plugin actions for screen */102 /* init plugin actions for screen */
98 bool initPluginForScreen (CompPlugin *p);103 bool initPluginForScreen (CompPlugin *p);