Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 49 additions & 6 deletions src/core/treeland.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@
#endif

#include <wsocket.h>
#include <wxwayland.h>

Check warning on line 34 in src/core/treeland.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <wxwayland.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <QCoreApplication>

Check warning on line 36 in src/core/treeland.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QCoreApplication> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDBusAbstractAdaptor>

Check warning on line 37 in src/core/treeland.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusAbstractAdaptor> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDBusConnection>

Check warning on line 38 in src/core/treeland.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusConnection> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDBusConnectionInterface>

Check warning on line 39 in src/core/treeland.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusConnectionInterface> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDBusMessage>

Check warning on line 40 in src/core/treeland.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusMessage> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDebug>
#include <QLocalSocket>
#include <QLoggingCategory>
Expand Down Expand Up @@ -265,6 +266,50 @@
std::map<PluginInterface *, QTranslator *> pluginTs;
};


class Compositor1Adaptor: public QDBusAbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.deepin.Compositor1")
Q_CLASSINFO("D-Bus Introspection",
" <interface name=\"org.deepin.Compositor1\">\n"
" <method name=\"ActivateWayland\">\n"
" <arg direction=\"in\" type=\"h\" name=\"fd\"/>\n"
" <arg direction=\"out\" type=\"b\" name=\"result\"/>\n"
" </method>\n"
" <method name=\"XWaylandName\">\n"
" <arg direction=\"out\" type=\"s\" name=\"result\"/>\n"
" <arg direction=\"out\" type=\"ay\" name=\"auth\"/>\n"
" </method>\n"
" <signal name=\"SessionChanged\"/>\n"
" </interface>\n"
"")
public:
Compositor1Adaptor(Treeland *parent)
: QDBusAbstractAdaptor(parent)
{
setAutoRelaySignals(true);
}

inline Treeland *parent() const
{ return static_cast<Treeland *>(QObject::parent()); }

public Q_SLOTS: // METHODS

bool ActivateWayland(const QDBusUnixFileDescriptor &fd)
{
return parent()->ActivateWayland(fd);
}

void XWaylandName()
{
parent()->XWaylandName();
}

Q_SIGNALS: // SIGNALS
void SessionChanged();
};

Treeland::Treeland()
: QObject()
, d_ptr(std::make_unique<TreelandPrivate>(this))
Expand Down Expand Up @@ -310,16 +355,14 @@
}
}

new Compositor1Adaptor(this);

// init dbus after QML engine loaded.
QDBusConnection::systemBus().registerService("org.deepin.Compositor1");
QDBusConnection::systemBus().registerObject("/org/deepin/Compositor1",
this,
QDBusConnection::ExportAllSlots);
QDBusConnection::systemBus().registerObject("/org/deepin/Compositor1", this);

QDBusConnection::sessionBus().registerService("org.deepin.Compositor1");
QDBusConnection::sessionBus().registerObject("/org/deepin/Compositor1",
this,
QDBusConnection::ExportAllSlots);
QDBusConnection::sessionBus().registerObject("/org/deepin/Compositor1", this);

#ifdef QT_DEBUG
QDir dir(QStringLiteral(TREELAND_PLUGINS_OUTPUT_PATH));
Expand Down
14 changes: 0 additions & 14 deletions src/core/treeland.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,6 @@ class Treeland
{
Q_OBJECT
Q_DECLARE_PRIVATE(Treeland)
Q_CLASSINFO("D-Bus Interface", "org.deepin.Compositor1")
Q_CLASSINFO("D-Bus Introspection",
" <interface name=\"org.deepin.Compositor1\">\n"
" <method name=\"ActivateWayland\">\n"
" <arg direction=\"in\" type=\"h\" name=\"fd\"/>\n"
" <arg direction=\"out\" type=\"b\" name=\"result\"/>\n"
" </method>\n"
" <method name=\"XWaylandName\">\n"
" <arg direction=\"out\" type=\"s\" name=\"result\"/>\n"
" <arg direction=\"out\" type=\"ay\" name=\"auth\"/>\n"
" </method>\n"
" <signal name=\"SessionChanged\"/>\n"
" </interface>\n"
"")

public:
explicit Treeland();
Expand Down
4 changes: 3 additions & 1 deletion src/greeter/greeterproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,13 +434,15 @@ void GreeterProxy::readyRead()
} break;
case DaemonMessages::UserLoggedIn: {
QString user;
input >> user;
int sessionId;
input >> user >> sessionId;

// This will happen after a crash recovery of treeland
qCInfo(treelandGreeter) << "User " << user << " is already logged in";
auto userPtr = d->userModel->getUser(user);
if (userPtr) {
userPtr.get()->setLogined(true);
Q_EMIT d->userModel->userLoggedIn(user, sessionId);
} else {
qCWarning(treelandGreeter) << "User " << user << " logged in but not found";
}
Expand Down
12 changes: 0 additions & 12 deletions src/systemd-socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,24 +144,12 @@ int main(int argc, char *argv[])
}
};

QDBusServiceWatcher *compositorWatcher =
new QDBusServiceWatcher("org.deepin.Compositor1",
connection,
QDBusServiceWatcher::WatchForRegistration);

QObject::connect(compositorWatcher,
&QDBusServiceWatcher::serviceRegistered,
compositorWatcher,
activateFd);

// Listen to SessionChanged signal and activate fd when session changed
connection.connect("org.deepin.Compositor1",
"/org/deepin/Compositor1",
"org.deepin.Compositor1",
"SessionChanged",
new SignalReceiver(activateFd),
SLOT(onSessionChanged()));

activateFd();
};

Expand Down