static void
staticAddWindowGeometry (CompWindow *w,
                         CompMatrix *matrix,
                         int        nMatrix,
                         Region     region,
                         Region     clip)
{
    CompScreen *s = w->screen;
    STATIC_SCREEN (s);

    if (ss->staticMode == STATIC_STATIC && isStatic(w)) {
        addWindowGeometry (w, matrix, nMatrix, region, clip);
        return;
    }

    UNWRAP (ss, s, addWindowGeometry);
    (*s->addWindowGeometry) (w, matrix, nMatrix, region, clip);
    WRAP (ss, s, addWindowGeometry, staticAddWindowGeometry);
}
Пример #2
0
/*
 * groupPaintTabBar
 *
 */
static void
groupPaintTabBar (GroupSelection          *group,
                  const WindowPaintAttrib *wAttrib,
                  const CompTransform     *transform,
                  unsigned int            mask,
                  Region                  clipRegion)
{
	CompWindow      *topTab;
	CompScreen      *s = group->screen;
	GroupTabBar     *bar = group->tabBar;
	int count;
	REGION box;

	GROUP_SCREEN (s);

	if (HAS_TOP_WIN (group))
		topTab = TOP_TAB (group);
	else
		topTab = PREV_TOP_TAB (group);

#define PAINT_BG     0
#define PAINT_SEL    1
#define PAINT_THUMBS 2
#define PAINT_TEXT   3
#define PAINT_MAX    4

	box.rects = &box.extents;
	box.numRects = 1;

	const BananaValue *
	option_fade_time = bananaGetOption (bananaIndex,
	                                    "fade_time",
	                                    s->screenNum);

	const BananaValue *
	option_mipmaps = bananaGetOption (bananaIndex,
	                                  "mipmaps",
	                                  s->screenNum);

	const BananaValue *
	option_fade_text_time = bananaGetOption (bananaIndex,
	                                         "fade_text_time",
	                                         s->screenNum);

	for (count = 0; count < PAINT_MAX; count++)
	{
		int alpha = OPAQUE;
		float wScale = 1.0f, hScale = 1.0f;
		GroupCairoLayer *layer = NULL;

		if (bar->state == PaintFadeIn)
			alpha -= alpha * bar->animationTime / (option_fade_time->f * 1000);
		else if (bar->state == PaintFadeOut)
			alpha = alpha * bar->animationTime / (option_fade_time->f * 1000);

		switch (count) {
		case PAINT_BG:
		{
			int newWidth;

			layer = bar->bgLayer;

			/* handle the repaint of the background */
			newWidth = bar->region->extents.x2 - bar->region->extents.x1;
			if (layer && (newWidth > layer->texWidth))
				newWidth = layer->texWidth;

			wScale = (double) (bar->region->extents.x2 -
			                   bar->region->extents.x1) / (double) newWidth;

			/* FIXME: maybe move this over to groupResizeTabBarRegion -
			   the only problem is that we would have 2 redraws if
			   there is an animation */
			if (newWidth != bar->oldWidth || bar->bgAnimation)
				groupRenderTabBarBackground (group);

			bar->oldWidth = newWidth;
			box.extents = bar->region->extents;
		}
		break;

		case PAINT_SEL:
			if (group->topTab != gs->draggedSlot)
			{
				layer = bar->selectionLayer;
				box.extents = group->topTab->region->extents;
			}
			break;

		case PAINT_THUMBS:
		{
			GLenum oldTextureFilter;
			GroupTabBarSlot *slot;

			oldTextureFilter = display.textureFilter;

			if (option_mipmaps->b)
				display.textureFilter = GL_LINEAR_MIPMAP_LINEAR;

			for (slot = bar->slots; slot; slot = slot->next)
			{
				if (slot != gs->draggedSlot || !gs->dragged)
					groupPaintThumb (group, slot, transform,
					                 wAttrib->opacity);
			}

			display.textureFilter = oldTextureFilter;
		}
		break;

		case PAINT_TEXT:
			if (bar->textLayer && (bar->textLayer->state != PaintOff))
			{
				layer = bar->textLayer;

				box.extents.x1 = bar->region->extents.x1 + 5;
				box.extents.x2 = bar->region->extents.x1 +
				                 bar->textLayer->texWidth + 5;
				box.extents.y1 = bar->region->extents.y2 -
				                 bar->textLayer->texHeight - 5;
				box.extents.y2 = bar->region->extents.y2 - 5;

				if (box.extents.x2 > bar->region->extents.x2)
					box.extents.x2 = bar->region->extents.x2;

				/* recalculate the alpha again for text fade... */
				if (layer->state == PaintFadeIn)
					alpha -= alpha * layer->animationTime /
					         (option_fade_text_time->f * 1000);
				else if (layer->state == PaintFadeOut)
					alpha = alpha * layer->animationTime /
					        (option_fade_text_time->f * 1000);
			}
			break;
		}

		if (layer)
		{
			CompMatrix matrix = layer->texture.matrix;

			/* remove the old x1 and y1 so we have a relative value */
			box.extents.x2 -= box.extents.x1;
			box.extents.y2 -= box.extents.y1;
			box.extents.x1 = (box.extents.x1 - topTab->attrib.x) / wScale +
			                 topTab->attrib.x;
			box.extents.y1 = (box.extents.y1 - topTab->attrib.y) / hScale +
			                 topTab->attrib.y;

			/* now add the new x1 and y1 so we have a absolute value again,
			   also we don't want to stretch the texture... */
			if (box.extents.x2 * wScale < layer->texWidth)
				box.extents.x2 += box.extents.x1;
			else
				box.extents.x2 = box.extents.x1 + layer->texWidth;

			if (box.extents.y2 * hScale < layer->texHeight)
				box.extents.y2 += box.extents.y1;
			else
				box.extents.y2 = box.extents.y1 + layer->texHeight;

			matrix.x0 -= box.extents.x1 * matrix.xx;
			matrix.y0 -= box.extents.y1 * matrix.yy;
			topTab->vCount = topTab->indexCount = 0;

			addWindowGeometry (topTab, &matrix, 1, &box, clipRegion);

			if (topTab->vCount)
			{
				FragmentAttrib fragment;
				CompTransform wTransform = *transform;

				matrixTranslate (&wTransform,
				                 WIN_X (topTab), WIN_Y (topTab), 0.0f);
				matrixScale (&wTransform, wScale, hScale, 1.0f);
				matrixTranslate (&wTransform,
				                 wAttrib->xTranslate / wScale - WIN_X (topTab),
				                 wAttrib->yTranslate / hScale - WIN_Y (topTab),
				                 0.0f);

				glPushMatrix ();
				glLoadMatrixf (wTransform.m);

				alpha = alpha * ((float)wAttrib->opacity / OPAQUE);

				initFragmentAttrib (&fragment, wAttrib);
				fragment.opacity = alpha;

				(*s->drawWindowTexture)(topTab, &layer->texture,
				                        &fragment, mask |
				                        PAINT_WINDOW_BLEND_MASK |
				                        PAINT_WINDOW_TRANSFORMED_MASK |
				                        PAINT_WINDOW_TRANSLUCENT_MASK);

				glPopMatrix ();
			}
		}
	}
}