From 11070a090a9cc77d02315a3cb39eaf628bd9bfe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 29 Sep 2011 18:02:54 +0200 Subject: Added QWindow::isActive() and focus in / out events. Renamed QGuiApplication::activeWindow() to QGuiApplication::focusWindow(), implemented QWindow::isActive() as a style hint, and added focus in / out events. Change-Id: I71866e76c5a817def3e17bcc20a4fc32081a0e7a Reviewed-on: http://codereview.qt-project.org/5811 Reviewed-by: Qt Sanity Bot Reviewed-by: Gunnar Sletta --- src/widgets/kernel/qapplication_qpa.cpp | 2 +- src/widgets/kernel/qwidgetwindow_qpa.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qapplication_qpa.cpp b/src/widgets/kernel/qapplication_qpa.cpp index 29ac94bfb1..8732a194e8 100644 --- a/src/widgets/kernel/qapplication_qpa.cpp +++ b/src/widgets/kernel/qapplication_qpa.cpp @@ -157,7 +157,7 @@ void QApplicationPrivate::notifyActiveWindowChange(QWindow *previous) { Q_UNUSED(previous); Q_Q(QApplication); - QWindow *wnd = QGuiApplicationPrivate::active_window; + QWindow *wnd = QGuiApplicationPrivate::focus_window; if (inPopupMode()) // some delayed focus event to ignore return; QWidget *tlw = qt_tlw_for_window(wnd); diff --git a/src/widgets/kernel/qwidgetwindow_qpa.cpp b/src/widgets/kernel/qwidgetwindow_qpa.cpp index ee5cd7482e..2265fb55fb 100644 --- a/src/widgets/kernel/qwidgetwindow_qpa.cpp +++ b/src/widgets/kernel/qwidgetwindow_qpa.cpp @@ -79,6 +79,12 @@ bool QWidgetWindow::event(QEvent *event) handleEnterLeaveEvent(event); return true; + // these should not be sent to QWidget, the corresponding events + // are sent by QApplicationPrivate::notifyActiveWindowChange() + case QEvent::FocusIn: + case QEvent::FocusOut: + return false; + case QEvent::KeyPress: case QEvent::KeyRelease: handleKeyEvent(static_cast(event)); -- cgit v1.2.3