[Xfce4-commits] [xfce/xfdesktop] 01/01: Fix for monitors not getting updated

noreply at xfce.org noreply at xfce.org
Sun Apr 6 21:16:38 CEST 2014


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

eric pushed a commit to branch master
in repository xfce/xfdesktop.

commit 8d98759ac0a576b25c7ede1d07d95ce5084206a4
Author: Eric Koegel <eric.koegel at gmail.com>
Date:   Sun Apr 6 21:52:50 2014 +0300

    Fix for monitors not getting updated
    
    When multiple monitors are connected there are cases where the
    backgrounds don't get drawn. This patch makes it so that the
    backdrop is always drawn on a workspace change. Because of that
    change it makes sense to always cache the backdrop image since it
    would have to reload the image/canvas often.
---
 src/xfce-backdrop.c  |   98 +-------------------------------------------------
 src/xfce-backdrop.h  |    5 ---
 src/xfce-desktop.c   |   39 +++-----------------
 src/xfce-workspace.c |   47 ------------------------
 src/xfce-workspace.h |    3 --
 5 files changed, 5 insertions(+), 187 deletions(-)

diff --git a/src/xfce-backdrop.c b/src/xfce-backdrop.c
index 607c951..8989a65 100644
--- a/src/xfce-backdrop.c
+++ b/src/xfce-backdrop.c
@@ -95,7 +95,6 @@ struct _XfceBackdropPriv
 
     GdkPixbuf *pix;
     XfceBackdropImageData *image_data;
-    gboolean cache_pixbuf;
 
     XfceBackdropColorStyle color_style;
     GdkColor color1;
@@ -1359,49 +1358,6 @@ xfce_backdrop_get_random_order(XfceBackdrop *backdrop)
     return backdrop->priv->random_backdrop_order;
 }
 
-/**
- * xfce_backdrop_set_cache_pixbuf:
- * @backdrop: An #XfceBackdrop.
- * @cache_pixbuf: When TRUE XfceBackdrop will keep a reference to the current
- *                pixbuf until another one is set.
- *
- * XfceBackdrop can be set to keep a reference to the current backdrop and
- * increment the reference count when xfce_backdrop_get_pixbuf is called.
- * Setting cache_pixbuf to FALSE will cause xfce_backdrop_get_pixbuf to
- * return XfceBackdrop's only reference and free any memory allocated. This
- * will use less memory, especially when the backdrop isn't expected to change
- * as in single workspace mode.
- **/
-void
-xfce_backdrop_set_cache_pixbuf(XfceBackdrop *backdrop,
-                               gboolean cache_pixbuf)
-{
-    g_return_if_fail(XFCE_IS_BACKDROP(backdrop));
-
-    TRACE("entering");
-
-    if(backdrop->priv->cache_pixbuf == cache_pixbuf) {
-        DBG("No change, cache_pixbuf %s", cache_pixbuf ? "TRUE" : "FALSE");
-        return;
-    }
-
-    backdrop->priv->cache_pixbuf = cache_pixbuf;
-
-    DBG("cache_pixbuf now %s", cache_pixbuf ? "TRUE" : "FALSE");
-
-    /* release any cached pixbuf now to save memory */
-    if(!cache_pixbuf)
-        xfce_backdrop_clear_cached_image(backdrop);
-}
-
-gboolean
-xfce_backdrop_get_cache_pixbuf(XfceBackdrop *backdrop)
-{
-    g_return_val_if_fail(XFCE_IS_BACKDROP(backdrop), FALSE);
-
-    return backdrop->priv->cache_pixbuf;
-}
-
 /* Generates the background that will either be displayed or will have the
  * image drawn on top of */
 static GdkPixbuf *
