示例#1
0
Bool
pushPlugin (CompPlugin *p)
{
	if (findActivePlugin (p->vTable->name))
	{
		compLogMessage ("core", CompLogLevelWarn,
		                "Plugin '%s' already active",
		                p->vTable->name);

		return FALSE;
	}

	p->next = plugins;
	plugins = p;

	if (!initPlugin (p))
	{
		compLogMessage ("core", CompLogLevelError,
		                "Couldn't activate plugin '%s'", p->vTable->name);
		plugins = p->next;

		return FALSE;
	}

	return TRUE;
}
/*
 * groupCreateCairoLayer
 *
 */
GroupCairoLayer*
groupCreateCairoLayer (CompScreen *s,
		       int        width,
		       int        height)
{
    GroupCairoLayer *layer;


    layer = malloc (sizeof (GroupCairoLayer));
    if (!layer)
        return NULL;

    layer->surface = NULL;
    layer->cairo   = NULL;
    layer->buffer  = NULL;
    layer->pixmap  = None;

    layer->animationTime = 0;
    layer->state         = PaintOff;

    layer->texWidth  = width;
    layer->texHeight = height;

    initTexture (s, &layer->texture);

    layer->buffer = calloc (4 * width * height, sizeof (unsigned char));
    if (!layer->buffer)
    {
	compLogMessage ("group", CompLogLevelError,
			"Failed to allocate cairo layer buffer.");
	groupDestroyCairoLayer (s, layer);
	return NULL;
    }

    layer->surface = cairo_image_surface_create_for_data (layer->buffer,
							  CAIRO_FORMAT_ARGB32,
							  width, height,
							  4 * width);
    if (cairo_surface_status (layer->surface) != CAIRO_STATUS_SUCCESS)
    {
	compLogMessage ("group", CompLogLevelError,
			"Failed to create cairo layer surface.");
	groupDestroyCairoLayer (s, layer);
	return NULL;
    }

    layer->cairo = cairo_create (layer->surface);
    if (cairo_status (layer->cairo) != CAIRO_STATUS_SUCCESS)
    {
	compLogMessage ("group", CompLogLevelError,
			"Failed to create cairo layer context.");
	groupDestroyCairoLayer (s, layer);
	return NULL;
    }

    groupClearCairoLayer (layer);

    return layer;
}
bool
StackDebugger::cmpStack (CompWindowList &windows,
			 CompWindowList &serverWindows,
			 bool           verbose)
{
    std::vector <Window>             serverSideWindows;
    CompWindowList::reverse_iterator lrrit = windows.rbegin ();
    CompWindowList::reverse_iterator lsrit = mLastServerWindows.rbegin ();
    unsigned int                     i = 0;
    bool                             err = false;

    for (unsigned int n = 0; n < mServerNChildren; n++)
    {
	if (std::find (mDestroyedFrames.begin (),
		       mDestroyedFrames.end (), mServerChildren[n])
		== mDestroyedFrames.end ())
	    serverSideWindows.push_back (mServerChildren[n]);
    }

    if (verbose)
	compLogMessage ("core", CompLogLevelDebug, "sent       | recv       | server     |");

    for (;(lrrit != windows.rend () ||
	   lsrit != mLastServerWindows.rend () ||
	   i != serverSideWindows.size ());)
    {
	Window lrXid = 0;
	Window lsXid = 0;
	Window sXid = 0;

	if (lrrit != windows.rend ())
	    lrXid = (*lrrit)->priv->frame ? (*lrrit)->priv->frame : (*lrrit)->id ();

	if (lsrit != mLastServerWindows.rend ())
	    lsXid = (*lsrit)->priv->frame ? (*lsrit)->priv->frame : (*lsrit)->id ();

	if (i != serverSideWindows.size ())
	    sXid = serverSideWindows[serverSideWindows.size () - (i + 1)];

	if (verbose)
	    compLogMessage ("core", CompLogLevelDebug, "id 0x%x id 0x%x id 0x%x %s",
		     (unsigned int) lsXid, (unsigned int) lrXid,
		     (unsigned int) sXid, (lrXid != sXid) ? "  /!\\ " : "");

	if (lrXid != sXid)
	    err = true;

	if (lrrit != windows.rend ())
	    ++lrrit;

	if (lsrit != mLastServerWindows.rend())
	    ++lsrit;

	if (i != serverSideWindows.size ())
	    i++;
    }

    return err;
}
static Bool
loadImages (CompScreen *s)
{
    MAG_SCREEN (s);

    if (!s->multiTexCoord2f)
	return FALSE;

    ms->overlay.loaded = readImageToTexture (s, &ms->overlay.tex,
					     magGetOverlay (s),
					     &ms->overlay.width,
					     &ms->overlay.height);
    
    if (!ms->overlay.loaded)
    {
	compLogMessage ("mag", CompLogLevelWarn,
			"Could not load magnifier overlay image \"%s\"!",
			magGetOverlay (s));
	return FALSE;
    }

    ms->mask.loaded = readImageToTexture (s, &ms->mask.tex,
					  magGetMask (s),
					  &ms->mask.width,
					  &ms->mask.height);

    if (!ms->mask.loaded)
    {
	compLogMessage ("mag", CompLogLevelWarn,
			"Could not load magnifier mask image \"%s\"!",
			magGetOverlay (s));
	ms->overlay.loaded = FALSE;
	finiTexture (s, &ms->overlay.tex);
	initTexture (s, &ms->overlay.tex);
	return FALSE;
    }

    if (ms->overlay.width != ms->mask.width ||
	ms->overlay.height != ms->mask.height)
    {
	compLogMessage ("mag", CompLogLevelWarn,
			"Image dimensions do not match!");
	ms->overlay.loaded = FALSE;
	finiTexture (s, &ms->overlay.tex);
	initTexture (s, &ms->overlay.tex);
	ms->mask.loaded = FALSE;
	finiTexture (s, &ms->mask.tex);
	initTexture (s, &ms->mask.tex);
	return FALSE;
    }

    return TRUE;
}
示例#5
0
static Bool
initPlugin (CompPlugin *p)
{
	if (strcmp (p->vTable->name, "core") == 0)
		return TRUE;

	//InitPlugin
	if (!(*p->vTable->init) (p))
	{
		compLogMessage ("core", CompLogLevelError,
		                "InitPlugin '%s' failed", p->vTable->name);
		return FALSE;
	}

	//InitDisplay
	if (p->vTable->initDisplay && !(*p->vTable->initDisplay) (p, &display))
	{
		compLogMessage ("core", CompLogLevelError,
		                "InitDisplay '%s' failed", p->vTable->name);
		return FALSE;
	}

	//InitScreen
	if (p->vTable->initScreen)
	{
		CompScreen *s;
		for (s = display.screens; s; s = s->next)
		{
			if (!(*p->vTable->initScreen) (p, s))
			{
				compLogMessage ("core", CompLogLevelError,
				                "InitScreen '%s' failed", p->vTable->name);
				return FALSE;
			}

			if (p->vTable->initWindow)
			{
				CompWindow *w;
				for (w = s->windows; w; w = w->next)
				{
					if (!(*p->vTable->initWindow) (p, w))
					{
						compLogMessage ("core", CompLogLevelError,
						                "InitWindow '%s' failed", p->vTable->name);
						return FALSE;
					}
				}
			}
		}
	}

	return TRUE;
}
示例#6
0
文件: core.c 项目: berylline/compiz
CompBool initCore(void)
{
    CompPlugin *corePlugin;

    compObjectInit(&core.base, 0, COMP_OBJECT_TYPE_CORE);

    core.displays = NULL;

    core.tmpRegion = XCreateRegion();
    if(!core.tmpRegion)
    {
		return FALSE;
    }

    core.outputRegion = XCreateRegion();
    if(!core.outputRegion)
    {
		XDestroyRegion(core.tmpRegion);
		return FALSE;
    }

    core.fileWatch	     = NULL;
    core.lastFileWatchHandle = 1;

    core.timeouts	   = NULL;
    core.lastTimeoutHandle = 1;

    core.watchFds	   = NULL;
    core.lastWatchFdHandle = 1;
    core.watchPollFds	   = NULL;
    core.nWatchFds	   = 0;

    gettimeofday(&core.lastTimeout, 0);

    setCoreProcs();

    corePlugin = loadPlugin("core");
    if(!corePlugin)
    {
		compLogMessage("core", CompLogLevelFatal, "Couldn't load core plugin");
		return FALSE;
    }

    if(!pushPlugin(corePlugin))
    {
		compLogMessage("core", CompLogLevelFatal, "Couldn't activate core plugin");
		return FALSE;
    }

    return TRUE;
}
示例#7
0
CairoLayer::CairoLayer (const CompSize &size, GroupSelection *g) :
    TextureLayer::TextureLayer (size, g),
    mBuffer (NULL),
    mSurface (NULL),
    mCairo (NULL),
    mFailed (true)
{
    unsigned int bufSize = 4 * width () * height ();

    mAnimationTime = 0;
    mState         = PaintOff;

    mBuffer = new unsigned char[bufSize];
    if (mBuffer)
    {
	mSurface = cairo_image_surface_create_for_data (mBuffer,
						CAIRO_FORMAT_ARGB32,
						width (),
						height (),
						4 * width ());

	if (cairo_surface_status (mSurface) == CAIRO_STATUS_SUCCESS)
	{
	    mCairo = cairo_create (mSurface);

	    if (cairo_status (mCairo) == CAIRO_STATUS_SUCCESS)
	    {
		clear ();
		mFailed = false;
	    }
	    else
	    {
		compLogMessage ("group", CompLogLevelError,
				"Failed to create cairo layer context.");
		cairo_surface_destroy (mSurface);
		delete[] mBuffer;
	    }
	}
	else
	{
	    compLogMessage ("group", CompLogLevelError,
			    "Failed to create cairo layer surface");
	    delete[] mBuffer;
	}
    }
    else
    {
	compLogMessage ("group", CompLogLevelError,
			"Failed to allocate cairo layer buffer.");
    }
}
示例#8
0
CompPlugin *
loadPlugin (const char *name)
{
	CompPlugin *p;
	char       *home, *plugindir;
	Bool       status;

	compLogMessage("core", CompLogLevelInfo,
	               "Loading plugin: %s",
	               name);

	p = malloc (sizeof (CompPlugin));
	if (!p)
		return 0;

	p->next            = 0;
	p->dlhand          = 0;
	p->vTable          = 0;

	home = getenv ("HOME");
	if (home)
	{
		plugindir = malloc (strlen (home) + strlen (HOME_PLUGINDIR) + 3);
		if (plugindir)
		{
			sprintf (plugindir, "%s/%s", home, HOME_PLUGINDIR);
			status = dlloaderLoadPlugin (p, plugindir, name);
			free (plugindir);

			if (status)
				return p;
		}
	}

	status = dlloaderLoadPlugin (p, PLUGINDIR, name);
	if (status)
		return p;

	status = dlloaderLoadPlugin (p, NULL, name);
	if (status)
		return p;

	compLogMessage ("core", CompLogLevelError,
	                "Couldn't load plugin '%s'", name);

	free (p);

	return 0;
}
示例#9
0
TextSurface::TextSurface () :
    mWidth  (0),
    mHeight (0),
    mPixmap (None),
    cr (NULL),
    surface (NULL),
    layout (NULL),
    format (NULL),
    font (NULL),
    scrn (NULL)
{
    Display *dpy = screen->dpy ();

    scrn = ScreenOfDisplay (dpy, screen->screenNum ());

    if (!scrn)
    {
	compLogMessage ("text", CompLogLevelError,
			"Couldn't get screen for %d.", screen->screenNum ());
	return;
    }

    format = XRenderFindStandardFormat (dpy, PictStandardARGB32);
    if (!format)
    {
	compLogMessage ("text", CompLogLevelError, "Couldn't get format.");
	return;
    }

    if (!initCairo (1, 1))
	return;

    /* init pango */
    layout = pango_cairo_create_layout (cr);
    if (!layout)
    {
	compLogMessage ("text", CompLogLevelError,
			"Couldn't create pango layout.");
	return;
    }

    font = pango_font_description_new ();
    if (!font)
    {
	compLogMessage ("text", CompLogLevelError,
			"Couldn't create font description.");
	return;
    }
}
示例#10
0
static Bool
minInit (CompPlugin *p)
{
	if (getCoreABI() != CORE_ABIVERSION)
	{
		compLogMessage ("minimize", CompLogLevelError,
		                "ABI mismatch\n"
		                "\tPlugin was compiled with ABI: %d\n"
		                "\tFusilli Core was compiled with ABI: %d\n",
		                CORE_ABIVERSION, getCoreABI());

		return FALSE;
	}

	displayPrivateIndex = allocateDisplayPrivateIndex ();

	if (displayPrivateIndex < 0)
		return FALSE;

	bananaIndex = bananaLoadPlugin ("minimize");

	if (bananaIndex == -1)
		return FALSE;

	bananaAddChangeNotifyCallBack (bananaIndex, minChangeNotify);

	return TRUE;
}
示例#11
0
//run InitWindow(w) for every active plugin
Bool
windowInitPlugins (CompWindow *w)
{
	CompPlugin *p;
	int        i, j = 0;

	for (p = plugins; p; p = p->next)
		j++;

	while (j--)
	{
		i = 0;
		for (p = plugins; i < j; p = p->next)
			i++;

		if (p->vTable->initWindow)
		{
			if (!(*p->vTable->initWindow) (p, w))
			{
				compLogMessage ("core", CompLogLevelError,
				                "InitWindow '%s' failed", p->vTable->name);
				return FALSE;
			}
		}
	}

	return TRUE;
}
示例#12
0
static int
loadFragmentProgram (CompScreen *s,
		     GLuint	*program,
		     const char *string)
{
    GLint errorPos;

    /* clear errors */
    glGetError ();

    if (!*program)
	(*s->genPrograms) (1, program);

    (*s->bindProgram) (GL_FRAGMENT_PROGRAM_ARB, *program);
    (*s->programString) (GL_FRAGMENT_PROGRAM_ARB,
			 GL_PROGRAM_FORMAT_ASCII_ARB,
			 strlen (string), string);

    glGetIntegerv (GL_PROGRAM_ERROR_POSITION_ARB, &errorPos);
    if (glGetError () != GL_NO_ERROR || errorPos != -1)
    {
	compLogMessage ("water", CompLogLevelError,
			"failed to load bump map program");

	(*s->deletePrograms) (1, program);
	*program = 0;

	return 0;
    }

    return 1;
}
示例#13
0
Bool
compAddMetadataFromFile (CompMetadata *metadata,
			 const char   *file)
{
    char *home;
    Bool status = FALSE;

    home = getenv ("HOME");
    if (home)
    {
	char *path;

	path = malloc (strlen (home) + strlen (HOME_METADATADIR) + 2);
	if (path)
	{
	    sprintf (path, "%s/%s", home, HOME_METADATADIR);
	    status |= addMetadataFromFilename (metadata, path, file);
	    free (path);
	}
    }

    status |= addMetadataFromFilename (metadata, METADATADIR, file);
    if (!status)
    {
	compLogMessage ("core", CompLogLevelWarn,
			"Unable to parse XML metadata from file \"%s%s\"",
			file, EXTENSION);

	return FALSE;
    }

    return TRUE;
}
GLFramebufferObject *
GLFramebufferObject::bind ()
{
    GLFramebufferObject *old = NULL;

    if (priv->boundId != 0)
    {
	std::map<GLuint, GLFramebufferObject *>::iterator it;
	it = PrivateGLFramebufferObject::idMap.find (priv->boundId);

	if (it != PrivateGLFramebufferObject::idMap.end ())
	    old = it->second;
	else
	    compLogMessage ("opengl", CompLogLevelError,
		"An FBO without GLFramebufferObject cannot be restored");
    }

    (*GL::bindFramebuffer) (GL::FRAMEBUFFER, priv->fboId);
    priv->boundId = priv->fboId;

    (*GL::framebufferRenderbuffer) (GL::FRAMEBUFFER, GL::DEPTH_ATTACHMENT, GL::RENDERBUFFER, priv->rbStencilId);
    (*GL::framebufferRenderbuffer) (GL::FRAMEBUFFER, GL::STENCIL_ATTACHMENT, GL::RENDERBUFFER, priv->rbStencilId);

    return old;
}
示例#15
0
Bool
compAddMetadataFromString (CompMetadata *metadata,
			   const char   *string)
{
    xmlDoc **d, *doc;

    doc = xmlReadMemory (string, strlen (string), NULL, NULL, 0);
    if (!doc)
    {
	compLogMessage ("core", CompLogLevelWarn,
			"Unable to parse XML metadata");

	return FALSE;
    }

    d = realloc (metadata->doc, (metadata->nDoc + 1) * sizeof (xmlDoc *));
    if (!d)
    {
	xmlFreeDoc (doc);
	return FALSE;
    }

    d[metadata->nDoc++] = doc;
    metadata->doc = d;

    return TRUE;
}
示例#16
0
static Bool
titleinfoInit (CompPlugin *p)
{
	if (getCoreABI() != CORE_ABIVERSION)
	{
		compLogMessage ("titleinfo", CompLogLevelError,
		                "ABI mismatch\n"
		                "\tPlugin was compiled with ABI: %d\n"
		                "\tFusilli Core was compiled with ABI: %d\n",
		                CORE_ABIVERSION, getCoreABI());

		return FALSE;
	}

	displayPrivateIndex = allocateDisplayPrivateIndex ();

	if (displayPrivateIndex < 0)
		return FALSE;

	bananaIndex = bananaLoadPlugin ("titleinfo");

	if (bananaIndex == -1)
		return FALSE;

	return TRUE;
}
示例#17
0
static Bool
wsnamesInit (CompPlugin *p)
{
	if (getCoreABI() != CORE_ABIVERSION)
	{
		compLogMessage ("wsnames", CompLogLevelError,
		                "ABI mismatch\n"
		                "\tPlugin was compiled with ABI: %d\n"
		                "\tFusilli Core was compiled with ABI: %d\n",
		                CORE_ABIVERSION, getCoreABI());

		return FALSE;
	}

	displayPrivateIndex = allocateDisplayPrivateIndex ();

	if (displayPrivateIndex < 0)
		return FALSE;

	bananaIndex = bananaLoadPlugin ("wsnames");

	if (bananaIndex == -1)
		return FALSE;

	bananaAddChangeNotifyCallBack (bananaIndex, wsnamesChangeNotify);

	if (core.dbusConnection != NULL)
	{
		dbus_connection_register_object_path (core.dbusConnection,
		                                      "/org/fusilli/wsnames",
		                                      &wsnamesDbusMessagesVTable, 0);
	}

	return TRUE;
}
示例#18
0
Bool
compAddMetadataFromIO (CompMetadata	     *metadata,
		       xmlInputReadCallback  ioread,
		       xmlInputCloseCallback ioclose,
		       void		     *ioctx)
{
    xmlDoc **d, *doc;

    doc = xmlReadIO (ioread, ioclose, ioctx, NULL, NULL, 0);
    if (!doc)
    {
	compLogMessage ("core", CompLogLevelWarn,
			"Unable to parse XML metadata");

	return FALSE;
    }

    d = realloc (metadata->doc, (metadata->nDoc + 1) * sizeof (xmlDoc *));
    if (!d)
    {
	xmlFreeDoc (doc);
	return FALSE;
    }

    d[metadata->nDoc++] = doc;
    metadata->doc = d;

    return TRUE;
}
示例#19
0
文件: opacify.c 项目: jordigh/fusilli
/* Dim an (inactive) window. Place it on the passive list and
 * update passiveNum. Then change the opacity.
 */
