Bug 588343 - Major rework of window monitoring to be application-based

The previous application monitoring code was originally designed
to be based on WM_CLASS, which was then resolved on a server.
We have that resolution code locally now, so instead
of saving WM_CLASS data, save application IDs.

Also, inside the WM we have a much better
infrastructure for tracking windows.  In particular, rather
than polling, we can just watch for focus notification on
the display, and window add/remove.

Instead of polling XScreensaver, use DBus to watch org.gnome.Session
which already has an idle time watch.

Now there is no polling at all inside the monitor.
This commit is contained in:
Colin Walters 2009-07-30 15:40:26 -04:00
parent b1150eb147
commit 2726fdb831
3 changed files with 713 additions and 590 deletions

View File

@ -277,7 +277,8 @@ AppDisplay.prototype = {
}, },
_getMostUsed: function() { _getMostUsed: function() {
return this._appMonitor.get_most_used_apps(0, 30).map(Lang.bind(this, function (id) { let context = "";
return this._appMonitor.get_most_used_apps(context, 30).map(Lang.bind(this, function (id) {
return this._appSystem.lookup_app(id + '.desktop'); return this._appSystem.lookup_app(id + '.desktop');
})).filter(function (e) { return e != null }); })).filter(function (e) { return e != null });
}, },
@ -723,6 +724,9 @@ AppWell.prototype = {
}, },
_redisplay: function() { _redisplay: function() {
/* hardcode here pending some design about how exactly activities behave */
let contextId = "";
let arrayToObject = function(a) { let arrayToObject = function(a) {
let o = {}; let o = {};
for (let i = 0; i < a.length; i++) for (let i = 0; i < a.length; i++)
@ -731,7 +735,8 @@ AppWell.prototype = {
}; };
let favoriteIds = this._appSystem.get_favorites(); let favoriteIds = this._appSystem.get_favorites();
let favoriteIdsObject = arrayToObject(favoriteIds); let favoriteIdsObject = arrayToObject(favoriteIds);
let runningIds = this._appMonitor.get_running_app_ids().filter(function (e) {
let runningIds = this._appMonitor.get_running_app_ids(contextId).filter(function (e) {
return !(e in favoriteIdsObject); return !(e in favoriteIdsObject);
}); });
let favorites = this._lookupApps(favoriteIds); let favorites = this._lookupApps(favoriteIds);

File diff suppressed because it is too large Load Diff

View File

@ -40,15 +40,14 @@ ShellAppMonitor* shell_app_monitor_get_default(void);
ShellAppInfo *shell_app_monitor_get_window_app (ShellAppMonitor *monitor, MetaWindow *metawin); ShellAppInfo *shell_app_monitor_get_window_app (ShellAppMonitor *monitor, MetaWindow *metawin);
/* Get the most popular applications for a given activity */ GList *shell_app_monitor_get_most_used_apps (ShellAppMonitor *monitor,
GSList *shell_app_monitor_get_most_used_apps (ShellAppMonitor *monitor, const char *context,
int activity,
gint number); gint number);
GSList *shell_app_monitor_get_windows_for_app (ShellAppMonitor *monitor, const char *appid); GSList *shell_app_monitor_get_windows_for_app (ShellAppMonitor *monitor, const char *appid);
/* Get whatever's running right now */ /* Get whatever's running right now */
GList *shell_app_monitor_get_running_app_ids (ShellAppMonitor *monitor); GSList *shell_app_monitor_get_running_app_ids (ShellAppMonitor *monitor, const char *context);
G_END_DECLS G_END_DECLS