Index: trunk/Cocoa/AntiRSI/AntiRSI.h
===================================================================
--- trunk/Cocoa/AntiRSI/AntiRSI.h	(revision 369)
+++ trunk/Cocoa/AntiRSI/AntiRSI.h	(revision 370)
@@ -80,5 +80,5 @@
     double sample_interval;
     
-    // verious other options
+    // various other options
     bool lock_focus;
     bool draw_dock_image;
Index: trunk/Cocoa/AntiRSI/AntiRSI.m
===================================================================
--- trunk/Cocoa/AntiRSI/AntiRSI.m	(revision 369)
+++ trunk/Cocoa/AntiRSI/AntiRSI.m	(revision 370)
@@ -24,4 +24,15 @@
 #include <ApplicationServices/ApplicationServices.h>
 
+// 10.5-only
+enum {
+    NSWindowCollectionBehaviorDefault = 0,
+    NSWindowCollectionBehaviorCanJoinAllSpaces = 1 << 0,
+    NSWindowCollectionBehaviorMoveToActiveSpace = 1 << 1
+};
+typedef unsigned NSWindowCollectionBehavior;
+@interface NSWindow (NSWindowCollectionBehavior)
+- (void)setCollectionBehavior:(NSWindowCollectionBehavior)behavior;
+@end
+
 extern CFTimeInterval CGSSecondsSinceLastInputEvent(unsigned long eventType);
 
@@ -194,4 +205,7 @@
     [main_window setHasShadow:NO];
     [main_window setMovableByWindowBackground:YES];
+    if ([main_window respondsToSelector:@selector(setCollectionBehavior:)])
+	[main_window setCollectionBehavior: NSWindowCollectionBehaviorCanJoinAllSpaces];
+
     [main_window center];
     [main_window setContentView:view];
@@ -235,5 +249,5 @@
     [dc setInitialValues:initial];
     
-    // bind to defauls controller
+    // bind to defaults controller
     [self bind:@"micro_pause_period" toObject:dc withKeyPath:@"values.micro_pause_period" options:nil];
     [self bind:@"micro_pause_duration" toObject:dc withKeyPath:@"values.micro_pause_duration" options:nil];
@@ -550,11 +564,30 @@
 }
 
+static ProcessSerialNumber frontmostApp;
+
 // done with micro pause or work break
 - (void)endBreak
 {
     [main_window orderOut:NULL];
+    if (lock_focus && (frontmostApp.highLongOfPSN != 0 || frontmostApp.lowLongOfPSN != 0)) {
+	SetFrontProcess(&frontmostApp);
+	frontmostApp.highLongOfPSN = kNoProcess;
+    }
     state = s_normal;
     // reset time interval to user's choice
     [self installTimer:sample_interval];
+}
+
+// bring app to front, saving previous app
+- (void)focus
+{
+    NSDictionary *activeProcessInfo = [[NSWorkspace sharedWorkspace] activeApplication];
+    if (lock_focus) {
+	frontmostApp.highLongOfPSN = [[activeProcessInfo objectForKey:@"NSApplicationProcessSerialNumberHigh"] longValue];
+	frontmostApp.lowLongOfPSN = [[activeProcessInfo objectForKey:@"NSApplicationProcessSerialNumberLow"] longValue];
+    }
+    [self tick: nil];
+    [main_window center];
+    [main_window orderFrontRegardless];
 }
 
@@ -570,7 +603,5 @@
     [postpone setHidden:YES];
     state = s_taking_micro_pause;
-    [self tick: nil];
-    [main_window center];
-    [main_window orderFrontRegardless];
+    [self focus];
 }
 
@@ -591,7 +622,5 @@
     [postpone setHidden:NO];
     state = s_taking_work_break;
-    [self tick: nil];
-    [main_window center];
-    [main_window orderFrontRegardless];
+    [self focus];
 }
 
@@ -656,5 +685,5 @@
 	int r = NSRunInformationalAlertPanel(
 	     @"New Version",
-	     [NSString stringWithFormat:@"A new version (%@) of AntiRSI is available; would you like to go to the website now?", latest_version],
+	     [NSString stringWithFormat:@"A new version (%@) of AntiRSI is available; would you like to go to its Web site now?", latest_version],
 	     @"Goto Website", @"Cancel", nil);
 	if (r == NSOKButton) {
Index: trunk/Cocoa/AntiRSI/AntiRSI.xcodeproj/project.pbxproj
===================================================================
--- trunk/Cocoa/AntiRSI/AntiRSI.xcodeproj/project.pbxproj	(revision 369)
+++ trunk/Cocoa/AntiRSI/AntiRSI.xcodeproj/project.pbxproj	(revision 370)
@@ -27,4 +27,6 @@
 		8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
 		E1203BFC0894184900759E75 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E1203BFB0894184900759E75 /* ApplicationServices.framework */; };