static void
dimWindow (CompWindow *w)
{
	OPACIFY_SCREEN (w->screen);

	if (os->passiveNum >= MAX_WINDOWS - 1)
	{
		compLogMessage ("opacify", CompLogLevelWarn,
		                "Trying to store information "
		                "about too many windows, or you hit a bug.\nIf "
		                "you don't have around %d windows blocking the "
		                "currently targeted window, please report this.",
		                MAX_WINDOWS);
		return;
	}

	os->passive[os->passiveNum++] = w->id;

	const BananaValue *
	option_passive_opacity = bananaGetOption (bananaIndex,
	                                          "passive_opacity",
	                                          w->screen->screenNum);

	setOpacity (w, MIN (OPAQUE * option_passive_opacity->i / 100,
	                    w->paint.opacity));
}
void
updateOptionSets (CompScreen *s,
		  AnimEvent e)
{
    ANIM_SCREEN (s);

    OptionSets *oss = &as->eventOptionSets[e];
    CompListValue *listVal = &as->opt[customOptionOptionIds[e]].value.list;
    int n = listVal->nValue;

    if (oss->sets)
	freeSingleEventOptionSets(oss);

    oss->sets = calloc(n, sizeof(OptionSet));
    if (!oss->sets)
    {
	compLogMessage ("animation", CompLogLevelError,
			"Not enough memory");
	return;
    }
    oss->nSets = n;

    int i;
    for (i = 0; i < n; i++)
	updateOptionSet(s, &oss->sets[i], listVal->value[i].s);
}
示例#21
0
static Bool
shotInit (CompPlugin *p)
{
	if (getCoreABI() != CORE_ABIVERSION)
	{
		compLogMessage ("screenshot", CompLogLevelError,
		                "ABI mismatch\n"
		                "\tPlugin was compiled with ABI: %d\n"
		                "\tFusilli Core was compiled with ABI: %d\n",
		                CORE_ABIVERSION, getCoreABI());

		return FALSE;
	}

	displayPrivateIndex = allocateDisplayPrivateIndex ();

	if (displayPrivateIndex < 0)
		return FALSE;

	bananaIndex = bananaLoadPlugin ("screenshot");

	if (bananaIndex == -1)
		return FALSE;

	bananaAddChangeNotifyCallBack (bananaIndex, shotChangeNotify);

	const BananaValue *
	option_initiate_button = bananaGetOption (bananaIndex,
	                                          "initiate_button",
	                                          -1);

	registerButton (option_initiate_button->s, &initiate_button);

	return TRUE;
}
示例#22
0
static Bool
mateInit (CompPlugin *p)
{
	if (getCoreABI() != CORE_ABIVERSION)
	{
		compLogMessage ("matecompat", CompLogLevelError,
		                "ABI mismatch\n"
		                "\tPlugin was compiled with ABI: %d\n"
		                "\tFusilli Core was compiled with ABI: %d\n",
		                CORE_ABIVERSION, getCoreABI());

		return FALSE;
	}

	displayPrivateIndex = allocateDisplayPrivateIndex ();

	if (displayPrivateIndex < 0)
		return FALSE;

	bananaIndex = bananaLoadPlugin ("matecompat");

	if (bananaIndex == -1)
		return FALSE;

	bananaAddChangeNotifyCallBack (bananaIndex, mateChangeNotify);

	const BananaValue *
	option_main_menu_key = bananaGetOption (bananaIndex, "main_menu_key", -1);

	const BananaValue *
	option_run_key = bananaGetOption (bananaIndex, "run_key", -1);

	const BananaValue *
	option_run_command_screenshot_key = 
	     bananaGetOption (bananaIndex, "run_command_screenshot_key", -1);

	const BananaValue *
	option_run_command_window_screenshot_key = 
	     bananaGetOption (bananaIndex, "run_command_window_screenshot_key", -1);

	const BananaValue *
	option_run_command_terminal_key = 
	     bananaGetOption (bananaIndex, "run_command_terminal_key", -1);

	registerKey (option_main_menu_key->s, &main_menu_key);

	registerKey (option_run_key->s, &run_key);

	registerKey (option_run_command_screenshot_key->s,
	             &run_command_screenshot_key);

	registerKey (option_run_command_window_screenshot_key->s,
	             &run_command_window_screenshot_key);

	registerKey (option_run_command_terminal_key->s,
	             &run_command_terminal_key);

	return TRUE;
}
示例#23
0
static Bool
colorFilterInitScreen (CompPlugin *p,
                       CompScreen *s)
{
	ColorFilterScreen *cfs;

	FILTER_DISPLAY (&display);

	if (!s->fragmentProgram)
	{
		compLogMessage ("colorfilter", CompLogLevelFatal,
		                "Fragment program support missing.");
		return TRUE;
	}

	cfs = malloc (sizeof (ColorFilterScreen));
	if (!cfs)
		return FALSE;

	cfs->windowPrivateIndex = allocateWindowPrivateIndex (s);
	if (cfs->windowPrivateIndex < 0)
	{
		free (cfs);
		return FALSE;
	}

	cfs->isFiltered = FALSE;
	cfs->currentFilter = 0;

	cfs->filtersLoaded = FALSE;
	cfs->filtersFunctions = NULL;
	cfs->filtersCount = 0;	

	WRAP (cfs, s, drawWindowTexture, colorFilterDrawWindowTexture);
	WRAP (cfs, s, windowAddNotify, colorFilterWindowAddNotify);

	s->privates[cfd->screenPrivateIndex].ptr = cfs;

	const BananaValue *
	option_filter_match = bananaGetOption (bananaIndex,
	                                       "filter_match",
	                                       s->screenNum);

	matchInit (&cfs->filter_match);
	matchAddFromString (&cfs->filter_match, option_filter_match->s);
	matchUpdate (&cfs->filter_match);

	const BananaValue *
	option_exclude_match = bananaGetOption (bananaIndex,
	                                        "exclude_match",
	                                        s->screenNum);

	matchInit (&cfs->exclude_match);
	matchAddFromString (&cfs->exclude_match, option_exclude_match->s);
	matchUpdate (&cfs->exclude_match);

	return TRUE;
}
示例#24
0
BicubicScreen::BicubicScreen (CompScreen *screen) :
    PluginClassHandler <BicubicScreen, CompScreen> (screen),
    gScreen (GLScreen::get (screen)),
    cScreen (CompositeScreen::get (screen))
{
    bool           failed = false;
    const char     *glExtensions;
    GLenum         format = GL_RGBA16F_ARB;

    if (!GL::fragmentProgram)
    {
	compLogMessage ("bicube", CompLogLevelFatal,
			"GL_ARB_fragment_program not supported.");
	setFailed ();
	failed = true;
    }

    if (!failed)
    {

	glExtensions = (const char *) glGetString (GL_EXTENSIONS);
	if (!glExtensions)
	{
	    compLogMessage ("bicubic", CompLogLevelFatal,
			    "No valid GL extensions string found.");
	    setFailed ();
	    failed = true;
	}

    }

    if (!failed)
    {

	if (!strstr (glExtensions, "GL_ARB_texture_float"))
	{
	    compLogMessage ("bicubic", CompLogLevelFatal,
			    "GL_ARB_texture_float not supported. "
			    "This can lead to visual artifacts.");
	    format = GL_RGBA;
	}
    }

    generateLookupTexture (format);
}
示例#25
0
/*
 * Switch current filter
 */
