Merge lp:~docky-core/plank/workspace-only into lp:plank

Proposed by Rico Tzschichholz
Status: Merged
Approved by: Robert Dyer
Approved revision: 714
Merged at revision: 718
Proposed branch: lp:~docky-core/plank/workspace-only
Merge into: lp:plank
Diff against target: 443 lines (+174/-42)
5 files modified
lib/DockItems.vala (+136/-38)
lib/DockPreferences.vala (+7/-0)
lib/DockRenderer.vala (+2/-4)
lib/Services/WindowControl.vala (+26/-0)
lib/libplank.symbols (+3/-0)
To merge this branch: bzr merge lp:~docky-core/plank/workspace-only
Reviewer Review Type Date Requested Status
Robert Dyer (community) Approve
Review via email: mp+127535@code.launchpad.net

Description of the change

Adds optional ability to show windows of current workspace only

DockItems: removed signals which aren't used in their desired way which makes them useless it this condition, and add a common changed signal instead

To post a comment you must log in.
lp:~docky-core/plank/workspace-only updated
688. By Rico Tzschichholz

build: dbusmenu is optional so enable it conditionally by default

don't force this dependency and make it more clear it is optional

689. By Rico Tzschichholz

build: Stop including pregenerated c-sources in tarballs

Shipping c-sources results in problems with custom configure flags and
conditional compile options. So drop them for good!

690. By Robert Dyer

plank.desktop was invalid - bug 1063970

691. By Rico Tzschichholz

Revert r690

692. By Robert Dyer

Reinstating rev 690 - Plank does not directly support any specific window manager or DE. IF a specific DE has a problem with our packages, they are welcome to package it themselves.

693. By Robert Dyer

fix theme files - bug 1034755

694. By Rico Tzschichholz

dockwindow: Restrict amount of hover-repositions using a Timeout

This is suppose to avoid spamming the WM with lots of window repositions
while fast hovering dockitems.

695. By Robert Dyer

stop timers when destructing objects

696. By Rico Tzschichholz

Move symbols generation in separate target and add non-fatal check rule

697. By Rico Tzschichholz

hoverwindow: wait for move/show/hide to be executed before continuing

This fixes the appearance of hovers with metacity (introduced with r653)

698. By Rico Tzschichholz

vapi: update Bamf bindings

699. By Rico Tzschichholz

window-control: output name of current window-manager and on its change

700. By Rico Tzschichholz

lib: make sure not to show the hoverwindow while a menu is visible

701. By Rico Tzschichholz

misc: remove custom bamf vapi generation

we are using a patched upstream generated vapi now

702. By Rico Tzschichholz

Use statically sized Gtk.Window and improve non-compositing support

Avoids visually corruptions on adding/removing items caused by set_size
and move operation on Gtk.Window

703. By Rico Tzschichholz

drawing: small optimization and add some convenience methods in Color

704. By Rico Tzschichholz

Fix visual clitch on initially showing the dockwindow

Make the dockwindow invisible until its content is fully drawn the first
time. (Reworked patch from Tom Beckmann)

705. By Rico Tzschichholz

Don't delay initial positioning of the dockwindow

706. By Rico Tzschichholz

Revert r704

It introduced problems with openbox and a race condition with metacity
resulting in the dock not showing at all.

707. By Rico Tzschichholz

update_regions: force triggering a redraw with active compositing support

A changed static_dock_region doesn't implicate the window-size changed
and DockWindow.set_size() won't trigger a redraw.

708. By Rico Tzschichholz

build: Rename libplank.pc to plank.pc

It is more common to have a matching name for vapi, header and pkg-config
files.

709. By Rico Tzschichholz

Fix size/position updates while switching screen-resolution

With enabled compositing support those updates weren't properly handled
after the introduction of "static-window" changes.

Refactor DockWindow.set_size to handle resize and reposition separately.

Move parts of PositionManager.reset_caches into update_dimensions and
cache all needed theme-values.

711. By Rico Tzschichholz

items: pass actual changed items with items_changed

712. By Rico Tzschichholz

reuse wnck.screen reference

Revision history for this message
Robert Dyer (psybers) wrote :

Line 318 - typo in comment 'wether'

Revision history for this message
Robert Dyer (psybers) wrote :

Has this been tested on multiple WMs? Compiz, Mutter, Pantheon, etc?

