static Bool svgInitScreen(CompPlugin *p, CompScreen *s) { SvgScreen *ss; SVG_DISPLAY(s->display); ss = malloc(sizeof (SvgScreen)); if (!ss) return FALSE; ss->windowPrivateIndex = allocateWindowPrivateIndex(s); if (ss->windowPrivateIndex < 0) { free(ss); return FALSE; } memset(&ss->zoom, 0, sizeof (BoxRec)); WRAP(ss, s, drawWindow, svgDrawWindow); WRAP(ss, s, windowMoveNotify, svgWindowMoveNotify); WRAP(ss, s, windowResizeNotify, svgWindowResizeNotify); s->base.privates[sd->screenPrivateIndex].ptr = ss; return TRUE; }
static CompOption * svgGetDisplayOptions(CompPlugin *plugin, CompDisplay *display, int *count) { SVG_DISPLAY(display); *count = NUM_OPTIONS(sd); return sd->opt; }
static Bool svgSetDisplayOption(CompPlugin *plugin, CompDisplay *display, const char *name, CompOptionValue *value) { CompOption *o; SVG_DISPLAY(display); o = compFindOption(sd->opt, NUM_OPTIONS(sd), name, NULL); if (!o) return FALSE; return compSetDisplayOption(display, o, value); }
static void svgFiniDisplay (CompPlugin *p, CompDisplay *d) { CompScreen *s; SVG_DISPLAY (d); UNWRAP (sd, d, handleFusilliEvent); UNWRAP (sd, d, fileToImage); for (s = d->screens; s; s = s->next) updateDefaultIcon (s); freeScreenPrivateIndex (sd->screenPrivateIndex); free (sd); }
static Bool svgFileToImage(CompDisplay *d, const char *path, const char *name, int *width, int *height, int *stride, void **data) { Bool status = FALSE; char *extension = svgExtension(name); char *file; int len; SVG_DISPLAY(d); len = (path ? strlen(path) : 0) + strlen(name) + strlen(extension) + 2; file = malloc(len); if (file) { if (path) sprintf(file, "%s/%s%s", path, name, extension); else sprintf(file, "%s%s", name, extension); status = readSvgFileToImage(file, width, height, data); free(file); if (status) { *stride = *width * 4; return TRUE; } } UNWRAP(sd, d, fileToImage); status = (*d->fileToImage)(d, path, name, width, height, stride, data); WRAP(sd, d, fileToImage, svgFileToImage); return status; }
static void svgFiniDisplay(CompPlugin *p, CompDisplay *d) { CompScreen *s; SVG_DISPLAY(d); UNWRAP(sd, d, handleCompizEvent); UNWRAP(sd, d, fileToImage); for (s = d->screens; s; s = s->next) updateDefaultIcon(s); freeScreenPrivateIndex(d, sd->screenPrivateIndex); compFiniDisplayOptions(d, sd->opt, SVG_DISPLAY_OPTION_NUM); free(sd); }
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)); } } } }
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)); } } } }