bool CompText::renderWindowTitle (Window window, bool withViewportNumber, const CompText::Attrib &attrib) { CompString text; TEXT_SCREEN (screen); if (!ts) return false; if (withViewportNumber) { CompString title; CompPoint winViewport; CompSize viewportSize; title = ts->getWindowName (window); if (!title.empty ()) { CompWindow *w; w = screen->findWindow (window); if (w) { int viewport; winViewport = w->defaultViewport (); viewportSize = screen->vpSize (); viewport = winViewport.y () * viewportSize.width () + winViewport.x () + 1; text = compPrintf ("%s -[%d]-", title.c_str (), viewport); } else { text = title; } } } else { text = ts->getWindowName (window); } if (text.empty ()) return false; return renderText (text, attrib); }
CompString PrivateTextScreen::getWindowName (Window id) { CompString name; name = getUtf8Property (id, visibleNameAtom); if (name.empty ()) name = getUtf8Property (id, wmNameAtom); if (name.empty ()) name = getTextProperty (id, XA_WM_NAME); return name; }
/* * Add a new fragment offset to the offsets stack from an ADD op string */ FragmentParser::FragmentOffset * FragmentParser::programAddOffsetFromAddOp (const CompString &source) { FragmentOffset offset; CompString op; size_t pos = 0; CompString name; CompString offsetString; CompString temp; std::list <FragmentOffset>::iterator it = offsets.begin (); if (source.size () < 5) return NULL; op = source; pos += 3; name = getFirstArgument (op, pos); if (name.empty ()) return NULL; temp = getFirstArgument (op, pos); /* If an offset with the same name is * already registered, skip this one */ if ((!offsets.empty () && !programFindOffset (it, name).empty ()) || temp.empty ()) return &(*it); /* Just use the end of the op as the offset */ pos += 1; offsetString = ltrim (op.substr (pos)); if (offsetString.empty ()) return NULL; offset.name = name; offset.offset = offsetString; offsets.push_back (offset); return &(offsets.back ()); }
void WSNamesScreen::renderNameText () { CompText::Attrib attrib; CompString name; textData.clear (); name = getCurrentWSName (); if (name.empty ()) return; /* 75% of the output device as maximum width */ attrib.maxWidth = screen->getCurrentOutputExtents ().width () * 3 / 4; attrib.maxHeight = 100; attrib.family = "Sans"; attrib.size = optionGetTextFontSize (); attrib.color[0] = optionGetFontColorRed (); attrib.color[1] = optionGetFontColorGreen (); attrib.color[2] = optionGetFontColorBlue (); attrib.color[3] = optionGetFontColorAlpha (); attrib.flags = CompText::WithBackground | CompText::Ellipsized; if (optionGetBoldText ()) attrib.flags |= CompText::StyleBold; attrib.bgHMargin = 15; attrib.bgVMargin = 15; attrib.bgColor[0] = optionGetBackColorRed (); attrib.bgColor[1] = optionGetBackColorGreen (); attrib.bgColor[2] = optionGetBackColorBlue (); attrib.bgColor[3] = optionGetBackColorAlpha (); textData.renderText (name, attrib); }
/* * Load a source file and build a Compiz Fragment Function from it */ GLFragment::FunctionId FragmentParser::loadFragmentProgram (const CompString &file, CompString &name, int target) { CompString source; GLFragment::FunctionId handle; /* Clean fragment program name */ programCleanName (name); /* Read the source file */ source = programReadSource (file); if (source.empty ()) { return 0; } /* Build the Compiz Fragment Program */ handle = buildFragmentProgram (source, name, target); return handle; }