@@ -1473,16 +1429,9 @@ xfce_backdrop_get_pixbuf(XfceBackdrop *backdrop)
 {
     TRACE("entering");
 
-    if(backdrop->priv->pix && backdrop->priv->cache_pixbuf) {
+    if(backdrop->priv->pix) {
         /* return a reference so we can cache it */
         return g_object_ref(backdrop->priv->pix);
-    } else if(backdrop->priv->pix) {
-        /* We're not going to cache it so return our reference and set our
-         * pointer to NULL */
-        GdkPixbuf *pix = backdrop->priv->pix;
-        backdrop->priv->pix = NULL;
-
-        return pix;
     }
 
     /* !backdrop->priv->pix, call xfce_backdrop_generate_async */
@@ -1849,48 +1798,3 @@ xfce_backdrop_file_input_stream_ready_cb(GObject *source_object,
         g_object_unref(source_object);
     }
 }
-
-/* returns TRUE if they have identical settings. */
-gboolean
-xfce_backdrop_compare_backdrops(XfceBackdrop *backdrop_a,
-                                XfceBackdrop *backdrop_b)
-{
-    if(g_strcmp0(backdrop_a->priv->image_path, backdrop_b->priv->image_path) != 0) {
-        DBG("filename different");
-        return FALSE;
-    }
-
-    if(backdrop_a->priv->image_style != backdrop_b->priv->image_style) {
-        DBG("image_style different");
-        return FALSE;
-    }
-
-    if(backdrop_a->priv->color_style != backdrop_b->priv->color_style) {
-        DBG("color_style different");
-        return FALSE;
-    }
-
-    /* Every color style uses color1 except for transparent which does not need
-     * a color check */
-    if(backdrop_a->priv->color_style != XFCE_BACKDROP_COLOR_TRANSPARENT &&
-       !gdk_color_equal(&backdrop_a->priv->color1, &backdrop_b->priv->color1)) {
-        DBG("colors different");
-        return FALSE;
-    }
-
-    /* When the style is set to gradient then we should check color2 as well */
-    if((backdrop_a->priv->color_style == XFCE_BACKDROP_COLOR_HORIZ_GRADIENT ||
-        backdrop_a->priv->color_style == XFCE_BACKDROP_COLOR_VERT_GRADIENT) &&
-       !gdk_color_equal(&backdrop_a->priv->color2, &backdrop_b->priv->color2)) {
-        DBG("colors different");
-        return FALSE;
-    }
-
-    if(backdrop_a->priv->cycle_backdrop != backdrop_b->priv->cycle_backdrop ||
-       backdrop_a->priv->cycle_backdrop == TRUE) {
-        DBG("backdrop cycle different");
-        return FALSE;
-    }
-
-    return TRUE;
-}
diff --git a/src/xfce-backdrop.h b/src/xfce-backdrop.h
index 364b916..8edda4b 100644
--- a/src/xfce-backdrop.h
+++ b/src/xfce-backdrop.h
@@ -143,16 +143,11 @@ void xfce_backdrop_set_random_order      (XfceBackdrop *backdrop,
                                           gboolean random_order);
 gboolean xfce_backdrop_get_random_order  (XfceBackdrop *backdrop);
 
-void xfce_backdrop_set_cache_pixbuf      (XfceBackdrop *backdrop,
-                                          gboolean cache_pixbuf);
-gboolean xfce_backdrop_get_cache_pixbuf  (XfceBackdrop *backdrop);
 
 GdkPixbuf *xfce_backdrop_get_pixbuf      (XfceBackdrop *backdrop);
 
 void xfce_backdrop_generate_async        (XfceBackdrop *backdrop);
 
-gboolean xfce_backdrop_compare_backdrops (XfceBackdrop *backdrop_a,
-                                          XfceBackdrop *backdrop_b);
 
 G_END_DECLS
 
diff --git a/src/xfce-desktop.c b/src/xfce-desktop.c
index 14bdb90..dee946b 100644
--- a/src/xfce-desktop.c
+++ b/src/xfce-desktop.c
@@ -607,15 +607,10 @@ workspace_changed_cb(WnckScreen *wnck_screen,
 {
     XfceDesktop *desktop = XFCE_DESKTOP(user_data);
     gint current_workspace, new_workspace, i;
-    XfceBackdrop *current_backdrop, *new_backdrop;
+    XfceBackdrop *backdrop;
 
     TRACE("entering");
 
-    /* Ignore workspace changes in single workspace mode so long as we
-     * already have the bg_pixmap loaded */
-    if(xfce_desktop_get_single_workspace_mode(desktop) && desktop->priv->bg_pixmap)
-        return;
-
     current_workspace = desktop->priv->current_workspace;
     new_workspace = xfce_desktop_get_current_workspace(desktop);
 
@@ -628,22 +623,9 @@ workspace_changed_cb(WnckScreen *wnck_screen,
         current_workspace, new_workspace);
 
     for(i = 0; i < xfce_desktop_get_n_monitors(desktop); i++) {
-        /* We want to compare the current workspace backdrop with the new one
-         * and see if we can avoid changing them if they are the same image/style */
-        if(current_workspace < desktop->priv->nworkspaces && current_workspace >= 0) {
-            current_backdrop = xfce_workspace_get_backdrop(desktop->priv->workspaces[current_workspace], i);
-            new_backdrop = xfce_workspace_get_backdrop(desktop->priv->workspaces[new_workspace], i);
-
-            if(!xfce_backdrop_compare_backdrops(current_backdrop, new_backdrop) || !desktop->priv->bg_pixmap) {
-                /* only update monitors that require it */
-                backdrop_changed_cb(new_backdrop, user_data);
-            }
-        } else {
-            /* If current_workspace was removed or never existed, get the new
-             * backdrop and apply it */
-            new_backdrop = xfce_workspace_get_backdrop(desktop->priv->workspaces[new_workspace], i);
-            backdrop_changed_cb(new_backdrop, user_data);
-        }
+        backdrop = xfce_workspace_get_backdrop(desktop->priv->workspaces[new_workspace], i);
+        /* update it */
+        backdrop_changed_cb(backdrop, user_data);
 
         /* When we're spanning screens we only care about the first monitor */
         if(xfce_workspace_get_xinerama_stretch(desktop->priv->workspaces[new_workspace]))
@@ -675,10 +657,6 @@ workspace_created_cb(WnckScreen *wnck_screen,
                                                                     desktop->priv->property_prefix,
                                                                     nlast_workspace);
 
-    /* Tell workspace whether to cache pixbufs */
-    xfce_workspace_set_cache_pixbufs(desktop->priv->workspaces[nlast_workspace],
-                                     !desktop->priv->single_workspace_mode);
-
     xfce_workspace_monitors_changed(desktop->priv->workspaces[nlast_workspace],
                                     desktop->priv->gscreen);
 
@@ -1547,8 +1525,6 @@ static void
 xfce_desktop_set_single_workspace_mode(XfceDesktop *desktop,
                                        gboolean single_workspace)
 {
-    gint i;
-
     g_return_if_fail(XFCE_IS_DESKTOP(desktop));
 
     if(single_workspace == desktop->priv->single_workspace_mode)
@@ -1558,13 +1534,6 @@ xfce_desktop_set_single_workspace_mode(XfceDesktop *desktop,
 
     DBG("single_workspace_mode now %s", single_workspace ? "TRUE" : "FALSE");
 
-    /* update the workspaces & backdrops if they should cache their pixbuf */
-    if(desktop->priv->workspaces) {
-        for(i = 0; i < desktop->priv->nworkspaces; i++) {
-            /* set cache to TRUE when single_workspace is FALSE */
-            xfce_workspace_set_cache_pixbufs(desktop->priv->workspaces[i], !single_workspace);
-        }
-    }
 
     /* If the desktop has been realized then fake a screen size change to
      * update the backdrop. There's no reason to if there's no desktop yet */
diff --git a/src/xfce-workspace.c b/src/xfce-workspace.c
index c4fb2f2..b061963 100644
--- a/src/xfce-workspace.c
+++ b/src/xfce-workspace.c
@@ -84,7 +84,6 @@ struct _XfceWorkspacePriv
     guint nbackdrops;
     gboolean xinerama_stretch;
     XfceBackdrop **backdrops;
-    gboolean cache_pixbufs;
 
     gulong *first_color_id;
     gulong *second_color_id;
@@ -675,9 +674,6 @@ xfce_workspace_connect_backdrop_settings(XfceWorkspace *workspace,
     xfconf_g_property_bind(channel, buf, G_TYPE_STRING,
                            G_OBJECT(backdrop), "image-filename");
 
-    /* determine if the backdrop will be required to keep a ref of it's pixbuf
-     * when it generates one */
-    xfce_backdrop_set_cache_pixbuf(backdrop, workspace->priv->cache_pixbufs);
 
     g_free(monitor_name);
 }
@@ -776,49 +772,6 @@ xfce_workspace_set_workspace_num(XfceWorkspace *workspace, gint number)
 }
 
 /**
- * xfce_workspace_set_cache_pixbufs:
- * @workspace: An #XfceWorkspace.
- * @cache_pixbuf: When TRUE XfceWorkspace will have all it's backdrops keep
- *                a reference to the current pixbuf.
- *
- * This function will control whether XfceWorkspace's backdrops keep a reference
- * to their respective pixbufs or not. Setting it to TRUE is useful for the
- * per-workspace-wallpapers, FALSE will save memory for single workspace mode.
- **/
-void
-xfce_workspace_set_cache_pixbufs(XfceWorkspace *workspace,
-                                 gboolean cache_pixbuf)
-{
-    guint i;
-    guint n_monitors;
-
-    g_return_if_fail(XFCE_IS_WORKSPACE(workspace));
-
-    /* If nothing changed then avoid doing any work */
-    if(workspace->priv->cache_pixbufs == cache_pixbuf)
-        return;
-
-    workspace->priv->cache_pixbufs = cache_pixbuf;
-
-    DBG("cache_pixbuf now %s", cache_pixbuf ? "TRUE" : "FALSE");
-
-    n_monitors = gdk_screen_get_n_monitors(workspace->priv->gscreen);
-
-    /* update all the backdrops */
-    for(i = 0; i < n_monitors && i < workspace->priv->nbackdrops; ++i) {
-        xfce_backdrop_set_cache_pixbuf(workspace->priv->backdrops[i], cache_pixbuf);
-    }
-}
-
-gboolean
-xfce_workspace_get_cache_pixbufs(XfceWorkspace *workspace)
-{
-    g_return_val_if_fail(XFCE_IS_WORKSPACE(workspace), FALSE);
-
-    return workspace->priv->cache_pixbufs;
-}
-
-/**
  * xfce_workspace_get_backdrop:
  * @workspace: An #XfceWorkspace.
  * @monitor: monitor number
diff --git a/src/xfce-workspace.h b/src/xfce-workspace.h
index dc4c6b6..0c8aa64 100644
--- a/src/xfce-workspace.h
+++ b/src/xfce-workspace.h
@@ -70,9 +70,6 @@ void xfce_workspace_monitors_changed(XfceWorkspace *workspace,
 
 gboolean xfce_workspace_get_xinerama_stretch(XfceWorkspace *workspace);
 
-void xfce_workspace_set_cache_pixbufs    (XfceWorkspace *workspace,
-                                          gboolean cache_pixbuf);
-gboolean xfce_workspace_get_cache_pixbufs(XfceWorkspace *workspace);
 
 XfceBackdrop *xfce_workspace_get_backdrop(XfceWorkspace *workspace,
                                           guint monitor);

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


More information about the Xfce4-commits mailing list