All pastes #348984 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-02-10 13:56 UTC
rendered paste body
Index: src/group/group.h
===================================================================
--- src/group/group.h	(Revision 3911)
+++ src/group/group.h	(Arbeitskopie)
@@ -324,7 +324,8 @@
 	GroupTabBarSlot	*revSlots;
 	int		nSlots;
 
-	GroupTabBarSlot	*lastHoveredSlot;
+	GroupTabBarSlot	*hoveredSlot;
+	GroupTabBarSlot *textSlot;
 
 	GroupCairoLayer	*textLayer;
 	GroupCairoLayer	*bgLayer;
Index: src/group/debug.c
===================================================================
--- src/group/debug.c	(Revision 3911)
+++ src/group/debug.c	(Arbeitskopie)
@@ -153,7 +153,8 @@
 	printf("DEBUG: Debugging tab bar (%p)...\n", bar);
 
 	if (DEBUG_LEVEL >= DEBUG_IMPORTANT ) {
-		printf("lastHoveredSlot => %p\n", bar->lastHoveredSlot);
+		printf("hoveredSlot => %p\n", bar->hoveredSlot);
+		printf("textSlot => %p\n", bar->textSlot);
 		//printf("mouseOver => %s\n",			(bar->mouseOver ? "TRUE" : "FALSE"));
 		printf("state => %i\n",				bar->state);
 		printf("timeoutHandle => %i\n", bar->timeoutHandle);
Index: src/group/tab.c
===================================================================
--- src/group/tab.c	(Revision 3911)
+++ src/group/tab.c	(Arbeitskopie)
@@ -1596,8 +1596,20 @@
 	if(IS_PREV_TOP_TAB(w, gw->group) && !temporary)
 		gw->group->prevTopTab = NULL;
 
-	if (slot == bar->lastHoveredSlot)
-		bar->lastHoveredSlot = NULL;
+	if (slot == bar->hoveredSlot)
+		bar->hoveredSlot = NULL;
+	
+	if (slot == bar->textSlot)
+	{
+		bar->textSlot = NULL;
+		
+		if (bar->textLayer->state == PaintFadeIn || bar->textLayer->state == PaintOn)
+		{
+			bar->textLayer->animationTime = (gs->opt[GROUP_SCREEN_OPTION_FADE_TEXT_TIME].value.f * 1000)
+													- bar->textLayer->animationTime;
+			bar->textLayer->state = PaintFadeOut;
+		}
+	}
 
 	//Moving bar->region->extents.x1 / x2 as minX1 / maxX2 will work,
 	//because the tab-bar got thiner now, so (bar->region->extents.x1 + bar->region->extents.x2) / 2
@@ -1964,7 +1976,8 @@
 	bar->textLayer = NULL;
 	bar->bgLayer = NULL;
 	bar->selectionLayer = NULL;
-	bar->lastHoveredSlot = NULL;
+	bar->hoveredSlot = NULL;
+	bar->textSlot = NULL;
 	group->tabBar = bar;
 
 	bar->region = XCreateRegion();
@@ -2187,9 +2200,9 @@
 
 		group->inputPrevention = None; 
 	}
-
-	if (group->tabBar)
-		group->tabBar->lastHoveredSlot = NULL; 
+//
+//	if (group->tabBar)
+//		group->tabBar->lastHoveredSlot = NULL; 
 } 
 
 
Index: src/group/paint.c
===================================================================
--- src/group/paint.c	(Revision 3911)
+++ src/group/paint.c	(Arbeitskopie)
@@ -227,8 +227,8 @@
 
 	int font_size = gs->opt[GROUP_SCREEN_OPTION_TABBAR_FONTSIZE].value.i;
 	
-	if (bar->lastHoveredSlot && bar->lastHoveredSlot->name)
-		title = bar->lastHoveredSlot->name;
+	if (bar->textSlot && bar->textSlot->name)
+		title = bar->textSlot->name;
 	else
 		title = " ";
 
