Commit b2f56c47 authored by Martin Flöser's avatar Martin Flöser
Browse files

Print useful information for a Client in scripting

Reusing the debug information already specified for QDebug.

FEATURE: 314402
FIXED-IN: 4.11
REVIEW: 108959
parent d284289b
......@@ -2350,8 +2350,7 @@ void Client::cancelAutoRaise()
void Client::debug(QDebug& stream) const
{
stream << "\'ID:" << window() << ";WMCLASS:" << resourceClass() << ":"
<< resourceName() << ";Caption:" << caption() << "\'";
print<QDebug>(stream);
}
QPixmap* kwin_get_menu_pix_hack()
......
......@@ -651,6 +651,9 @@ public:
}
#endif
template <typename T>
void print(T &stream) const;
public slots:
void closeWindow();
void updateCaption();
......@@ -1277,6 +1280,13 @@ inline bool Client::hiddenPreview() const
return mapping_state == Kept;
}
template <typename T>
inline void Client::print(T &stream) const
{
stream << "\'ID:" << window() << ";WMCLASS:" << resourceClass() << ":"
<< resourceName() << ";Caption:" << caption() << "\'";
}
KWIN_COMPARE_PREDICATE(WrapperIdMatchPredicate, Client, Window, cl->wrapperId() == value);
KWIN_COMPARE_PREDICATE(InputIdMatchPredicate, Client, Window, cl->inputId() == value);
......
......@@ -57,11 +57,17 @@ QScriptValue kwinScriptPrint(QScriptContext *context, QScriptEngine *engine)
return engine->undefinedValue();
}
QString result;
QTextStream stream(&result);
for (int i = 0; i < context->argumentCount(); ++i) {
if (i > 0) {
result.append(" ");
stream << " ";
}
QScriptValue argument = context->argument(i);
if (KWin::Client *client = qscriptvalue_cast<KWin::Client*>(argument)) {
client->print<QTextStream>(stream);
} else {
stream << argument.toString();
}
result.append(context->argument(i).toString());
}
script->printMessage(result);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment