[geary: 17/66] WIP towards responding to window focus in cleanup



commit 2b20f1cc4dae768ce75a03224c0f0a0e679c63dc
Author: Chris Heywood <15127-creywood users noreply gitlab gnome org>
Date:   Wed Jan 8 14:22:51 2020 +0100

    WIP towards responding to window focus in cleanup
    
    The idea being that if we've returned into the foreground while old
    message detachment was running the remaining background cleanup tasks
    shouldn't be run.

 src/client/application/application-controller.vala      | 5 +++++
 src/engine/imap-engine/imap-engine-generic-account.vala | 4 ++++
 2 files changed, 9 insertions(+)
---
diff --git a/src/client/application/application-controller.vala 
b/src/client/application/application-controller.vala
index cfb7d1867..903f7943b 100644
--- a/src/client/application/application-controller.vala
+++ b/src/client/application/application-controller.vala
@@ -95,6 +95,9 @@ internal class Application.Controller : Geary.BaseObject {
     // Timeout to do work in idle after all windows have been sent to the background
     private Geary.TimeoutManager all_windows_backgrounded_timeout = null;
 
+    // Whether we're fully in the background
+    public bool all_windows_backgrounded { get; private set; default = false; }
+
 
     /**
      * Emitted when an account is added or is enabled.
@@ -1399,6 +1402,7 @@ internal class Application.Controller : Geary.BaseObject {
 
     // Track a window receiving focus, for idle background work
     public void window_focus_in() {
+        this.all_windows_backgrounded = false;
         if (this.all_windows_backgrounded_timeout != null) {
             this.all_windows_backgrounded_timeout.reset();
             this.all_windows_backgrounded_timeout = null;
@@ -1414,6 +1418,7 @@ internal class Application.Controller : Geary.BaseObject {
     private void on_unfocused_idle() {
         // Schedule later, catching cases where work should occur later while still in background
         this.all_windows_backgrounded_timeout = null;
+        this.all_windows_backgrounded = true;
         window_focus_out();
 
         debug("Checking for backgrounded idle work");
diff --git a/src/engine/imap-engine/imap-engine-generic-account.vala 
b/src/engine/imap-engine/imap-engine-generic-account.vala
index b1f673c8e..dc8ade268 100644
--- a/src/engine/imap-engine/imap-engine-generic-account.vala
+++ b/src/engine/imap-engine/imap-engine-generic-account.vala
@@ -551,6 +551,10 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
     // Continue backgrounded app cleanup work after the first phase,
     // old message detachment, has completed
     public void app_backgrounded_cleanup_continued(bool messages_detached, Cancellable? cancellable) {
+        // TODO bail on remaining work if we've returned from the background
+        // if (!application.controller.all_windows_backgrounded)
+        //    return;
+
         // Kick off GC, allowing vacuum and forcing reap if we've removed messages
         local.db.run_gc.begin(cancellable, messages_detached, this);
     }


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