[gnome-shell] Rework compare to take into account closed windows
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] Rework compare to take into account closed windows
- Date: Mon, 17 May 2010 17:37:43 +0000 (UTC)
commit b736f52037006507932d0bf56fd21eb9f28ffd0b
Author: Colin Walters <walters verbum org>
Date: Tue May 11 11:55:33 2010 -0400
Rework compare to take into account closed windows
The API docs for ShellApp claimed it sorted by the last time the
user interacted with the app, but if one closed a window, then
we would fall back to comparing against a possibly much older
timestamp from another window. Fix this by just keeping a
user time per app.
Also clean up the comparison function to explicitly check the state
instead of deferring to the window list.
https://bugzilla.gnome.org/show_bug.cgi?id=618378
src/shell-app.c | 26 +++++++++++++++++++-------
1 files changed, 19 insertions(+), 7 deletions(-)
---
diff --git a/src/shell-app.c b/src/shell-app.c
index bf01a52..b627994 100644
--- a/src/shell-app.c
+++ b/src/shell-app.c
@@ -25,6 +25,8 @@ struct _ShellApp
ShellAppInfo *info;
+ guint32 last_user_time;
+
guint workspace_switch_id;
GSList *windows;
@@ -560,10 +562,9 @@ shell_app_is_on_workspace (ShellApp *app,
* @other: A #ShellApp
*
* Compare one #ShellApp instance to another, in the following way:
+ * - Running applications sort before not-running applications.
* - If one of them has visible windows and the other does not, the one
* with visible windows is first.
- * - If one has no windows at all (i.e. it's not running) and the other
- * does, the one with windows is first.
* - Finally, the application which the user interacted with most recently
* compares earlier.
*/
@@ -572,7 +573,13 @@ shell_app_compare (ShellApp *app,
ShellApp *other)
{
gboolean vis_app, vis_other;
- GSList *windows_app, *windows_other;
+
+ if (app->state != other->state)
+ {
+ if (app->state == SHELL_APP_STATE_RUNNING)
+ return -1;
+ return 1;
+ }
vis_app = shell_app_has_visible_windows (app);
vis_other = shell_app_has_visible_windows (other);
@@ -587,10 +594,7 @@ shell_app_compare (ShellApp *app,
else if (!app->windows && other->windows)
return 1;
- windows_app = shell_app_get_windows (app);
- windows_other = shell_app_get_windows (other);
-
- return meta_window_get_user_time (windows_other->data) - meta_window_get_user_time (windows_app->data);
+ return other->last_user_time - app->last_user_time;
}
ShellApp *
@@ -642,6 +646,8 @@ shell_app_on_user_time_changed (MetaWindow *window,
GParamSpec *pspec,
ShellApp *app)
{
+ app->last_user_time = meta_window_get_user_time (window);
+
/* Ideally we don't want to emit windows-changed if the sort order
* isn't actually changing. This check catches most of those.
*/
@@ -668,6 +674,8 @@ void
_shell_app_add_window (ShellApp *app,
MetaWindow *window)
{
+ guint32 user_time;
+
if (g_slist_find (app->windows, window))
return;
@@ -676,6 +684,10 @@ _shell_app_add_window (ShellApp *app,
g_signal_connect (window, "notify::user-time", G_CALLBACK(shell_app_on_user_time_changed), app);
app->window_sort_stale = TRUE;
+ user_time = meta_window_get_user_time (window);
+ if (user_time > app->last_user_time)
+ app->last_user_time = user_time;
+
if (app->state != SHELL_APP_STATE_RUNNING)
shell_app_state_transition (app, SHELL_APP_STATE_RUNNING);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]