Merge lp:~shippo/plank/fix-1248689 into lp:~shippo/plank/test

Proposed by Peter Feichtinger
Status: Merged
Approved by: Peter Feichtinger
Approved revision: 1592
Merged at revision: 1593
Proposed branch: lp:~shippo/plank/fix-1248689
Merge into: lp:~shippo/plank/test
Diff against target: 284 lines (+127/-39)
4 files modified
lib/Items/ApplicationDockItem.vala (+43/-23)
lib/Items/DefaultApplicationDockItemProvider.vala (+4/-0)
lib/Services/WindowControl.vala (+79/-16)
lib/libplank.symbols (+1/-0)
To merge this branch: bzr merge lp:~shippo/plank/fix-1248689
Reviewer Review Type Date Requested Status
Peter Feichtinger Approve
Review via email: mp+319849@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Peter Feichtinger (shippo) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/Items/ApplicationDockItem.vala'
--- lib/Items/ApplicationDockItem.vala 2017-02-09 12:53:29 +0000
+++ lib/Items/ApplicationDockItem.vala 2017-03-14 17:22:36 +0000
@@ -276,27 +276,45 @@
276 app_window_removed ();276 app_window_removed ();
277 }277 }
278 278
279 void update_indicator ()279 public void update_indicator ()
280 {280 {
281 //FIXME Do not be silly if the application is running281 switch (get_window_count ()) {
282 // we must indicate it, same goes for the opposite.282 case 0:
283
284 var is_running = is_running ();
285
286 if (!is_running) {
287 if (Indicator != IndicatorState.NONE)283 if (Indicator != IndicatorState.NONE)
288 Indicator = IndicatorState.NONE;284 Indicator = IndicatorState.NONE;
289 return;285 break;
290 }286 case 1:
291
292 var window_count = App.get_windows ().length ();
293
294 if (window_count <= 1) {
295 if (Indicator != IndicatorState.SINGLE)287 if (Indicator != IndicatorState.SINGLE)
296 Indicator = IndicatorState.SINGLE;288 Indicator = IndicatorState.SINGLE;
297 } else {289 break;
290 default:
298 if (Indicator != IndicatorState.SINGLE_PLUS)291 if (Indicator != IndicatorState.SINGLE_PLUS)
299 Indicator = IndicatorState.SINGLE_PLUS;292 Indicator = IndicatorState.SINGLE_PLUS;
293 break;
294 }
295 }
296
297 uint get_window_count () {
298 if (App == null)
299 return 0;
300
301 if (get_dock ().prefs.CurrentWorkspaceOnly) {
302 unowned Wnck.Workspace? active_workspace = Wnck.Screen.get_default ().get_active_workspace ();
303 return WindowControl.count_windows_on_workspace (App, active_workspace);
304 } else {
305 return App.get_windows ().length ();
306 }
307 }
308
309 GLib.List<unowned Bamf.View>? get_windows () {
310 if (App == null)
311 return null;
312
313 if (get_dock ().prefs.CurrentWorkspaceOnly) {
314 unowned Wnck.Workspace? active_workspace = Wnck.Screen.get_default ().get_active_workspace ();
315 return WindowControl.get_windows_on_workspace (App, active_workspace);
316 } else {
317 return App.get_windows ();
300 }318 }
301 }319 }
302 320
@@ -321,13 +339,13 @@
321 {339 {
322 if (!is_window ())340 if (!is_window ())
323 if (button == PopupButton.MIDDLE341 if (button == PopupButton.MIDDLE
324 || (button == PopupButton.LEFT && (App == null || App.get_windows ().length () == 0342 || (button == PopupButton.LEFT && (get_window_count () == 0
325 || (mod & Gdk.ModifierType.CONTROL_MASK) == Gdk.ModifierType.CONTROL_MASK))) {343 || (mod & Gdk.ModifierType.CONTROL_MASK) == Gdk.ModifierType.CONTROL_MASK))) {
326 launch ();344 launch ();
327 return AnimationType.BOUNCE;345 return AnimationType.BOUNCE;
328 }346 }
329 347
330 if (button == PopupButton.LEFT && App != null && App.get_windows ().length () > 0) {348 if (button == PopupButton.LEFT && get_window_count () > 0) {
331 WindowControl.smart_focus (App, event_time);349 WindowControl.smart_focus (App, event_time);
332 return AnimationType.DARKEN;350 return AnimationType.DARKEN;
333 }351 }
@@ -340,7 +358,7 @@
340 */358 */
341 protected override AnimationType on_scrolled (Gdk.ScrollDirection direction, Gdk.ModifierType mod, uint32 event_time)359 protected override AnimationType on_scrolled (Gdk.ScrollDirection direction, Gdk.ModifierType mod, uint32 event_time)
342 {360 {
343 if (App == null || App.get_windows ().length () == 0)361 if (get_window_count () == 0)
344 return AnimationType.NONE;362 return AnimationType.NONE;
345 363
346 if (GLib.get_monotonic_time () - LastScrolled < ITEM_SCROLL_DURATION * 1000)364 if (GLib.get_monotonic_time () - LastScrolled < ITEM_SCROLL_DURATION * 1000)
@@ -348,10 +366,14 @@
348 366
349 LastScrolled = GLib.get_monotonic_time ();367 LastScrolled = GLib.get_monotonic_time ();
350 368
369 unowned Wnck.Workspace? active_workspace = null;
370 if (get_dock ().prefs.CurrentWorkspaceOnly)
371 active_workspace = Wnck.Screen.get_default ().get_active_workspace ();
372
351 if (direction == Gdk.ScrollDirection.UP || direction == Gdk.ScrollDirection.LEFT)373 if (direction == Gdk.ScrollDirection.UP || direction == Gdk.ScrollDirection.LEFT)
352 WindowControl.focus_previous (App, event_time);374 WindowControl.focus_previous (App, event_time, active_workspace);
353 else375 else
354 WindowControl.focus_next (App, event_time);376 WindowControl.focus_next (App, event_time, active_workspace);
355 377
356 return AnimationType.DARKEN;378 return AnimationType.DARKEN;
357 }379 }
@@ -397,9 +419,7 @@
397 {419 {
398 var items = new Gee.ArrayList<Gtk.MenuItem> ();420 var items = new Gee.ArrayList<Gtk.MenuItem> ();
399 421
400 GLib.List<unowned Bamf.View>? windows = null;422 GLib.List<unowned Bamf.View>? windows = get_windows ();
401 if (App != null)
402 windows = App.get_windows ();
403 423
404 var window_count = 0U;424 var window_count = 0U;
405 if (windows != null)425 if (windows != null)
406426
=== modified file 'lib/Items/DefaultApplicationDockItemProvider.vala'
--- lib/Items/DefaultApplicationDockItemProvider.vala 2016-02-22 10:55:51 +0000
+++ lib/Items/DefaultApplicationDockItemProvider.vala 2017-03-14 17:22:36 +0000
@@ -68,6 +68,10 @@
68 unowned TransientDockItem? transient = (item as TransientDockItem);68 unowned TransientDockItem? transient = (item as TransientDockItem);
69 item.IsAttached = (transient == null || transient.App == null || active_workspace == null69 item.IsAttached = (transient == null || transient.App == null || active_workspace == null
70 || WindowControl.has_window_on_workspace (transient.App, active_workspace));70 || WindowControl.has_window_on_workspace (transient.App, active_workspace));
71
72 unowned ApplicationDockItem? app = (item as ApplicationDockItem);
73 if (item.IsAttached && app != null)
74 app.update_indicator ();
71 }75 }
72 } else {76 } else {
73 foreach (var item in internal_elements)77 foreach (var item in internal_elements)
7478
=== modified file 'lib/Services/WindowControl.vala'
--- lib/Services/WindowControl.vala 2016-11-05 19:48:09 +0000
+++ lib/Services/WindowControl.vala 2017-03-14 17:22:36 +0000
@@ -171,6 +171,20 @@
171 return false;171 return false;
172 }172 }
173 173
174 static bool is_on_workspace (Wnck.Window? window, Wnck.Workspace workspace) {
175 if (window == null)
176 return false;
177
178 var is_virtual = workspace.is_virtual ();
179
180 if (!is_virtual && window.is_on_workspace (workspace))
181 return true;
182 else if (is_virtual && window.is_in_viewport (workspace))
183 return true;
184
185 return false;
186 }
187
174 public static bool has_window_on_workspace (Bamf.Application app, Wnck.Workspace workspace)188 public static bool has_window_on_workspace (Bamf.Application app, Wnck.Workspace workspace)
175 {189 {
176 Wnck.Screen.get_default ();190 Wnck.Screen.get_default ();
@@ -178,23 +192,48 @@
178 192
179 warn_if_fail (xids != null);193 warn_if_fail (xids != null);
180 194
181 var is_virtual = workspace.is_virtual ();195 for (var i = 0; xids != null && i < xids.length; i++) {
182 196 unowned Wnck.Window window = Wnck.Window.@get (xids.index (i));
183 for (var i = 0; xids != null && i < xids.length; i++) {197 if (is_on_workspace (window, workspace))
184 unowned Wnck.Window window = Wnck.Window.@get (xids.index (i));198 return true;
185 if (window == null)199 }
186 continue;200
187 201 return false;
188 if (!is_virtual) {202 }
189 if (window.is_on_workspace (workspace))203
190 return true;204 public static int count_windows_on_workspace (Bamf.Application app, Wnck.Workspace workspace)
191 } else {205 {
192 if (window.is_in_viewport (workspace))206 Wnck.Screen.get_default ();
193 return true;207 Array<uint32>? xids = app.get_xids ();
208
209 warn_if_fail (xids != null);
210
211 int count = 0;
212
213 for (var i = 0; xids != null && i < xids.length; i++) {
214 unowned Wnck.Window window = Wnck.Window.@get (xids.index (i));
215 if (is_on_workspace (window, workspace))
216 count++;
217 }
218
219 return count;
220 }
221
222 public static GLib.List<unowned Bamf.View> get_windows_on_workspace (Bamf.Application app, Wnck.Workspace workspace)
223 {
224 Wnck.Screen.get_default ();
225 GLib.List<unowned Bamf.View> windows = app.get_windows ();
226
227 var result = new GLib.List<unowned Bamf.View> ();
228 foreach (var view in windows) {
229 if (view is Bamf.Window) {
230 unowned Wnck.Window window = Wnck.Window.@get ((view as Bamf.Window).get_xid ());
231 if (is_on_workspace (window, workspace))
232 result.append (view);
194 }233 }
195 }234 }
196 235
197 return false;236 return result;
198 }237 }
199 238
200 public static void update_icon_regions (Bamf.Application app, Gdk.Rectangle rect)239 public static void update_icon_regions (Bamf.Application app, Gdk.Rectangle rect)
@@ -262,7 +301,7 @@
262 return i;301 return i;
263 }302 }
264 303
265 public static void focus_previous (Bamf.Application app, uint32 event_time)304 public static void focus_previous (Bamf.Application app, uint32 event_time, Wnck.Workspace? workspace = null)
266 {305 {
267 Wnck.Screen.get_default ();306 Wnck.Screen.get_default ();
268 Array<uint32>? xids = app.get_xids ();307 Array<uint32>? xids = app.get_xids ();
@@ -278,10 +317,22 @@
278 if (i < 0)317 if (i < 0)
279 i = (int) xids.length - 1;318 i = (int) xids.length - 1;
280 319
320 // Look for window on workspace if specified
321 if (workspace != null) {
322 var start = i;
323 do {
324 unowned Wnck.Window window = Wnck.Window.@get (xids.index (i));
325 if (is_on_workspace (window, workspace))
326 break;
327
328 i = (i == 0 ? (int) xids.length - 1 : i - 1);
329 } while (i != start);
330 }
331
281 focus_window_by_xid (xids.index (i), event_time);332 focus_window_by_xid (xids.index (i), event_time);
282 }333 }
283 334
284 public static void focus_next (Bamf.Application app, uint32 event_time)335 public static void focus_next (Bamf.Application app, uint32 event_time, Wnck.Workspace? workspace = null)
285 {336 {
286 Wnck.Screen.get_default ();337 Wnck.Screen.get_default ();
287 Array<uint32>? xids = app.get_xids ();338 Array<uint32>? xids = app.get_xids ();
@@ -297,6 +348,18 @@
297 if (i == xids.length)348 if (i == xids.length)
298 i = 0;349 i = 0;
299 350
351 // Look for window on workspace if specified
352 if (workspace != null) {
353 var start = i;
354 do {
355 unowned Wnck.Window window = Wnck.Window.@get (xids.index (i));
356 if (is_on_workspace (window, workspace))
357 break;
358
359 i = (i + 1) % (int) xids.length;
360 } while (i != start);
361 }
362
300 focus_window_by_xid (xids.index (i), event_time);363 focus_window_by_xid (xids.index (i), event_time);
301 }364 }
302 365
303366
=== modified file 'lib/libplank.symbols'
--- lib/libplank.symbols 2017-02-09 12:53:29 +0000
+++ lib/libplank.symbols 2017-03-14 17:22:36 +0000
@@ -57,6 +57,7 @@
57plank_application_dock_item_set_urgent57plank_application_dock_item_set_urgent
58plank_application_dock_item_unity_reset58plank_application_dock_item_unity_reset
59plank_application_dock_item_unity_update59plank_application_dock_item_unity_update
60plank_application_dock_item_update_indicator
60plank_check_version61plank_check_version
61plank_color_add_hue62plank_color_add_hue
62plank_color_brighten_val63plank_color_brighten_val

Subscribers

People subscribed via source and target branches

to all changes: