void
groupEnqueueUngrabNotify (CompWindow *w)
{
    GroupPendingUngrabs *ungrab;

    GROUP_SCREEN (w->screen);

    ungrab = malloc (sizeof (GroupPendingUngrabs));

    if (!ungrab)
	return;

    ungrab->w    = w;
    ungrab->next = NULL;

    if (gs->pendingUngrabs)
    {
	GroupPendingUngrabs *temp;
	for (temp = gs->pendingUngrabs; temp->next; temp = temp->next);

	temp->next = ungrab;
    }
    else
	gs->pendingUngrabs = ungrab;

    if (!gs->dequeueTimeoutHandle)
    {
	gs->dequeueTimeoutHandle =
	    compAddTimeout (0, 0, groupDequeueTimer, (void *) w->screen);
    }
}
Example #2
0
static Bool
waterToggleRain(CompDisplay * d,
		CompAction * action,
		CompActionState state, CompOption * option, int nOption)
{
	CompScreen *s;

	WATER_DISPLAY(d);

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

		if (!ws->rainHandle) {
			int delay;

			delay =
			    wd->opt[WATER_DISPLAY_OPTION_RAIN_DELAY].value.i;
			ws->rainHandle =
			    compAddTimeout(delay, (float)delay * 1.2,
					   waterRainTimeout, s);
		} else {
			compRemoveTimeout(ws->rainHandle);
			ws->rainHandle = 0;
		}
	}

	return FALSE;
}
Example #3
0
static Bool
winrulesInitWindow (CompPlugin *p,
                    CompWindow *w)
{
	WinrulesWindow *ww;

	WINRULES_SCREEN (w->screen);

	ww = malloc (sizeof (WinrulesWindow));
	if (!ww)
		return FALSE;

	ww->stateSetMask    = 0;
	ww->protocolSetMask = 0;

	ww->allowedActions = ~0;

	ww->hasAlpha     = w->alpha;
	ww->oldInputHint = w->inputHint;

	w->privates[ws->windowPrivateIndex].ptr = ww;

	ww->handle = compAddTimeout (0, 0, winrulesApplyRulesTimeout, w);

	return TRUE;
}
Example #4
0
static Bool
waterToggleWiper (CompDisplay     *d,
		  CompAction      *action,
		  CompActionState state,
		  CompOption      *option,
		  int	          nOption)
{
    CompScreen *s;

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

	if (!ws->wiperHandle)
	{
	    ws->wiperHandle = compAddTimeout (2000, 2400, waterWiperTimeout, s);
	}
	else
	{
	    compRemoveTimeout (ws->wiperHandle);
	    ws->wiperHandle = 0;
	}
    }

    return FALSE;
}
Example #5
0
static void
glibPrepare (CompDisplay  *display,
	     GMainContext *context)
{
    int nFds = 0;
    int timeout = -1;
    int i;

    GLIB_DISPLAY (display);

    g_main_context_prepare (context, &gd->maxPriority);

    do
    {
	if (nFds > gd->fdsSize)
	{
	    if (gd->fds)
		free (gd->fds);

	    gd->fds = malloc ((sizeof (GPollFD) + sizeof (GLibWatch)) * nFds);
	    if (!gd->fds)
	    {
		nFds = 0;
		break;
	    }

	    gd->watch   = (GLibWatch *) (gd->fds + nFds);
	    gd->fdsSize = nFds;
	}

	nFds = g_main_context_query (context,
				     gd->maxPriority,
				     &timeout,
				     gd->fds,
				     gd->fdsSize);
    } while (nFds > gd->fdsSize);

    if (timeout < 0)
	timeout = INT_MAX;

    for (i = 0; i < nFds; i++)
    {
	gd->watch[i].display = display;
	gd->watch[i].index   = i;
	gd->watch[i].handle  = compAddWatchFd (gd->fds[i].fd,
					       gd->fds[i].events,
					       glibCollectEvents,
					       &gd->watch[i]);
    }

    gd->nFds	      = nFds;
    gd->timeoutHandle =
	compAddTimeout (timeout, timeout, glibDispatchAndPrepare, display);
}
Example #6
0
static void
kconfigRcChanged (const char *name,
		  void	     *closure)
{
    if (strcmp (name, COMPIZ_KCONFIG_RC) == 0)
    {
	KCONFIG_CORE (&core);

	if (!kc->reloadHandle)
	    kc->reloadHandle = compAddTimeout (0, 0, kconfigRcReload, closure);
    }
}
static void
glibWakeup (CompDisplay *display)
{
    GLIB_DISPLAY (display);

    if (gd->timeoutHandle)
    {
	compRemoveTimeout (gd->timeoutHandle);
	compAddTimeout (0, 0, glibDispatchAndPrepare, (void *) display);

	gd->timeoutHandle = 0;
    }
}
Example #8
0
static Bool
waterSetDisplayOption (CompPlugin      *plugin,
		       CompDisplay     *display,
		       const char      *name,
		       CompOptionValue *value)
{
    CompOption *o;
    int	       index;

    WATER_DISPLAY (display);

    o = compFindOption (wd->opt, NUM_OPTIONS (wd), name, &index);
    if (!o)
	return FALSE;

    switch (index) {
    case WATER_DISPLAY_OPTION_OFFSET_SCALE:
	if (compSetFloatOption (o, value))
	{
	    wd->offsetScale = o->value.f * 50.0f;
	    return TRUE;
	}
	break;
    case WATER_DISPLAY_OPTION_RAIN_DELAY:
	if (compSetIntOption (o, value))
	{
	    CompScreen *s;

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

		if (!ws->rainHandle)
		    continue;

		compRemoveTimeout (ws->rainHandle);
		ws->rainHandle = compAddTimeout (value->i,
						 (float)value->i * 1.2,
						 waterRainTimeout, s);
	    }
	    return TRUE;
	}
	break;
    default:
	return compSetDisplayOption (display, o, value);
    }

    return FALSE;
}
static int
sessionInitDisplay (CompPlugin  *p,
		    CompDisplay *d)
{
    SessionDisplay *sd;
    char           *prevClientId;

    sd = malloc (sizeof (SessionDisplay));
    if (!sd)
	return FALSE;

    if (!compInitDisplayOptionsFromMetadata (d,
					     &sessionMetadata,
					     sessionDisplayOptionInfo,
					     sd->opt,
					     SESSION_DISPLAY_OPTION_NUM))
    {
	compFiniDisplayOptions (d, sd->opt, SESSION_DISPLAY_OPTION_NUM);
	free (sd);
	return FALSE;
    }

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

    sd->visibleNameAtom = XInternAtom (d->display, "_NET_WM_VISIBLE_NAME", 0);
    sd->clientIdAtom = XInternAtom (d->display, "SM_CLIENT_ID", 0);
    sd->embedInfoAtom = XInternAtom (d->display, "_XEMBED_INFO", 0);
    sd->roleAtom = XInternAtom (d->display, "WM_WINDOW_ROLE", 0);
    sd->commandAtom = XInternAtom (d->display, "WM_COMMAND", 0);

    prevClientId = getSessionClientId (CompSessionPrevClientId);
    if (prevClientId)
    {
	loadState (d, prevClientId);
	free (prevClientId);
    }

    sd->windowAddTimeout = compAddTimeout (0, 0, sessionWindowAddTimeout, d);

    WRAP (sd, d, handleEvent, sessionHandleEvent);

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

    return TRUE;
}
Example #10
0
static Bool
kconfigInitCore (CompPlugin *p,
		 CompCore   *c)
{
    KconfigCore *kc;
    QString	dir;

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

    kc = new KconfigCore;
    if (!kc)
	return FALSE;

    kc->config = new KConfig (COMPIZ_KCONFIG_RC);
    if (!kc->config)
    {
	delete kc;
	return FALSE;
    }

    kc->reloadHandle = compAddTimeout (0, 0, kconfigRcReload, 0);
    kc->syncHandle   = 0;
    kc->fileWatch    = 0;

    dir = KGlobal::dirs ()->saveLocation ("config", QString::null, false);

    if (QFile::exists (dir))
    {
	kc->fileWatch = addFileWatch (dir.ascii (), ~0, kconfigRcChanged, 0);
    }
    else
    {
	compLogMessage ("kconfig", CompLogLevelWarn, "Bad access \"%s\"",
			dir.ascii ());
    }

    WRAP (kc, c, initPluginForObject, kconfigInitPluginForObject);
    WRAP (kc, c, setOptionForPlugin, kconfigSetOptionForPlugin);

    c->base.privates[corePrivateIndex].ptr = kc;

    return TRUE;
}
Example #11
0
static Bool
decorInitScreen (CompPlugin *p,
		 CompScreen *s)
{
    DecorScreen *ds;

    DECOR_DISPLAY (s->display);

    ds = malloc (sizeof (DecorScreen));
    if (!ds)
	return FALSE;

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

    memset (ds->decor, 0, sizeof (ds->decor));

    ds->dmWin                = None;
    ds->decoratorStartHandle = 0;

    WRAP (ds, s, drawWindow, decorDrawWindow);
    WRAP (ds, s, damageWindowRect, decorDamageWindowRect);
    WRAP (ds, s, getOutputExtentsForWindow, decorGetOutputExtentsForWindow);
    WRAP (ds, s, windowMoveNotify, decorWindowMoveNotify);
    WRAP (ds, s, windowResizeNotify, decorWindowResizeNotify);
    WRAP (ds, s, windowStateChangeNotify, decorWindowStateChangeNotify);
    WRAP (ds, s, addSupportedAtoms, decorAddSupportedAtoms);

    s->base.privates[dd->screenPrivateIndex].ptr = ds;

    decorCheckForDmOnScreen (s, FALSE);
    setSupportedWmHints (s);

    if (!ds->dmWin)
	ds->decoratorStartHandle = compAddTimeout (0, -1,
						   decorStartDecorator, s);

    return TRUE;
}
		setElementTexture (eScreen, ele++);
	}
}

