Ejemplo n.º 1
0
Archivo: svg.c Proyecto: zmike/compiz
static void
svgFiniScreen(CompPlugin *p,
              CompScreen *s)
{
    SVG_SCREEN(s);

    freeWindowPrivateIndex(s, ss->windowPrivateIndex);

    UNWRAP(ss, s, drawWindow);
    UNWRAP(ss, s, windowMoveNotify);
    UNWRAP(ss, s, windowResizeNotify);

    free(ss);
}
Ejemplo n.º 2
0
Archivo: svg.c Proyecto: zmike/compiz
static void
svgWindowResizeNotify(CompWindow *w,
                      int dx,
                      int dy,
                      int dwidth,
                      int dheight)
{
    SVG_SCREEN(w->screen);
    SVG_WINDOW(w);

    if (sw->source)
        updateWindowSvgContext(w, sw->source);

    UNWRAP(ss, w->screen, windowResizeNotify);
    (*w->screen->windowResizeNotify)(w, dx, dy, dwidth, dheight);
    WRAP(ss, w->screen, windowResizeNotify, svgWindowResizeNotify);
}
Ejemplo n.º 3
0
Archivo: svg.c Proyecto: zmike/compiz
static Bool
svgInitWindow(CompPlugin *p,
              CompWindow *w)
{
    SvgWindow *sw;

    SVG_SCREEN(w->screen);

    sw = malloc(sizeof (SvgWindow));
    if (!sw)
        return FALSE;

    sw->source = NULL;
    sw->context = NULL;

    w->base.privates[ss->windowPrivateIndex].ptr = sw;

    return TRUE;
}
Ejemplo n.º 4
0
Archivo: svg.c Proyecto: zmike/compiz
static void
svgHandleCompizEvent(CompDisplay *d,
                     const char *pluginName,
                     const char *eventName,
                     CompOption *option,
                     int nOption)
{
    SVG_DISPLAY(d);

    UNWRAP(sd, d, handleCompizEvent);
    (*d->handleCompizEvent)(d, pluginName, eventName, option, nOption);
    WRAP(sd, d, handleCompizEvent, svgHandleCompizEvent);

    if (strcmp(pluginName, "zoom") == 0)
    {
        CompScreen *s;
        int output = getIntOptionNamed(option, nOption, "output", 0);

        s = findScreenAtDisplay(d, getIntOptionNamed(option, nOption,
                                "root", 0));
        if (s && output == 0)
        {
            SVG_SCREEN(s);

            if (strcmp(eventName, "in") == 0)
            {
                ss->zoom.x1 = getIntOptionNamed(option, nOption, "x1", 0);
                ss->zoom.y1 = getIntOptionNamed(option, nOption, "y1", 0);
                ss->zoom.x2 = getIntOptionNamed(option, nOption, "x2", 0);
                ss->zoom.y2 = getIntOptionNamed(option, nOption, "y2", 0);
            }
            else if (strcmp(eventName, "out") == 0)
            {
                memset(&ss->zoom, 0, sizeof (BoxRec));
            }
        }
    }
}
Ejemplo n.º 5
0
Archivo: svg.c Proyecto: zmike/compiz
static void
svgWindowMoveNotify(CompWindow *w,
                    int dx,
                    int dy,
                    Bool immediate)
{
    SVG_SCREEN(w->screen);
    SVG_WINDOW(w);

    if (sw->context)
    {
        sw->context->box.extents.x1 += dx;
        sw->context->box.extents.y1 += dy;
        sw->context->box.extents.x2 += dx;
        sw->context->box.extents.y2 += dy;

        updateWindowSvgMatrix(w);
    }

    UNWRAP(ss, w->screen, windowMoveNotify);
    (*w->screen->windowMoveNotify)(w, dx, dy, immediate);
    WRAP(ss, w->screen, windowMoveNotify, svgWindowMoveNotify);
}
Ejemplo n.º 6
0
Archivo: svg.c Proyecto: zmike/compiz
static Bool
svgDrawWindow(CompWindow *w,
              const CompTransform *transform,
              const FragmentAttrib *attrib,
              Region region,
              unsigned int mask)
{
    Bool status;

    SVG_SCREEN(w->screen);

    UNWRAP(ss, w->screen, drawWindow);
    status = (*w->screen->drawWindow)(w, transform, attrib, region, mask);
    WRAP(ss, w->screen, drawWindow, svgDrawWindow);

    if (status)
    {
        SVG_WINDOW(w);

        if (mask & PAINT_WINDOW_TRANSFORMED_MASK)
            region = &infiniteRegion;

        if (sw->context && region->numRects)
        {
            CompTexture *texture = &sw->context->texture[0].texture;
            CompMatrix *matrix = &sw->context->texture[0].matrix;
            REGION r;

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

            r.extents = sw->context->box.extents;

            if (r.extents.x1 < ss->zoom.x1)
                r.extents.x1 = ss->zoom.x1;
            if (r.extents.y1 < ss->zoom.y1)
                r.extents.y1 = ss->zoom.y1;
            if (r.extents.x2 > ss->zoom.x2)
                r.extents.x2 = ss->zoom.x2;
            if (r.extents.y2 > ss->zoom.y2)
                r.extents.y2 = ss->zoom.y2;

            w->vCount = w->indexCount = 0;

            (*w->screen->addWindowGeometry)(w,
                                            matrix, 1,
                                            &sw->context->box,
                                            region);

            if (mask & PAINT_WINDOW_TRANSLUCENT_MASK)
                mask |= PAINT_WINDOW_BLEND_MASK;

            (*w->screen->drawWindowTexture)(w, texture, attrib, mask);

            if (r.extents.x1 < r.extents.x2 && r.extents.y1 < r.extents.y2)
            {
                float xScale, yScale;
                float dx, dy;
                int width, height;
                int saveFilter;

                r.extents.x1--;
                r.extents.y1--;
                r.extents.x2++;
                r.extents.y2++;

                xScale = w->screen->width / (float)
                         (ss->zoom.x2 - ss->zoom.x1);
                yScale = w->screen->height / (float)
                         (ss->zoom.y2 - ss->zoom.y1);

                dx = r.extents.x2 - r.extents.x1;
                dy = r.extents.y2 - r.extents.y1;

                width = dx * xScale + 0.5f;
                height = dy * yScale + 0.5f;

                if (r.extents.x1 != sw->context->rect.x1 ||
                        r.extents.y1 != sw->context->rect.y1 ||
                        r.extents.x2 != sw->context->rect.x2 ||
                        r.extents.y2 != sw->context->rect.y2 ||
                        width != sw->context->width ||
                        height != sw->context->height)
                {
                    float x1, y1, x2, y2;

                    sw->context->rect = r.extents;

                    sw->context->width = width;
                    sw->context->height = height;

                    dx = sw->context->box.extents.x2 -
                         sw->context->box.extents.x1;
                    dy = sw->context->box.extents.y2 -
                         sw->context->box.extents.y1;

                    x1 = (r.extents.x1 - sw->context->box.extents.x1) / dx;
                    y1 = (r.extents.y1 - sw->context->box.extents.y1) / dy;
                    x2 = (r.extents.x2 - sw->context->box.extents.x1) / dx;
                    y2 = (r.extents.y2 - sw->context->box.extents.y1) / dy;

                    finiSvgTexture(w->screen, &sw->context->texture[1]);

                    if (initSvgTexture(w, sw->context->source,
                                       &sw->context->texture[1],
                                       width, height))
                    {
                        renderSvg(w->screen, sw->context->source,
                                  &sw->context->texture[1],
                                  x1, y1, x2, y2,
                                  width, height);

                        updateWindowSvgMatrix(w);
                    }
                }

                texture = &sw->context->texture[1].texture;
                matrix = &sw->context->texture[1].matrix;

                w->vCount = w->indexCount = 0;

                saveFilter = w->screen->filter[SCREEN_TRANS_FILTER];
                w->screen->filter[SCREEN_TRANS_FILTER] =
                    COMP_TEXTURE_FILTER_GOOD;

                (*w->screen->addWindowGeometry)(w, matrix, 1, &r, region);
                (*w->screen->drawWindowTexture)(w, texture, attrib, mask);

                w->screen->filter[SCREEN_TRANS_FILTER] = saveFilter;
            }
            else if (sw->context->texture[1].width)
            {
                finiSvgTexture(w->screen, &sw->context->texture[1]);
                initSvgTexture(w, sw->source, &sw->context->texture[1], 0, 0);

                memset(&sw->context->rect, 0, sizeof (BoxRec));

                sw->context->width = 0;
                sw->context->height = 0;
            }
        }
    }

    return status;
}
Ejemplo n.º 7
0
static void
svgHandleFusilliEvent (const char     *pluginName,
                       const char     *eventName,
                       BananaArgument *arg,
                       int            nArg)
{
	SVG_DISPLAY (&display);

	UNWRAP (sd, &display, handleFusilliEvent);
	(*display.handleFusilliEvent) (pluginName, eventName, arg, nArg);
	WRAP (sd, &display, handleFusilliEvent, svgHandleFusilliEvent);

	if (strcmp (pluginName, "zoom") == 0)
	{
		CompScreen *s;
		int        output;
		BananaValue *arg_output = getArgNamed ("output", arg, nArg);

		if (arg_output != NULL)
			output = arg_output->i;
		else
			output = 0;

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

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

		s = findScreenAtDisplay (root);

		if (s && output == 0)
		{
			SVG_SCREEN (s);

			if (strcmp (eventName, "in") == 0)
			{
				BananaValue *arg_x1 = getArgNamed ("x1", arg, nArg);
				if (arg_x1 != NULL)
					ss->zoom.x1 = arg_x1->i;
				else
					ss->zoom.x1 = 0;

				BananaValue *arg_y1 = getArgNamed ("y1", arg, nArg);
				if (arg_y1 != NULL)
					ss->zoom.y1 = arg_y1->i;
				else
					ss->zoom.y1 = 0;

				BananaValue *arg_x2 = getArgNamed ("x2", arg, nArg);
				if (arg_x2 != NULL)
					ss->zoom.x2 = arg_x2->i;
				else
					ss->zoom.x2 = 0;

				BananaValue *arg_y2 = getArgNamed ("y2", arg, nArg);
				if (arg_y2 != NULL)
					ss->zoom.y2 = arg_y2->i;
				else
					ss->zoom.y2 = 0;
			}
			else if (strcmp (eventName, "out") == 0)
			{
				memset (&ss->zoom, 0, sizeof (BoxRec));
			}
		}
	}
}