adium 2887:f046b16a0a17: Set the focus element for all elements ...

commits at adium.im commits at adium.im
Sat Nov 7 21:24:16 UTC 2009


details:	http://hg.adium.im/adium/rev/f046b16a0a17
revision:	2887:f046b16a0a17
author:		Zachary West <zacw at adium.im>
date:		Sat Nov 07 16:24:00 2009 -0500

Set the focus element for all elements when out of focus. Fixes #13356.

This also fixes setting the mark location correctly, as well as sets the first non-focused message as having class "firstFocus".
(transplanted from df722b0497cae792cd43606afc5ea446fffe3053)

diffs (61 lines):

diff -r 0f33e5e602ff -r f046b16a0a17 Plugins/WebKit Message View/AIWebKitMessageViewController.m
--- a/Plugins/WebKit Message View/AIWebKitMessageViewController.m	Sat Nov 07 15:42:01 2009 -0500
+++ b/Plugins/WebKit Message View/AIWebKitMessageViewController.m	Sat Nov 07 16:24:00 2009 -0500
@@ -680,14 +680,19 @@
 		if (content.trackContent && [content.displayClasses containsObject:@"mention"]) {
 			[self markCurrentLocation];
 		}
-		
-		// Set it as a focus if appropriate.
-		if (nextMessageFocus && [content.type isEqualToString:CONTENT_MESSAGE_TYPE]) {
-			if (adium.interfaceController.activeChat != content.chat) {
-				[content addDisplayClass:@"focus"];
+
+		if (adium.interfaceController.activeChat != content.chat && [content.type isEqualToString:CONTENT_MESSAGE_TYPE]) {
+			if (nextMessageFocus) {
+				[self.markedScroller addMarkAt:[self.currentOffsetHeight integerValue] withIdentifier:@"focus" withColor:[NSColor redColor]];
+				
+				// Add a class for "first message to lose focus"
+				[content addDisplayClass:@"firstFocus"];
+				
+				nextMessageFocus = NO;
 			}
-			
-			nextMessageFocus = NO;
+
+			// Add a class for "this message received while out of focus"
+			[content addDisplayClass:@"focus"];
 		}
 		
 		//Add the content object
@@ -1456,12 +1461,10 @@
 
 - (void)markForFocusChange
 {
-	JVMarkedScroller *scroller = self.markedScroller;
+	// We use the current Chat element's height to determine our mark location.
+	[self.markedScroller removeMarkWithIdentifier:@"focus"];
 	
-	// We use the current Chat element's height to determine our mark location.
-	[scroller removeMarkWithIdentifier:@"focus"];
-	[scroller addMarkAt:[self.currentOffsetHeight integerValue] withIdentifier:@"focus" withColor:[NSColor redColor]];	
-	
+	// The next message being inserted needs to add a mark.
 	nextMessageFocus = YES;
 	
 	DOMNodeList *nodeList = [webView.mainFrameDocument querySelectorAll:@".focus"];
@@ -1472,13 +1475,13 @@
 		classes = [[node.className componentsSeparatedByString:@" "] mutableCopy];
 		
 		[classes removeObject:@"focus"];
+		[classes removeObject:@"firstFocus"];
 		
 		node.className = [classes componentsJoinedByString:@" "];
 		
 		[classes release];
 	}
 	
-	nextMessageFocus = YES;
 }
 
 - (void)addMark




More information about the commits mailing list