static Bool
elementsInitScreen (CompPlugin *p,
		CompScreen *s)
{
	screen *eScreen;
	E_DISPLAY (s->display);

	eScreen = calloc (1, sizeof(screen));
	s->base.privates[ed->privateIndex].ptr = eScreen;
	eScreen->cScreen = s;
	eScreen->numElements = 0;
	eScreen->textu = NULL;
	eScreen->needUpdate = FALSE;
	eScreen->useKeys = elementsGetToggle (s->display);

	if (!eScreen->useKeys)
	{
	eScreen->isActive[0] = elementsGetToggleAutumnCheck (s->display);
	eScreen->isActive[1] = elementsGetToggleFirefliesCheck (s->display);
	eScreen->isActive[2] = elementsGetToggleSnowCheck (s->display);
	eScreen->isActive[3] = elementsGetToggleStarsCheck (s->display);
	eScreen->isActive[4] = elementsGetToggleBubblesCheck (s->display);
	}
	else
	{
	eScreen->isActive[0] = FALSE;
	eScreen->isActive[1] = FALSE;
	eScreen->isActive[2] = FALSE;
	eScreen->isActive[3] = FALSE;
	eScreen->isActive[4] = FALSE;
	}

	createAll( s->display);
	updateElementTextures (s, TRUE);
	setupDisplayList (eScreen);
	WRAP (eScreen, s, paintOutput, elementsPaintOutput);
	WRAP (eScreen, s, drawWindow, elementsDrawWindow);
	eScreen->timeoutHandle = compAddTimeout (elementsGetUpdateDelay (s->display),
							elementsGetUpdateDelay (s->display),
Example #13
0
static void
wsnamesHandleEvent (XEvent      *event)
{
	WSNAMES_DISPLAY (&display);

	UNWRAP (wd, &display, handleEvent);
	(*display.handleEvent) (event);
	WRAP (wd, &display, handleEvent, wsnamesHandleEvent);

	switch (event->type) {
	case PropertyNotify:
		if (event->xproperty.atom == display.desktopViewportAtom)
		{
			CompScreen *s;
			s = findScreenAtDisplay (event->xproperty.window);
			if (s)
			{
				int timeout;

				WSNAMES_SCREEN (s);

				ws->timer = 0;
				if (ws->timeoutHandle)
					compRemoveTimeout (ws->timeoutHandle);

				const BananaValue *
				option_display_time = bananaGetOption (bananaIndex,
				                                       "display_time",
				                                       s->screenNum);

				wsnamesRenderNameText (s);
				timeout = option_display_time->f * 1000;
				ws->timeoutHandle = compAddTimeout (timeout, timeout + 200,
				                                    wsnamesHideTimeout, s);

				damageScreen (s);
			}
		}
		break;
	}
}
static Bool
snowInitScreen (CompPlugin *p,
		CompScreen *s)
{
    SnowScreen *ss;
    int        i, numFlakes = starGetNumSnowflakes (s->display);
    SnowFlake  *snowFlake;

    SNOW_DISPLAY (s->display);

    ss = calloc (1, sizeof(SnowScreen));

    s->base.privates[sd->screenPrivateIndex].ptr = ss;

    ss->s = s;
    ss->snowTexturesLoaded = 0;
    ss->snowTex = NULL;
    ss->active = FALSE;
    ss->displayListNeedsUpdate = FALSE;

    ss->allSnowFlakes = snowFlake = malloc (numFlakes * sizeof (SnowFlake));

    for (i = 0; i < numFlakes; i++)
    {
	initiateSnowFlake (ss, snowFlake);
	setSnowflakeTexture (ss, snowFlake);
	snowFlake++;
    }

    updateSnowTextures (s);
    setupDisplayList (ss);

    WRAP (ss, s, paintOutput, snowPaintOutput);
    WRAP (ss, s, drawWindow, snowDrawWindow);

    ss->timeoutHandle = compAddTimeout (starGetSnowUpdateDelay (s->display),
					starGetSnowUpdateDelay (s->display) * 1.2, stepSnowPositions, s);

    return TRUE;
}
void
groupEnqueueGrabNotify (CompWindow   *w,
			int          x,
			int          y,
			unsigned int state,
			unsigned int mask)
{
    GroupPendingGrabs *grab;

    GROUP_SCREEN (w->screen);

    grab = malloc (sizeof (GroupPendingGrabs));
    if (!grab)
	return;

    grab->w = w;
    grab->x = x;
    grab->y = y;

    grab->state = state;
    grab->mask  = mask;
    grab->next  = NULL;

    if (gs->pendingGrabs)
    {
	GroupPendingGrabs *temp;
	for (temp = gs->pendingGrabs; temp->next; temp = temp->next);

	temp->next = grab;
    }
    else
	gs->pendingGrabs = grab;

    if (!gs->dequeueTimeoutHandle)
    {
	gs->dequeueTimeoutHandle =
	    compAddTimeout (0, 0, groupDequeueTimer, (void *) w->screen);
    }
}
void
groupEnqueueMoveNotify (CompWindow *w,
			int        dx,
			int        dy,
			Bool       immediate,
			Bool       sync)
{
    GroupPendingMoves *move;

    GROUP_SCREEN (w->screen);

    move = malloc (sizeof (GroupPendingMoves));
    if (!move)
	return;

    move->w  = w;
    move->dx = dx;
    move->dy = dy;

    move->immediate = immediate;
    move->sync      = sync;
    move->next      = NULL;

    if (gs->pendingMoves)
    {
	GroupPendingMoves *temp;
	for (temp = gs->pendingMoves; temp->next; temp = temp->next);

	temp->next = move;
    }
    else
	gs->pendingMoves = move;

    if (!gs->dequeueTimeoutHandle)
    {
	gs->dequeueTimeoutHandle =
	    compAddTimeout (0, 0, groupDequeueTimer, (void *) w->screen);
    }
}
Example #17
0
static void
decorWindowResizeNotify (CompWindow *w,
			 int	    dx,
			 int	    dy,
			 int	    dwidth,
			 int	    dheight)
{
    DECOR_SCREEN (w->screen);
    DECOR_WINDOW (w);

    /* FIXME: we should not need a timer for calling decorWindowUpdate,
       and only call updateWindowDecorationScale if decorWindowUpdate
       returns FALSE. Unfortunately, decorWindowUpdate may call
       updateWindowOutputExtents, which may call WindowResizeNotify. As
       we never should call a wrapped function that's currently
       processed, we need the timer for the moment. updateWindowOutputExtents
       should be fixed so that it does not emit a resize notification. */
    dw->resizeUpdateHandle = compAddTimeout (0, 0, decorResizeUpdateTimeout, w);
    updateWindowDecorationScale (w);

    UNWRAP (ds, w->screen, windowResizeNotify);
    (*w->screen->windowResizeNotify) (w, dx, dy, dwidth, dheight);
    WRAP (ds, w->screen, windowResizeNotify, decorWindowResizeNotify);
}
Example #18
0
static void
snowChangeNotify (const char        *optionName,
                  BananaType        optionType,
                  const BananaValue *optionValue,
                  int               screenNum)
{
	SNOW_DISPLAY (&display);

	if (strcasecmp (optionName, "snow_size") == 0)
	{
		CompScreen *s;

		for (s = display.screens; s; s = s->next)
		{
			SNOW_SCREEN (s);
			ss->displayListNeedsUpdate = TRUE;
			updateSnowTextures (s);
		}
	}
	else if (strcasecmp (optionName, "snow_update_delay") == 0)
	{
		CompScreen *s;

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

			if (ss->timeoutHandle)
				compRemoveTimeout (ss->timeoutHandle);
			ss->timeoutHandle =
			    compAddTimeout (optionValue->i,
			            (float) optionValue->i * 1.2,
			            stepSnowPositions, s);
		}
	}
	else if (strcasecmp (optionName, "num_snowflakes") == 0)
	{
		CompScreen *s;
		int        i, numFlakes;
		SnowFlake  *snowFlake;

		numFlakes = optionValue->i;
		for (s = display.screens; s; s = s->next)
		{
			SNOW_SCREEN (s);
			ss->allSnowFlakes = realloc (ss->allSnowFlakes,
			                             numFlakes * sizeof (SnowFlake));
			snowFlake = ss->allSnowFlakes;

			for (i = 0; i < numFlakes; i++)
			{
				initiateSnowFlake (ss, snowFlake);
				setSnowflakeTexture (ss, snowFlake);
				snowFlake++;
			}
		}
	}
	else if (strcasecmp (optionName, "snow_textures") == 0)
	{
		CompScreen *s;

		for (s = display.screens; s; s = s->next)
			updateSnowTextures (s);
	}
	else if (strcasecmp (optionName, "toggle_key") == 0)
		updateKey (optionValue->s, &sd->toggle_key);

}
Example #19
0
/* Takes the inital event.
 * If we were configured, recalculate the opacify-windows if
 * it was our window.
 * If a window was entered: call upon handle_timeout after od->timeout
 * micro seconds, or directly if od->timeout is 0 (no delay).
 *
 */
static void
opacifyHandleEvent (XEvent      *event)
{
	CompScreen *s;

	OPACIFY_DISPLAY (&display);

	UNWRAP (od, &display, handleEvent);
	(display.handleEvent) (event);
	WRAP (od, &display, handleEvent, opacifyHandleEvent);

	switch (event->type) {
	case EnterNotify:
		if (!od->toggle)
			return;

		s = findScreenAtDisplay (event->xcrossing.root);

		if (s)
		{
			Window id;

			OPACIFY_SCREEN (s);

			id = event->xcrossing.window;
			os->newActive = findTopLevelWindowAtScreen (s, id);

			if (od->timeoutHandle)
				compRemoveTimeout (od->timeoutHandle);

			const BananaValue *
			option_timeout = bananaGetOption (bananaIndex,
			                                  "timeout",
			                                  -1);

			if (checkDelay (s))
				handleTimeout (s);
			else
				od->timeoutHandle = compAddTimeout (option_timeout->i,
				                                    (float)
				                                    option_timeout->i * 1.2,
				                                    handleTimeout, s);
		}
		break;
	case ConfigureNotify:
		if (!od->toggle)
			return;

		s = findScreenAtDisplay (event->xconfigure.event);
		if (s)
		{
			OPACIFY_SCREEN (s);

			if (os->active != event->xconfigure.window)
				break;

			clearPassive (s);
			if (os->active)
			{
				CompWindow *w;

				w = findWindowAtScreen (s, os->active);
				if (w)
					passiveWindows (s, w->region);
			}
		}
	case KeyPress:
		if (isKeyPressEvent (event, &od->toggle_key))
			opacifyToggle ();

		break;
	default:
		break;
	}
}
static void
snowDisplayOptionChanged (CompDisplay        *d,
			  CompOption         *opt,
			  StarDisplayOptions num)
{
    SNOW_DISPLAY (d);

    switch (num)
    {
    case StarDisplayOptionSnowSize:
	{
	    CompScreen *s;

	    for (s = d->screens; s; s = s->next)
	    {
		SNOW_SCREEN (s);
		ss->displayListNeedsUpdate = TRUE;
		updateSnowTextures (s);
	    }
	}
	break;
    case StarDisplayOptionSnowUpdateDelay:
	{
	    CompScreen *s;

	    for (s = d->screens; s; s = s->next)
	    {
		SNOW_SCREEN (s);

		if (ss->timeoutHandle)
		    compRemoveTimeout (ss->timeoutHandle);
		ss->timeoutHandle =
		    compAddTimeout (starGetSnowUpdateDelay (d),
									   starGetSnowUpdateDelay (d) *1.2,  stepSnowPositions, s);
	    }
	}
	break;
    case StarDisplayOptionNumSnowflakes:
	{
	    CompScreen *s;
	    int        i, numFlakes;
	    SnowFlake  *snowFlake;

	    numFlakes = starGetNumSnowflakes (d);
	    for (s = d->screens; s; s = s->next)
	    {
		SNOW_SCREEN (s);
		ss->allSnowFlakes = realloc (ss->allSnowFlakes,
					     numFlakes * sizeof (SnowFlake));
		snowFlake = ss->allSnowFlakes;

		for (i = 0; i < numFlakes; i++)
		{
		    initiateSnowFlake (ss, snowFlake);
		    setSnowflakeTexture (ss, snowFlake);
		    snowFlake++;
		}
	    }
	}
	break;
    case StarDisplayOptionSnowTextures:
	{
	    CompScreen *s;
	    CompOption *texOpt;

	    texOpt = starGetSnowTexturesOption (d);

	    sd->snowTexFiles = texOpt->value.list.value;
	    sd->snowTexNFiles = texOpt->value.list.nValue;

	    for (s = d->screens; s; s = s->next)
		updateSnowTextures (s);
	}
	break;
    default:
	break;
    }
}
Example #21
0
/*
 * groupHandleEvent
 *
 */
void
groupHandleEvent (XEvent *event)
{
	CompWindow *w;
	CompScreen *s;

	GROUP_DISPLAY (&display);

	switch (event->type) {
	case KeyPress:
		if (isKeyPressEvent (event, &gd->select_single_key))
			groupSelectSingle (display.activeWindow);

		else if (isKeyPressEvent (event, &gd->group_key))
			groupGroupWindows (event->xkey.root);

		else if (isKeyPressEvent (event, &gd->ungroup_key))
			groupUnGroupWindows (event->xkey.root);

		else if (isKeyPressEvent (event, &gd->remove_key))
			groupRemoveWindow (display.activeWindow);

		else if (isKeyPressEvent (event, &gd->close_key))
			groupCloseWindows (display.activeWindow);

		else if (isKeyPressEvent (event, &gd->ignore_key))
			groupSetIgnore ();

		else if (isKeyPressEvent (event, &gd->tabmode_key))
			groupInitTab (display.activeWindow);

		else if (isKeyPressEvent (event, &gd->change_tab_left_key))
			groupChangeTabLeft (display.activeWindow);

		else if (isKeyPressEvent (event, &gd->change_tab_right_key))
			groupChangeTabRight (display.activeWindow);

		else if (isKeyPressEvent (event, &gd->change_color_key))
			groupChangeColor (display.activeWindow);

		break;
	case KeyRelease:
		if (gd->ignore_key.keycode == event->xkey.keycode)
			groupUnsetIgnore ();
		break;

	case MotionNotify:
		s = findScreenAtDisplay (event->xmotion.root);
		if (s)
			groupHandleMotionEvent (s, pointerX, pointerY);
		break;

	case ButtonPress:
		if (isButtonPressEvent (event, &gd->select_button))
			groupSelect (event->xbutton.window);

		s = findScreenAtDisplay (event->xbutton.root);
		if (s)
			groupHandleButtonPressEvent (s, event);
		break;

	case ButtonRelease:
		if (gd->select_button.button == event->xbutton.button)
			groupSelectTerminate (event->xbutton.root);

		s = findScreenAtDisplay (event->xbutton.root);
		if (s)
			groupHandleButtonReleaseEvent (s, event);
		break;

	case MapNotify:
		w = findWindowAtDisplay (event->xmap.window);
		if (w)
		{
			CompWindow *cw;
			for (cw = w->screen->windows; cw; cw = cw->next)
			{
				if (w->id == cw->frame)
				{
					GROUP_WINDOW (cw);
					if (gw->windowHideInfo)
						XUnmapWindow (display.display, cw->frame);
				}
			}
		}
		break;

	case UnmapNotify:
		w = findWindowAtDisplay (event->xunmap.window);
		if (w)
		{
			GROUP_WINDOW (w);

			if (w->pendingUnmaps)
			{
				if (w->shaded)
				{
					gw->windowState = WindowShaded;

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

					if (gw->group && option_shade_all->b)
						groupShadeWindows (w, gw->group, TRUE);
				}
				else if (w->minimized)
				{
					gw->windowState = WindowMinimized;

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

					if (gw->group && option_minimize_all->b)
						groupMinimizeWindows (w, gw->group, TRUE);
				}
			}

			if (gw->group)
			{
				if (gw->group->tabBar && IS_TOP_TAB (w, gw->group))
				{
					/* on unmap of the top tab, hide the tab bar and the
					   input prevention window */
					groupTabSetVisibility (gw->group, FALSE, PERMANENT);
				}
				if (!w->pendingUnmaps)
				{
					/* close event */
					if (!(gw->animateState & IS_UNGROUPING))
					{
						groupDeleteGroupWindow (w);
						damageScreen (w->screen);
					}
				}
			}
		}
		break;

	case ClientMessage:
		if (event->xclient.message_type == display.winActiveAtom)
		{
			w = findWindowAtDisplay (event->xclient.window);
			if (w)
			{
				GROUP_WINDOW (w);

				if (gw->group && gw->group->tabBar &&
				    !IS_TOP_TAB (w, gw->group))
				{
					gw->group->checkFocusAfterTabChange = TRUE;
					groupChangeTab (gw->slot, RotateUncertain);
				}
			}
		}
		else if (event->xclient.message_type == gd->resizeNotifyAtom)
		{
			CompWindow *w;
			w = findWindowAtDisplay (event->xclient.window);

			if (w && gd->resizeInfo && (w == gd->resizeInfo->resizedWindow))
			{
				GROUP_WINDOW (w);
				GROUP_SCREEN (w->screen);

				if (gw->group)
				{
					int i;
					XRectangle rect;

					rect.x      = event->xclient.data.l[0];
					rect.y      = event->xclient.data.l[1];
					rect.width  = event->xclient.data.l[2];
					rect.height = event->xclient.data.l[3];

					for (i = 0; i < gw->group->nWins; i++)
					{
						CompWindow  *cw = gw->group->windows[i];
						GroupWindow *gcw;

						gcw = GET_GROUP_WINDOW (cw, gs);
						if (gcw->resizeGeometry)
						{
							if (groupUpdateResizeRectangle (cw, &rect, TRUE))
								addWindowDamage (cw);
						}
					}
				}
			}
		}
		break;

	default:
		if (event->type == display.shapeEvent + ShapeNotify)
		{
			XShapeEvent *se = (XShapeEvent *) event;
			if (se->kind == ShapeInput)
			{
				CompWindow *w;
				w = findWindowAtDisplay (se->window);
				if (w)
				{
					GROUP_WINDOW (w);

					if (gw->windowHideInfo)
						groupClearWindowInputShape (w, gw->windowHideInfo);
				}
			}
		}
		break;
	}

	UNWRAP (gd, &display, handleEvent);
	(*display.handleEvent)(event);
	WRAP (gd, &display, handleEvent, groupHandleEvent);

	switch (event->type) {
	case PropertyNotify:
		if (event->xproperty.atom == display.wmNameAtom)
		{
			CompWindow *w;
			w = findWindowAtDisplay (event->xproperty.window);
			if (w)
			{
				GROUP_WINDOW (w);

				if (gw->group && gw->group->tabBar &&
				    gw->group->tabBar->textSlot    &&
				    gw->group->tabBar->textSlot->window == w)
				{
					/* make sure we are using the updated name */
					groupRenderWindowTitle (gw->group);
					groupDamageTabBarRegion (gw->group);
				}
			}
		}
		break;

	case EnterNotify:
	{
		CompWindow *w;
		w = findWindowAtDisplay (event->xcrossing.window);
		if (w)
		{
			GROUP_WINDOW (w);
			GROUP_SCREEN (w->screen);

			if (gs->showDelayTimeoutHandle)
				compRemoveTimeout (gs->showDelayTimeoutHandle);

			if (w->id != w->screen->grabWindow)
				groupUpdateTabBars (w->screen, w->id);

			if (gw->group)
			{
				if (gs->draggedSlot && gs->dragged &&
				    IS_TOP_TAB (w, gw->group))
				{
					int hoverTime;

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

					hoverTime = option_drag_hover_time->f * 1000;
					if (gs->dragHoverTimeoutHandle)
						compRemoveTimeout (gs->dragHoverTimeoutHandle);

					if (hoverTime > 0)
						gs->dragHoverTimeoutHandle =
						        compAddTimeout (hoverTime,
						                        (float) hoverTime * 1.2,
						                        groupDragHoverTimeout, w);
				}
			}
		}
	}
	break;

	case ConfigureNotify:
	{
		CompWindow *w;

		w = findWindowAtDisplay (event->xconfigure.window);
		if (w)
		{
			GROUP_WINDOW (w);

			if (gw->group && gw->group->tabBar &&
			    IS_TOP_TAB (w, gw->group)      &&
			    gw->group->inputPrevention && gw->group->ipwMapped)
			{
				XWindowChanges xwc;

				xwc.stack_mode = Above;
				xwc.sibling = w->id;

				XConfigureWindow (display.display,
				                  gw->group->inputPrevention,
				                  CWSibling | CWStackMode, &xwc);
			}

			if (event->xconfigure.above != None)
			{
				if (gw->group && !gw->group->tabBar &&
				    (gw->group != gd->lastRestackedGroup))
				{
					const BananaValue *
					option_raise_all = bananaGetOption (bananaIndex,
					                                    "raise_all",
					                                    w->screen->screenNum);

					if (option_raise_all->b)
						groupRaiseWindows (w, gw->group);
				}
				if (w->managed && !w->attrib.override_redirect)
					gd->lastRestackedGroup = gw->group;
			}
		}
	}
	break;

	default:
		break;
	}
}
Example #22
0
static void
positionUpdate (CompScreen *s,
                int x,
                int y)
{
	CompWindow *cw    = s->windows;
	CompWindow *found = NULL;

	THUMB_SCREEN (s);

	for (; cw && !found; cw = cw->next)
	{
		if (cw->destroyed)
			continue;

		if (!cw->iconGeometrySet)
			continue;

		if (cw->attrib.map_state != IsViewable)
			continue;

		if (cw->state & CompWindowStateSkipTaskbarMask)
			continue;

		if (cw->state & CompWindowStateSkipPagerMask)
			continue;

		if (!cw->managed)
			continue;

		if (!cw->texture->pixmap)
			continue;

		if (x >= cw->iconGeometry.x                          &&
		    x < cw->iconGeometry.x + cw->iconGeometry.width  &&
		    y >= cw->iconGeometry.y                          &&
		    y < cw->iconGeometry.y + cw->iconGeometry.height &&
		    checkPosition (cw))
		{
			found = cw;

		}
	}

	if (found)
	{
		if (!ts->showingThumb &&
		    !(ts->thumb.opacity != 0.0 && ts->thumb.win == found))
		{
			const BananaValue *
			option_show_delay = bananaGetOption (bananaIndex,
			                                     "show_delay",
			                                     s->screenNum);

			if (ts->displayTimeout)
			{
				if (ts->pointedWin != found)
				{
					compRemoveTimeout (ts->displayTimeout);
					ts->displayTimeout =
					        compAddTimeout (option_show_delay->i,
					                        option_show_delay->i + 500,
					                        thumbShowThumbnail, s);
				}
			}
			else
			{
				ts->displayTimeout =
				        compAddTimeout (option_show_delay->i,
				                        option_show_delay->i + 500,
				                        thumbShowThumbnail, s);
			}
		}

		ts->pointedWin = found;
		thumbUpdateThumbnail (s);
	}
	else
	{
		if (ts->displayTimeout)
		{
			compRemoveTimeout (ts->displayTimeout);
			ts->displayTimeout = 0;
		}

		ts->pointedWin   = NULL;
		ts->showingThumb = FALSE;
	}
}
Example #23
0
/*
 * groupInitScreen
 *
 */
static Bool
groupInitScreen (CompPlugin *p,
                 CompScreen *s)
{
    GroupScreen       *gs;
    int glowType;

    GROUP_DISPLAY (&display);

    gs = malloc (sizeof (GroupScreen));
    if (!gs)
        return FALSE;

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

    WRAP (gs, s, windowMoveNotify, groupWindowMoveNotify);
    WRAP (gs, s, windowResizeNotify, groupWindowResizeNotify);
    WRAP (gs, s, getOutputExtentsForWindow, groupGetOutputExtentsForWindow);
    WRAP (gs, s, preparePaintScreen, groupPreparePaintScreen);
    WRAP (gs, s, paintOutput, groupPaintOutput);
    WRAP (gs, s, drawWindow, groupDrawWindow);
    WRAP (gs, s, paintWindow, groupPaintWindow);
    WRAP (gs, s, paintTransformedOutput, groupPaintTransformedOutput);
    WRAP (gs, s, donePaintScreen, groupDonePaintScreen);
    WRAP (gs, s, windowGrabNotify, groupWindowGrabNotify);
    WRAP (gs, s, windowUngrabNotify, groupWindowUngrabNotify);
    WRAP (gs, s, damageWindowRect, groupDamageWindowRect);
    WRAP (gs, s, windowStateChangeNotify, groupWindowStateChangeNotify);
    WRAP (gs, s, activateWindow, groupActivateWindow);

    s->privates[gd->screenPrivateIndex].ptr = gs;

    gs->groups = NULL;

    gs->tmpSel.windows = NULL;
    gs->tmpSel.nWins   = 0;

    gs->grabIndex = 0;
    gs->grabState = ScreenGrabNone;

    gs->lastHoveredGroup = NULL;

    gs->queued          = FALSE;
    gs->pendingMoves    = NULL;
    gs->pendingGrabs    = NULL;
    gs->pendingUngrabs  = NULL;

    gs->dequeueTimeoutHandle = 0;

    gs->draggedSlot            = NULL;
    gs->dragged                = FALSE;
    gs->dragHoverTimeoutHandle = 0;

    gs->prevX = 0;
    gs->prevY = 0;

    gs->showDelayTimeoutHandle = 0;

    /* one-shot timeout for stuff that needs to be initialized after
       all screens and windows are initialized */
    gs->initialActionsTimeoutHandle =
        compAddTimeout (0, 0, groupApplyInitialActions, (void *) s);

    initTexture (s, &gs->glowTexture);

    const BananaValue *
    option_glow_type = bananaGetOption (bananaIndex,
                                        "glow_type",
                                        s->screenNum);

    glowType = option_glow_type->i;
    imageDataToTexture (s, &gs->glowTexture,
                        glowTextureProperties[glowType].textureData,
                        glowTextureProperties[glowType].textureSize,
                        glowTextureProperties[glowType].textureSize,
                        GL_RGBA, GL_UNSIGNED_BYTE);

    const BananaValue *
    option_window_match = bananaGetOption (bananaIndex,
                                           "window_match",
                                           s->screenNum);

    matchInit (&gs->window_match);
    matchAddFromString (&gs->window_match, option_window_match->s);
    matchUpdate (&gs->window_match);

    const BananaValue *
    option_autotab_windows = bananaGetOption (bananaIndex,
                             "autotab_windows",
                             s->screenNum);

    gs->autotabCount = option_autotab_windows->list.nItem;
    gs->autotab = malloc (gs->autotabCount * sizeof (CompMatch));

    int i;
    for (i = 0; i <= gs->autotabCount - 1; i++)
    {
        matchInit (&gs->autotab[i]);
        matchAddFromString (&gs->autotab[i],
                            option_autotab_windows->list.item[i].s);
        matchUpdate (&gs->autotab[i]);
    }

    return TRUE;
}
				}
	    		}
}

static void
elementsDisplayOptionChanged (CompDisplay        *d,
			  CompOption         *opt,
			  ElementsDisplayOptions num)
{
	E_DISPLAY (d);
	switch (num)
	{
		case ElementsDisplayOptionToggleAutumnCheck:
		{
			Bool useKeys;
			CompScreen *s;
			for (s = d->screens; s; s = s->next)
	    		{
				E_SCREEN (s);
				useKeys = eScreen->useKeys;
				if (!useKeys)
				{
					eScreen->isActive[0] = elementsGetToggleAutumnCheck(s->display);
					damageScreen (s);
					eScreen->needUpdate = TRUE;
				}
			}
			if (!useKeys)
				createAll( d );
		}
		break;
		case ElementsDisplayOptionToggleFirefliesCheck:
		{
			Bool useKeys;
			CompScreen *s;
			for (s = d->screens; s; s = s->next)
	    		{
				E_SCREEN (s);
				useKeys = eScreen->useKeys;
				if (!useKeys)
				{
					eScreen->isActive[1] = elementsGetToggleFirefliesCheck(s->display);
					damageScreen (s);
					eScreen->needUpdate = TRUE;
				}
			}
			if (!useKeys)
				createAll( d );
		}
		break;
		case ElementsDisplayOptionToggleSnowCheck:
		{
			Bool useKeys;
			CompScreen *s;
			for (s = d->screens; s; s = s->next)
	    		{
				E_SCREEN (s);
				useKeys = eScreen->useKeys;
				if (!useKeys)
				{
					eScreen->isActive[2] = elementsGetToggleSnowCheck(s->display);
					damageScreen (s);
					eScreen->needUpdate = TRUE;
				}
			}
			if (!useKeys)
			createAll( d );
		}
		break;
		case ElementsDisplayOptionToggleStarsCheck:
		{
			Bool useKeys;
			CompScreen *s;
			for (s = d->screens; s; s = s->next)
	    		{
				E_SCREEN (s);
				useKeys = eScreen->useKeys;
				if (!useKeys)
				{
					eScreen->isActive[3] = elementsGetToggleStarsCheck(s->display);
					damageScreen (s);
					eScreen->needUpdate = TRUE;
				}
			}
			if (!useKeys)
				createAll( d );
		}
		break;
		case ElementsDisplayOptionToggleBubblesCheck:
		{
			Bool useKeys;
			CompScreen *s;
			for (s = d->screens; s; s = s->next)
	    		{
				E_SCREEN (s);
				useKeys = eScreen->useKeys;
				if (!useKeys)
				{
					eScreen->isActive[4] = elementsGetToggleBubblesCheck(s->display);
					damageScreen (s);
					eScreen->needUpdate = TRUE;
				}
			}
			if (!useKeys)
			createAll( d );
		}
		break;
		case ElementsDisplayOptionToggle:
		{
			CompScreen *s;

			for (s = d->screens; s; s = s->next)
	    		{
				E_SCREEN (s);
				eScreen->useKeys = elementsGetToggle(d);
				if (!eScreen->useKeys)
				{
					eScreen->isActive[0] = elementsGetToggleAutumnCheck(s->display);
					eScreen->isActive[1] = elementsGetToggleFirefliesCheck(s->display);
					eScreen->isActive[2] = elementsGetToggleSnowCheck(s->display);
					eScreen->isActive[3] = elementsGetToggleStarsCheck(s->display);
					eScreen->isActive[4] = elementsGetToggleBubblesCheck(s->display);
					createAll( d);
				}
				damageScreen (s);
			}
		}
		break;
		case ElementsDisplayOptionLeafSize:
		{
			CompScreen *s;

			for (s = d->screens; s; s = s->next)
	    		{
				E_SCREEN (s);
				eScreen->needUpdate = TRUE;
				updateElementTextures (s, FALSE);
		    	}
		}
		break;
		case ElementsDisplayOptionBubblesSize:
		{
			CompScreen *s;

			for (s = d->screens; s; s = s->next)
	    		{
				E_SCREEN (s);
				eScreen->needUpdate = TRUE;
				updateElementTextures (s, FALSE);
		    	}
		}

		break;
    		case ElementsDisplayOptionSnowSize:
		{
			CompScreen *s;

			for (s = d->screens; s; s = s->next)
			{
				E_SCREEN (s);
				eScreen->needUpdate = TRUE;
				updateElementTextures (s, FALSE);
			}
		}
		break;
    		case ElementsDisplayOptionSnowSway:
		{
			createAll( d );
		}
		break;
		case ElementsDisplayOptionStarsSize:
		{
			CompScreen *s;

			for (s = d->screens; s; s = s->next)
			{
				E_SCREEN (s);
				eScreen->needUpdate = TRUE;
				updateElementTextures (s, FALSE);
			}
		}
		break;
		case ElementsDisplayOptionFireflySize:
		{
			CompScreen *s;
			for (s = d->screens; s; s = s->next)
	    		{
				E_SCREEN (s);
				eScreen->needUpdate = TRUE;
				updateElementTextures (s, FALSE);
	    		}	
		}
		break;
    		case ElementsDisplayOptionUpdateDelay:
		{
			CompScreen *s;

	   		for (s = d->screens; s; s = s->next)
	   	 	{
			E_SCREEN (s);
					
			if (eScreen->timeoutHandle)
		  	  	compRemoveTimeout (eScreen->timeoutHandle);
				eScreen->timeoutHandle =
					compAddTimeout (elementsGetUpdateDelay (d),
							elementsGetUpdateDelay (d),
							stepPositions, s);
			}
		}
		break;
   		case ElementsDisplayOptionNumLeaves:
		{
			createAll( d );
		}
		break;
 		case ElementsDisplayOptionNumBubbles:
		{
			createAll( d );
		}
		break;

  		case ElementsDisplayOptionAutumnSway:
		{
			createAll( d );
		}
		break;
		case ElementsDisplayOptionNumFireflies:
		{
			createAll( d );
		}
		break;
		case ElementsDisplayOptionNumSnowflakes:
		{
			createAll( d );
		}
		break;
		case ElementsDisplayOptionNumStars:
		{
			createAll( d );
		}
		break;
		case ElementsDisplayOptionLeafTextures:
		{
			CompScreen *s;
			CompOption *texAutOpt;
			texAutOpt = elementsGetLeafTexturesOption (d);
			ed->texFiles[0] = texAutOpt->value.list.value;
			ed->numTex[0] = texAutOpt->value.list.nValue;
			for (s = d->screens; s; s = s->next)
				updateElementTextures (s, TRUE);
		}
		break;
		case ElementsDisplayOptionBubblesTextures:
		{
			CompScreen *s;
			CompOption *texBubblesOpt;
			texBubblesOpt = elementsGetBubblesTexturesOption (d);
			ed->texFiles[4] = texBubblesOpt->value.list.value;
			ed->numTex[4] = texBubblesOpt->value.list.nValue;
			for (s = d->screens; s; s = s->next)
				updateElementTextures (s, TRUE);
		}
		break;
		case ElementsDisplayOptionFirefliesTextures:
		{
			CompScreen *s;
			CompOption *texFfOpt;

			texFfOpt = elementsGetFirefliesTexturesOption (d);

			ed->texFiles[1] = texFfOpt->value.list.value;
			ed->numTex[1] = texFfOpt->value.list.nValue;

			for (s = d->screens; s; s = s->next)
				updateElementTextures (s, TRUE);
		}
		break;
		case ElementsDisplayOptionSnowTextures:
		{
			CompScreen *s;
			CompOption *texSnowOpt;

			texSnowOpt = elementsGetSnowTexturesOption (d);

			ed->texFiles[2] = texSnowOpt->value.list.value;
			ed->numTex[2] = texSnowOpt->value.list.nValue;

			for (s = d->screens; s; s = s->next)
				updateElementTextures (s, TRUE);
		}
		break;
		case ElementsDisplayOptionStarsTextures:
		{
			CompScreen *s;
			CompOption *texStarsOpt;

			texStarsOpt = elementsGetStarsTexturesOption (d);
			ed->texFiles[3] = texStarsOpt->value.list.value;
			ed->numTex[3] = texStarsOpt->value.list.nValue;

			for (s = d->screens; s; s = s->next)
				updateElementTextures (s, TRUE);

		}
		break;
static Bool
ccpInitCore (CompPlugin *p,
	     CompCore   *c)
{
    CCPCore *cc;
    CompObject  *o;

    int i;
    unsigned int *screens;

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

    cc = malloc (sizeof (CCPCore));
    if (!cc)
	return FALSE;

    ccsSetBasicMetadata (TRUE);

    o = compObjectFind (&core.base, COMP_OBJECT_TYPE_DISPLAY, NULL);

    if (o)
    {
	CompScreen *s;
	CORE_DISPLAY (o);
	
	for (s = d->screens, i = 0; s; s = s->next, i++);

	screens = calloc (i, sizeof (unsigned int));
	if (!screens)
	{
	    free (cc);
	    return FALSE;
	}

	for (s = d->screens, i = 0; s; s = s->next)
	    screens[i++] = s->screenNum;

	cc->context = ccsContextNew (screens, i);

	free (screens);
    }
    else
	cc->context = ccsContextNew (NULL, 0);

    if (!cc->context)
    {
	free (cc);
	return FALSE;
    }

    ccsReadSettings (cc->context);

    cc->context->changedSettings =
	ccsSettingListFree (cc->context->changedSettings, FALSE);

    cc->applyingSettings = FALSE;

    cc->reloadHandle = compAddTimeout (0, 0, ccpReload, 0);
    cc->timeoutHandle = compAddTimeout (CCP_UPDATE_MIN_TIMEOUT,
					CCP_UPDATE_MAX_TIMEOUT,
					ccpTimeout, 0);

    core.base.privates[corePrivateIndex].ptr = cc;

    WRAP (cc, c, initPluginForObject, ccpInitPluginForObject);
    WRAP (cc, c, setOptionForPlugin, ccpSetOptionForPlugin);

    return TRUE;
}
Example #26
0
static void
kconfigSetOption (CompObject *object,
		  CompOption *o,
		  const char *plugin)
{
    QString group (QString (plugin) + "_" + kconfigObjectString (object));

    KCONFIG_CORE (&core);

    kc->config->setGroup (group);

    switch (o->type) {
    case CompOptionTypeBool:
    case CompOptionTypeBell:
	kc->config->writeEntry (o->name,
				kconfigValueToBool (o->type, &o->value));
	break;
    case CompOptionTypeInt:
	kc->config->writeEntry (o->name, o->value.i);
	break;
    case CompOptionTypeFloat:
	kc->config->writeEntry (o->name, (double) o->value.f);
	break;
    case CompOptionTypeString:
    case CompOptionTypeColor:
    case CompOptionTypeKey:
    case CompOptionTypeButton:
    case CompOptionTypeEdge:
    case CompOptionTypeMatch:
	kc->config->writeEntry (o->name,
				kconfigValueToString (object, o->type,
						      &o->value));
	break;
    case CompOptionTypeList: {
	int i;

	switch (o->value.list.type) {
	case CompOptionTypeInt: {
	    QValueList< int > list;

	    for (i = 0; i < o->value.list.nValue; i++)
		list += o->value.list.value[i].i;

	    kc->config->writeEntry (o->name, list);
	} break;
	case CompOptionTypeBool:
	case CompOptionTypeFloat:
	case CompOptionTypeString:
	case CompOptionTypeColor:
	case CompOptionTypeKey:
	case CompOptionTypeButton:
	case CompOptionTypeEdge:
	case CompOptionTypeBell:
	case CompOptionTypeMatch: {
	    QStringList list;

	    for (i = 0; i < o->value.list.nValue; i++)
		list += kconfigValueToString (object,
					      o->value.list.type,
					      &o->value.list.value[i]);

	    kc->config->writeEntry (o->name, list);
	} break;
	case CompOptionTypeAction:
	case CompOptionTypeList:
	    break;
	}
    } break;
    case CompOptionTypeAction:
	return;
    }

    if (!kc->syncHandle)
	kc->syncHandle = compAddTimeout (0, 0, kconfigRcSync, 0);
}
Example #27
0
static void
scalefilterHandleKeyPress (CompScreen *s,
			   XKeyEvent  *event)
{
    ScaleFilterInfo *info;
    Bool            needRelayout = FALSE;
    Bool            dropKeyEvent = FALSE;
    int             count, timeout;
    char            buffer[10];
    wchar_t         wbuffer[10];
    KeySym          ks;

    FILTER_DISPLAY (s->display);
    FILTER_SCREEN (s);
    SCALE_SCREEN (s);

    info = fs->filterInfo;
    memset (buffer, 0, sizeof (buffer));
    memset (wbuffer, 0, sizeof (wbuffer));

    if (fd->xic)
    {
	Status status;

	XSetICFocus (fd->xic);
	count = Xutf8LookupString (fd->xic, event, buffer, 9, &ks, &status);
	XUnsetICFocus (fd->xic);
    }
    else
    {
	count = XLookupString (event, buffer, 9, &ks, NULL);
    }

    mbstowcs (wbuffer, buffer, 9);

    if (ks == XK_Escape)
    {
	if (info)
	{
	    /* Escape key - drop current filter */
	    ss->currentMatch = info->origMatch;
	    scalefilterFiniFilterInfo (s, TRUE);
	    needRelayout = TRUE;
	    dropKeyEvent = TRUE;
	}
	else if (fs->matchApplied)
	{
	    /* remove filter applied previously
	       if currently not in input mode */
	    matchFini (&ss->match);
	    matchInit (&ss->match);
	    matchCopy (&ss->match, &fs->scaleMatch);
	    matchUpdate (s->display, &ss->match);

	    ss->currentMatch = &ss->match;
	    fs->matchApplied = FALSE;
	    needRelayout = TRUE;
	    dropKeyEvent = TRUE;
	}
    }
    else if (ks == XK_Return)
    {
	if (info)
	{
	    /* Return key - apply current filter persistently */
	    matchFini (&ss->match);
	    matchInit (&ss->match);
	    matchCopy (&ss->match, &info->match);
	    matchUpdate (s->display, &ss->match);

	    ss->currentMatch = &ss->match;
	    fs->matchApplied = TRUE;
	    dropKeyEvent = TRUE;
	    needRelayout = TRUE;
	    scalefilterFiniFilterInfo (s, TRUE);
	}
    }
    else if (ks == XK_BackSpace)
    {
	if (info && info->filterStringLength > 0)
	{
	    /* remove last character in string */
	    info->filterString[--(info->filterStringLength)] = '\0';
	    needRelayout = TRUE;
	}
    }
    else if (count > 0)
    {
	if (!info)
	{
	    fs->filterInfo = info = malloc (sizeof (ScaleFilterInfo));
	    scalefilterInitFilterInfo (s);
	}
	else if (info->timeoutHandle)
	    compRemoveTimeout (info->timeoutHandle);

	timeout = scalefilterGetTimeout (s);
	if (timeout > 0)
	    info->timeoutHandle = compAddTimeout (timeout,
				     		  scalefilterFilterTimeout, s);

	if (info->filterStringLength < MAX_FILTER_SIZE)
	{
	    info->filterString[info->filterStringLength++] = wbuffer[0];
	    info->filterString[info->filterStringLength] = '\0';
	    needRelayout = TRUE;
	}
    }

    /* set the event type invalid if we
       don't want other plugins see it */
    if (dropKeyEvent)
	event->type = LASTEvent+1;

    if (needRelayout)
    {
	scalefilterRenderFilterText (s);

	if (fs->filterInfo)
	    scalefilterUpdateFilter (s, &fs->filterInfo->match);

	scalefilterRelayout (s);
    }
}
Example #28
0
static Bool
snowInitScreen (CompPlugin *p,
                CompScreen *s)
{
	SnowScreen *ss;

	const BananaValue *
	option_num_snowflakes = bananaGetOption (bananaIndex,
	                                         "num_snowflakes",
	                                         -1);

	const BananaValue *
	option_snow_update_delay = bananaGetOption (bananaIndex,
	                                            "snow_update_delay",
	                                            -1);

	int        i, numFlakes = option_num_snowflakes->i;
	SnowFlake  *snowFlake;

	SNOW_DISPLAY (&display);

	ss = calloc (1, sizeof(SnowScreen));
	if (!ss)
		return FALSE;

	s->privates[sd->screenPrivateIndex].ptr = ss;

	ss->s = s;
	ss->snowTexturesLoaded = 0;
	ss->snowTex = NULL;
	ss->active = FALSE;
	ss->displayListNeedsUpdate = FALSE;

	ss->allSnowFlakes = snowFlake = malloc (numFlakes * sizeof (SnowFlake));
	if (!snowFlake)
	{
		free (ss);
		return FALSE;
	}

	for (i = 0; i < numFlakes; i++)
	{
		initiateSnowFlake (ss, snowFlake);
		setSnowflakeTexture (ss, snowFlake);
		snowFlake++;
	}

	updateSnowTextures (s);
	setupDisplayList (ss);

	WRAP (ss, s, paintOutput, snowPaintOutput);
	WRAP (ss, s, drawWindow, snowDrawWindow);

	ss->timeoutHandle = compAddTimeout (option_snow_update_delay->i,
	                (float)
	                option_snow_update_delay->i *
	                1.2,
	                stepSnowPositions, s);

	return TRUE;
}