Example #1
0
File: svg.c Project: 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);
}
Example #2
0
File: svg.c Project: zmike/compiz
static Bool
svgSet(CompDisplay *d,
       CompAction *action,
       CompActionState state,
       CompOption *option,
       int nOption)
{
    CompWindow *w;
    Window xid;

    xid = getIntOptionNamed(option, nOption, "window", 0);

    w = findWindowAtDisplay(d, xid);
    if (w)
    {
        decor_point_t p[2];
        char *data;
        RsvgHandle *svg = NULL;
        GError *error = NULL;

        SVG_WINDOW(w);

        memset(p, 0, sizeof (p));

        p[0].gravity = getIntOptionNamed(option, nOption, "gravity0",
                                         GRAVITY_NORTH | GRAVITY_WEST);

        p[0].x = getIntOptionNamed(option, nOption, "x0", 0);
        p[0].y = getIntOptionNamed(option, nOption, "y0", 0);

        p[1].gravity = getIntOptionNamed(option, nOption, "gravity1",
                                         GRAVITY_SOUTH | GRAVITY_EAST);

        p[1].x = getIntOptionNamed(option, nOption, "x1", 0);
        p[1].y = getIntOptionNamed(option, nOption, "y1", 0);

        data = getStringOptionNamed(option, nOption, "data", 0);
        if (data)
            svg = rsvg_handle_new_from_data((guint8 *)data, strlen(data),
                                            &error);

        if (sw->source)
        {
            rsvg_handle_free(sw->source->svg);
            sw->source->svg = svg;
        }
        else
        {
            sw->source = malloc(sizeof (SvgSource));
            if (sw->source)
                sw->source->svg = svg;
        }

        if (sw->source && sw->source->svg)
        {
            sw->source->p1 = p[0];
            sw->source->p2 = p[1];

            sw->source->svg = svg;

            rsvg_handle_get_dimensions(svg, &sw->source->dimension);

            updateWindowSvgContext(w, sw->source);
        }
        else
        {
            if (svg)
                rsvg_handle_free(svg);

            if (sw->source)
            {
                free(sw->source);
                sw->source = NULL;
            }

            if (sw->context)
            {
                finiSvgTexture(w->screen, &sw->context->texture[0]);
                free(sw->context);
                sw->context = NULL;
            }
        }
    }

    return FALSE;
}
Example #3
0
static Bool
svgSet (BananaArgument     *arg,
        int                nArg)
{
	CompWindow *w;
	Window     xid;

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

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

	w = findWindowAtDisplay (xid);

	if (w)
	{
		decor_point_t p[2];
		char          *data;
		RsvgHandle    *svg = NULL;
		GError        *error = NULL;

		SVG_WINDOW (w);

		memset (p, 0, sizeof (p));

		BananaValue *gravity0 = getArgNamed ("gravity0", arg, nArg);
		if (gravity0 != NULL)
			p[0].gravity = gravity0->i;
		else
			p[0].gravity =  GRAVITY_NORTH | GRAVITY_WEST;

		BananaValue *x0 = getArgNamed ("x0", arg, nArg);
		if (x0 != NULL)
			p[0].x = x0->i;
		else
			p[0].x =  0;

		BananaValue *y0 = getArgNamed ("y0", arg, nArg);
		if (y0 != NULL)
			p[0].y = y0->i;
		else
			p[0].y =  0;

		BananaValue *gravity1 = getArgNamed ("gravity1", arg, nArg);
		if (gravity1 != NULL)
			p[1].gravity = gravity1->i;
		else
			p[1].gravity =  GRAVITY_SOUTH | GRAVITY_EAST;

		BananaValue *x1 = getArgNamed ("x1", arg, nArg);
		if (x0 != NULL)
			p[1].x = x1->i;
		else
			p[1].x =  0;

		BananaValue *y1 = getArgNamed ("y1", arg, nArg);
		if (y1 != NULL)
			p[1].y = y1->i;
		else
			p[1].y =  0;

		BananaValue *b_data = getArgNamed ("data", arg, nArg);
		if (b_data != NULL)
			data = b_data->s;
		else
			data = NULL;

		if (data)
			svg = rsvg_handle_new_from_data ((guint8 *) data, strlen (data),
			                          &error);

		if (sw->source)
		{
			rsvg_handle_free (sw->source->svg);
			sw->source->svg = svg;
		}
		else
		{
			sw->source = malloc (sizeof (SvgSource));
			if (sw->source)
				sw->source->svg = svg;
		}

		if (sw->source && sw->source->svg)
		{
			sw->source->p1 = p[0];
			sw->source->p2 = p[1];

			sw->source->svg = svg;

			rsvg_handle_get_dimensions (svg, &sw->source->dimension);

			updateWindowSvgContext (w, sw->source);
		}
		else
		{
			if (svg)
				rsvg_handle_free (svg);

			if (sw->source)
			{
				free (sw->source);
				sw->source = NULL;
			}

			if (sw->context)
			{
				finiSvgTexture (w->screen, &sw->context->texture[0]);
				free (sw->context);
				sw->context = NULL;
			}
		}
	}

	return FALSE;
}