Add focusWindowChanged signal to QGuiApplication
authorJames Turner <james.turner@kdab.com>
Fri, 13 Apr 2012 09:57:43 +0000 (10:57 +0100)
committerQt by Nokia <qt-info@nokia.com>
Wed, 16 May 2012 17:36:48 +0000 (19:36 +0200)
Required for Cocoa platform menus support, we need a
way to update state after focusWindow() result changes.

Change-Id: Idc573888c3d75bcbff2252e243c4b57b15fc2fcd
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
src/gui/kernel/qguiapplication.cpp
src/gui/kernel/qguiapplication.h

index 4aa3348..03c28a7 100644 (file)
@@ -521,6 +521,13 @@ QWindow *QGuiApplication::focusWindow()
 */
 
 /*!
+    \fn QGuiApplication::focusWindowChanged(QWindow *focusWindow)
+
+    This signal is emitted when the focused window changes.
+    \sa focusWindow()
+*/
+
+/*!
     Returns the QObject in currently active window that will be final receiver of events
     tied to focus, such as key events.
  */
@@ -1337,6 +1344,8 @@ void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate
         if (previousFocusObject != qApp->focusObject())
             self->q_updateFocusObject(qApp->focusObject());
     }
+
+    emit qApp->focusWindowChanged(newFocus);
 }
 
 void QGuiApplicationPrivate::processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *wse)
index 9aad39e..a366826 100644 (file)
@@ -148,6 +148,7 @@ Q_SIGNALS:
     void screenAdded(QScreen *screen);
     void lastWindowClosed();
     void focusObjectChanged(QObject *focusObject);
+    void focusWindowChanged(QWindow *focusWindow);
 
 protected:
     bool event(QEvent *);