Revision history for this message
Rico Tzschichholz (ricotz) wrote :

> Has this been tested on multiple WMs? Compiz, Mutter, Pantheon, etc?

I am testing it with Gnome-Shell/Mutter with is comparable with Patheon (aka Gala/Mutter). So I am hoping you can give it a spin on compiz?

lp:~docky-core/plank/workspace-only updated
713. By Rico Tzschichholz

Fix typo in blurb

Revision history for this message
Robert Dyer (psybers) wrote :

In my experience Gala isn't equal to Mutter. Can you get Cassidy to test?

I'll test it on Compiz.

Revision history for this message
Robert Dyer (psybers) wrote :

Fails entirely on Compiz.

review: Needs Fixing
Revision history for this message
Rico Tzschichholz (ricotz) wrote :

> Fails entirely on Compiz.

Right, compiz doesn't use real workspaces but viewports.

lp:~docky-core/plank/workspace-only updated
714. By Rico Tzschichholz

add support for viewports which are used in compiz

Revision history for this message
Rico Tzschichholz (ricotz) wrote :

Please give it another try.

Revision history for this message
Robert Dyer (psybers) wrote :

Closer! At least now it does things.

I think I found a bug (probably not just with Compiz) though.

If an app is pinned, it will show on the dock regardless of which workspace its open window is on.

If an app is not pinned, it only shows on the dock if its window is on the current workspace.

review: Needs Fixing
Revision history for this message
Rico Tzschichholz (ricotz) wrote :

This is the behavior I intended since pinned means pinned ;)

Revision history for this message
Robert Dyer (psybers) wrote :

I think this is not what we want. Most people are only going to run apps that are pinned. So what use would this be - it would act the same as without.

Revision history for this message
Rico Tzschichholz (ricotz) wrote :

Depends on how you use the dock which works if you want to manage open windows.

But how would one handle this another way?
So if you filter pinned apps too what happens with not running pinned apps? Should they show up all the time and disappear if they are already running on another workspace? This could be quite confusing.

The how it works now it was handled in docky too.

