Esempio n. 1
0
static Bool
minSetScreenOption(CompPlugin * plugin,
		   CompScreen * screen,
		   const char *name, CompOptionValue * value)
{
	CompOption *o;
	int index;

	MIN_SCREEN(screen);

	o = compFindOption(ms->opt, NUM_OPTIONS(ms), name, &index);
	if (!o)
		return FALSE;

	switch (index) {
	case MIN_SCREEN_OPTION_SHADE_RESISTANCE:
		if (compSetIntOption(o, value)) {
			if (o->value.i)
				ms->shadeStep = o->rest.i.max - o->value.i + 1;
			else
				ms->shadeStep = 0;

			return TRUE;
		}
		break;
	default:
		if (compSetOption(o, value))
			return TRUE;
		break;
	}

	return FALSE;
}
Esempio n. 2
0
static void
minChangeNotify (const char        *optionName,
                 BananaType        optionType,
                 const BananaValue *optionValue,
                 int               screenNum)
{
	CompScreen *screen = getScreenFromScreenNum (screenNum);

	MIN_SCREEN (screen);

	if (strcasecmp (optionName, "shade_resistance") == 0)
	{
		if (optionValue->i)
			ms->shadeStep = 100 - optionValue->i + 1;
		else
			ms->shadeStep = 0;
	}
	else if (strcasecmp (optionName, "window_match") == 0)
	{
		matchFini (&ms->match);
		matchInit (&ms->match);
		matchAddFromString (&ms->match, optionValue->s);
		matchUpdate (&ms->match);
	}
}
Esempio n. 3
0
static void
minDonePaintScreen (CompScreen *s)
{
	MIN_SCREEN (s);

	if (ms->moreAdjust)
	{
		CompWindow *w;
		int        h;

		for (w = s->windows; w; w = w->next)
		{
			MIN_WINDOW (w);

			if (mw->adjust)
			{
				addWindowDamage (w);
			}
			else if (mw->region)
			{
				h = w->attrib.height + w->attrib.border_width * 2;
				if (mw->shade && mw->shade < h)
					addWindowDamage (w);
			}
		}
	}

	UNWRAP (ms, s, donePaintScreen);
	(*s->donePaintScreen) (s);
	WRAP (ms, s, donePaintScreen, minDonePaintScreen);
}
Esempio n. 4
0
static Bool
minPaintWindow (CompWindow              *w,
                const WindowPaintAttrib *attrib,
                const CompTransform     *transform,
                Region                  region,
                unsigned int            mask)
{
	CompScreen *s = w->screen;
	Bool       status;

	MIN_SCREEN (s);
	MIN_WINDOW (w);

	if (mw->adjust)
	{
		FragmentAttrib fragment;
		CompTransform  wTransform = *transform;

		if (mask & PAINT_WINDOW_OCCLUSION_DETECTION_MASK)
			return FALSE;

		UNWRAP (ms, s, paintWindow);
		status = (*s->paintWindow) (w, attrib, transform, region,
		                       mask | PAINT_WINDOW_NO_CORE_INSTANCE_MASK);
		WRAP (ms, s, paintWindow, minPaintWindow);

		initFragmentAttrib (&fragment, &w->lastPaint);

		if (w->alpha || fragment.opacity != OPAQUE)
			mask |= PAINT_WINDOW_TRANSLUCENT_MASK;

		matrixTranslate (&wTransform, w->attrib.x, w->attrib.y, 0.0f);
		matrixScale (&wTransform, mw->xScale, mw->yScale, 1.0f);
		matrixTranslate (&wTransform,
		                 mw->tx / mw->xScale - w->attrib.x,
		                 mw->ty / mw->yScale - w->attrib.y,
		                 0.0f);

		glPushMatrix ();
		glLoadMatrixf (wTransform.m);

		(*s->drawWindow) (w, &wTransform, &fragment, region,
		                  mask | PAINT_WINDOW_TRANSFORMED_MASK);

		glPopMatrix ();
	}
	else
	{
		/* no core instance from windows that have been animated */
		if (mw->state == IconicState)
			mask |= PAINT_WINDOW_NO_CORE_INSTANCE_MASK;

		UNWRAP (ms, s, paintWindow);
		status = (*s->paintWindow) (w, attrib, transform, region, mask);
		WRAP (ms, s, paintWindow, minPaintWindow);
	}

	return status;
}
Esempio n. 5
0
static CompOption *minGetScreenOptions(CompPlugin * plugin,
				       CompScreen * screen, int *count)
{
	MIN_SCREEN(screen);

	*count = NUM_OPTIONS(ms);
	return ms->opt;
}
Esempio n. 6
0
static Bool
minInitWindow (CompPlugin *p,
               CompWindow *w)
{
	MinWindow *mw;

	MIN_SCREEN (w->screen);

	mw = malloc (sizeof (MinWindow));
	if (!mw)
		return FALSE;

	mw->xScale = mw->yScale = 1.0f;
	mw->tx = mw->ty = 0.0f;
	mw->adjust = FALSE;
	mw->xVelocity = mw->yVelocity = 0.0f;
	mw->xScaleVelocity = mw->yScaleVelocity = 1.0f;

	mw->unmapCnt = 0;

	mw->ignoreDamage = FALSE;

	if (w->state & CompWindowStateHiddenMask)
	{
		if (w->shaded)
		{
			mw->state = mw->newState = NormalState;
			mw->shade = 0;
			mw->region = XCreateRegion ();
		}
		else
		{
			mw->state = mw->newState = minGetWindowState (w);
			mw->shade = MAXSHORT;
			mw->region = NULL;
		}
	}
	else
	{
			mw->state = mw->newState = NormalState;
			mw->shade = MAXSHORT;
			mw->region = NULL;
	}

	w->privates[ms->windowPrivateIndex].ptr = mw;

	return TRUE;
}
Esempio n. 7
0
static Bool minFocusWindow(CompWindow * w)
{
	Bool status;

	MIN_SCREEN(w->screen);
	MIN_WINDOW(w);

	if (mw->unmapCnt)
		return FALSE;

	UNWRAP(ms, w->screen, focusWindow);
	status = (*w->screen->focusWindow) (w);
	WRAP(ms, w->screen, focusWindow, minFocusWindow);

	return status;
}
Esempio n. 8
0
static void minFiniScreen(CompPlugin * p, CompScreen * s)
{
	MIN_SCREEN(s);

	freeWindowPrivateIndex(s, ms->windowPrivateIndex);

	UNWRAP(ms, s, preparePaintScreen);
	UNWRAP(ms, s, donePaintScreen);
	UNWRAP(ms, s, paintOutput);
	UNWRAP(ms, s, paintWindow);
	UNWRAP(ms, s, damageWindowRect);
	UNWRAP(ms, s, focusWindow);

	compFiniScreenOptions(s, ms->opt, MIN_SCREEN_OPTION_NUM);

	free(ms);
}
Esempio n. 9
0
static void
minFiniScreen (CompPlugin *p,
               CompScreen *s)
{
	MIN_SCREEN (s);

	matchFini (&ms->match);
	freeWindowPrivateIndex (s, ms->windowPrivateIndex);

	UNWRAP (ms, s, preparePaintScreen);
	UNWRAP (ms, s, donePaintScreen);
	UNWRAP (ms, s, paintOutput);
	UNWRAP (ms, s, paintWindow);
	UNWRAP (ms, s, damageWindowRect);
	UNWRAP (ms, s, focusWindow);

	free (ms);
}
Esempio n. 10
0
static Bool
minPaintOutput(CompScreen * s,
	       const ScreenPaintAttrib * sAttrib,
	       const CompTransform * transform,
	       Region region, CompOutput * output, unsigned int mask)
{
	Bool status;

	MIN_SCREEN(s);

	if (ms->moreAdjust)
		mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK;

	UNWRAP(ms, s, paintOutput);
	status =
	    (*s->paintOutput) (s, sAttrib, transform, region, output, mask);
	WRAP(ms, s, paintOutput, minPaintOutput);

	return status;
}
Esempio n. 11
0
static Bool
minDamageWindowRect (CompWindow *w,
                     Bool       initial,
                     BoxPtr     rect)
{
	Bool status = FALSE;

	MIN_SCREEN (w->screen);
	MIN_WINDOW (w);

	if (mw->ignoreDamage)
		return TRUE;

	if (initial)
	{
		if (mw->state == IconicState)
		{
			mw->state = NormalState;

			if (!w->invisible      &&
			    w->iconGeometrySet &&
			    matchEval (&ms->match, w))
			{
				if (!mw->adjust)
				{
					mw->adjust     = TRUE;
					ms->moreAdjust = TRUE;

					mw->tx     = w->iconGeometry.x - w->serverX;
					mw->ty     = w->iconGeometry.y - w->serverY;
					mw->xScale = (float) w->iconGeometry.width  / w->width;
					mw->yScale = (float) w->iconGeometry.height / w->height;

					addWindowDamage (w);
				}
			}
		}
		else if (mw->region && mw->shade < w->height)
		{
			if (ms->shadeStep && !w->invisible)
			{
				XSubtractRegion (w->region, &emptyRegion, mw->region);
				XOffsetRegion (mw->region, -w->attrib.x, -w->attrib.y);

				/* bind pixmap here so we have something to unshade with */
				if (!w->texture->pixmap && !w->bindFailed)
					bindWindow (w);

				ms->moreAdjust = TRUE;
			}
			else
			{
				mw->shade = MAXSHORT;
			}
		}

		mw->newState = NormalState;
	}
	else if (mw->adjust)
	{
		damageTransformedWindowRect (w,
		                         mw->xScale,
		                         mw->yScale,
		                         mw->tx,
		                         mw->ty,
		                         rect);

		status = TRUE;
	}

	UNWRAP (ms, w->screen, damageWindowRect);
	status |= (*w->screen->damageWindowRect) (w, initial, rect);
	WRAP (ms, w->screen, damageWindowRect, minDamageWindowRect);

	return status;
}
Esempio n. 12
0
static void
minHandleEvent (XEvent      *event)
{
	CompWindow *w;

	MIN_DISPLAY (&display);

	switch (event->type) {
	case MapNotify:
		w = findWindowAtDisplay (event->xmap.window);
		if (w)
		{
			MIN_WINDOW (w);

			if (mw->adjust)
				mw->state = mw->newState;

			if (mw->region)
				w->height = 0;

			mw->ignoreDamage = TRUE;
			while (mw->unmapCnt)
			{
				unmapWindow (w);
				mw->unmapCnt--;
			}
			mw->ignoreDamage = FALSE;
		}
		break;
	case UnmapNotify:
		w = findWindowAtDisplay (event->xunmap.window);
		if (w)
		{
			MIN_SCREEN (w->screen);

			if (w->pendingUnmaps && onCurrentDesktop (w)) /* Normal -> Iconic */
			{
				MIN_WINDOW (w);

				if (w->shaded)
				{
					if (!mw->region)
						mw->region = XCreateRegion ();

					if (mw->region && ms->shadeStep)
					{
						XSubtractRegion (w->region, &emptyRegion, mw->region);
						XOffsetRegion (mw->region, -w->attrib.x,
						           w->attrib.height +
						           w->attrib.border_width * 2 -
						           w->height - w->attrib.y);

						mw->shade = w->height;

						mw->adjust     = FALSE;
						ms->moreAdjust = TRUE;

						mw->unmapCnt++;
						w->unmapRefCnt++;

						addWindowDamage (w);
					}
				}
				else if (!w->invisible && matchEval (&ms->match, w))
				{
					if (w->iconGeometrySet)
					{
						mw->newState = IconicState;

						mw->xScale = w->paint.xScale;
						mw->yScale = w->paint.yScale;
						mw->tx     = w->attrib.x - w->serverX;
						mw->ty     = w->attrib.y - w->serverY;

						if (mw->region)
						{
							XDestroyRegion (mw->region);
							mw->region = NULL;
						}

						mw->shade = MAXSHORT;

						mw->adjust     = TRUE;
						ms->moreAdjust = TRUE;

						mw->unmapCnt++;
						w->unmapRefCnt++;

						addWindowDamage (w);
					}
				}
			}
			else  /* X -> Withdrawn */
			{
				MIN_WINDOW (w);

				if (mw->adjust)
				{
					mw->adjust = FALSE;
					mw->xScale = mw->yScale = 1.0f;
					mw->tx = mw->ty = 0.0f;
					mw->xVelocity = mw->yVelocity = 0.0f;
					mw->xScaleVelocity = mw->yScaleVelocity = 1.0f;
					mw->shade = MAXSHORT;

					if (mw->region)
					{
						XDestroyRegion (mw->region);
						mw->region = NULL;
					}
				}

				mw->state = NormalState;
			}
		}
	default:
		break;
	}

	UNWRAP (md, &display, handleEvent);
	(*display.handleEvent) (event);
	WRAP (md, &display, handleEvent, minHandleEvent);

	switch (event->type) {
	case MapRequest:
		w = findWindowAtDisplay (event->xmaprequest.window);
		if (w && w->hints && w->hints->initial_state == IconicState)
		{
			MIN_WINDOW (w);
			mw->newState = mw->state = IconicState;
		}
		break;
	default:
		break;
	}
}
Esempio n. 13
0
static void
minPreparePaintScreen (CompScreen *s,
                       int        msSinceLastPaint)
{
	MIN_SCREEN (s);

	if (ms->moreAdjust)
	{
		CompWindow *w;
		int        steps, h;
		float      amount, chunk;

		const BananaValue *
		option_speed = bananaGetOption (bananaIndex, "speed", s->screenNum);

		amount = msSinceLastPaint * 0.05f * option_speed->f;

		const BananaValue *
		option_timestep = bananaGetOption (bananaIndex,
		                                   "timestep",
		                                   s->screenNum);

		steps  = amount / (0.5f * option_timestep->f);
		if (!steps) steps = 1;
		chunk  = amount / (float) steps;

		while (steps--)
		{
			ms->moreAdjust = 0;

			for (w = s->windows; w; w = w->next)
			{
				MIN_WINDOW (w);

				if (mw->adjust)
				{
					mw->adjust = adjustMinVelocity (w);

					ms->moreAdjust |= mw->adjust;

					mw->tx += mw->xVelocity * chunk;
					mw->ty += mw->yVelocity * chunk;
					mw->xScale += mw->xScaleVelocity * chunk;
					mw->yScale += mw->yScaleVelocity * chunk;

					if (!mw->adjust)
					{
						mw->state = mw->newState;

						mw->ignoreDamage = TRUE;
						while (mw->unmapCnt)
						{
							unmapWindow (w);
							mw->unmapCnt--;
						}
						mw->ignoreDamage = FALSE;
					}
				}
				else if (mw->region && w->damaged)
				{
					if (w->shaded)
					{
						if (mw->shade > 0)
						{
							mw->shade -= (chunk * ms->shadeStep) + 1;

							if (mw->shade > 0)
							{
								ms->moreAdjust = TRUE;
							}
							else
							{
								mw->shade = 0;

								mw->ignoreDamage = TRUE;
								while (mw->unmapCnt)
								{
									unmapWindow (w);
									mw->unmapCnt--;
								}
								mw->ignoreDamage = FALSE;
							}
						}
					}
					else
					{
						h = w->attrib.height + w->attrib.border_width * 2;
						if (mw->shade < h)
						{
							mw->shade += (chunk * ms->shadeStep) + 1;

							if (mw->shade < h)
							{
								ms->moreAdjust = TRUE;
							}
							else
							{
								mw->shade = MAXSHORT;

								minSetShade (w, h);

								XDestroyRegion (mw->region);
								mw->region = NULL;

								addWindowDamage (w);
							}
						}
					}
				}
			}

			if (!ms->moreAdjust)
				break;
		}

		if (ms->moreAdjust)
		{
			for (w = s->windows; w; w = w->next)
			{
				MIN_WINDOW (w);

				if (mw->adjust)
				{
					addWindowDamage (w);
				}
				else if (mw->region && w->damaged)
				{
					h = w->attrib.height + w->attrib.border_width * 2;
					if (mw->shade && mw->shade < h)
					{
						minSetShade (w, mw->shade);
						addWindowDamage (w);
					}
				}
			}
		}
	}

	UNWRAP (ms, s, preparePaintScreen);
	(*s->preparePaintScreen) (s, msSinceLastPaint);
	WRAP (ms, s, preparePaintScreen, minPreparePaintScreen);
}