Drop Client::cap_deco as it's nowhere used

Summary:
cap_deco was only used in the caption with stripped arg case which was
unused and thus removed. Now cap_deco is completely unused.

Due to that we can also remove the stripped client script which only
manipulated the cap_deco.

Test Plan: Compiles

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7077
icc-effect-5.14.5
Martin Flöser 2017-08-02 18:41:38 +02:00
parent 00281711d9
commit ddf3536f19
4 changed files with 2 additions and 133 deletions

View File

@ -48,9 +48,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QFile>
#include <QMouseEvent>
#include <QProcess>
#include <QStandardPaths>
#include <QScriptEngine>
#include <QScriptProgram>
#include <QWhatsThis>
// XLib
#include <X11/Xutil.h>
@ -1434,31 +1431,8 @@ void Client::setCaption(const QString& _s, bool force)
if (!s[i].isPrint())
s[i] = QChar(u' ');
cap_normal = s;
if (options->condensedTitle()) {
static QScriptEngine engine;
static QScriptProgram stripTitle;
static QScriptValue script;
if (stripTitle.isNull()) {
const QString scriptFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral(KWIN_NAME "/stripTitle.js"));
if (!scriptFile.isEmpty()) {
QFile f(scriptFile);
if (f.open(QIODevice::ReadOnly|QIODevice::Text)) {
f.reset();
stripTitle = QScriptProgram(QString::fromLocal8Bit(f.readAll()), QStringLiteral("stripTitle.js"));
f.close();
}
}
if (stripTitle.isNull())
stripTitle = QScriptProgram(QStringLiteral("(function(title, wm_name, wm_class){ return title ; })"), QStringLiteral("stripTitle.js"));
script = engine.evaluate(stripTitle);
}
QScriptValueList args;
args << _s << QString::fromUtf8(resourceName()) << QString::fromUtf8(resourceClass());
s = script.call(QScriptValue(), args).toString();
}
if (!force && s == cap_deco)
if (!force)
return;
cap_deco = s;
bool reset_name = force;
bool was_suffix = (!cap_suffix.isEmpty());

View File

@ -555,7 +555,7 @@ private:
QRect geom_fs_restore;
QTimer* shadeHoverTimer;
xcb_colormap_t m_colormap;
QString cap_normal, cap_iconic, cap_suffix, cap_deco;
QString cap_normal, cap_iconic, cap_suffix;
Group* in_group;
TabGroup* tab_group;
QTimer* ping_timer;

View File

@ -7,6 +7,5 @@ install(TARGETS kwin5_update_default_rules DESTINATION ${LIB_INSTALL_DIR}/kconf_
########### install files ###############
install( FILES stripTitle.js DESTINATION ${DATA_INSTALL_DIR}/kwin )
install( FILES org_kde_kwin.categories DESTINATION ${KDE_INSTALL_CONFDIR} )

View File

@ -1,104 +0,0 @@
// ==============================================================
// Ok, *some* apps have really long and nasty window captions
// this looks clutterd, so we allow to crop them a bit and remove
// any information considered to be useless
// ==============================================================
function isBrowser(appName) {
if (appName.toLowerCase() == "konqueror")
return true;
if (appName.toLowerCase() == "rekonq")
return true;
if (appName.toLowerCase() == "qupzilla")
return true;
if (appName.toLowerCase() == "chromium")
return true;
if (appName.toLowerCase() == "firefox")
return true;
if (appName.toLowerCase() == "opera")
return true;
if (appName.toLowerCase() == "arora")
return true;
if (appName.toLowerCase() == "mozilla")
return true;
return false;
}
(function(title, wm_name, wm_class) {
var ret;
// == 1st off ======================================================================
// we assume the part beyond the last dash (if any) to be the
// uninteresting one (usually it's the apps name, if there's add info, that's
// more important to the user)
// --------------------------------------------------------------------------------
var lastPos = title.lastIndexOf(" "); // U+2013 "EN DASH"
if (lastPos > -1)
ret = title.slice(0, lastPos);
else {
lastPos = title.lastIndexOf(" - "); // ASCII Dash
if (lastPos > -1)
ret = title.slice(0, lastPos);
else {
lastPos = title.lastIndexOf(" — "); // U+2014 "EM DASH"
if (lastPos > -1)
ret = title.slice(0, lastPos);
else
ret = title;
}
}
// == 2nd =========================================================================
// Browsers set the caption to "<html><title/></html> - appname"
// Now the page titles can be ridiculously looooong, especially on news pages
// -------------------------------------------------------------------------------
if (isBrowser(wm_name)) {
var parts = ret.split(" - ");
ret = "";
if (parts.length > 2) { // select last two if 3 or more sects, prelast otherwise
for (i = Math.max(0,parts.length-2); i < parts.length - 1; ++i)
ret = ret + parts[i] + " - ";
ret = ret + parts[parts.length - 1];
} else {
ret = ret + parts[Math.max(0,parts.length-2)];
}
}
// 3rd ============================================================================
// if there're any details left, cut of stuff by ": ",
// we remove them as well
// --------------------------------------------------------------------------------
var lastPos = ret.lastIndexOf(": ");
if (lastPos > -1)
ret = title.slice(0, lastPos);
// 4th ============================================================================
// if this is a http url, please get rid of protocol, assuming the user knows or doesn't care
// --------------------------------------------------------------------------------
ret = ret.replace("http://", '');
// finally =========================================================================
// if the remaining string still contains the app name (which should have been removed),
// please shape away additional info like compile time, version numbers etc.
// we usitlize the caption string to preserve CapiTaliZation
// -----------------------------------------------------------------------------------
lastPos = ret.indexOf(RegExp("\\b" + wm_name + "\\b"));
if (lastPos > -1)
ret = ret.substr(lastPos, wm_name.length);
else {
lastPos = ret.indexOf(RegExp("\\b" + wm_class + "\\b"));
if (lastPos > -1)
ret = ret.substr(lastPos, wm_class.length);
}
if (ret.length == 0)
ret = title; // something _terribly_ went wrong -> fall back to the original string
// but in any case get replace the stupid [modified] hint by just an asterisk
ret = ret.replace("[modified]", "❖");
// in general, remove leading [and trailing] blanks and special chars
// ret = ret.replace(/^\W*/, ''); - this does not work - Umlauts and pot. other chars are considered "non Word"
ret = ret.replace(/^\s*/, '').replace(/\s*$/, '');
return ret;
})