@@ -312,65 +312,49 @@
 	/* FIXME: remove this after finding out how to get move notifies for input only windows */
 #if 1		
 	if (bar->state != PaintOff) {	// Tab-bar is visible.
-		Bool hasText = FALSE;
-		Bool animation = FALSE;
 		int mouseX, mouseY;
 		Bool mouseOnScreen;
 
 		mouseOnScreen = groupGetCurrentMousePosition(s, &mouseX, &mouseY);
 
-		if (mouseOnScreen && !(bar->lastHoveredSlot &&
-			XPointInRegion(bar->lastHoveredSlot->region, mouseX, mouseY)))
+		if (mouseOnScreen && !(bar->hoveredSlot && XPointInRegion(bar->hoveredSlot->region, mouseX, mouseY)))
 		{
-			if (bar->textLayer->state == PaintOn || bar->textLayer->state == PaintFadeIn) {
-				bar->textLayer->state = PaintFadeOut;
-				bar->textLayer->animationTime = (gs->opt[GROUP_SCREEN_OPTION_FADE_TEXT_TIME].value.f * 1000) - bar->textLayer->animationTime;
-				animation = TRUE;
-			} else if (bar->textLayer->state == PaintFadeOut) {
-				animation = TRUE;
-			}
+			bar->hoveredSlot = NULL;
+		
+			Region clip;
+			clip = groupGetClippingRegion(topTab);
 
-			Region clip = XCreateRegion();
-
-			// don't waste resources on this :P
-			if (!animation) {
-				clip = groupGetClippingRegion(topTab);
-			}
-
-			for (slot = bar->slots; slot; slot = slot->next) {
-
-				if (animation) // we don't want a change yet
-					break;
-
-				if (slot == bar->lastHoveredSlot)
-					continue;
-
+			for (slot = bar->slots; slot; slot = slot->next)
+			{
 				Region reg = XCreateRegion();
 				XSubtractRegion(slot->region, clip, reg);
 
-				if (XPointInRegion(reg, mouseX, mouseY)) {
-					hasText = TRUE;
-					bar->lastHoveredSlot = slot;
-
-					groupRenderWindowTitle(group);
-
-					bar->textLayer->animationTime = (gs->opt[GROUP_SCREEN_OPTION_FADE_TEXT_TIME].value.f * 1000)
-													- bar->textLayer->animationTime;
-					bar->textLayer->state = PaintFadeIn;
+				if (XPointInRegion(reg, mouseX, mouseY))
+				{
+					bar->hoveredSlot = slot;
+					
 					break;
 				}
 
 				XDestroyRegion(reg);
 			}
 
-			if (clip)
-				XDestroyRegion(clip);
+			XDestroyRegion(clip);
+		}
 
-			if (!animation && !hasText && bar->lastHoveredSlot) {
-				bar->lastHoveredSlot = NULL;
-				groupRenderWindowTitle(group);
-			}
+		if ((bar->textLayer->state == PaintFadeIn || bar->textLayer->state == PaintOn) &&
+		    bar->hoveredSlot != bar->textSlot)
+		{
+			bar->textLayer->animationTime = (gs->opt[GROUP_SCREEN_OPTION_FADE_TEXT_TIME].value.f * 1000)
+											- bar->textLayer->animationTime;
+			bar->textLayer->state = PaintFadeOut;
 		}
+		else if (bar->textLayer->state == PaintFadeOut && bar->hoveredSlot == bar->textSlot && bar->hoveredSlot)
+		{
+			bar->textLayer->animationTime = (gs->opt[GROUP_SCREEN_OPTION_FADE_TEXT_TIME].value.f * 1000)
+											- bar->textLayer->animationTime;
+			bar->textLayer->state = PaintFadeIn;
+		}
 	}
 #endif		
 
@@ -591,11 +575,13 @@
 	(*s->preparePaintScreen) (s, msSinceLastPaint);
 	WRAP(gs, s, preparePaintScreen, groupPreparePaintScreen);
 
-	for(group = gs->groups; group; group = group->next)
+	for (group = gs->groups; group; group = group->next)
 	{
 		if (group->changeState != PaintOff)
 			group->changeAnimationTime -= msSinceLastPaint;
-
+		
+		// Tab-bar animation.
+		
 		if(!group->tabBar)
 			continue;
 	
@@ -604,50 +590,81 @@
 
 		if (((group->tabBar->state == PaintFadeIn) || 
 		     (group->tabBar->state == PaintFadeOut)) &&
-		    group->tabBar->animationTime > 0) {
+		    group->tabBar->animationTime > 0)
+		{
 			group->tabBar->animationTime -= msSinceLastPaint;
+		
 			if (group->tabBar->animationTime < 0)
 				group->tabBar->animationTime = 0;
 
 			if (group->tabBar->animationTime == 0) {
-				if (group->tabBar->state == PaintFadeIn) {
+				if (group->tabBar->state == PaintFadeIn)
+				{
 					group->tabBar->state = PaintOn;
 					changedTabBarState = TRUE;
-				} else if (group->tabBar->state == PaintFadeOut) {
+				}
+			
+				else if (group->tabBar->state == PaintFadeOut)
+				{
 					group->tabBar->state = PaintOff;
 					changedTabBarState = TRUE;
 					if (group->tabBar->textLayer) {
+						// Tab-bar is no longer painted, clean up text animation variables.
+					
 						group->tabBar->textLayer->animationTime = 0;
 						group->tabBar->textLayer->state = PaintOff;
+						group->tabBar->textSlot = group->tabBar->hoveredSlot = NULL;
+						
+						groupRenderWindowTitle(group);
 					}
 				}
 			}
 		}
+		
+		// Text animation.
 
 		if (!group->tabBar->textLayer)
 			continue;
 
-		if (group->tabBar->textLayer->state == PaintOn ||
-			group->tabBar->textLayer->state == PaintOff) {
-			if (group->tabBar->textLayer->animationTime != 0) // clear up if needed
-				group->tabBar->textLayer->animationTime = 0;
-		}
-
-		if(((group->tabBar->textLayer->state == PaintFadeIn) ||
-			(group->tabBar->textLayer->state == PaintFadeOut)) &&
-			group->tabBar->textLayer->animationTime > 0)
+		if ( (group->tabBar->textLayer->state == PaintFadeIn || 
+		      group->tabBar->textLayer->state == PaintFadeOut) &&
+		    group->tabBar->textLayer->animationTime > 0)
 		{
 			group->tabBar->textLayer->animationTime -= msSinceLastPaint;
+			
 			if (group->tabBar->textLayer->animationTime < 0)
 				group->tabBar->textLayer->animationTime = 0;
-
-			if (group->tabBar->textLayer->animationTime == 0) {
+			
+			if (group->tabBar->textLayer->animationTime == 0)
+			{
 				if (group->tabBar->textLayer->state == PaintFadeIn)
-					group->tabBar->textLayer->state = PaintOn;
+					group->tabBar->state = PaintOn;
+				
 				else if (group->tabBar->textLayer->state == PaintFadeOut)
-					group->tabBar->textLayer->state = PaintOff;
-			} 
+					group->tabBar->state = PaintOff;
+			}
 		}
+		
+		if (group->tabBar->textLayer->state == PaintOff && group->tabBar->hoveredSlot)
+		{
+			// Start text animation for the new hovered slot.
+	
+			group->tabBar->textSlot = group->tabBar->hoveredSlot;
+			groupRenderWindowTitle(group);
+
+			group->tabBar->textLayer->state = PaintFadeIn;
+			group->tabBar->textLayer->animationTime = 
+					(gs->opt[GROUP_SCREEN_OPTION_FADE_TEXT_TIME].value.f * 1000);
+			
+		}
+		
+		else if (group->tabBar->textLayer->state == PaintOff && group->tabBar->textSlot)
+		{
+			// Clean Up.
+			group->tabBar->textSlot = NULL;
+			
+			groupRenderWindowTitle(group);
+		}
 	}
 
 	if (changedTabBarState)