Skip to content

Commit

Permalink
fix: [kwin] waitting for kwin
Browse files Browse the repository at this point in the history
[kwin] waitting for kwin

Log: [kwin] waitting for kwin
Bug: https://pms.uniontech.com/bug-view-236971.html
  • Loading branch information
pppanghu77 committed Apr 2, 2024
1 parent 8d65f3f commit e6fb0c1
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/apps/dde-desktop/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <QProcess>
#include <QDateTime>
#include <QTimer>
#include <QElapsedTimer>

#include <iostream>
#include <algorithm>
Expand Down Expand Up @@ -217,6 +218,23 @@ static void autoReleaseMemory()
timer.start(kTimerInterval);
}

static QString getCompositingType()
{
QDBusInterface kwinInterface("org.kde.KWin", "/Compositor", "org.kde.kwin.Compositing", QDBusConnection::sessionBus());

if (!kwinInterface.isValid()) {
qWarning() << "Failed to get compositingType property";
}

QVariant compositingType = kwinInterface.property("compositingType");
if (compositingType.isValid()) {
return compositingType.toString();
} else {
qWarning() << "Failed to get compositingType property, Waitfing for kwin";
return QString();
}
}

int main(int argc, char *argv[])
{
initLog();
Expand Down Expand Up @@ -279,6 +297,20 @@ int main(int argc, char *argv[])
// Notify dde-desktop start up
registerDDESession();

QElapsedTimer timer;
timer.start();

int maxTime = 2000;
while (maxTime > 0) {
QString type = getCompositingType();
if (!type.isEmpty())
break;
QThread::msleep(50);
maxTime -= 50;
}
qint64 elapsed = timer.nsecsElapsed() / 1000000;
qWarning() << "waiting for kwin ready cost" << elapsed << "ms";

int ret { a.exec() };
DPF_NAMESPACE::LifeCycle::shutdownPlugins();
return ret;
Expand Down

0 comments on commit e6fb0c1

Please sign in to comment.