42
43
return apps.ToArray ();
46
public static string CmdLineForPid (int pid)
50
reader = new StreamReader (Do.Paths.Combine ("/proc", pid.ToString (), "cmdline"));
51
} catch { return null; }
53
string cmdline = reader.ReadLine ();
45
59
public static List<Application> GetApplicationList (string exec)
47
61
exec = exec.Split (' ')[0];
54
68
try { pid = Convert.ToInt32 (dir.Substring (6)); }
55
69
catch { continue; }
58
reader = new StreamReader (Do.Paths.Combine ("/proc", dir, "cmdline"));
61
string exec_line = reader.ReadLine ();
71
string exec_line = CmdLineForPid (pid);
64
72
if (string.IsNullOrEmpty (exec_line))
67
75
if (exec_line.Contains (exec)) {
68
76
foreach (Application app in GetApplications ()) {
69
77
if (app.Pid == pid) {
78
if (app.Windows.Select (win => !win.IsSkipTasklist).Any ())
121
130
w.Activate (Gtk.Global.CurrentEventTime);
133
public static void PerformLogicalClick (IEnumerable<Application> apps)
135
bool not_in_viewport = true;
136
foreach (Wnck.Application application in apps) {
137
foreach (Wnck.Window window in application.Windows) {
138
if (!window.IsSkipTasklist && window.IsInViewport (Wnck.Screen.Default.ActiveWorkspace))
139
not_in_viewport = false;
143
if (not_in_viewport) {
144
foreach (Wnck.Application application in apps) {
145
foreach (Wnck.Window window in application.Windows) {
146
if (!window.IsSkipTasklist) {
147
window.CenterAndFocusWindow ();
154
foreach (Wnck.Application app in apps) {
155
foreach (Wnck.Window window in app.Windows) {
156
switch (GetClickAction (apps)) {
157
case ClickAction.Focus:
158
if (window.IsInViewport (Wnck.Screen.Default.ActiveWorkspace))
159
window.Activate (Gtk.Global.CurrentEventTime);
161
case ClickAction.Minimize:
162
if (window.IsInViewport (Wnck.Screen.Default.ActiveWorkspace))
165
case ClickAction.Restore:
166
if (window.IsInViewport (Wnck.Screen.Default.ActiveWorkspace))
167
window.Unminimize (Gtk.Global.CurrentEventTime);
174
static ClickAction GetClickAction (IEnumerable<Application> apps)
177
return ClickAction.None;
179
foreach (Wnck.Application app in apps) {
180
foreach (Wnck.Window window in app.Windows) {
181
if (window.IsMinimized && window.IsInViewport (Wnck.Screen.Default.ActiveWorkspace))
182
return ClickAction.Restore;
186
foreach (Wnck.Application app in apps) {
187
foreach (Wnck.Window window in app.Windows) {
188
if (window.IsActive && window.IsInViewport (Wnck.Screen.Default.ActiveWorkspace))
189
return ClickAction.Minimize;
193
return ClickAction.Focus;