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; }
static void opacifyChangeNotify (const char *optionName, BananaType optionType, const BananaValue *optionValue, int screenNum) { OPACIFY_DISPLAY (&display); if (strcasecmp (optionName, "toggle_key") == 0) updateKey (optionValue->s, &od->toggle_key); else if (strcasecmp (optionName, "init_toggle") == 0) od->toggle = optionValue->b; else if (strcasecmp (optionName, "window_match") == 0) { CompScreen *s = getScreenFromScreenNum (screenNum); OPACIFY_SCREEN (s); matchFini (&os->window_match); matchInit (&os->window_match); matchAddFromString (&os->window_match, optionValue->s); matchUpdate (&os->window_match); } }
static void scalefilterUpdateFilter (CompScreen *s, CompMatch *match) { char filterMatch[2 * MAX_FILTER_TEXT_LEN]; unsigned int offset; FILTER_SCREEN (s); matchFini (match); matchInit (match); if (scalefilterGetFilterCaseInsensitive (s)) { strncpy (filterMatch, "ititle=", MAX_FILTER_TEXT_LEN); offset = 7; } else { strncpy (filterMatch, "title=", MAX_FILTER_TEXT_LEN); offset = 6; } wcstombs (filterMatch + offset, fs->filterInfo->filterString, MAX_FILTER_STRING_LEN); matchAddExp (match, 0, filterMatch); matchAddGroup (match, MATCH_OP_AND_MASK, &fs->scaleMatch); matchUpdate (s->display, match); }
static Bool scalefilterInitScreen (CompPlugin *p, CompScreen *s) { ScaleFilterScreen *fs; FILTER_DISPLAY (s->display); SCALE_SCREEN (s); fs = malloc (sizeof (ScaleFilterScreen)); if (!fs) return FALSE; fs->filterInfo = NULL; matchInit (&fs->scaleMatch); fs->matchApplied = FALSE; WRAP (fs, s, paintOutput, scalefilterPaintOutput); WRAP (fs, ss, setScaledPaintAttributes, scalefilterSetScaledPaintAttributes); scalefilterSetFontBoldNotify (s, scalefilterScreenOptionChanged); scalefilterSetFontSizeNotify (s, scalefilterScreenOptionChanged); scalefilterSetFontColorNotify (s, scalefilterScreenOptionChanged); scalefilterSetBackColorNotify (s, scalefilterScreenOptionChanged); s->privates[fd->screenPrivateIndex].ptr = fs; return TRUE; }
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; }
static void minChangeNotify (const char *optionName, BananaType optionType, const BananaValue *optionValue, int screenNum) { CompScreen *screen = getScreenFromScreenNum (screenNum); MIN_SCREEN (screen); if (strcasecmp (optionName, "shade_resistance") == 0) { if (optionValue->i) ms->shadeStep = 100 - optionValue->i + 1; else ms->shadeStep = 0; } else if (strcasecmp (optionName, "window_match") == 0) { matchFini (&ms->match); matchInit (&ms->match); matchAddFromString (&ms->match, optionValue->s); matchUpdate (&ms->match); } }
static Bool kconfigStringToValue (CompObject *object, QString str, CompOptionType type, CompOptionValue *value) { switch (type) { case CompOptionTypeBool: value->b = str.toInt () ? TRUE : FALSE; break; case CompOptionTypeFloat: value->f = str.toFloat (); break; case CompOptionTypeString: value->s = strdup (str.ascii ()); if (!value->s) return FALSE; break; case CompOptionTypeColor: if (!stringToColor (str.ascii (), value->c)) return FALSE; break; case CompOptionTypeKey: while (object && object->type != COMP_OBJECT_TYPE_DISPLAY) object = object->parent; if (!object) return FALSE; stringToKeyAction (GET_CORE_DISPLAY (object), str.ascii (), &value->action); break; case CompOptionTypeButton: while (object && object->type != COMP_OBJECT_TYPE_DISPLAY) object = object->parent; if (!object) return FALSE; stringToButtonAction (GET_CORE_DISPLAY (object), str.ascii (), &value->action); break; case CompOptionTypeEdge: value->action.edgeMask = stringToEdgeMask (str.ascii ()); break; case CompOptionTypeBell: value->action.bell = str.toInt () ? TRUE : FALSE; break; case CompOptionTypeMatch: matchInit (&value->match); matchAddFromString (&value->match, str.ascii ()); break; default: return FALSE; } return TRUE; }
static void fadeUpdateWindowFadeMatch(CompDisplay *display, CompOptionValue *value, CompMatch *match) { matchFini(match); matchInit(match); matchAddFromString(match, "!type=desktop"); matchAddGroup(match, MATCH_OP_AND_MASK, &value->match); matchUpdate(display, match); }
static Bool ringInitScreen (CompPlugin *p, CompScreen *s) { RingScreen *rs; RING_DISPLAY (s->display); rs = malloc (sizeof (RingScreen)); if (!rs) return FALSE; rs->windowPrivateIndex = allocateWindowPrivateIndex (s); if (rs->windowPrivateIndex < 0) { free (rs); return FALSE; } rs->grabIndex = 0; rs->state = RingStateNone; rs->windows = NULL; rs->drawSlots = NULL; rs->windowsSize = 0; rs->paintingSwitcher = FALSE; rs->selectedWindow = NULL; rs->moreAdjust = FALSE; rs->rotateAdjust = FALSE; rs->rotAdjust = 0; rs->rVelocity = 0; rs->textData = NULL; matchInit (&rs->match); WRAP (rs, s, preparePaintScreen, ringPreparePaintScreen); WRAP (rs, s, donePaintScreen, ringDonePaintScreen); WRAP (rs, s, paintOutput, ringPaintOutput); WRAP (rs, s, paintWindow, ringPaintWindow); WRAP (rs, s, damageWindowRect, ringDamageWindowRect); s->base.privates[rd->screenPrivateIndex].ptr = rs; return TRUE; }
static Bool fadeInitScreen(CompPlugin *p, CompScreen *s) { FadeScreen *fs; FADE_DISPLAY(s->display); fs = malloc(sizeof (FadeScreen)); if (!fs) return FALSE; if (!compInitScreenOptionsFromMetadata(s, &fadeMetadata, fadeScreenOptionInfo, fs->opt, FADE_SCREEN_OPTION_NUM)) { free(fs); return FALSE; } fs->windowPrivateIndex = allocateWindowPrivateIndex(s); if (fs->windowPrivateIndex < 0) { compFiniScreenOptions(s, fs->opt, FADE_SCREEN_OPTION_NUM); free(fs); return FALSE; } fs->fadeTime = 1000.0f / fs->opt[FADE_SCREEN_OPTION_FADE_SPEED].value.f; matchInit(&fs->match); fadeUpdateWindowFadeMatch(s->display, &fs->opt[FADE_SCREEN_OPTION_WINDOW_MATCH].value, &fs->match); WRAP(fs, s, preparePaintScreen, fadePreparePaintScreen); WRAP(fs, s, paintWindow, fadePaintWindow); WRAP(fs, s, damageWindowRect, fadeDamageWindowRect); WRAP(fs, s, focusWindow, fadeFocusWindow); WRAP(fs, s, windowResizeNotify, fadeWindowResizeNotify); s->base.privates[fd->screenPrivateIndex].ptr = fs; return TRUE; }
static Bool minInitScreen (CompPlugin *p, CompScreen *s) { MinScreen *ms; MIN_DISPLAY (&display); ms = malloc (sizeof (MinScreen)); if (!ms) return FALSE; ms->windowPrivateIndex = allocateWindowPrivateIndex (s); if (ms->windowPrivateIndex < 0) { free (ms); return FALSE; } ms->moreAdjust = FALSE; const BananaValue * option_shade_resistance = bananaGetOption (bananaIndex, "shade_resistance", s->screenNum); ms->shadeStep = 100 - option_shade_resistance->i + 1; const BananaValue * option_window_match = bananaGetOption (bananaIndex, "window_match", s->screenNum); matchInit (&ms->match); matchAddFromString (&ms->match, option_window_match->s); matchUpdate (&ms->match); WRAP (ms, s, preparePaintScreen, minPreparePaintScreen); WRAP (ms, s, donePaintScreen, minDonePaintScreen); WRAP (ms, s, paintOutput, minPaintOutput); WRAP (ms, s, paintWindow, minPaintWindow); WRAP (ms, s, damageWindowRect, minDamageWindowRect); WRAP (ms, s, focusWindow, minFocusWindow); s->privates[md->screenPrivateIndex].ptr = ms; return TRUE; }
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; } } } }
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; }
static Bool opacifyInitScreen (CompPlugin *p, CompScreen *s) { OpacifyScreen *os; OPACIFY_DISPLAY (&display); os = malloc (sizeof (OpacifyScreen)); if (!os) return FALSE; os->windowPrivateIndex = allocateWindowPrivateIndex (s); if (os->windowPrivateIndex < 0) { free (os); return FALSE; } WRAP (os, s, paintWindow, opacifyPaintWindow); const BananaValue * option_window_match = bananaGetOption (bananaIndex, "window_match", s->screenNum); matchInit (&os->window_match); matchAddFromString (&os->window_match, option_window_match->s); matchUpdate (&os->window_match); s->privates[od->screenPrivateIndex].ptr = os; os->intersect = XCreateRegion (); os->justMoved = FALSE; os->passiveNum = 0; os->active = 0; return TRUE; }
static Bool fadeInitDisplay(CompPlugin *p, CompDisplay *d) { FadeDisplay *fd; if (!checkPluginABI("core", CORE_ABIVERSION)) return FALSE; fd = malloc(sizeof (FadeDisplay)); if (!fd) return FALSE; fd->screenPrivateIndex = allocateScreenPrivateIndex(d); if (fd->screenPrivateIndex < 0) { free(fd); return FALSE; } fd->displayModals = 0; fd->suppressMinimizeOpenClose = (findActivePlugin("animation") != NULL); /* Always fade opening and closing of screen-dimming layer of logout window and gksu. */ matchInit(&fd->alwaysFadeWindowMatch); matchAddExp(&fd->alwaysFadeWindowMatch, 0, "title=gksu"); matchAddExp(&fd->alwaysFadeWindowMatch, 0, "title=x-session-manager"); matchAddExp(&fd->alwaysFadeWindowMatch, 0, "title=mate-session"); matchUpdate(d, &fd->alwaysFadeWindowMatch); WRAP(fd, d, handleEvent, fadeHandleEvent); WRAP(fd, d, matchExpHandlerChanged, fadeMatchExpHandlerChanged); d->base.privates[displayPrivateIndex].ptr = fd; return TRUE; }
static void initMatchValue (CompDisplay *d, CompOptionValue *v, Bool helper, xmlDocPtr doc, xmlNodePtr node) { xmlChar *value; matchInit (&v->match); if (!doc) return; value = xmlNodeListGetString (doc, node->xmlChildrenNode, 1); if (value) { matchAddFromString (&v->match, (char *) value); xmlFree (value); } if (!helper) matchUpdate (d, &v->match); }
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; }
static Bool decorSetDisplayOption (CompPlugin *plugin, CompDisplay *display, const char *name, CompOptionValue *value) { CompOption *o; int index; DECOR_DISPLAY (display); o = compFindOption (dd->opt, NUM_OPTIONS (dd), name, &index); if (!o) return FALSE; switch (index) { case DECOR_DISPLAY_OPTION_COMMAND: if (compSetStringOption (o, value)) { CompScreen *s; for (s = display->screens; s; s = s->next) { DECOR_SCREEN (s); if (!ds->dmWin) runCommand (s, o->value.s); } return TRUE; } break; case DECOR_DISPLAY_OPTION_SHADOW_MATCH: { char *matchString; /* Make sure RGBA matching is always present and disable shadows for RGBA windows by default if the user didn't specify an RGBA match. Reasoning for that is that shadows are desired for some RGBA windows (e.g. rectangular windows that just happen to have an RGBA colormap), while it's absolutely undesired for others (especially shaped ones) ... by enforcing no shadows for RGBA windows by default, we are flexible to user desires while still making sure we don't show ugliness by default */ matchString = matchToString (&value->match); if (matchString) { if (!strstr (matchString, "rgba=")) { CompMatch rgbaMatch; matchInit (&rgbaMatch); matchAddFromString (&rgbaMatch, "rgba=0"); matchAddGroup (&value->match, MATCH_OP_AND_MASK, &rgbaMatch); matchFini (&rgbaMatch); } free (matchString); } } /* fall-through intended */ case DECOR_DISPLAY_OPTION_DECOR_MATCH: if (compSetMatchOption (o, value)) { CompScreen *s; CompWindow *w; for (s = display->screens; s; s = s->next) for (w = s->windows; w; w = w->next) decorWindowUpdate (w, TRUE); } break; default: if (compSetOption (o, value)) return TRUE; break; } return FALSE; }
static Bool fuseInitValueFromString(CompObject *object, CompOptionValue *value, CompOptionType type, char *str) { switch (type) { case CompOptionTypeBool: value->b = strcmp(str, "true") ? FALSE : TRUE; break; case CompOptionTypeInt: value->i = atoi(str); break; case CompOptionTypeFloat: value->f = strtod(str, NULL); break; case CompOptionTypeString: value->s = strdup(str); break; case CompOptionTypeColor: if (!stringToColor(str, value->c)) return FALSE; break; case CompOptionTypeKey: while (object && object->type != COMP_OBJECT_TYPE_DISPLAY) object = object->parent; if (!object) return FALSE; stringToKeyAction(GET_CORE_DISPLAY(object), str, &value->action); break; case CompOptionTypeButton: while (object && object->type != COMP_OBJECT_TYPE_DISPLAY) object = object->parent; if (!object) return FALSE; stringToButtonAction(GET_CORE_DISPLAY(object), str, &value->action); break; case CompOptionTypeEdge: value->action.edgeMask = stringToEdgeMask(str); break; case CompOptionTypeBell: value->action.bell = strcmp(str, "true") ? FALSE : TRUE; break; case CompOptionTypeMatch: matchInit(&value->match); matchAddFromString(&value->match, str); break; default: return FALSE; } return TRUE; }
static Bool csvToList (CompDisplay *d, char *csv, CompListValue *list, CompOptionType type) { char *splitStart = NULL; char *splitEnd = NULL; char *item = NULL; int itemLength, count, i; if (csv[0] == '\0') { list->nValue = 0; return FALSE; } int length = strlen (csv); count = 1; for (i = 0; csv[i] != '\0'; i++) if (csv[i] == ',' && i != length-1) count++; splitStart = csv; list->value = malloc (sizeof (CompOptionValue) * count); list->nValue = count; if (list->value) { for (i = 0; i < count; i++) { splitEnd = strchr (splitStart, ','); if (splitEnd) { itemLength = strlen (splitStart) - strlen (splitEnd); item = malloc (sizeof (char) * (itemLength + 1)); if (item) { strncpy (item, splitStart, itemLength); item[itemLength] = 0; } } else // last value { item = strdup (splitStart); } if (!item) { compLogMessage ("ini", CompLogLevelError, "Not enough memory"); list->nValue = 0; return FALSE; } switch (type) { case CompOptionTypeString: list->value[i].s = strdup (item); break; case CompOptionTypeBool: list->value[i].b = item[0] ? (Bool) atoi (item) : FALSE; break; case CompOptionTypeInt: list->value[i].i = item[0] ? atoi (item) : 0; break; case CompOptionTypeFloat: list->value[i].f = item[0] ? atof (item) : 0.0f; break; case CompOptionTypeKey: stringToKeyAction (d, item, &list->value[i].action); break; case CompOptionTypeButton: stringToButtonAction (d, item, &list->value[i].action); break; case CompOptionTypeEdge: list->value[i].action.edgeMask = stringToEdgeMask (item); break; case CompOptionTypeBell: list->value[i].action.bell = (Bool) atoi (item); break; case CompOptionTypeMatch: matchInit (&list->value[i].match); matchAddFromString (&list->value[i].match, item); break; default: break; } splitStart = ++splitEnd; if (item) { free (item); item = NULL; } } } return TRUE; }
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 winrulesInitScreen (CompPlugin *p, CompScreen *s) { WinrulesScreen *ws; WINRULES_DISPLAY (&display); ws = malloc (sizeof (WinrulesScreen)); if (!ws) return FALSE; ws->windowPrivateIndex = allocateWindowPrivateIndex (s); if (ws->windowPrivateIndex < 0) { free (ws); return FALSE; } WRAP (ws, s, getAllowedActionsForWindow, winrulesGetAllowedActionsForWindow); const BananaValue * option_skiptaskbar_match = bananaGetOption (bananaIndex, "skiptaskbar_match", s->screenNum); matchInit (&ws->skiptaskbar_match); matchAddFromString (&ws->skiptaskbar_match, option_skiptaskbar_match->s); matchUpdate (&ws->skiptaskbar_match); const BananaValue * option_skippager_match = bananaGetOption (bananaIndex, "skippager_match", s->screenNum); matchInit (&ws->skippager_match); matchAddFromString (&ws->skippager_match, option_skippager_match->s); matchUpdate (&ws->skippager_match); const BananaValue * option_above_match = bananaGetOption (bananaIndex, "above_match", s->screenNum); matchInit (&ws->above_match); matchAddFromString (&ws->above_match, option_above_match->s); matchUpdate (&ws->above_match); const BananaValue * option_below_match = bananaGetOption (bananaIndex, "below_match", s->screenNum); matchInit (&ws->below_match); matchAddFromString (&ws->below_match, option_below_match->s); matchUpdate (&ws->below_match); const BananaValue * option_sticky_match = bananaGetOption (bananaIndex, "sticky_match", s->screenNum); matchInit (&ws->sticky_match); matchAddFromString (&ws->sticky_match, option_sticky_match->s); matchUpdate (&ws->sticky_match); const BananaValue * option_fullscreen_match = bananaGetOption (bananaIndex, "fullscreen_match", s->screenNum); matchInit (&ws->fullscreen_match); matchAddFromString (&ws->fullscreen_match, option_fullscreen_match->s); matchUpdate (&ws->fullscreen_match); const BananaValue * option_maximize_match = bananaGetOption (bananaIndex, "maximize_match", s->screenNum); matchInit (&ws->maximize_match); matchAddFromString (&ws->maximize_match, option_maximize_match->s); matchUpdate (&ws->maximize_match); const BananaValue * option_no_argb_match = bananaGetOption (bananaIndex, "no_argb_match", s->screenNum); matchInit (&ws->no_argb_match); matchAddFromString (&ws->no_argb_match, option_no_argb_match->s); matchUpdate (&ws->no_argb_match); const BananaValue * option_no_move_match = bananaGetOption (bananaIndex, "no_move_match", s->screenNum); matchInit (&ws->no_move_match); matchAddFromString (&ws->no_move_match, option_no_move_match->s); matchUpdate (&ws->no_move_match); const BananaValue * option_no_resize_match = bananaGetOption (bananaIndex, "no_resize_match", s->screenNum); matchInit (&ws->no_resize_match); matchAddFromString (&ws->no_resize_match, option_no_resize_match->s); matchUpdate (&ws->no_resize_match); const BananaValue * option_no_minimize_match = bananaGetOption (bananaIndex, "no_minimize_match", s->screenNum); matchInit (&ws->no_minimize_match); matchAddFromString (&ws->no_minimize_match, option_no_minimize_match->s); matchUpdate (&ws->no_minimize_match); const BananaValue * option_no_maximize_match = bananaGetOption (bananaIndex, "no_maximize_match", s->screenNum); matchInit (&ws->no_maximize_match); matchAddFromString (&ws->no_maximize_match, option_no_maximize_match->s); matchUpdate (&ws->no_maximize_match); const BananaValue * option_no_close_match = bananaGetOption (bananaIndex, "no_close_match", s->screenNum); matchInit (&ws->no_close_match); matchAddFromString (&ws->no_close_match, option_no_close_match->s); matchUpdate (&ws->no_close_match); const BananaValue * option_no_focus_match = bananaGetOption (bananaIndex, "no_focus_match", s->screenNum); matchInit (&ws->no_focus_match); matchAddFromString (&ws->no_focus_match, option_no_focus_match->s); matchUpdate (&ws->no_focus_match); const BananaValue * option_size_matches = bananaGetOption (bananaIndex, "size_matches", s->screenNum); ws->size_matches_count = option_size_matches->list.nItem; int i; for (i = 0; i < option_size_matches->list.nItem; i++) { matchInit (&ws->size_matches[i]); matchAddFromString (&ws->size_matches[i], option_size_matches->list.item[i].s); matchUpdate (&ws->size_matches[i]); } s->privates[wd->screenPrivateIndex].ptr = ws; return TRUE; }
static Bool iniLoadOptionsFromFile (FILE *optionFile, CompObject *object, const char *plugin, Bool *reSave) { CompOption *option = NULL, *o; CompPlugin *p = NULL; CompOptionValue value; char *optionName = NULL, *optionValue = NULL; char tmp[MAX_OPTION_LENGTH]; int nOption, nOptionRead = 0; Bool status = FALSE, hasValue = FALSE; if (plugin) { p = findActivePlugin (plugin); if (!p) { compLogMessage ("ini", CompLogLevelWarn, "Could not find running plugin " \ "%s (iniLoadOptionsFromFile)", plugin); return FALSE; } } else { return FALSE; } if (p->vTable->getObjectOptions) option = (*p->vTable->getObjectOptions) (p, object, &nOption); while (fgets (tmp, MAX_OPTION_LENGTH, optionFile) != NULL) { status = FALSE; if (!iniParseLine (tmp, &optionName, &optionValue)) { compLogMessage ("ini", CompLogLevelWarn, "Ignoring line '%s' in %s", tmp, plugin); continue; } if (option) { o = compFindOption (option, nOption, optionName, 0); if (o) { value = o->value; switch (o->type) { case CompOptionTypeBool: hasValue = TRUE; value.b = (Bool) atoi (optionValue); break; case CompOptionTypeInt: hasValue = TRUE; value.i = atoi (optionValue); break; case CompOptionTypeFloat: hasValue = TRUE; value.f = atof (optionValue); break; case CompOptionTypeString: hasValue = TRUE; value.s = strdup (optionValue); break; case CompOptionTypeColor: hasValue = stringToColor (optionValue, value.c); break; case CompOptionTypeKey: hasValue = TRUE; stringToKeyAction (GET_CORE_DISPLAY (object), optionValue, &value.action); break; case CompOptionTypeButton: hasValue = TRUE; stringToButtonAction (GET_CORE_DISPLAY (object), optionValue, &value.action); break; case CompOptionTypeEdge: hasValue = TRUE; value.action.edgeMask = stringToEdgeMask (optionValue); break; case CompOptionTypeBell: hasValue = TRUE; value.action.bell = (Bool) atoi (optionValue); break; case CompOptionTypeList: hasValue = csvToList (GET_CORE_DISPLAY (object), optionValue, &value.list, value.list.type); break; case CompOptionTypeMatch: hasValue = TRUE; matchInit (&value.match); matchAddFromString (&value.match, optionValue); break; default: break; } if (hasValue) { status = (*core.setOptionForPlugin) (object, plugin, optionName, &value); if (o->type == CompOptionTypeMatch) { matchFini (&value.match); } } nOptionRead++; } } /* clear up */ if (optionName) free (optionName); if (optionValue) free (optionValue); } if (nOption != nOptionRead) { *reSave = TRUE; } return TRUE; }
static void winrulesChangeNotify (const char *optionName, BananaType optionType, const BananaValue *optionValue, int screenNum) { unsigned int updateStateMask = 0, updateActionsMask = 0; CompScreen *screen = getScreenFromScreenNum (screenNum); WINRULES_SCREEN (screen); CompMatch *match; if (strcasecmp (optionName, "skiptaskbar_match") == 0) { match = &ws->skiptaskbar_match; matchFini (match); matchInit (match); matchAddFromString (match, optionValue->s); matchUpdate (match); updateStateMask = CompWindowStateSkipTaskbarMask; } else if (strcasecmp (optionName, "skippager_match") == 0) { match = &ws->skippager_match; matchFini (match); matchInit (match); matchAddFromString (match, optionValue->s); matchUpdate (match); updateStateMask = CompWindowStateSkipPagerMask; } else if (strcasecmp (optionName, "above_match") == 0) { match = &ws->above_match; matchFini (match); matchInit (match); matchAddFromString (match, optionValue->s); matchUpdate (match); updateStateMask = CompWindowStateAboveMask; } else if (strcasecmp (optionName, "below_match") == 0) { match = &ws->below_match; matchFini (match); matchInit (match); matchAddFromString (match, optionValue->s); matchUpdate (match); updateStateMask = CompWindowStateBelowMask; } else if (strcasecmp (optionName, "sticky_match") == 0) { match = &ws->sticky_match; matchFini (match); matchInit (match); matchAddFromString (match, optionValue->s); matchUpdate (match); updateStateMask = CompWindowStateStickyMask; } else if (strcasecmp (optionName, "fullscreen_match") == 0) { match = &ws->fullscreen_match; matchFini (match); matchInit (match); matchAddFromString (match, optionValue->s); matchUpdate (match); updateStateMask = CompWindowStateFullscreenMask; } else if (strcasecmp (optionName, "maximize_match") == 0) { match = &ws->maximize_match; matchFini (match); matchInit (match); matchAddFromString (match, optionValue->s); matchUpdate (match); updateStateMask = CompWindowStateMaximizedHorzMask | CompWindowStateMaximizedVertMask; } else if (strcasecmp (optionName, "no_move_match") == 0) { match = &ws->no_move_match; matchFini (match); matchInit (match); matchAddFromString (match, optionValue->s); matchUpdate (match); updateActionsMask = CompWindowActionMoveMask; } else if (strcasecmp (optionName, "no_resize_match") == 0) { match = &ws->no_resize_match; matchFini (match); matchInit (match); matchAddFromString (match, optionValue->s); matchUpdate (match); updateActionsMask = CompWindowActionResizeMask; } else if (strcasecmp (optionName, "no_minimize_match") == 0) { match = &ws->no_minimize_match; matchFini (match); matchInit (match); matchAddFromString (match, optionValue->s); matchUpdate (match); updateActionsMask = CompWindowActionMinimizeMask; } else if (strcasecmp (optionName, "no_maximize_match") == 0) { match = &ws->no_maximize_match; matchFini (match); matchInit (match); matchAddFromString (match, optionValue->s); matchUpdate (match); updateActionsMask = CompWindowActionMaximizeVertMask | CompWindowActionMaximizeHorzMask; } else if (strcasecmp (optionName, "no_close_match") == 0) { match = &ws->no_close_match; matchFini (match); matchInit (match); matchAddFromString (match, optionValue->s); matchUpdate (match); updateActionsMask = CompWindowActionCloseMask; } else if (strcasecmp (optionName, "no_argb_match") == 0) { match = &ws->no_argb_match; matchFini (match); matchInit (match); matchAddFromString (match, optionValue->s); matchUpdate (match); CompWindow *w; for (w = screen->windows; w; w = w->next) winrulesSetNoAlpha (w, match); } else if (strcasecmp (optionName, "no_focus_match") == 0) { match = &ws->no_focus_match; matchFini (match); matchInit (match); matchAddFromString (match, optionValue->s); matchUpdate (match); CompWindow *w; for (w = screen->windows; w; w = w->next) winrulesSetNoFocus (w, match); } else if (strcasecmp (optionName, "size_matches") == 0) { int i; for (i = 0; i < ws->size_matches_count; i++) matchFini (&ws->size_matches[i]); ws->size_matches_count = optionValue->list.nItem; for (i = 0; i < ws->size_matches_count; i++) { matchInit (&ws->size_matches[i]); matchAddFromString (&ws->size_matches[i], optionValue->list.item[i].s); matchUpdate (&ws->size_matches[i]); } } if (strcasecmp (optionName, "size_matches") == 0 || strcasecmp (optionName, "size_width_values") == 0 || strcasecmp (optionName, "size_height_values") == 0) { CompWindow *w; for (w = screen->windows; w; w = w->next) { int width, height; if (winrulesMatchSize (w, &width, &height)) winrulesUpdateWindowSize (w, width, height); } } if (updateStateMask) { CompWindow *w; for (w = screen->windows; w; w = w->next) winrulesUpdateState (w, match, updateStateMask); } if (updateActionsMask) { CompWindow *w; for (w = screen->windows; w; w = w->next) winrulesSetAllowedActions (w, match, updateActionsMask); } }
static void ccpSetValueToValue (CompObject *object, CCSSettingValue *sv, CompOptionValue *v, CCSSettingType type) { switch (type) { case TypeInt: v->i = sv->value.asInt; break; case TypeFloat: v->f = sv->value.asFloat; break; case TypeBool: v->b = sv->value.asBool; break; case TypeColor: { int i; for (i = 0; i < 4; i++) v->c[i] = sv->value.asColor.array.array[i]; } break; case TypeString: v->s = strdup (sv->value.asString); break; case TypeMatch: matchInit (&v->match); matchAddFromString (&v->match, sv->value.asMatch); break; case TypeKey: { CompDisplay *d; while (object && object->type != COMP_OBJECT_TYPE_DISPLAY) object = object->parent; if (!object) return; d = GET_CORE_DISPLAY (object); v->action.key.keycode = (sv->value.asKey.keysym != NoSymbol) ? XKeysymToKeycode (d->display, sv->value.asKey.keysym) : 0; v->action.key.modifiers = sv->value.asKey.keyModMask; if (v->action.key.keycode || v->action.key.modifiers) v->action.type = CompBindingTypeKey; else v->action.type = CompBindingTypeNone; } break; case TypeButton: { v->action.button.button = sv->value.asButton.button; v->action.button.modifiers = sv->value.asButton.buttonModMask; v->action.edgeMask = sv->value.asButton.edgeMask; if (v->action.button.button || v->action.button.modifiers) { if (sv->value.asButton.edgeMask) v->action.type = CompBindingTypeEdgeButton; else v->action.type = CompBindingTypeButton; } else v->action.type = CompBindingTypeNone; } break; case TypeEdge: { v->action.edgeMask = sv->value.asEdge; } break; case TypeBell: { v->action.bell = sv->value.asBell; } break; default: break; } }
/* Add match expressions from string. Special characters are '(', ')', '!', '&', '|'. Escape character is '\'. Example: "type=desktop | !type=dock" "!type=dock & (state=fullscreen | state=shaded)" */ void matchAddFromString (CompMatch *match, const char *str) { char *value; int j, i = 0; int flags = 0; while (str[i] != '\0') { while (str[i] == ' ') i++; if (str[i] == '!') { flags |= MATCH_OP_NOT_MASK; i++; while (str[i] == ' ') i++; } if (str[i] == '(') { int level = 1; int length; j = ++i; while (str[j] != '\0') { if (str[j] == '(') { level++; } else if (str[j] == ')') { level--; if (level == 0) break; } j = nextIndex (str, ++j); } length = j - i; value = malloc (sizeof (char) * (length + 1)); if (value) { CompMatch group; strncpy (value, &str[i], length); value[length] = '\0'; matchInit (&group); matchAddFromString (&group, value); matchAddGroup (match, flags, &group); matchFini (&group); free (value); } while (str[j] != '\0' && str[j] != '|' && str[j] != '&') j++; } else { j = i; while (str[j] != '\0' && str[j] != '|' && str[j] != '&') j = nextIndex (str, ++j); value = strndupValue (&str[i], j - i); if (value) { matchAddExp (match, flags, value); free (value); } } i = j; if (str[i] != '\0') { if (str[i] == '&') flags = MATCH_OP_AND_MASK; i++; } } }
/* * 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 groupChangeNotify (const char *optionName, BananaType optionType, const BananaValue *optionValue, int screenNum) { GROUP_DISPLAY (&display); if (strcasecmp (optionName, "window_match") == 0) { CompScreen *s = getScreenFromScreenNum (screenNum); GROUP_SCREEN (s); matchFini (&gs->window_match); matchInit (&gs->window_match); matchAddFromString (&gs->window_match, optionValue->s); matchUpdate (&gs->window_match); } else if (strcasecmp (optionName, "tab_base_color") == 0 || strcasecmp (optionName, "tab_highlight_color") == 0 || strcasecmp (optionName, "tab_border_color") == 0 || strcasecmp (optionName, "tab_style") == 0 || strcasecmp (optionName, "border_radius") == 0 || strcasecmp (optionName, "border_width") == 0) { GroupSelection *group; CompScreen *s = getScreenFromScreenNum (screenNum); GROUP_SCREEN (s); for (group = gs->groups; group; group = group->next) if (group->tabBar) groupRenderTabBarBackground (group); } else if (strcasecmp (optionName, "tabbar_font_size") == 0 || strcasecmp (optionName, "tabbar_font_color") == 0) { GroupSelection *group; CompScreen *s = getScreenFromScreenNum (screenNum); GROUP_SCREEN (s); for (group = gs->groups; group; group = group->next) groupRenderWindowTitle (group); } else if (strcasecmp (optionName, "thumb_size") == 0 || strcasecmp (optionName, "thumb_space") == 0) { GroupSelection *group; CompScreen *s = getScreenFromScreenNum (screenNum); GROUP_SCREEN (s); for (group = gs->groups; group; group = group->next) if (group->tabBar) { BoxPtr box = &group->tabBar->region->extents; groupRecalcTabBarPos (group, (box->x1 + box->x2 ) / 2, box->x1, box->x2); } } else if (strcasecmp (optionName, "glow") == 0 || strcasecmp (optionName, "glow_size") == 0) { CompScreen *s = getScreenFromScreenNum (screenNum); GROUP_SCREEN (s); CompWindow *w; for (w = s->windows; w; w = w->next) { GROUP_WINDOW (w); groupComputeGlowQuads (w, &gs->glowTexture.matrix); if (gw->glowQuads) { damageWindowOutputExtents (w); updateWindowOutputExtents (w); damageWindowOutputExtents (w); } } } else if (strcasecmp (optionName, "glow_type") == 0) { CompScreen *s = getScreenFromScreenNum (screenNum); GROUP_SCREEN (s); int glowType; GlowTextureProperties *glowProperty; GROUP_DISPLAY (&display); const BananaValue * option_glow_type = bananaGetOption (bananaIndex, "glow_type", s->screenNum); glowType = option_glow_type->i; glowProperty = &gd->glowTextureProperties[glowType]; finiTexture (s, &gs->glowTexture); initTexture (s, &gs->glowTexture); imageDataToTexture (s, &gs->glowTexture, glowProperty->textureData, glowProperty->textureSize, glowProperty->textureSize, GL_RGBA, GL_UNSIGNED_BYTE); const BananaValue * option_glow = bananaGetOption (bananaIndex, "glow", s->screenNum); if (option_glow->b && gs->groups) { CompWindow *w; for (w = s->windows; w; w = w->next) groupComputeGlowQuads (w, &gs->glowTexture.matrix); damageScreen (s); } } else if (strcasecmp (optionName, "select_button") == 0) updateButton (optionValue->s, &gd->select_button); else if (strcasecmp (optionName, "select_single_key") == 0) updateKey (optionValue->s, &gd->select_single_key); else if (strcasecmp (optionName, "group_key") == 0) updateKey (optionValue->s, &gd->group_key); else if (strcasecmp (optionName, "ungroup_key") == 0) updateKey (optionValue->s, &gd->ungroup_key); else if (strcasecmp (optionName, "remove_key") == 0) updateKey (optionValue->s, &gd->remove_key); else if (strcasecmp (optionName, "close_key") == 0) updateKey (optionValue->s, &gd->close_key); else if (strcasecmp (optionName, "ignore_key") == 0) updateKey (optionValue->s, &gd->ignore_key); else if (strcasecmp (optionName, "tabmode_key") == 0) updateKey (optionValue->s, &gd->tabmode_key); else if (strcasecmp (optionName, "change_tab_left_key") == 0) updateKey (optionValue->s, &gd->change_tab_left_key); else if (strcasecmp (optionName, "change_tab_right_key") == 0) updateKey (optionValue->s, &gd->change_tab_right_key); else if (strcasecmp (optionName, "change_color_key") == 0) updateKey (optionValue->s, &gd->change_color_key); else if (strcasecmp (optionName, "autotab_windows") == 0) { CompScreen *s = getScreenFromScreenNum (screenNum); GROUP_SCREEN (s); int i; if (gs->autotab && gs->autotabCount != 0) { for (i = 0; i <= gs->autotabCount - 1; i++) matchFini (&gs->autotab[i]); free (gs->autotab); } gs->autotabCount = optionValue->list.nItem; gs->autotab = malloc (gs->autotabCount * sizeof (CompMatch)); for (i = 0; i <= gs->autotabCount - 1; i++) { matchInit (&gs->autotab[i]); matchAddFromString (&gs->autotab[i], optionValue->list.item[i].s); matchUpdate (&gs->autotab[i]); } } }