mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 10:22:49 +00:00
kwin: rework client killing to not rely on xon program
because xon is no longer a thing (not in debian repos apparently) killing remote clients and killing remote clients required it, assuming XKillClient() knows how to kill remote clients then it will now. if not then.. Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
94bfe02289
commit
87c93679b8
3 changed files with 30 additions and 38 deletions
|
@ -99,7 +99,7 @@ Client::Client()
|
|||
, tab_group(NULL)
|
||||
, in_layer(UnknownLayer)
|
||||
, ping_timer(NULL)
|
||||
, m_killHelperProc(0)
|
||||
, m_killHelperProc(NULL)
|
||||
, m_pingTimestamp(XCB_TIME_CURRENT_TIME)
|
||||
, m_userTime(XCB_TIME_CURRENT_TIME) // Not known yet
|
||||
, allowed_actions(0)
|
||||
|
@ -1248,9 +1248,11 @@ void Client::closeWindow()
|
|||
if (Pdeletewindow) {
|
||||
sendClientMessage(window(), atoms->wm_protocols, atoms->wm_delete_window);
|
||||
pingWindow();
|
||||
} else // Client will not react on wm_delete_window. We have not choice
|
||||
// but destroy his connection to the XServer.
|
||||
} else {
|
||||
// Client will not react on wm_delete_window, No choice but to destroy the
|
||||
// connection to the XServer.
|
||||
killWindow();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1260,7 +1262,6 @@ void Client::closeWindow()
|
|||
void Client::killWindow()
|
||||
{
|
||||
kDebug(1212) << "Client::killWindow():" << caption();
|
||||
killProcess(false);
|
||||
XKillClient(display(), window()); // Always kill this client at the server
|
||||
destroyClient();
|
||||
}
|
||||
|
@ -1303,36 +1304,36 @@ void Client::pingTimeout()
|
|||
kDebug(1212) << "Ping timeout:" << caption();
|
||||
ping_timer->deleteLater();
|
||||
ping_timer = NULL;
|
||||
killProcess(true, m_pingTimestamp);
|
||||
}
|
||||
|
||||
void Client::killProcess(bool ask, xcb_timestamp_t timestamp)
|
||||
{
|
||||
if (m_killHelperProc && m_killHelperProc->state() == QProcess::Running) // means the process is alive
|
||||
return;
|
||||
Q_ASSERT(!ask || timestamp != XCB_TIME_CURRENT_TIME);
|
||||
Q_ASSERT(!ask || m_pingTimestamp != XCB_TIME_CURRENT_TIME);
|
||||
pid_t pid = info->pid();
|
||||
if (pid <= 0 || clientMachine()->hostName().isEmpty()) // Needed properties missing
|
||||
return;
|
||||
kDebug(1212) << "Kill process:" << pid << "(" << clientMachine()->hostName() << ")";
|
||||
if (!ask) {
|
||||
if (!clientMachine()->isLocal()) {
|
||||
QStringList lst;
|
||||
lst << clientMachine()->hostName() << "kill" << QString::number(pid);
|
||||
QProcess::startDetached("xon", lst);
|
||||
} else {
|
||||
::kill(pid, SIGTERM);
|
||||
}
|
||||
} else {
|
||||
QString hostname = clientMachine()->isLocal() ? "localhost" : clientMachine()->hostName();
|
||||
m_killHelperProc = new QProcess(this);
|
||||
m_killHelperProc->start(KStandardDirs::findExe("kwin_killer_helper"),
|
||||
QStringList() << "--pid" << QByteArray::number(qulonglong(pid)) << "--hostname" << hostname
|
||||
<< "--windowname" << caption()
|
||||
<< "--applicationname" << resourceClass()
|
||||
<< "--wid" << QString::number(window())
|
||||
<< "--timestamp" << QString::number(timestamp));
|
||||
QString hostname = clientMachine()->isLocal() ? "localhost" : clientMachine()->hostName();
|
||||
m_killHelperProc = new QProcess(this);
|
||||
connect(m_killHelperProc, SIGNAL(finished(int)), this, SLOT(killHelperFinished(int)));
|
||||
m_killHelperProc->start(
|
||||
KStandardDirs::findExe("kwin_killer_helper"),
|
||||
QStringList() << "--pid" << QByteArray::number(qulonglong(pid)) << "--hostname" << hostname
|
||||
<< "--windowname" << caption()
|
||||
<< "--applicationname" << resourceClass()
|
||||
<< "--wid" << QString::number(window())
|
||||
<< "--timestamp" << QString::number(m_pingTimestamp)
|
||||
);
|
||||
}
|
||||
|
||||
void Client::killHelperFinished(int exitCode)
|
||||
{
|
||||
if (exitCode == 2) {
|
||||
kDebug(1212) << "Kill confirmed:" << caption();
|
||||
killWindow();
|
||||
}
|
||||
kDebug(1212) << "Kill not confirmed:" << caption();
|
||||
m_killHelperProc->deleteLater();
|
||||
m_killHelperProc = nullptr;
|
||||
}
|
||||
|
||||
void Client::setSkipTaskbar(bool b, bool from_outside)
|
||||
|
|
|
@ -666,6 +666,7 @@ private slots:
|
|||
void performMoveResize();
|
||||
void removeSyncSupport();
|
||||
void pingTimeout();
|
||||
void killHelperFinished(int exitCode);
|
||||
|
||||
//Signals for the scripting interface
|
||||
//Signals make an excellent way for communication
|
||||
|
@ -750,7 +751,6 @@ private:
|
|||
void createDecoration(const QRect &oldgeom);
|
||||
|
||||
void pingWindow();
|
||||
void killProcess(bool ask, xcb_timestamp_t timestamp = XCB_TIME_CURRENT_TIME);
|
||||
void updateUrgency();
|
||||
static void sendClientMessage(xcb_window_t w, xcb_atom_t a, xcb_atom_t protocol,
|
||||
long data1 = 0, long data2 = 0, long data3 = 0);
|
||||
|
|
|
@ -72,7 +72,7 @@ int main(int argc, char* argv[])
|
|||
caption = Qt::escape(caption);
|
||||
appname = Qt::escape(appname);
|
||||
hostname = Qt::escape(hostname);
|
||||
QString pidString = QString::number(pid); // format pid ourself as it does not make sense to format an ID according to locale settings
|
||||
QString pidString = QString::number(pid);
|
||||
|
||||
QString question = i18nc("@info", "<b>Application \"%1\" is not responding</b>", appname);
|
||||
question += isLocal
|
||||
|
@ -89,16 +89,7 @@ int main(int argc, char* argv[])
|
|||
KGuiItem cancelButton = KGuiItem(i18n("Wait Longer"), "chronometer");
|
||||
app.updateUserTimestamp(timestamp);
|
||||
if (KMessageBox::warningContinueCancelWId(id, question, QString(), continueButton, cancelButton) == KMessageBox::Continue) {
|
||||
if (!isLocal) {
|
||||
QStringList lst;
|
||||
lst << hostname << "kill" << QString::number(pid);
|
||||
QProcess::startDetached("xon", lst);
|
||||
} else {
|
||||
if (::kill(pid, SIGKILL) == -1) {
|
||||
kWarning(1212) << "KWin process killer failed";
|
||||
}
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue