示例#1
0
文件: scalefilter.c 项目: Elive/ecomp
static void
scalefilterInitFilterInfo (CompScreen *s)
{
    FILTER_SCREEN (s);
    SCALE_SCREEN (s);

    ScaleFilterInfo *info = fs->filterInfo;

    memset (info->filterString, 0, sizeof (info->filterString));
    info->filterStringLength = 0;

    info->textPixmap = None;
    info->textWidth  = 0;
    info->textHeight = 0;

    info->timeoutHandle = 0;

    info->outputDevice = s->currentOutputDev;

    initTexture (s, &info->textTexture);

    matchInit (&info->match);
    matchCopy (&info->match, &fs->scaleMatch);

    info->origMatch  = ss->currentMatch;
    ss->currentMatch = &info->match;
}
示例#2
0
文件: scalefilter.c 项目: Elive/ecomp
static void
scalefilterHandleEcompEvent (CompDisplay *d,
	 		      char        *pluginName,
	 		      char        *eventName,
	 		      CompOption  *option,
	 		      int         nOption)
{
    FILTER_DISPLAY (d);

    UNWRAP (fd, d, handleEcompEvent);
    (*d->handleEcompEvent) (d, pluginName, eventName, option, nOption);
    WRAP (fd, d, handleEcompEvent, scalefilterHandleEcompEvent);

    if ((strcmp (pluginName, "scale") == 0) &&
	(strcmp (eventName, "activate") == 0))
    {
	Window xid = getIntOptionNamed (option, nOption, "root", 0);
	Bool activated = getBoolOptionNamed (option, nOption, "active", FALSE);
	CompScreen *s = findScreenAtDisplay (d, xid);

	if (s)
	{
	    FILTER_SCREEN (s);
	    SCALE_SCREEN (s);

	    if (activated)
	    {
		matchFini (&fs->scaleMatch);
		matchInit (&fs->scaleMatch);
		matchCopy (&fs->scaleMatch, ss->currentMatch);
		matchUpdate (d, &fs->scaleMatch);
		fs->matchApplied = FALSE;
	    }

	    if (!activated)
	    {
		if (fs->filterInfo)
		{
		    ss->currentMatch = fs->filterInfo->origMatch;
		    scalefilterFiniFilterInfo (s, TRUE);
		}
		fs->matchApplied = FALSE;
	    }
	}
    }
}
示例#3
0
文件: fuse.c 项目: zmike/compiz
static Bool
fuseInitValue(CompOptionValue *value,
              CompOptionType type,
              CompOptionValue *src)
{
   switch (type)
     {
      case CompOptionTypeBool:
        value->b = src->b;
        break;

      case CompOptionTypeInt:
        value->i = src->i;
        break;

      case CompOptionTypeFloat:
        value->f = src->f;
        break;

      case CompOptionTypeString:
        value->s = strdup(src->s);
        break;

      case CompOptionTypeColor:
        memcpy(value->c, src->c, sizeof (*src->c));
        break;

      case CompOptionTypeKey:
      case CompOptionTypeButton:
      case CompOptionTypeEdge:
      case CompOptionTypeBell:
        value->action = src->action;
        break;

      case CompOptionTypeMatch:
        matchInit(&value->match);
        matchCopy(&value->match, &src->match);
        break;

      default:
        return FALSE;
     }

   return TRUE;
}
示例#4
0
Bool compSetMatchOption(CompOption * option, CompOptionValue * value)
{
	CompDisplay *display = option->value.match.display;
	CompMatch match;

	if (matchEqual(&option->value.match, &value->match))
		return FALSE;

	if (!matchCopy(&match, &value->match))
		return FALSE;

	matchFini(&option->value.match);

	option->value.match.op = match.op;
	option->value.match.nOp = match.nOp;

	if (display)
		matchUpdate(display, &option->value.match);

	return TRUE;
}
示例#5
0
文件: scalefilter.c 项目: Elive/ecomp
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);
    }
}
static Bool
ringInitiate (CompScreen      *s,
 	      CompAction      *action,
	      CompActionState state,
	      CompOption      *option,
	      int	      nOption)
{
    CompMatch *match;
    int       count; 

    RING_SCREEN (s);

    if (otherScreenGrabExist (s, "ring", NULL))
	return FALSE;
	   
    rs->currentMatch = ringGetWindowMatch (s);

    match = getMatchOptionNamed (option, nOption, "match", NULL);
    if (match)
    {
	matchFini (&rs->match);
	matchInit (&rs->match);
	if (matchCopy (&rs->match, match))
	{
	    matchUpdate (s->display, &rs->match);
	    rs->currentMatch = &rs->match;
	}
    }

    count = ringCountWindows (s);

    if (count < 1)
	return FALSE;

    if (!rs->grabIndex)
    {
	if (ringGetSelectWithMouse (s))
	    rs->grabIndex = pushScreenGrab (s, s->normalCursor, "ring");
	else
	    rs->grabIndex = pushScreenGrab (s, s->invisibleCursor, "ring");
    }

    if (rs->grabIndex)
    {
	rs->state = RingStateOut;

	if (!ringCreateWindowList (s))
	    return FALSE;

	rs->selectedWindow = rs->windows[0];
	ringRenderWindowTitle (s);
	rs->rotTarget = 0;

    	rs->moreAdjust = TRUE;
	damageScreen (s);

	switchActivateEvent (s, TRUE);
    }

    return TRUE;
}