Revision history for this message
Robert Dyer (psybers) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/DockItems.vala'
2--- lib/DockItems.vala 2012-08-07 19:38:29 +0000
3+++ lib/DockItems.vala 2012-11-16 19:21:20 +0000
4@@ -31,27 +31,29 @@
5 public class DockItems : GLib.Object
6 {
7 /**
8+ * Triggered when the items collection has changed.
9+ *
10+ * @param added the list of added items
11+ * @param removed the list of removed items
12+ */
13+ public signal void items_changed (Gee.List<DockItem> added, Gee.List<DockItem> removed);
14+
15+ /**
16 * Triggered when the state of an item changes.
17 */
18 public signal void item_state_changed ();
19
20 /**
21- * Triggered when a new item is added to the collection.
22- *
23- * @param item the dockitem which was added
24- */
25- public signal void item_added (DockItem item);
26- /**
27- * Triggered when an item is removed from the collection.
28- *
29- * @param item the dockitem which was removed
30- */
31- public signal void item_removed (DockItem item);
32-
33- /**
34 * A list of the dock items.
35 */
36- public ArrayList<DockItem> Items = new ArrayList<DockItem> ();
37+ public unowned ArrayList<DockItem> Items {
38+ get {
39+ return visible_items;
40+ }
41+ }
42+
43+ ArrayList<DockItem> visible_items = new ArrayList<DockItem> ();
44+ ArrayList<DockItem> internal_items = new ArrayList<DockItem> ();
45
46 FileMonitor? items_monitor = null;
47
48@@ -84,20 +86,36 @@
49
50 load_items ();
51 add_running_apps ();
52- set_item_positions ();
53+ update_visible_items ();
54+
55+ controller.prefs.changed["CurrentWorkspaceOnly"].connect (handle_setting_changed);
56
57 Matcher.get_default ().app_opened.connect (app_opened);
58+
59+ var wnck_screen = Wnck.Screen.get_default ();
60+ wnck_screen.active_window_changed.connect (handle_window_changed);
61+ wnck_screen.active_workspace_changed.connect (handle_workspace_changed);
62+ wnck_screen.viewports_changed.connect (handle_viewports_changed);
63 }
64
65 ~DockItems ()
66 {
67+ controller.prefs.changed["CurrentWorkspaceOnly"].disconnect (handle_setting_changed);
68+
69 Matcher.get_default ().app_opened.disconnect (app_opened);
70
71+ var wnck_screen = Wnck.Screen.get_default ();
72+ wnck_screen.active_window_changed.disconnect (handle_window_changed);
73+ wnck_screen.active_workspace_changed.disconnect (handle_workspace_changed);
74+ wnck_screen.viewports_changed.disconnect (handle_viewports_changed);
75+
76+ visible_items.clear ();
77+
78 var items = new HashSet<DockItem> ();
79- items.add_all (Items);
80+ items.add_all (internal_items);
81 foreach (var item in items)
82 remove_item_without_signaling (item);
83- Items.clear ();
84+ internal_items.clear ();
85
86 if (items_monitor != null) {
87 items_monitor.changed.disconnect (handle_items_dir_changed);
88@@ -114,9 +132,8 @@
89 public void add_item (DockItem item)
90 {
91 add_item_without_signaling (item);
92- set_item_positions ();
93-
94- item_added (item);
95+
96+ update_visible_items ();
97 }
98
99 /**
100@@ -127,9 +144,8 @@
101 public void remove_item (DockItem item)
102 {
103 remove_item_without_signaling (item);
104- set_item_positions ();
105
106- item_removed (item);
107+ update_visible_items ();
108 }
109
110 void signal_item_state_changed ()
111@@ -139,7 +155,7 @@
112
113 ApplicationDockItem? item_for_application (Bamf.Application app)
114 {
115- foreach (var item in Items) {
116+ foreach (var item in internal_items) {
117 unowned ApplicationDockItem? appitem = (item as ApplicationDockItem);
118 if (appitem == null)
119 continue;
120@@ -164,7 +180,7 @@
121 var item = Factory.item_factory.make_item (file);
122
123 if (item.ValidItem)
124- add_item (item);
125+ add_item_without_signaling (item);
126 else
127 warning ("The launcher '%s' in dock item '%s' does not exist", item.Launcher, file.get_path ());
128 }
129@@ -174,7 +190,7 @@
130
131 var favs = new ArrayList<string> ();
132
133- foreach (var item in Items)
134+ foreach (var item in internal_items)
135 if ((item is ApplicationDockItem) && !(item is TransientDockItem))
136 favs.add (item.Launcher);
137
138@@ -183,6 +199,41 @@
139 debug ("done.");
140 }
141
142+ void update_visible_items ()
143+ {
144+ Logger.verbose ("DockItems.update_visible_items ()");
145+
146+ var old_items = new ArrayList<DockItem> ();
147+ old_items.add_all (visible_items);
148+
149+ visible_items.clear ();
150+
151+ if (controller.prefs.CurrentWorkspaceOnly) {
152+ var active_workspace = Wnck.Screen.get_default ().get_active_workspace ();
153+ foreach (var item in internal_items) {
154+ var transient = (item as TransientDockItem);
155+ if (transient != null
156+ && !WindowControl.has_window_on_workspace (transient.App, active_workspace))
157+ continue;
158+ visible_items.add (item);
159+ }
160+ } else {
161+ visible_items.add_all (internal_items);
162+ }
163+
164+ set_item_positions ();
165+
166+ var added_items = new ArrayList<DockItem> ();
167+ added_items.add_all (visible_items);
168+ added_items.remove_all (old_items);
169+
170+ var removed_items = old_items;
171+ removed_items.remove_all (visible_items);
172+
173+ if (added_items.size > 0 || removed_items.size > 0)
174+ items_changed (added_items, removed_items);
175+ }
176+
177 void add_running_apps ()
178 {
179 // do this a better more efficient way
180@@ -194,7 +245,7 @@
181 {
182 var last_sort = 1000;
183
184- foreach (var item in Items)
185+ foreach (var item in internal_items)
186 if (item is TransientDockItem)
187 last_sort = item.Sort;
188
189@@ -217,7 +268,7 @@
190 void set_item_positions ()
191 {
192 int pos = 0;
193- foreach (var i in Items)
194+ foreach (var i in visible_items)
195 i.Position = pos++;
196 }
197
198@@ -242,7 +293,7 @@
199
200 // remove peristent and invalid items
201 var remove = new ArrayList<DockItem> ();
202- foreach (var item in Items)
203+ foreach (var item in internal_items)
204 if (!(item is TransientDockItem) || !item.ValidItem)
205 remove.add (item);
206 foreach (var item in remove)
207@@ -250,15 +301,48 @@
208
209 load_items ();
210 add_running_apps ();
211- set_item_positions ();
212-
213- item_state_changed ();
214+ update_visible_items ();
215+ }
216+
217+ void handle_setting_changed ()
218+ {
219+ update_visible_items ();
220+ }
221+
222+ void handle_window_changed (Wnck.Window? previous)
223+ {
224+ if (!controller.prefs.CurrentWorkspaceOnly)
225+ return;
226+
227+ if (previous == null
228+ || previous.get_workspace () == previous.get_screen ().get_active_workspace ())
229+ return;
230+
231+ update_visible_items ();
232+ }
233+
234+ void handle_workspace_changed (Wnck.Screen screen, Wnck.Workspace previously_active_space)
235+ {
236+ if (!controller.prefs.CurrentWorkspaceOnly
237+ || screen.get_active_workspace ().is_virtual ())
238+ return;
239+
240+ update_visible_items ();
241+ }
242+
243+ void handle_viewports_changed (Wnck.Screen screen)
244+ {
245+ if (!controller.prefs.CurrentWorkspaceOnly
246+ || !screen.get_active_workspace ().is_virtual ())
247+ return;
248+
249+ update_visible_items ();
250 }
251
252 void add_item_without_signaling (DockItem item)
253 {
254- Items.add (item);
255- Items.sort ((CompareFunc) compare_items);
256+ internal_items.add (item);
257+ internal_items.sort ((CompareFunc) compare_items);
258
259 item.AddTime = new DateTime.now_utc ();
260 item.notify["Icon"].connect (signal_item_state_changed);
261@@ -289,7 +373,7 @@
262 (item as ApplicationDockItem).pin_launcher.disconnect (pin_item);
263 }
264
265- Items.remove (item);
266+ internal_items.remove (item);
267 controller.unity.remove_entry (item);
268 }
269
270@@ -304,12 +388,19 @@
271 return;
272 }
273
274+ var index = internal_items.index_of (item);
275+
276 remove_item_without_signaling (item);
277-
278 var new_item = new TransientDockItem.with_application (app);
279 new_item.Position = item.Position;
280-
281 add_item_without_signaling (new_item);
282+
283+ if (index >= 0) {
284+ internal_items.remove (new_item);
285+ internal_items.insert (index, new_item);
286+ }
287+
288+ update_visible_items ();
289 item_state_changed ();
290 }
291
292@@ -318,7 +409,7 @@
293 if (item is TransientDockItem) {
294 var last_sort = 0;
295
296- foreach (var i in Items) {
297+ foreach (var i in internal_items) {
298 if (i == item)
299 break;
300 if (!(i is TransientDockItem))
301@@ -329,12 +420,19 @@
302 if (dockitem_file == null)
303 return;
304
305+ var index = visible_items.index_of (item);
306+
307 remove_item_without_signaling (item);
308 var new_item = new ApplicationDockItem.with_dockitem_file (dockitem_file);
309 new_item.Position = item.Position;
310 add_item_without_signaling (new_item);
311
312- item_state_changed ();
313+ if (index >= 0) {
314+ visible_items.insert (index, new_item);
315+ item_state_changed ();
316+ } else {
317+ update_visible_items ();
318+ }
319 } else {
320 item.delete ();
321 }
322
323=== modified file 'lib/DockPreferences.vala'
324--- lib/DockPreferences.vala 2012-09-26 00:34:22 +0000
325+++ lib/DockPreferences.vala 2012-11-16 19:21:20 +0000
326@@ -31,6 +31,9 @@
327 const int MIN_ICON_SIZE = 24;
328 const int MAX_ICON_SIZE = 128;
329
330+ [Description(nick = "current-workspace-only", blurb = "Whether to show only windows of the current workspace.")]
331+ public bool CurrentWorkspaceOnly { get; set; }
332+
333 [Description(nick = "icon-size", blurb = "The size of dock icons (in pixels).")]
334 public int IconSize { get; set; }
335
336@@ -79,6 +82,7 @@
337 {
338 Logger.verbose ("DockPreferences.reset_properties ()");
339
340+ CurrentWorkspaceOnly = false;
341 IconSize = 48;
342 HideMode = HideType.INTELLIGENT;
343 UnhideDelay = 0;
344@@ -138,6 +142,9 @@
345 protected override void verify (string prop)
346 {
347 switch (prop) {
348+ case "CurrentWorkspaceOnly":
349+ break;
350+
351 case "IconSize":
352 if (IconSize < MIN_ICON_SIZE)
353 IconSize = MIN_ICON_SIZE;
354
355=== modified file 'lib/DockRenderer.vala'
356--- lib/DockRenderer.vala 2012-10-04 11:54:18 +0000
357+++ lib/DockRenderer.vala 2012-11-16 19:21:20 +0000
358@@ -86,9 +86,8 @@
359 controller.prefs.notify.connect (prefs_changed);
360 theme.changed.connect (theme_changed);
361
362- controller.items.item_removed.connect (items_changed);
363- controller.items.item_added.connect (items_changed);
364 controller.items.item_state_changed.connect (item_state_changed);
365+ controller.items.items_changed.connect (items_changed);
366
367 screen_is_composited = Gdk.Screen.get_default ().is_composited ();
368 Gdk.Screen.get_default ().composited_changed.connect (composited_changed);
369@@ -113,9 +112,8 @@
370 controller.prefs.notify.disconnect (prefs_changed);
371 theme.changed.disconnect (theme_changed);
372
373- controller.items.item_removed.disconnect (items_changed);
374- controller.items.item_added.disconnect (items_changed);
375 controller.items.item_state_changed.disconnect (item_state_changed);
376+ controller.items.items_changed.disconnect (items_changed);
377
378 Gdk.Screen.get_default ().composited_changed.disconnect (composited_changed);
379
380
381=== modified file 'lib/Services/WindowControl.vala'
382--- lib/Services/WindowControl.vala 2012-10-22 06:21:06 +0000
383+++ lib/Services/WindowControl.vala 2012-11-16 19:21:20 +0000
384@@ -134,6 +134,32 @@
385 return false;
386 }
387
388+ public static bool has_window_on_workspace (Bamf.Application app, Wnck.Workspace workspace)
389+ {
390+ Screen.get_default ();
391+ Array<uint32>? xids = app.get_xids ();
392+
393+ warn_if_fail (xids != null);
394+
395+ var is_virtual = workspace.is_virtual ();
396+
397+ for (var i = 0; xids != null && i < xids.length; i++) {
398+ var window = Wnck.Window.@get (xids.index (i));
399+ if (window == null)
400+ continue;
401+
402+ if (!is_virtual) {
403+ if (window.is_on_workspace (workspace))
404+ return true;
405+ } else {
406+ if (window.is_in_viewport (workspace))
407+ return true;
408+ }
409+ }
410+
411+ return false;
412+ }
413+
414 public static ArrayList<Bamf.Window> get_windows (Bamf.Application app)
415 {
416 var windows = new ArrayList<Bamf.Window> ();
417
418=== modified file 'lib/libplank.symbols'
419--- lib/libplank.symbols 2012-11-15 11:26:39 +0000
420+++ lib/libplank.symbols 2012-11-16 19:21:20 +0000
421@@ -3,12 +3,14 @@
422 plank_dock_controller_new
423 plank_dock_items_add_item
424 plank_dock_items_construct
425+plank_dock_items_get_Items
426 plank_dock_items_get_type
427 plank_dock_items_new
428 plank_dock_items_remove_item
429 plank_dock_preferences_construct
430 plank_dock_preferences_construct_with_filename
431 plank_dock_preferences_decrease_icon_size
432+plank_dock_preferences_get_CurrentWorkspaceOnly
433 plank_dock_preferences_get_HideMode
434 plank_dock_preferences_get_IconSize
435 plank_dock_preferences_get_monitor
436@@ -21,6 +23,7 @@
437 plank_dock_preferences_is_horizontal_dock
438 plank_dock_preferences_new
439 plank_dock_preferences_new_with_filename
440+plank_dock_preferences_set_CurrentWorkspaceOnly
441 plank_dock_preferences_set_HideMode
442 plank_dock_preferences_set_IconSize
443 plank_dock_preferences_set_Monitor

Subscribers

People subscribed via source and target branches

to status/vote changes: