[gnome-shell/gnome-3-20] app: Consider minimized windows for app comparisons



commit ae6256ba16764b785518d26278fd26cedc62981a
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue May 10 21:15:36 2016 +0200

    app: Consider minimized windows for app comparisons
    
    We used to take window visibility into account when comparing apps
    until commit 1dfc38d078, following changes in the window switcher
    due to auto-minimization. However auto-minimization was abolished
    and the window switcher changes reverted, so it makes sense again
    to sort apps without non-minimized windows last again.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=766238

 src/shell-app.c |   33 ++++++++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)
---
diff --git a/src/shell-app.c b/src/shell-app.c
index afc45cb..1593c89 100644
--- a/src/shell-app.c
+++ b/src/shell-app.c
@@ -722,6 +722,23 @@ shell_app_get_last_user_time (ShellApp *app)
   return (int)last_user_time;
 }
 
+static gboolean
+shell_app_is_minimized (ShellApp *app)
+{
+  GSList *iter;
+
+  if (app->running_state == NULL)
+    return FALSE;
+
+  for (iter = app->running_state->windows; iter; iter = iter->next)
+    {
+      if (meta_window_showing_on_its_workspace (iter->data))
+        return FALSE;
+    }
+
+  return TRUE;
+}
+
 /**
  * shell_app_compare:
  * @app:
@@ -729,13 +746,17 @@ shell_app_get_last_user_time (ShellApp *app)
  *
  * Compare one #ShellApp instance to another, in the following way:
  *   - Running applications sort before not-running applications.
- *   - The application which the user interacted with most recently
+ *   - If one of them has non-minimized windows and the other does not,
+ *     the one with visible windows is first.
+ *   - Finally, the application which the user interacted with most recently
  *     compares earlier.
  */
 int
 shell_app_compare (ShellApp *app,
                    ShellApp *other)
 {
+  gboolean min_app, min_other;
+
   if (app->state != other->state)
     {
       if (app->state == SHELL_APP_STATE_RUNNING)
@@ -743,6 +764,16 @@ shell_app_compare (ShellApp *app,
       return 1;
     }
 
+  min_app = shell_app_is_minimized (app);
+  min_other = shell_app_is_minimized (other);
+
+  if (min_app != min_other)
+    {
+      if (min_other)
+        return -1;
+      return 1;
+    }
+
   if (app->state == SHELL_APP_STATE_RUNNING)
     {
       if (app->running_state->windows && !other->running_state->windows)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]