static void
colorFilterSwitchFilter (CompScreen *s)
{
	int id;
	CompFunction *function;
	CompWindow *w;

	FILTER_SCREEN (s);

	/* % (count + 1) because of the cumulative filters mode */
	cfs->currentFilter++;
	if (cfs->currentFilter >= cfs->filtersCount + 1)
		cfs->currentFilter = 0;

	if (cfs->currentFilter == 0)
		compLogMessage ("colorfilter", CompLogLevelInfo,
		                "Cumulative filters mode");
	else
	{
		id = cfs->filtersFunctions[cfs->currentFilter - 1];

		if (id)
		{
			function = findFragmentFunction (s, id);
			compLogMessage ("colorfilter", CompLogLevelInfo,
			                "Single filter mode (using %s filter)",
			                function->name);
		}
		else
		{
			compLogMessage ("colorfilter", CompLogLevelInfo,
			                "Single filter mode (filter loading failure)");
		}
	}

	/* Damage currently filtered windows */
	for (w = s->windows; w; w = w->next)
	{
		FILTER_WINDOW (w);

		if (cfw->isFiltered)
			addWindowDamage (w);
	}
}
示例#26
0
static Bool
textInitCairo (CompScreen      *s,
	       TextSurfaceData *data,
	       int             width,
	       int             height)
{
    Display *dpy = s->display->display;

    data->pixmap = None;
    if (width > 0 && height > 0)
	data->pixmap = XCreatePixmap (dpy, s->root, width, height, 32);

    data->width  = width;
    data->height = height;

    if (!data->pixmap)
    {
	compLogMessage ("text", CompLogLevelError,
			"Couldn't create %d x %d pixmap.", width, height);
	return FALSE;
    }

    data->surface = cairo_xlib_surface_create_with_xrender_format (dpy,
								   data->pixmap,
								   data->screen,
								   data->format,
								   width,
								   height);
    if (cairo_surface_status (data->surface) != CAIRO_STATUS_SUCCESS)
    {
	compLogMessage ("text", CompLogLevelError, "Couldn't create surface.");
	return FALSE;
    }

    data->cr = cairo_create (data->surface);
    if (cairo_status (data->cr) != CAIRO_STATUS_SUCCESS)
    {
	compLogMessage ("text", CompLogLevelError,
			"Couldn't create cairo context.");
	return FALSE;
    }

    return TRUE;
}
示例#27
0
bool
MagScreen::loadImages ()
{
    CompString overlay_s = optionGetOverlay ();
    CompString mask_s = optionGetMask ();
    CompString pname ("mag");
    if (!GL::multiTexCoord2f)
	return false;

    overlay = GLTexture::readImageToTexture (overlay_s, pname,
				    	       overlaySize);
    
    if (!overlay.size ())
    {
	compLogMessage ("mag", CompLogLevelWarn,
			"Could not load magnifier overlay image \"%s\"!",
			overlay_s.c_str ());
	return false;
    }

    mask = GLTexture::readImageToTexture (mask_s, pname,
				    	  maskSize);

    if (!mask.size ())
    {
	compLogMessage ("mag", CompLogLevelWarn,
			"Could not load magnifier mask image \"%s\"!",
			mask_s.c_str ());
	overlay.clear ();
	return false;
    }

    if (overlaySize.width () != maskSize.width () ||
	overlaySize.height () != maskSize.height ())
    {
	compLogMessage ("mag", CompLogLevelWarn,
			"Image dimensions do not match!");
	overlay.clear ();
	mask.clear ();
	return false;
    }

    return true;
}
示例#28
0
static CompTextData *
textRenderText (CompScreen           *s,
		const char           *text,
		const CompTextAttrib *attrib)
{
    TextSurfaceData surface;
    CompTextData    *retval = NULL;

    if (!text || !strlen (text))
	return NULL;

    memset (&surface, 0, sizeof (TextSurfaceData));

    if (textInitSurface (s, &surface) &&
	textRenderTextToSurface (s, text, &surface, attrib))
    {
	retval = calloc (1, sizeof (CompTextData));
	if (retval && !(attrib->flags & CompTextFlagNoAutoBinding))
	{
	    retval->texture = malloc (sizeof (CompTexture));
	    if (!retval->texture)
	    {
		free (retval);
		retval = NULL;
	    }
	}

	if (retval)
	{
	    retval->pixmap = surface.pixmap;
	    retval->width  = surface.width;
	    retval->height = surface.height;

	    if (retval->texture)
	    {
		initTexture (s, retval->texture);
		if (!bindPixmapToTexture (s, retval->texture, retval->pixmap,
					  retval->width, retval->height, 32))
		{
		    compLogMessage ("text", CompLogLevelError,
				    "Failed to bind text pixmap to texture.");
		    free (retval->texture);
		    free (retval);
		    retval = NULL;
		}
	    }
	}
    }

    if (!retval && surface.pixmap)
	XFreePixmap (s->display->display, surface.pixmap);

    textCleanupSurface (&surface);

    return retval;
}
static Bool
scaleaddonInitDisplay (CompPlugin  *p,
                       CompDisplay *d)
{
    ScaleAddonDisplay *ad;
    int               index;

    if (!checkPluginABI ("core", CORE_ABIVERSION))
        return FALSE;

    if (!checkPluginABI ("scale", SCALE_ABIVERSION))
        return FALSE;

    if (!getPluginDisplayIndex (d, "scale", &scaleDisplayPrivateIndex))
        return FALSE;

    ad = malloc (sizeof (ScaleAddonDisplay));
    if (!ad)
        return FALSE;

    ad->screenPrivateIndex = allocateScreenPrivateIndex (d);
    if (ad->screenPrivateIndex < 0)
    {
        free (ad);
        return FALSE;
    }

    if (checkPluginABI ("text", TEXT_ABIVERSION) &&
            getPluginDisplayIndex (d, "text", &index))
    {
        ad->textFunc = d->base.privates[index].ptr;
    }
    else
    {
        compLogMessage ("scaleaddon", CompLogLevelWarn,
                        "No compatible text plugin found.");
        ad->textFunc = NULL;
    }

    WRAP (ad, d, handleEvent, scaleaddonHandleEvent);
    WRAP (ad, d, handleCompizEvent, scaleaddonHandleCompizEvent);

    d->base.privates[displayPrivateIndex].ptr = ad;

    ad->highlightedWindow     = None;
    ad->lastHighlightedWindow = None;

    scaleaddonSetCloseKeyInitiate (d, scaleaddonCloseWindow);
    scaleaddonSetZoomKeyInitiate (d, scaleaddonZoomWindow);
    scaleaddonSetPullKeyInitiate (d, scaleaddonPullWindow);
    scaleaddonSetCloseButtonInitiate (d, scaleaddonCloseWindow);
    scaleaddonSetZoomButtonInitiate (d, scaleaddonZoomWindow);
    scaleaddonSetPullButtonInitiate (d, scaleaddonPullWindow);

    return TRUE;
}
示例#30
0
文件: scalefilter.c 项目: Elive/ecomp
static Bool
scalefilterInitDisplay (CompPlugin  *p,
	    		CompDisplay *d)
{
    ScaleFilterDisplay *fd;
    CompPlugin         *scale = findActivePlugin ("scale");
    CompOption         *option;
    int                nOption;

    if (!scale || !scale->vTable->getDisplayOptions)
	return FALSE;

    option = (*scale->vTable->getDisplayOptions) (scale, d, &nOption);

    if (getIntOptionNamed (option, nOption, "abi", 0) != SCALE_ABIVERSION)
    {
	compLogMessage (d, "scalefilter", CompLogLevelError,
			"scale ABI version mismatch");
	return FALSE;
    }

    scaleDisplayPrivateIndex = getIntOptionNamed (option, nOption, "index", -1);
    if (scaleDisplayPrivateIndex < 0)
	return FALSE;

    fd = malloc (sizeof (ScaleFilterDisplay));
    if (!fd)
	return FALSE;

    fd->screenPrivateIndex = allocateScreenPrivateIndex (d);
    if (fd->screenPrivateIndex < 0)
    {
	free (fd);
	return FALSE;
    }

    fd->xim = XOpenIM (d->display, NULL, NULL, NULL);
    if (fd->xim)
	fd->xic = XCreateIC (fd->xim,
			     XNClientWindow, d->screens->root,
			     XNInputStyle,
			     XIMPreeditNothing  | XIMStatusNothing,
			     NULL);
    else
	fd->xic = NULL;

    if (fd->xic)
	setlocale (LC_CTYPE, "");

    WRAP (fd, d, handleEvent, scalefilterHandleEvent);
    WRAP (fd, d, handleEcompEvent, scalefilterHandleEcompEvent);

    d->privates[displayPrivateIndex].ptr = fd;

    return TRUE;
}