static void
damageRegion (CompScreen *s)
{
    REGION   r;
//    int      i;
//    Particle *p;
//    float cOff;
    float    x1, x2, y1, y2;

    WIZARD_SCREEN (s);

    if (!ws->ps)
	return;

    x1 = 0;
    x2 = s->width;
    y1 = 0;
    y2 = s->height;

/*  // I don't know much about this system, but since this plugin is meant to be
    // a heavy toy, which occupies almost the whole screen, calculating the
    // exact region each time seems to waste more ressources than just using
    // the whole screen.
    x1 = s->width;
    x2 = 0;
    y1 = s->height;
    y2 = 0;

    p = ws->ps->particles;

    for (i = 0; i < ws->ps->hardLimit; i++, p++)
    {
	cOff = p->s / 2;
	if (p->t > ws->ps->tnew)
	    cOff += (p->snew - p->s) * (p->t - ws->ps->tnew)
		    / (1. - ws->ps->tnew) / 2.;
	else if (p->t < ws->ps->told)
	    cOff -= p->s * (ws->ps->told - p->t) / ws->ps->told / 2.;

	x1 = MIN (x1, p->x - cOff);
	x2 = MAX (x2, p->x + cOff);
	y1 = MIN (y1, p->y - cOff);
	y2 = MAX (y2, p->y + cOff);
    }
*/

    r.rects = &r.extents;
    r.numRects = r.size = 1;

    r.extents.x1 = floor (x1);
    r.extents.x2 = ceil (x2);
    r.extents.y1 = floor (y1);
    r.extents.y2 = ceil (y2);

    damageScreenRegion (s, &r);
}
Beispiel #2
0
static Bool
shotTerminate (BananaArgument     *arg,
               int                nArg)
{
	CompScreen *s;
	Window     xid;

	BananaValue *root = getArgNamed ("root", arg, nArg);

	if (root != NULL)
		xid = root->i;
	else
		xid = 0;

	for (s = display.screens; s; s = s->next)
	{
		SHOT_SCREEN (s);

		if (xid && s->root != xid)
			continue;

		if (ss->grabIndex)
		{
			removeScreenGrab (s, ss->grabIndex, NULL);
			ss->grabIndex = 0;

			BananaValue *cancel = getArgNamed ("cancel", arg, nArg);

			if (cancel != NULL && cancel->b)
				ss->grab = FALSE;

			if (ss->x1 != ss->x2 && ss->y1 != ss->y2)
			{
				REGION reg;

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

				reg.extents.x1 = MIN (ss->x1, ss->x2) - 1;
				reg.extents.y1 = MIN (ss->y1, ss->y2) - 1;
				reg.extents.x2 = MAX (ss->x1, ss->x2) + 1;
				reg.extents.y2 = MAX (ss->y1, ss->y2) + 1;

				damageScreenRegion (s, &reg);
			}
		}
	}

	return FALSE;
}
Beispiel #3
0
static void
shotHandleMotionEvent (CompScreen *s,
                       int        xRoot,
                       int        yRoot)
{
	SHOT_SCREEN (s);

	/* update screenshot rectangle size */

	if (ss->grabIndex)
	{
		REGION reg;

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

		reg.extents.x1 = MIN (ss->x1, ss->x2) - 1;
		reg.extents.y1 = MIN (ss->y1, ss->y2) - 1;
		reg.extents.x2 = MAX (ss->x1, ss->x2) + 1;
		reg.extents.y2 = MAX (ss->y1, ss->y2) + 1;

		damageScreenRegion (s, &reg);

		ss->x2 = xRoot;
		ss->y2 = yRoot;

		reg.extents.x1 = MIN (ss->x1, ss->x2) - 1;
		reg.extents.y1 = MIN (ss->y1, ss->y2) - 1;
		reg.extents.x2 = MAX (ss->x1, ss->x2) + 1;
		reg.extents.y2 = MAX (ss->y1, ss->y2) + 1;

		damageScreenRegion (s, &reg);

		damageScreen (s);
	}
}
static void
damageRegion (CompScreen *s)
{
    REGION r;

    MAG_SCREEN (s);

    r.rects = &r.extents;
    r.numRects = r.size = 1;

    switch (ms->mode)
    {
    case ModeSimple:
        {
	    int  w, h, b;

	    w = magGetBoxWidth (s);
	    h = magGetBoxHeight (s);
	    b = magGetBorder (s);
	    w += 2 * b;
	    h += 2 * b;

	    r.extents.x1 = MAX (0, MIN (ms->posX - (w / 2), s->width - w));
	    r.extents.x2 = r.extents.x1 + w;
	    r.extents.y1 = MAX (0, MIN (ms->posY - (h / 2), s->height - h));
	    r.extents.y2 = r.extents.y1 + h;
	}
	break;
    case ModeImageOverlay:
	r.extents.x1 = ms->posX - magGetXOffset (s);
	r.extents.x2 = r.extents.x1 + ms->overlay.width;
	r.extents.y1 = ms->posY - magGetYOffset (s);
	r.extents.y2 = r.extents.y1 + ms->overlay.height;
	break;
    case ModeFisheye:
        {
	    int radius = magGetRadius (s);

	    r.extents.x1 = MAX (0.0, ms->posX - radius);
	    r.extents.x2 = MIN (s->width, ms->posX + radius);
	    r.extents.y1 = MAX (0.0, ms->posY - radius);
	    r.extents.y2 = MIN (s->height, ms->posY + radius);
	}
	break;
    }

    damageScreenRegion (s, &r);
}
Beispiel #5
0
void
groupDamagePaintRectangle (CompScreen *s,
                           BoxPtr     pBox)
{
	REGION reg;

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

	reg.extents = *pBox;

	reg.extents.x1 -= 1;
	reg.extents.y1 -= 1;
	reg.extents.x2 += 1;
	reg.extents.y2 += 1;

	damageScreenRegion (s, &reg);
}
Beispiel #6
0
static void
damageThumbRegion (CompScreen *s,
                   Thumbnail  *t)
{
	REGION region;

	region.extents.x1 = t->x - t->offset;
	region.extents.y1 = t->y - t->offset;
	region.extents.x2 = region.extents.x1 + t->width + (t->offset * 2);
	region.extents.y2 = region.extents.y1 + t->height + (t->offset * 2);

	if (t->textData)
		region.extents.y2 += t->textData->height + TEXT_DISTANCE;

	region.rects    = &region.extents;
	region.numRects = region.size = 1;

	damageScreenRegion (s, &region);
}
Beispiel #7
0
void
addCursorDamageRect (CompCursor *c,
		     BoxPtr     rect)
{
    REGION region;

    if (c->screen->damageMask & COMP_SCREEN_DAMAGE_ALL_MASK)
	return;

    region.extents = *rect;

    if (!(*c->screen->damageCursorRect) (c, FALSE, &region.extents))
    {
	region.extents.x1 += c->x;
	region.extents.y1 += c->y;
	region.extents.x2 += c->x;
	region.extents.y2 += c->y;

	region.rects = &region.extents;
	region.numRects = region.size = 1;

	damageScreenRegion (c->screen, &region);
    }
}
static void
swapDoWindowDamage (CompWindow *w)
{
    if (w->attrib.map_state == IsViewable || w->shaded)
	addWindowDamage (w);
    else
    {
	BoxRec box;
	if (swapGetPaintRectangle (w, &box, NULL))
	{
	    REGION reg;

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

	    reg.extents.x1 = box.x1 - 2;
	    reg.extents.y1 = box.y1 - 2;
	    reg.extents.x2 = box.x2 + 2;
	    reg.extents.y2 = box.y2 + 2;

	    damageScreenRegion (w->screen, &reg);
	}
    }
}
static void
damagePaintRegion (CompScreen *s)
{
    REGION reg;
    int    x, y;

    GRID_SCREEN (s);

    /* if (!is->fadeTime && !is->drawing)
       return; */

    x = gs->anim.currentRect.x;
    y = gs->anim.currentRect.y;

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

    reg.extents.x1 = x - 5;
    reg.extents.y1 = y - 5;
    reg.extents.x2 = x + gs->anim.currentRect.width + 5;
    reg.extents.y2 = y + gs->anim.currentRect.height + 5;

    damageScreenRegion (s, &reg);
}
Beispiel #10
0
static void
scalefilterRenderFilterText (CompScreen *s)
{
    CompDisplay    *d = s->display;
    CompTextAttrib tA;
    int            stride;
    void*          data;
    int            x1, x2, y1, y2;
    int            width, height;
    REGION         reg;
    char           buffer[2 * MAX_FILTER_STRING_LEN];

    FILTER_SCREEN (s);

    if (!fs->filterInfo)
	return;

    x1 = s->outputDev[fs->filterInfo->outputDevice].region.extents.x1;
    x2 = s->outputDev[fs->filterInfo->outputDevice].region.extents.x2;
    y1 = s->outputDev[fs->filterInfo->outputDevice].region.extents.y1;
    y2 = s->outputDev[fs->filterInfo->outputDevice].region.extents.y2;

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

    /* damage the old draw rectangle */
    width  = fs->filterInfo->textWidth + (2 * scalefilterGetBorderSize (s));
    height = fs->filterInfo->textHeight + (2 * scalefilterGetBorderSize (s));

    reg.extents.x1 = x1 + ((x2 - x1) / 2) - (width / 2) - 1;
    reg.extents.x2 = reg.extents.x1 + width + 1;
    reg.extents.y1 = y1 + ((y2 - y1) / 2) - (height / 2) - 1;
    reg.extents.y2 = reg.extents.y1 + height + 1;

    damageScreenRegion (s, &reg);

    scalefilterFreeFilterText (s);

    if (!scalefilterGetFilterDisplay (s))
	return;

    if (fs->filterInfo->filterStringLength == 0)
	return;

    tA.maxwidth = x2 - x1 - (2 * scalefilterGetBorderSize (s));
    tA.maxheight = y2 - y1 - (2 * scalefilterGetBorderSize (s));
    tA.screen = s;
    tA.size = scalefilterGetFontSize (s);
    tA.color[0] = scalefilterGetFontColorRed (s);
    tA.color[1] = scalefilterGetFontColorGreen (s);
    tA.color[2] = scalefilterGetFontColorBlue (s);
    tA.color[3] = scalefilterGetFontColorAlpha (s);
    tA.style = (scalefilterGetFontBold (s)) ?
	       TEXT_STYLE_BOLD : TEXT_STYLE_NORMAL;
    tA.family = "Sans";
    tA.ellipsize = TRUE;

    wcstombs (buffer, fs->filterInfo->filterString, MAX_FILTER_STRING_LEN);
    tA.renderMode = TextRenderNormal;
    tA.data = (void*)buffer;

    if ((*d->fileToImage) (s->display, TEXT_ID, (char *)&tA,
			   &fs->filterInfo->textWidth,
			   &fs->filterInfo->textHeight,
			   &stride, &data))
    {
	fs->filterInfo->textPixmap = (Pixmap)data;
	if (!bindPixmapToTexture (s, &fs->filterInfo->textTexture,
				  fs->filterInfo->textPixmap,
				  fs->filterInfo->textWidth,
				  fs->filterInfo->textHeight, 32))
	{
	    compLogMessage (d, "scalefilterinfo", CompLogLevelError,
			    "Bind Pixmap to Texture failure");
	    XFreePixmap (d->display, fs->filterInfo->textPixmap);
	    fs->filterInfo->textPixmap = None;
	    return;
	}
    }
    else
    {
	fs->filterInfo->textPixmap = None;
	fs->filterInfo->textWidth = 0;
	fs->filterInfo->textHeight = 0;
    }

    /* damage the new draw rectangle */
    width  = fs->filterInfo->textWidth + (2 * scalefilterGetBorderSize (s));
    height = fs->filterInfo->textHeight + (2 * scalefilterGetBorderSize (s));

    reg.extents.x1 = x1 + ((x2 - x1) / 2) - (width / 2) - 1;
    reg.extents.x2 = reg.extents.x1 + width + 1;
    reg.extents.y1 = y1 + ((y2 - y1) / 2) - (height / 2) - 1;
    reg.extents.y2 = reg.extents.y1 + height + 1;

    damageScreenRegion (s, &reg);
}
Beispiel #11
0
Bool
groupDamageWindowRect (CompWindow *w,
                       Bool       initial,
                       BoxPtr     rect)
{
	Bool status;
	CompScreen *s = w->screen;

	GROUP_SCREEN (s);
	GROUP_WINDOW (w);

	UNWRAP (gs, s, damageWindowRect);
	status = (*s->damageWindowRect)(w, initial, rect);
	WRAP (gs, s, damageWindowRect, groupDamageWindowRect);

	if (initial)
	{
		const BananaValue *
		option_autotab_create = bananaGetOption (bananaIndex,
		                                         "autotab_create",
		                                         s->screenNum);

		if (option_autotab_create->b && groupIsGroupWindow (w))
		{
			if (!gw->group && (gw->windowState == WindowNormal))
			{
				/* First check if this window should be added to an
				 * existing group */
				GroupSelection *g = NULL;
				int i;
				for (i = 0; i <= gs->autotabCount - 1; i++)
				{
					if (matchEval (&gs->autotab[i], w))
					{
						Bool foundGroup = FALSE;
						GroupSelection *tg;

						for (tg = gs->groups; tg; tg = tg->next)
						{
							int i;
							for (i = 0; i <= tg->nWins - 1; i++)
							{
								if (matchEval (&gs->autotab[i], tg->windows[i]))
								{
									foundGroup = TRUE;
									g = tg;
									break;
								}
							}

							if (foundGroup)
								break;
						}

						if (foundGroup)
							break;
					}
				}

				if (g)
				{
					groupAddWindowToGroup (w, g, 0);
					//groupTabGroup (w);
				}
				else
				{
					groupAddWindowToGroup (w, NULL, 0);
					//groupTabGroup (w);
				}
			}
		}

		if (gw->group)
		{
			if (gw->windowState == WindowMinimized)
			{
				const BananaValue *
				option_minimize_all = bananaGetOption (bananaIndex,
				                                       "minimize_all",
				                                       s->screenNum);

				if (option_minimize_all->b)
					groupMinimizeWindows (w, gw->group, FALSE);
			}
			else if (gw->windowState == WindowShaded)
			{
				const BananaValue *
				option_shade_all = bananaGetOption (bananaIndex,
				                                    "shade_all",
				                                    s->screenNum);

				if (option_shade_all->b)
					groupShadeWindows (w, gw->group, FALSE);
			}
		}

		gw->windowState = WindowNormal;
	}

	if (gw->resizeGeometry)
	{
		BoxRec box;

		groupGetStretchRectangle (w, &box, NULL, NULL);
		groupDamagePaintRectangle (s, &box);
	}

	if (gw->slot)
	{
		int vx, vy;
		Region reg;

		groupGetDrawOffsetForSlot (gw->slot, &vx, &vy);
		if (vx || vy)
		{
			reg = XCreateRegion ();
			XUnionRegion (reg, gw->slot->region, reg);
			XOffsetRegion (reg, vx, vy);
		}
		else
			reg = gw->slot->region;

		damageScreenRegion (s, reg);

		if (vx || vy)
			XDestroyRegion (reg);
	}

	return status;
}
Beispiel #12
0
static void
groupHandleMotionEvent (CompScreen *s,
                        int        xRoot,
                        int        yRoot)
{
	GROUP_SCREEN (s);

	if (gs->grabState == ScreenGrabTabDrag)
	{
		int dx, dy;
		int vx, vy;
		REGION reg;
		Region draggedRegion = gs->draggedSlot->region;

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

		dx = xRoot - gs->prevX;
		dy = yRoot - gs->prevY;

		if (gs->dragged || abs (dx) > RADIUS || abs (dy) > RADIUS)
		{
			gs->prevX = xRoot;
			gs->prevY = yRoot;

			if (!gs->dragged)
			{
				GroupSelection *group;
				BoxRec         *box;

				GROUP_WINDOW (gs->draggedSlot->window);

				gs->dragged = TRUE;

				for (group = gs->groups; group; group = group->next)
					groupTabSetVisibility (group, TRUE, PERMANENT);

				box = &gw->group->tabBar->region->extents;
				groupRecalcTabBarPos (gw->group, (box->x1 + box->x2) / 2,
				                      box->x1, box->x2);
			}

			groupGetDrawOffsetForSlot (gs->draggedSlot, &vx, &vy);

			reg.extents.x1 = draggedRegion->extents.x1 + vx;
			reg.extents.y1 = draggedRegion->extents.y1 + vy;
			reg.extents.x2 = draggedRegion->extents.x2 + vx;
			reg.extents.y2 = draggedRegion->extents.y2 + vy;
			damageScreenRegion (s, &reg);

			XOffsetRegion (gs->draggedSlot->region, dx, dy);
			gs->draggedSlot->springX =
			        (gs->draggedSlot->region->extents.x1 +
			         gs->draggedSlot->region->extents.x2) / 2;

			reg.extents.x1 = draggedRegion->extents.x1 + vx;
			reg.extents.y1 = draggedRegion->extents.y1 + vy;
			reg.extents.x2 = draggedRegion->extents.x2 + vx;
			reg.extents.y2 = draggedRegion->extents.y2 + vy;
			damageScreenRegion (s, &reg);
		}
	}
	else if (gs->grabState == ScreenGrabSelect)
	{
		groupDamageSelectionRect (s, xRoot, yRoot);
	}
}