refactor: wrap clientList api call

This commit is contained in:
Mikhail Zolotukhin 2022-03-26 16:05:57 +03:00 committed by Genda
parent 8ec6b95161
commit 0387c0f486
2 changed files with 18 additions and 0 deletions

View File

@ -58,6 +58,22 @@ QRect Workspace::clientArea(ClientAreaOption option, int screen, int desktop)
BI_METHOD_IMPL_WRAP(QRect, "clientArea(ClientAreaOption, int, int)", Q_ARG(ClientAreaOption, option), Q_ARG(int, screen), Q_ARG(int, desktop));
};
std::vector<PlasmaApi::Client> Workspace::clientList() const
{
auto apiCall = [&]() -> QList<KWin::AbstractClient *> {
BI_METHOD_IMPL_WRAP(QList<KWin::AbstractClient *>, "clientList()", QGenericArgument(nullptr));
};
auto apiCallRes = apiCall();
auto result = std::vector<PlasmaApi::Client>(apiCallRes.size());
for (auto clientPtr : apiCallRes) {
result.push_back(Client(reinterpret_cast<QObject *>(clientPtr)));
}
return result;
}
void Workspace::currentDesktopChangedTransformer(int desktop, KWin::AbstractClient *kwinClient)
{
// Since we don't know the KWin internal implementation we have to use reinterpret_cast

View File

@ -55,6 +55,8 @@ public:
*/
Q_INVOKABLE QRect clientArea(ClientAreaOption, int screen, int desktop);
Q_INVOKABLE std::vector<PlasmaApi::Client> clientList() const;
private Q_SLOTS:
void currentDesktopChangedTransformer(int desktop, KWin::AbstractClient *kwinClient);
void clientAddedTransformer(KWin::AbstractClient *);