Sophie

Sophie

distrib > Fedora > 13 > i386 > by-pkgid > cfd5a9dd583fb1ae0fd3ada5d6b760fc > files > 3

wallpapoz-0.5-2.fc13.src.rpm

--- wallpapoz-0.4.1-svn92_trunk/share/wallpapoz/lib/wallpapoz_system.py.compiz	2009-08-30 01:22:07.000000000 +0900
+++ wallpapoz-0.4.1-svn92_trunk/share/wallpapoz/lib/wallpapoz_system.py	2010-03-18 00:40:58.000000000 +0900
@@ -25,18 +25,40 @@
 # achieve goal by calling external program
 
 import os
+import sys
 import string
 
 class WallpapozSystem:
 
+  # Define static variable to save the initial value of self.beryl
+  static_check_beryl_called_p = False
+  static_beryl = False
+
+  # Also for total_workspaces
+  static_finding_total_workspaces_called_p = False
+  static_total_workspaces = 0
+
   def __init__(self):
     self.wallpaper_style = 'scaled'
     self.finding_screen_resolution()
+
+    # Save the first result of self.beryl, and respawn daemon
+    # if self.beryl value changed.
     self.check_beryl()
+    if not WallpapozSystem.static_check_beryl_called_p :
+      WallpapozSystem.static_check_beryl_called_p = True
+      WallpapozSystem.static_beryl = self.beryl
+
     if self.beryl:
       self.finding_row_and_column()
     self.finding_total_workspaces()
 
+    # Check if total_workspaces changed only here
+    if WallpapozSystem.static_total_workspaces != self.total_workspaces:
+      print "daemon_wallpapoz: the number of total workspaces changed during initialization process."
+      print "daemon_wallpapoz: respawning daemon_wallpapoz."
+      self.respawn_system()
+
   def set_style(self, style):
     self.wallpaper_style = style
 
@@ -57,6 +79,11 @@
     else:
       self.total_workspaces = int(os.popen("xprop -root _NET_NUMBER_OF_DESKTOPS").read()[36:38])
 
+    # Save this total_workspaces value
+    if not WallpapozSystem.static_finding_total_workspaces_called_p:
+      WallpapozSystem.static_finding_total_workspaces_called = True
+      WallpapozSystem.static_total_workspaces = self.total_workspaces
+
   ## class method to find if user use beryl in his system or not
   def check_beryl(self):
     raw_geometry = os.popen('xprop -root _NET_DESKTOP_GEOMETRY').read()
@@ -69,10 +96,15 @@
     self.beryl = False
     if self.geometry_width!=self.screen_width:
       self.beryl = True
-      return
-    if self.geometry_height!=self.screen_height:
+    elif self.geometry_height!=self.screen_height:
       self.beryl = True
 
+    # respawn daemon if self.beryl value changed
+    if WallpapozSystem.static_check_beryl_called_p:
+      if WallpapozSystem.static_beryl != self.beryl:
+        print "Compiz status changed, respawning daemon_wallpapoz."
+        self.respawn_system()
+
   ## class method to find how many rows and columns of workspaces
   def finding_row_and_column(self):
     self.row_workspaces = self.geometry_height / self.screen_height
@@ -113,3 +145,11 @@
       return True
     else:
       return False
+
+  def respawn_system(self):
+    new_argv = []
+    new_argv.extend(sys.argv)
+    os.execvp('daemon_wallpapoz', new_argv)
+    print "os.execvp failed, exiting..."
+    sys.exit(1)
+
--- wallpapoz-0.4.1-svn92_trunk/src/daemon_wallpapoz.compiz	2009-08-30 01:22:07.000000000 +0900
+++ wallpapoz-0.4.1-svn92_trunk/src/daemon_wallpapoz	2010-03-18 00:25:42.000000000 +0900
@@ -134,11 +134,20 @@
     if wallpapozxml.get_type() == "workspace":
       while True:
 	# don't get rush
-	time.sleep(1)
+       # sleep a bit more
+	time.sleep(2)
+
+	# check if compiz is working every loop (and
+	# if compiz status changed, respawn daemon)
+	wallpapoz_system.check_beryl()
 
 	# what workspace we are in now?
 	cur_desk = wallpapoz_system.current_desktop()
 
+        if cur_desk >= wallpapoz_system.get_total_workspaces() :
+          # ignore
+          continue
+
 	# requirement for changing wallpaper
 	# 1. we change workspace
 	# 2. index of wallpaper list change