+		E128CD160D0A40660031ACD5 /* AntiRSIButton.h in Headers */ = {isa = PBXBuildFile; fileRef = E128CD140D0A40660031ACD5 /* AntiRSIButton.h */; };
+		E128CD170D0A40660031ACD5 /* AntiRSIButton.m in Sources */ = {isa = PBXBuildFile; fileRef = E128CD150D0A40660031ACD5 /* AntiRSIButton.m */; };
 		E1F60361098592D800806C3B /* AntiRSILevelIndicator.m in Sources */ = {isa = PBXBuildFile; fileRef = E1F6035F098592D800806C3B /* AntiRSILevelIndicator.m */; };
 		E1F60362098592D800806C3B /* AntiRSILevelIndicator.h in Headers */ = {isa = PBXBuildFile; fileRef = E1F60360098592D800806C3B /* AntiRSILevelIndicator.h */; };
@@ -42,5 +44,5 @@
 		464D9ADB0C6A622B005A0582 /* CTBadge.m */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 2; lastKnownFileType = sourcecode.c.objc; name = CTBadge.m; path = CTBadge/CTBadge.m; sourceTree = "<group>"; tabWidth = 4; usesTabs = 0; };
 		464D9ADC0C6A622B005A0582 /* CTGradient.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CTGradient.h; path = CTBadge/CTGradient.h; sourceTree = "<group>"; };
-		464D9ADD0C6A622B005A0582 /* CTGradient.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = CTGradient.m; path = CTBadge/CTGradient.m; sourceTree = "<group>"; };
+		464D9ADD0C6A622B005A0582 /* CTGradient.m */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 2; lastKnownFileType = sourcecode.c.objc; name = CTGradient.m; path = CTBadge/CTGradient.m; sourceTree = "<group>"; tabWidth = 4; };
 		464D9B750C6A760B005A0582 /* CTBadge_1.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = CTBadge_1.pdf; sourceTree = "<group>"; };
 		464D9B760C6A760B005A0582 /* CTBadge_3.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = CTBadge_3.pdf; sourceTree = "<group>"; };
@@ -55,4 +57,6 @@
 		8D1107320486CEB800E47090 /* AntiRSI.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AntiRSI.app; sourceTree = BUILT_PRODUCTS_DIR; };
 		E1203BFB0894184900759E75 /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = /System/Library/Frameworks/ApplicationServices.framework; sourceTree = "<absolute>"; };
+		E128CD140D0A40660031ACD5 /* AntiRSIButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AntiRSIButton.h; sourceTree = "<group>"; };
+		E128CD150D0A40660031ACD5 /* AntiRSIButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AntiRSIButton.m; sourceTree = "<group>"; };
 		E1F6035F098592D800806C3B /* AntiRSILevelIndicator.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = AntiRSILevelIndicator.m; sourceTree = "<group>"; };
 		E1F60360098592D800806C3B /* AntiRSILevelIndicator.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = AntiRSILevelIndicator.h; sourceTree = "<group>"; };
@@ -79,6 +83,8 @@
 				4DF73F66061E136200B0D9C9 /* AntiRSIView.h */,
 				4DF73F65061E136200B0D9C9 /* AntiRSIView.m */,
+				E1F60360098592D800806C3B /* AntiRSILevelIndicator.h */,
 				E1F6035F098592D800806C3B /* AntiRSILevelIndicator.m */,
-				E1F60360098592D800806C3B /* AntiRSILevelIndicator.h */,
+				E128CD140D0A40660031ACD5 /* AntiRSIButton.h */,
+				E128CD150D0A40660031ACD5 /* AntiRSIButton.m */,
 			);
 			name = Classes;
@@ -190,4 +196,5 @@
 				464D9ADE0C6A622B005A0582 /* CTBadge.h in Headers */,
 				464D9AE00C6A622B005A0582 /* CTGradient.h in Headers */,
+				E128CD160D0A40660031ACD5 /* AntiRSIButton.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -267,4 +274,5 @@
 				464D9ADF0C6A622B005A0582 /* CTBadge.m in Sources */,
 				464D9AE10C6A622B005A0582 /* CTGradient.m in Sources */,
