summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Endrodi <ext-adam.endrodi@nokia.com>2010-11-29 16:17:39 +0200
committerAdam Endrodi <ext-adam.endrodi@nokia.com>2010-12-03 14:05:23 +0200
commit8cd5efa1795293eef8573437f7a1f44aec908061 (patch)
tree438e734ff20ea82615b3fcb6521a42acaf619e42
parent761a00c870cf55d81102cd3fc05ebf1c64b7e248 (diff)
delete rootWindow::_NET_SUPPORTING_WM_CHECK on exit
If it remains there all Qt applications will start with a BadWindow error. * src/mcompositemanager_p.h: Added MCompositeManagerPrivate::prepared. * src/mcompositemanager.cpp (MCompositeManager::~MCompositeManager): If prepare()d delete the property. * mcompositor/xserverpinger.h * mcompositor/xserverpinger.cpp: Stand guard for the parent and delete the property for it if terminated by a SIGINT or SIGTERM.
-rw-r--r--mcompositor/xserverpinger.cpp29
-rw-r--r--mcompositor/xserverpinger.h1
-rw-r--r--src/mcompositemanager.cpp13
-rw-r--r--src/mcompositemanager_p.h4
4 files changed, 46 insertions, 1 deletions
diff --git a/mcompositor/xserverpinger.cpp b/mcompositor/xserverpinger.cpp
index 654cf39..afb00b3 100644
--- a/mcompositor/xserverpinger.cpp
+++ b/mcompositor/xserverpinger.cpp
@@ -14,11 +14,13 @@
#include <signal.h>
#include <sys/prctl.h>
+#include <sys/signalfd.h>
// Ping X in @pingInterval miliseconds.
XServerPinger::XServerPinger(int pingInterval)
{
Display *dpy;
+ sigset_t sigs;
// Open a separate connection to X.
dpy = XOpenDisplay(NULL);
@@ -33,6 +35,15 @@ XServerPinger::XServerPinger(int pingInterval)
timer = new QTimer();
connect(timer, SIGNAL(timeout()), SLOT(tick()));
timer->start(pingInterval);
+
+ // die() if we get SIGINT or SIGTERM.
+ sigemptyset(&sigs);
+ sigaddset(&sigs, SIGINT);
+ sigaddset(&sigs, SIGTERM);
+ connect(new QSocketNotifier(signalfd(-1, &sigs, 0),
+ QSocketNotifier::Read),
+ SIGNAL(activated(int)), SLOT(die(int)));
+ sigprocmask(SIG_BLOCK, &sigs, NULL);
}
void XServerPinger::xInput(int)
@@ -68,6 +79,22 @@ void XServerPinger::tick()
qWarning("X is on holidays");
}
+void XServerPinger::die(int)
+{
+ const char *wmcheck = "_NET_SUPPORTING_WM_CHECK";
+
+ xcb_delete_property(xcb,
+ xcb_setup_roots_iterator(xcb_get_setup(xcb)).data->root,
+ xcb_intern_atom_reply(xcb,
+ xcb_intern_atom(xcb,
+ False,
+ strlen(wmcheck),
+ wmcheck),
+ NULL)->atom);
+ xcb_flush(xcb);
+ QCoreApplication::quit();
+}
+
// Start XServerPinger in a separate process if it's not running yet.
static void altmain() __attribute__((constructor));
static void altmain()
@@ -82,7 +109,7 @@ static void altmain()
return;
// Die with the parent.
- prctl(PR_SET_PDEATHSIG, SIGKILL);
+ prctl(PR_SET_PDEATHSIG, SIGTERM);
int meh = 0;
QCoreApplication app(meh, 0);
diff --git a/mcompositor/xserverpinger.h b/mcompositor/xserverpinger.h
index 6482946..8d3c52f 100644
--- a/mcompositor/xserverpinger.h
+++ b/mcompositor/xserverpinger.h
@@ -20,6 +20,7 @@ protected:
public slots:
void xInput(int);
void tick();
+ void die(int);
};
#endif // ! XSERVERPINGER_H
diff --git a/src/mcompositemanager.cpp b/src/mcompositemanager.cpp
index 0f0c80a..a957e98 100644
--- a/src/mcompositemanager.cpp
+++ b/src/mcompositemanager.cpp
@@ -712,6 +712,7 @@ MCompositeManagerPrivate::MCompositeManagerPrivate(QObject *p)
glwidget(0),
compositing(true),
changed_properties(false),
+ prepared(false),
stacking_timeout_check_visibility(false),
stacking_timeout_timestamp(CurrentTime)
{
@@ -734,6 +735,11 @@ MCompositeManagerPrivate::MCompositeManagerPrivate(QObject *p)
MCompositeManagerPrivate::~MCompositeManagerPrivate()
{
+ if (prepared)
+ // Advertise the world we're gone.
+ XDeleteProperty(QX11Info::display(), QX11Info::appRootWindow(),
+ ATOM(_NET_SUPPORTING_WM_CHECK));
+
delete watch;
delete atom;
watch = 0;
@@ -834,6 +840,8 @@ void MCompositeManagerPrivate::prepare()
XSelectInput(QX11Info::display(), home_button_win,
ButtonReleaseMask | ButtonPressMask);
XMapWindow(QX11Info::display(), home_button_win);
+
+ prepared = true;
}
void MCompositeManagerPrivate::loadPlugins()
@@ -3940,6 +3948,9 @@ void MCompositeManager::remoteControl(int cmdfd)
const char **argv;
unsigned i;
+ delete d;
+ XFlush(QX11Info::display());
+
// Convert the QStringList of args into a char *[].
i = 0;
argv = new const char *[args.count()+1];
@@ -3953,6 +3964,8 @@ void MCompositeManager::remoteControl(int cmdfd)
qDebug("Gothca!");
} else if (!strcmp(cmd, "exit") || !strcmp(cmd, "quit")) {
// exit() deadlocks, go the fast route
+ delete d;
+ XFlush(QX11Info::display());
_exit(0);
} else if (!strcmp(cmd, "help")) {
qDebug("Commands i understand:");
diff --git a/src/mcompositemanager_p.h b/src/mcompositemanager_p.h
index 4179cfa..6a27174 100644
--- a/src/mcompositemanager_p.h
+++ b/src/mcompositemanager_p.h
@@ -160,6 +160,10 @@ public:
bool changed_properties;
MDeviceState *device_state;
+ // Indicates whether MCompositeManager::prepare() has finished.
+ // Used by the destructor.
+ bool prepared;
+
xcb_connection_t *xcb_conn;
// mechanism for lazy stacking