From 6632f3437f19a985d3b6b311b30bc1bafbca0002 Mon Sep 17 00:00:00 2001
From: Sam Moore <matches@ucc.asn.au>
Date: Tue, 2 Apr 2013 15:05:29 +0800
Subject: [PATCH] Make --blackout option turn off screen

Because the SDL_ENABLE_SCREENSAVER flag wasn't working
---
 qchess/qchess.py       | 10 +++++++---
 qchess/src/graphics.py |  8 ++++++--
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/qchess/qchess.py b/qchess/qchess.py
index 0f79276..8861d98 100755
--- a/qchess/qchess.py
+++ b/qchess/qchess.py
@@ -1954,6 +1954,7 @@ class GraphicsThread(StoppableThread):
 		self.cond = threading.Condition()
 		self.sleep_timeout = None
 		self.last_event = time.time()
+		self.blackout = False
 
 		#print "Test font"
 		pygame.font.Font(os.path.join(os.path.curdir, "data", "DejaVuSans.ttf"), 32).render("Hello", True,(0,0,0))
@@ -1987,8 +1988,11 @@ class GraphicsThread(StoppableThread):
 
 				#print "Display pieces"
 				self.board.display_pieces(window = self.window, grid_sz = self.grid_sz) # Draw the board		
+				self.blackout = False
 				
-			else:
+			elif pygame.mouse.get_focused() and not self.blackout:
+				os.system("xset dpms force off")
+				self.blackout = True
 				self.window.fill((0,0,0))
 
 			pygame.display.flip()
@@ -2013,7 +2017,7 @@ class GraphicsThread(StoppableThread):
 				
 				
 					
-
+  
 				
 								
 						
@@ -2687,4 +2691,4 @@ if __name__ == "__main__":
 		sys.exit(102)
 
 # --- main.py --- #
-# EOF - created from make on Fri Mar 29 18:33:24 WST 2013
+# EOF - created from make on Tue Apr  2 15:05:07 WST 2013
diff --git a/qchess/src/graphics.py b/qchess/src/graphics.py
index 0097ec2..fefcbf3 100644
--- a/qchess/src/graphics.py
+++ b/qchess/src/graphics.py
@@ -29,6 +29,7 @@ class GraphicsThread(StoppableThread):
 		self.cond = threading.Condition()
 		self.sleep_timeout = None
 		self.last_event = time.time()
+		self.blackout = False
 
 		#print "Test font"
 		pygame.font.Font(os.path.join(os.path.curdir, "data", "DejaVuSans.ttf"), 32).render("Hello", True,(0,0,0))
@@ -62,8 +63,11 @@ class GraphicsThread(StoppableThread):
 
 				#print "Display pieces"
 				self.board.display_pieces(window = self.window, grid_sz = self.grid_sz) # Draw the board		
+				self.blackout = False
 				
-			else:
+			elif pygame.mouse.get_focused() and not self.blackout:
+				os.system("xset dpms force off")
+				self.blackout = True
 				self.window.fill((0,0,0))
 
 			pygame.display.flip()
@@ -88,7 +92,7 @@ class GraphicsThread(StoppableThread):
 				
 				
 					
-
+  
 				
 								
 						
-- 
GitLab