@@ -85,7 +85,7 @@ I3Ipc::I3Ipc() {
8585 QObject::connect (&this ->liveEventSocket , &QLocalSocket::errorOccurred, this , &I3Ipc::eventSocketError);
8686 QObject::connect (&this ->liveEventSocket , &QLocalSocket::stateChanged, this , &I3Ipc::eventSocketStateChanged);
8787 QObject::connect (&this ->liveEventSocket , &QLocalSocket::readyRead, this , &I3Ipc::eventSocketReady);
88- QObject::connect (&this ->liveEventSocket , &QLocalSocket::connected, this , &I3Ipc::subscribe );
88+ QObject::connect (&this ->liveEventSocket , &QLocalSocket::connected, this , &I3Ipc::eventSocketConnected );
8989 // clang-format on
9090
9191 this ->liveEventSocketDs .setDevice (&this ->liveEventSocket );
@@ -94,18 +94,23 @@ I3Ipc::I3Ipc() {
9494 this ->liveEventSocket .connectToServer (this ->mSocketPath );
9595}
9696
97- void I3Ipc::subscribe () {
97+ void I3Ipc::eventSocketConnected () {
9898 auto payload = QByteArray (R"( ["workspace","output"])" );
99- auto message = I3Ipc::buildRequestMessage (EventCode::Subscribe, payload);
100-
101- this ->makeRequest (message);
99+ this ->subscribeEvent (payload);
102100
103101 // Workspaces must be refreshed before monitors or no focus will be
104102 // detected on launch.
105103 this ->refreshWorkspaces ();
106104 this ->refreshMonitors ();
107105}
108106
107+ void I3Ipc::subscribe (const QString& payload) { this ->subscribeEvent (payload.toLocal8Bit ()); }
108+
109+ void I3Ipc::subscribeEvent (const QByteArray& payload) {
110+ auto message = I3Ipc::buildRequestMessage (EventCode::Subscribe, payload);
111+ this ->makeRequest (message);
112+ }
113+
109114void I3Ipc::eventSocketReady () {
110115 for (auto & [type, data]: this ->parseResponse ()) {
111116 this ->event .mCode = type;
0 commit comments