[Xfce4-commits] [apps/xfdashboard] 01/01: Rewrote function xfdashboard_window_tracker_get_root_window() to lookup desktop window

noreply at xfce.org noreply at xfce.org
Sat Apr 25 11:57:09 CEST 2015


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

nomad pushed a commit to branch master
in repository apps/xfdashboard.

commit 62d87094630d157ca4e5b195de1f88380589d62d
Author: Stephan Haller <nomad at froevel.de>
Date:   Sat Apr 25 11:54:47 2015 +0200

    Rewrote function xfdashboard_window_tracker_get_root_window() to lookup desktop window
    
    Rewrote function to lookup desktop window by trying first to get window by known background pixmap ID and if it fails it will iterate through window list to lookup a window of type 'desktop'. If both methods fail, NULL will be returned to indicate that there is no matching window.
    
    This should fix issue GH #80
---
 xfdashboard/stage.c          |    4 ++--
 xfdashboard/window-tracker.c |   49 ++++++++++++++++++++++++------------------
 2 files changed, 30 insertions(+), 23 deletions(-)

diff --git a/xfdashboard/stage.c b/xfdashboard/stage.c
index 8ae95d6..0b1e057 100644
--- a/xfdashboard/stage.c
+++ b/xfdashboard/stage.c
@@ -1665,7 +1665,7 @@ void xfdashboard_stage_set_background_image_type(XfdashboardStage *self, Xfdashb
 							clutter_actor_set_content(priv->backgroundImageLayer, backgroundContent);
 							g_object_unref(backgroundContent);
 
-							g_debug("Dekstop window was found and set up as background image for stage");
+							g_debug("Desktop window was found and set up as background image for stage");
 						}
 							else
 							{
@@ -1673,7 +1673,7 @@ void xfdashboard_stage_set_background_image_type(XfdashboardStage *self, Xfdashb
 															"window-opened",
 															G_CALLBACK(_xfdashboard_stage_on_desktop_window_opened),
 															self);
-								g_debug("Dekstop window was not found. Setting up signal to get notified when desktop background image was signalled");
+								g_debug("Desktop window was not found. Setting up signal to get notified when desktop window might be opened.");
 							}
 					}
 					break;
diff --git a/xfdashboard/window-tracker.c b/xfdashboard/window-tracker.c
index a5d9567..185df16 100644
--- a/xfdashboard/window-tracker.c
+++ b/xfdashboard/window-tracker.c
@@ -1323,41 +1323,48 @@ XfdashboardWindowTrackerWindow* xfdashboard_window_tracker_get_root_window(Xfdas
 {
 	XfdashboardWindowTrackerPrivate		*priv;
 	gulong								backgroundWindowID;
-	WnckWindow							*backgroundWindow;
+	GList								*windows;
 
 	g_return_val_if_fail(XFDASHBOARD_IS_WINDOW_TRACKER(self), NULL);
 
 	priv=self->priv;
 
-	/* Return root window (the desktop) */
+	/* Find and return root window (the desktop) by known ID */
 	backgroundWindowID=wnck_screen_get_background_pixmap(priv->screen);
-	if(!backgroundWindowID)
+	if(backgroundWindowID)
 	{
-		GList							*windows;
-		WnckWindow						*window;
-		WnckWindowType					windowType;
+		WnckWindow						*backgroundWindow;
 
-		backgroundWindow=NULL;
-		for(windows=wnck_screen_get_windows(priv->screen); !backgroundWindowID && windows; windows=g_list_next(windows))
+		backgroundWindow=wnck_window_get(backgroundWindowID);
+		if(backgroundWindow)
 		{
-			window=(WnckWindow*)windows->data;
-			windowType=wnck_window_get_window_type(window);
-			if(windowType==WNCK_WINDOW_DESKTOP) backgroundWindowID=wnck_window_get_xid(window);
+			g_debug("Found desktop window by known background pixmap ID");
+			return(XFDASHBOARD_WINDOW_TRACKER_WINDOW(backgroundWindow));
 		}
 	}
 
-	if(!backgroundWindowID)
+	/* Either there was no known ID for the root window or the root window
+	 * could not be found (happened a lot when running in daemon mode).
+	 * So iterate through list of all known windows and lookup window of
+	 * type 'desktop'.
+	 */
+	for(windows=wnck_screen_get_windows(priv->screen); windows; windows=g_list_next(windows))
 	{
-		g_debug("Desktop window was not found - maybe it was not created or signalled yet");
-		return(NULL);
-	}
+		WnckWindow					*window;
+		WnckWindowType				windowType;
 
-	backgroundWindow=wnck_window_get(backgroundWindowID);
-	if(!backgroundWindow)
-	{
-		g_debug("Could not get window instance for desktop window ID");
-		return(NULL);
+		window=(WnckWindow*)windows->data;
+		windowType=wnck_window_get_window_type(window);
+		if(windowType==WNCK_WINDOW_DESKTOP)
+		{
+			g_debug("Desktop window ID found while iterating through window list");
+				return(XFDASHBOARD_WINDOW_TRACKER_WINDOW(window));
+		}
 	}
 
-	return(XFDASHBOARD_WINDOW_TRACKER_WINDOW(backgroundWindow));
+	/* If we get here either desktop window does not exist or is not known
+	 * in window list. So return NULL here.
+	 */
+	g_debug("Desktop window could not be found");
+	return(NULL);
 }

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


More information about the Xfce4-commits mailing list