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
1=== modified file 'unity-private/launcher/application-controller.vala'
2--- unity-private/launcher/application-controller.vala 2010-09-27 10:42:46 +0000
3+++ unity-private/launcher/application-controller.vala 2010-09-27 16:20:59 +0000
4@@ -344,6 +344,36 @@
5 }
6
7
8+ private void launch_desktop_file ()
9+ {
10+ Gdk.AppLaunchContext context = new Gdk.AppLaunchContext ();
11+ try
12+ {
13+ var appinfo = new DesktopAppInfo.from_filename (desktop_file);
14+ context.set_screen (Gdk.Display.get_default ().get_default_screen ());
15+ context.set_timestamp (Gdk.CURRENT_TIME);
16+
17+ appinfo.launch (null, context);
18+ child.activating = true;
19+ // timeout after eight seconds
20+ GLib.Timeout.add_seconds (8, on_launch_timeout);
21+ }
22+ catch (Error e)
23+ {
24+ warning (e.message);
25+ }
26+ }
27+
28+ private bool app_has_visable_window ()
29+ requires (app is Bamf.Application)
30+ {
31+ foreach (Bamf.Window window in app.get_windows ())
32+ {
33+ if (window.user_visible ()) return true;
34+ }
35+ return false;
36+ }
37+
38 public override void activate ()
39 {
40 if (app is Bamf.Application)
41@@ -359,31 +389,20 @@
42 global_shell.expose_xids (xids);
43 }
44 }
45- else if (app.is_running ())
46+ else if (app.is_running () && app_has_visable_window ())
47 {
48 unowned List<Bamf.Window> windows = app.get_windows ();
49 windows.sort ((CompareFunc)order_app_windows);
50 Unity.global_shell.show_window (windows.nth_data (windows.length ()-1).get_xid ());
51 }
52+ else
53+ {
54+ launch_desktop_file ();
55+ }
56 }
57 else
58 {
59- Gdk.AppLaunchContext context = new Gdk.AppLaunchContext ();
60- try
61- {
62- var appinfo = new DesktopAppInfo.from_filename (desktop_file);
63- context.set_screen (Gdk.Display.get_default ().get_default_screen ());
64- context.set_timestamp (Gdk.CURRENT_TIME);
65-
66- appinfo.launch (null, context);
67- child.activating = true;
68- // timeout after eight seconds
69- GLib.Timeout.add_seconds (8, on_launch_timeout);
70- }
71- catch (Error e)
72- {
73- warning (e.message);
74- }
75+ launch_desktop_file ();
76 }
77 global_shell.hide_unity ();
78 }