Merge lp:~unity-team/unity/unity.launcher-activate-change into lp:unity

Proposed by Gord Allott
Status: Merged
Merged at revision: 564
Proposed branch: lp:~unity-team/unity/unity.launcher-activate-change
Merge into: lp:unity
Diff against target: 78 lines (+36/-17)
1 file modified
unity-private/launcher/application-controller.vala (+36/-17)
To merge this branch: bzr merge lp:~unity-team/unity/unity.launcher-activate-change
Reviewer Review Type Date Requested Status
Mikkel Kamstrup Erlandsen (community) Approve
Review via email: mp+36752@code.launchpad.net

Description of the change

changes the logic of the launcher so that it launches the application instead of switching to it if there are no visible windows. helps towards fixing lp:647979 - but it won't fix that until a change is made in bamf to ignore the file copy dialog

To post a comment you must log in.
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

Looks innocent enough and does as described in the merge request. Approved!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'unity-private/launcher/application-controller.vala'
--- unity-private/launcher/application-controller.vala 2010-09-27 10:42:46 +0000
+++ unity-private/launcher/application-controller.vala 2010-09-27 16:20:59 +0000
@@ -344,6 +344,36 @@
344 }344 }
345345
346346
347 private void launch_desktop_file ()
348 {
349 Gdk.AppLaunchContext context = new Gdk.AppLaunchContext ();
350 try
351 {
352 var appinfo = new DesktopAppInfo.from_filename (desktop_file);
353 context.set_screen (Gdk.Display.get_default ().get_default_screen ());
354 context.set_timestamp (Gdk.CURRENT_TIME);
355
356 appinfo.launch (null, context);
357 child.activating = true;
358 // timeout after eight seconds
359 GLib.Timeout.add_seconds (8, on_launch_timeout);
360 }
361 catch (Error e)
362 {
363 warning (e.message);
364 }
365 }
366
367 private bool app_has_visable_window ()
368 requires (app is Bamf.Application)
369 {
370 foreach (Bamf.Window window in app.get_windows ())
371 {
372 if (window.user_visible ()) return true;
373 }
374 return false;
375 }
376
347 public override void activate ()377 public override void activate ()
348 {378 {
349 if (app is Bamf.Application)379 if (app is Bamf.Application)
@@ -359,31 +389,20 @@
359 global_shell.expose_xids (xids);389 global_shell.expose_xids (xids);
360 }390 }
361 }391 }
362 else if (app.is_running ())392 else if (app.is_running () && app_has_visable_window ())
363 {393 {
364 unowned List<Bamf.Window> windows = app.get_windows ();394 unowned List<Bamf.Window> windows = app.get_windows ();
365 windows.sort ((CompareFunc)order_app_windows);395 windows.sort ((CompareFunc)order_app_windows);
366 Unity.global_shell.show_window (windows.nth_data (windows.length ()-1).get_xid ());396 Unity.global_shell.show_window (windows.nth_data (windows.length ()-1).get_xid ());
367 }397 }
398 else
399 {
400 launch_desktop_file ();
401 }
368 }402 }
369 else403 else
370 {404 {
371 Gdk.AppLaunchContext context = new Gdk.AppLaunchContext ();405 launch_desktop_file ();
372 try
373 {
374 var appinfo = new DesktopAppInfo.from_filename (desktop_file);
375 context.set_screen (Gdk.Display.get_default ().get_default_screen ());
376 context.set_timestamp (Gdk.CURRENT_TIME);
377
378 appinfo.launch (null, context);
379 child.activating = true;
380 // timeout after eight seconds
381 GLib.Timeout.add_seconds (8, on_launch_timeout);
382 }
383 catch (Error e)
384 {
385 warning (e.message);
386 }
387 }406 }
388 global_shell.hide_unity ();407 global_shell.hide_unity ();
389 }408 }