summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2012-10-24 12:57:01 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-11-15 13:56:58 +0100
commit2ca6606dca44253df49f4805028a9878e4fa0237 (patch)
treefe8abcc26f3ad6802c236a9e4f9b193270246b66 /src/gui
parent9ae215925159f4e8f1a88fc6691c916eead67539 (diff)
Bring back -nograb/-dograb for debugging.
Task-number: QTBUG-27632 Change-Id: I4b59df01519af4684d9dbe6e4b6c18a5ebd9aeae Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qguiapplication.cpp25
-rw-r--r--src/gui/kernel/qguiapplication_p.h1
-rw-r--r--src/gui/kernel/qwindow.cpp4
3 files changed, 30 insertions, 0 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 4c4e75c4f6..949c963d0c 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -151,6 +151,7 @@ QWindow *QGuiApplicationPrivate::focus_window = 0;
static QBasicMutex applicationFontMutex;
QFont *QGuiApplicationPrivate::app_font = 0;
bool QGuiApplicationPrivate::obey_desktop_settings = true;
+bool QGuiApplicationPrivate::noGrab = false;
static qreal fontSmoothingGamma = 1.7;
@@ -864,8 +865,18 @@ void QGuiApplicationPrivate::setEventDispatcher(QAbstractEventDispatcher *eventD
}
+#if defined(QT_DEBUG) && defined(Q_OS_LINUX)
+// Find out if our parent process is gdb by looking at the 'exe' symlink under /proc.
+static bool runningUnderDebugger()
+{
+ const QFileInfo parentProcExe(QStringLiteral("/proc/") + QString::number(getppid()) + QStringLiteral("/exe"));
+ return parentProcExe.isSymLink() && parentProcExe.symLinkTarget().endsWith(QStringLiteral("/gdb"));
+}
+#endif
+
void QGuiApplicationPrivate::init()
{
+ bool doGrabUnderDebugger = false;
QList<QByteArray> pluginList;
// Get command line params
@@ -894,6 +905,10 @@ void QGuiApplicationPrivate::init()
QDir::setCurrent(qbundlePath.section(QLatin1Char('/'), 0, -2));
}
#endif
+ } else if (arg == "-nograb") {
+ QGuiApplicationPrivate::noGrab = true;
+ } else if (arg == "-dograb") {
+ doGrabUnderDebugger = true;
} else {
argv[j++] = argv[i];
}
@@ -904,6 +919,16 @@ void QGuiApplicationPrivate::init()
argc = j;
}
+#if defined(QT_DEBUG) && defined(Q_OS_LINUX)
+ if (!doGrabUnderDebugger && !QGuiApplicationPrivate::noGrab && runningUnderDebugger()) {
+ QGuiApplicationPrivate::noGrab = true;
+ qDebug("Qt: gdb: -nograb added to command-line options.\n"
+ "\t Use the -dograb option to enforce grabbing.");
+ }
+#else
+ Q_UNUSED(doGrabUnderDebugger)
+#endif
+
// Load environment exported generic plugins
foreach (const QByteArray &plugin, qgetenv("QT_QPA_GENERIC_PLUGINS").split(','))
pluginList << plugin;
diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h
index 173f4e6ba2..9044d40ab0 100644
--- a/src/gui/kernel/qguiapplication_p.h
+++ b/src/gui/kernel/qguiapplication_p.h
@@ -220,6 +220,7 @@ public:
QStyleHints *styleHints;
static bool obey_desktop_settings;
+ static bool noGrab;
QInputMethod *inputMethod;
static QList<QObject *> generic_plugin_list;
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index 9fb3c70efb..f930c720c2 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -1314,6 +1314,8 @@ QPlatformSurface *QWindow::surfaceHandle() const
bool QWindow::setKeyboardGrabEnabled(bool grab)
{
Q_D(QWindow);
+ if (grab && QGuiApplicationPrivate::noGrab)
+ return false;
if (d->platformWindow)
return d->platformWindow->setKeyboardGrabEnabled(grab);
return false;
@@ -1331,6 +1333,8 @@ bool QWindow::setKeyboardGrabEnabled(bool grab)
bool QWindow::setMouseGrabEnabled(bool grab)
{
Q_D(QWindow);
+ if (grab && QGuiApplicationPrivate::noGrab)
+ return false;
if (d->platformWindow)
return d->platformWindow->setMouseGrabEnabled(grab);
return false;