[Xfce4-commits] [apps/xfce4-screensaver] 01/01: Rebuild windows on monitor reconfiguration, draw overlays during reconstruction to protect screen contents

noreply at xfce.org noreply at xfce.org
Sat Mar 21 23:25:55 CET 2020


This is an automated email from the git hooks/post-receive script.

b   l   u   e   s   a   b   r   e       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository apps/xfce4-screensaver.

commit e90c61adcd09e55f769ba1d6733d46be4fb5118a
Author: Sean Davis <smd.seandavis at gmail.com>
Date:   Sat Mar 21 18:25:41 2020 -0400

    Rebuild windows on monitor reconfiguration, draw overlays during reconstruction to protect screen contents
---
 src/gs-manager.c | 74 ++++++++++++++++++++++++++++++++++++++++----------------
 1 file changed, 53 insertions(+), 21 deletions(-)

diff --git a/src/gs-manager.c b/src/gs-manager.c
index 7a08b50..bf91f2a 100644
--- a/src/gs-manager.c
+++ b/src/gs-manager.c
@@ -650,12 +650,16 @@ find_window_at_pointer (GSManager *manager) {
     if (window == NULL) {
         gs_debug ("WARNING: Could not find the GSWindow for display %s",
                   gdk_display_get_name (display));
+
         /* bail if there are no windows available */
         if (manager->priv->windows == NULL)
             return NULL;
 
         /* take the first one */
         window = manager->priv->windows->data;
+        if (window->data == NULL || !GS_IS_WINDOW (GS_WINDOW (window->data))) {
+            return NULL;
+        }
     } else {
         gs_debug ("Requesting unlock for display %s",
                   gdk_display_get_name (display));
@@ -1004,42 +1008,73 @@ gs_manager_create_window_for_monitor (GSManager  *manager,
     }
 }
 
-static void
-reconfigure_monitors (GdkDisplay *display,
-                      GSManager  *manager) {
+static GSList *
+add_overlays (GSManager *manager) {
     GSList     *l;
-    int         n_monitors;
-
-    n_monitors = gs_manager_get_n_monitors (display);
+    GSList     *windows = NULL;
 
-    if (n_monitors == 0)
-        return;
+    gs_debug("Reconfiguring monitors, adding overlays");
 
-    /* Remove lost windows */
     l = manager->priv->windows;
     while (l != NULL) {
         GdkMonitor *this_monitor;
-        int         idx;
         GSList     *next = l->next;
+        GtkWidget  *window;
+        GdkRectangle rect;
 
         this_monitor = gs_window_get_monitor (GS_WINDOW (l->data));
 
-        idx = manager_get_monitor_index (this_monitor);
-        if (idx < 0) {
-            manager_maybe_stop_job_for_window (manager, GS_WINDOW (l->data));
-            g_hash_table_remove (manager->priv->jobs, l->data);
-            gs_window_destroy (GS_WINDOW (l->data));
-            manager->priv->windows = g_slist_delete_link (manager->priv->windows, l);
-        } else {
-            gs_window_reposition (GS_WINDOW (l->data));
+        // Display an overlay to protect each window as we redraw everything
+        if (GDK_IS_MONITOR (this_monitor)) {
+            window = gtk_window_new (GTK_WINDOW_POPUP);
+            gdk_monitor_get_geometry (this_monitor, &rect);
+            gtk_window_move (GTK_WINDOW (window), rect.x, rect.y);
+            gtk_window_resize (GTK_WINDOW (window), rect.width, rect.height);
+            gtk_widget_show (GTK_WIDGET (window));
+            windows = g_slist_append (windows, window);
         }
 
         l = next;
     }
 
+    return windows;
+}
+
+static gboolean
+remove_overlays (GSList *windows) {
+    gs_debug("Done reconfiguring monitors, removing overlays");
+    g_slist_free_full (windows, (GDestroyNotify) gtk_widget_destroy);
+    return FALSE;
+}
+
+static void
+reconfigure_monitors (GdkDisplay *display,
+                      GSManager  *manager) {
+    GSList     *l;
+    GSList     *windows;
+
+    windows = add_overlays (manager);
+
+    /* Remove lost windows */
+    l = manager->priv->windows;
+    while (l != NULL) {
+        GSList     *next = l->next;
+
+        manager_maybe_stop_job_for_window (manager, GS_WINDOW (l->data));
+        g_hash_table_remove (manager->priv->jobs, l->data);
+        gs_window_destroy (GS_WINDOW (l->data));
+        manager->priv->windows = g_slist_delete_link (manager->priv->windows, l);
+
+        l = next;
+    }
+
     gs_manager_create_windows_for_display (manager, display);
 
     gs_manager_request_unlock (manager);
+
+    g_timeout_add (2000,
+                   (GSourceFunc)remove_overlays,
+                   windows);
 }
 
 static void
@@ -1053,9 +1088,6 @@ on_display_monitor_added (GdkDisplay *display,
     gs_debug ("Monitor %s added on display %s, now there are %d",
               gdk_monitor_get_model(monitor), gdk_display_get_name (display), n_monitors);
 
-    if (!gs_manager_is_real_monitor (monitor))
-        return;
-
     reconfigure_monitors (display, manager);
 }
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list