+				E128CD170D0A40660031ACD5 /* AntiRSIButton.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -406,4 +414,5 @@
 				);
 				GCC_C_LANGUAGE_STANDARD = c99;
+				MACOSX_DEPLOYMENT_TARGET = 10.4;
 				PREBINDING = NO;
 				SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
Index: trunk/Cocoa/AntiRSI/CTBadge/CTGradient.m
===================================================================
--- trunk/Cocoa/AntiRSI/CTBadge/CTGradient.m	(revision 369)
+++ trunk/Cocoa/AntiRSI/CTBadge/CTGradient.m	(revision 370)
@@ -779,9 +779,7 @@
 - (void)setBlendingMode:(CTGradientBlendingMode)mode;
   {
-  blendingMode = mode;
-  
   //Choose what blending function to use
   void *evaluationFunction;
-  switch(blendingMode)
+  switch(mode)
 	{
 	case CTLinearBlendingMode:
@@ -791,6 +789,11 @@
 	case CTInverseChromaticBlendingMode:
 		 evaluationFunction = &inverseChromaticEvaluation;	break;
-	}
-  
+	default:
+		 NSParameterAssert("blending mode not supported" && NO);
+		 return; // unreachable, satisfy compiler
+	}
+
+  blendingMode = mode;
+
   //replace the current CoreGraphics Function with new one
   if(gradientFunction != NULL)
@@ -1183,7 +1186,6 @@
 
 
-void transformRGB_HSV(float *components) //H,S,B -> R,G,B
-	{
-	float H, S, V;
+void transformRGB_HSV(float *components) //H,S,B <- R,G,B
+	{
 	float R = components[0],
 		  G = components[1],
@@ -1193,18 +1195,21 @@
 	      MIN = R < G ? (R < B ? R : B) : (G < B ? G : B);
 	
-	if(MAX == MIN)
-		H = NAN;
-	else if(MAX == R)
-		if(G >= B)
-			H = 60*(G-B)/(MAX-MIN)+0;
-		else
-			H = 60*(G-B)/(MAX-MIN)+360;
-	else if(MAX == G)
-		H = 60*(B-R)/(MAX-MIN)+120;
-	else if(MAX == B)
-		H = 60*(R-G)/(MAX-MIN)+240;
-	
-	S = MAX == 0 ? 0 : 1 - MIN/MAX;
-	V = MAX;
+	float H = NAN;
+
+	if(MAX != MIN)
+	  {
+	  if(MAX == R)
+		  if(G >= B)
+			  H = 60*(G-B)/(MAX-MIN)+0;
+		  else
+			  H = 60*(G-B)/(MAX-MIN)+360;
+	  else if(MAX == G)
+		  H = 60*(B-R)/(MAX-MIN)+120;
+	  else if(MAX == B)
+		  H = 60*(R-G)/(MAX-MIN)+240;
+	  }
+	
+	float S = MAX == 0 ? 0 : 1 - MIN/MAX;
+	float V = MAX;
 	
 	components[0] = H;
@@ -1234,4 +1239,5 @@
 		case 4:	R=t;G=p;B=V;	break;
 		case 5:	R=V;G=p;B=q;	break;
+		default: R=0;G=0;B=0;   // unreachable, satisfy compiler
 		}
 	
Index: trunk/Cocoa/AntiRSI/English.lproj/MainMenu.nib/classes.nib
===================================================================
--- trunk/Cocoa/AntiRSI/English.lproj/MainMenu.nib/classes.nib	(revision 369)
+++ trunk/Cocoa/AntiRSI/English.lproj/MainMenu.nib/classes.nib	(revision 370)
@@ -1,39 +1,105 @@
-{
-    IBClasses = (
-        {
-            ACTIONS = {
-                breakNow = id; 
-                checkForUpdate = id; 
-                gotoWebsite = id; 
-                postpone = id; 
-                resetSession = id; 
-            }; 
-            CLASS = AntiRSI; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {
-                "dock_menu" = NSMenu; 
-                "next_break" = NSTextField; 
-                postpone = NSButton; 
-                progress = NSLevelIndicator; 
-                "reset_session_time" = NSDatePicker; 
-                "session_time" = NSTextField; 
-                "session_time_item" = NSMenuItem; 
-                status = NSTextField; 
-                time = NSTextField; 
-                version = NSTextField; 
-                view = AntiRSIView; 
-            }; 
-            SUPERCLASS = NSObject; 
-        }, 
-        {
-            CLASS = AntiRSILevelIndicator; 
-            LANGUAGE = ObjC; 
-            SUPERCLASS = NSLevelIndicator; 
-        }, 
-        {CLASS = AntiRSIView; LANGUAGE = ObjC; SUPERCLASS = NSView; }, 
-        {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, 
-        {CLASS = NSDatePicker; LANGUAGE = ObjC; SUPERCLASS = NSControl; }, 
-        {CLASS = NSLevelIndicator; LANGUAGE = ObjC; SUPERCLASS = NSControl; }
-    ); 
-    IBVersion = 1; 
-}
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>IBClasses</key>
+	<array>
+		<dict>
+			<key>CLASS</key>
+			<string>NSLevelIndicator</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>SUPERCLASS</key>
+			<string>NSControl</string>
+		</dict>
+		<dict>
+			<key>CLASS</key>
+			<string>AntiRSIButton</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>SUPERCLASS</key>
+			<string>NSButton</string>
+		</dict>
+		<dict>
+			<key>ACTIONS</key>
+			<dict>
+				<key>breakNow</key>
+				<string>id</string>
+				<key>checkForUpdate</key>
+				<string>id</string>
+				<key>gotoWebsite</key>
+				<string>id</string>
+				<key>postpone</key>
+				<string>id</string>
+				<key>resetSession</key>
+				<string>id</string>
+			</dict>
+			<key>CLASS</key>
+			<string>AntiRSI</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>OUTLETS</key>
+			<dict>
+				<key>dock_menu</key>
+				<string>NSMenu</string>
+				<key>next_break</key>
+				<string>NSTextField</string>
+				<key>postpone</key>
+				<string>NSButton</string>
+				<key>progress</key>
+				<string>NSLevelIndicator</string>
+				<key>reset_session_time</key>
+				<string>NSDatePicker</string>
+				<key>session_time</key>
+				<string>NSTextField</string>
+				<key>session_time_item</key>
+				<string>NSMenuItem</string>
+				<key>status</key>
+				<string>NSTextField</string>
+				<key>time</key>
+				<string>NSTextField</string>
+				<key>version</key>
+				<string>NSTextField</string>
+				<key>view</key>
+				<string>AntiRSIView</string>
+			</dict>
+			<key>SUPERCLASS</key>
+			<string>NSObject</string>
+		</dict>
+		<dict>
+			<key>CLASS</key>
+			<string>FirstResponder</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>SUPERCLASS</key>
+			<string>NSObject</string>
+		</dict>
+		<dict>
+			<key>CLASS</key>
+			<string>NSDatePicker</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>SUPERCLASS</key>
+			<string>NSControl</string>
+		</dict>
+		<dict>
+			<key>CLASS</key>
+			<string>AntiRSIView</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>SUPERCLASS</key>
+			<string>NSView</string>
+		</dict>
+		<dict>
+			<key>CLASS</key>
+			<string>AntiRSILevelIndicator</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>SUPERCLASS</key>
+			<string>NSLevelIndicator</string>
+		</dict>
+	</array>
+	<key>IBVersion</key>
+	<string>1</string>
+</dict>
+</plist>
Index: trunk/Cocoa/AntiRSI/English.lproj/MainMenu.nib/info.nib
===================================================================
--- trunk/Cocoa/AntiRSI/English.lproj/MainMenu.nib/info.nib	(revision 369)
+++ trunk/Cocoa/AntiRSI/English.lproj/MainMenu.nib/info.nib	(revision 370)
@@ -1,21 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
-	<key>IBDocumentLocation</key>
-	<string>70 16 441 309 0 0 1680 1028 </string>
-	<key>IBEditorPositions</key>
-	<dict>
-		<key>259</key>
-		<string>668 524 300 322 0 0 1680 1028 </string>
-		<key>29</key>
-		<string>276 845 249 44 0 0 1680 1028 </string>
-		<key>343</key>
-		<string>241 262 145 99 0 0 1680 1028 </string>
-	</dict>
 	<key>IBFramework Version</key>
-	<string>446.1</string>
+	<string>629</string>
+	<key>IBLastKnownRelativeProjectPath</key>
+	<string>../../AntiRSI.xcodeproj</string>
 	<key>IBOldestOS</key>
-	<integer>4</integer>
+	<integer>5</integer>
 	<key>IBOpenObjects</key>
 	<array>
@@ -23,5 +14,7 @@
 	</array>
 	<key>IBSystem Version</key>
-	<string>8R2232</string>
+	<string>9B18</string>
+	<key>targetFramework</key>
+	<string>IBCocoaFramework</string>
 </dict>
 </plist>
Index: trunk/Cocoa/AntiRSI/Info.plist
===================================================================
--- trunk/Cocoa/AntiRSI/Info.plist	(revision 369)
+++ trunk/Cocoa/AntiRSI/Info.plist	(revision 370)
@@ -18,5 +18,5 @@
 	<string>ONNE</string>
 	<key>CFBundleVersion</key>
-	<string>1.4njr3</string>
+	<string>1.4njr4</string>
 	<key>NSMainNibFile</key>
 	<string>MainMenu</string>
