summaryrefslogtreecommitdiffstats
path: root/src/windowmanager.cpp
diff options
context:
space:
mode:
authorSimon Rettberg2019-07-04 15:04:58 +0200
committerSimon Rettberg2019-07-04 15:04:58 +0200
commit65a4fff11c84c886bce97e103f6177becd34c879 (patch)
treefd0e639b21c1663f73db05b683b192ac2d6cc7b5 /src/windowmanager.cpp
parentGive 'last lectures' a section as it's expected everywhere (diff)
downloadvmchooser2-65a4fff11c84c886bce97e103f6177becd34c879.tar.gz
vmchooser2-65a4fff11c84c886bce97e103f6177becd34c879.tar.xz
vmchooser2-65a4fff11c84c886bce97e103f6177becd34c879.zip
Change WM spawning once again to hopefully fix invisible chooser
Now we wait until the chooser window is actually visible and only then try to spawn openbox. This leads to the problem of vmchooser not having focus in case we really didn't have a WM before. For that reason, try to give focus to vmchooser again by calling wmctrl...........
Diffstat (limited to 'src/windowmanager.cpp')
-rw-r--r--src/windowmanager.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/windowmanager.cpp b/src/windowmanager.cpp
index e85a08e..077801e 100644
--- a/src/windowmanager.cpp
+++ b/src/windowmanager.cpp
@@ -14,24 +14,26 @@ static void killInstance();
void ensureRunning()
{
+ static bool once = false;
+ if (once)
+ return;
+ once = true;
wm.start(QLatin1String("openbox"));
wm.closeReadChannel(QProcess::StandardError);
wm.closeReadChannel(QProcess::StandardOutput);
wm.closeWriteChannel();
wm.waitForStarted(500);
- // Ugly, but if openbox initializes just as we map
- // the main window, it might become invisible
- for (int i = 0; i < 10 && wm.state() == QProcess::Running; ++i) {
- QThread::msleep(25);
- }
- if (wm.state() == QProcess::Running) {
- qDebug() << "- Spawned openbox";
- QObject::connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, killInstance);
- } else if (wm.exitCode() == 0) {
- qDebug() << "- A WM is already running";
- } else {
- qDebug() << "- openbox binary not in $PATH";
- }
+ QTimer::singleShot(100, []() {
+ if (wm.state() == QProcess::Running) {
+ qDebug() << "- Spawned openbox";
+ QObject::connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, killInstance);
+ QProcess::startDetached("wmctrl", QStringList() << "-a" << "vmchooser" << "-F");
+ } else if (wm.exitCode() == 0) {
+ qDebug() << "- A WM is already running";
+ } else {
+ qDebug() << "- openbox binary not in $PATH";
+ }
+ });
}
void stopOwnInstance()