Send ApplicationActivate and ApplicationDeactivate from QtGui.

Instead of only from QApplication in QtWidgets, as we need these events
for example in QDeclarativeApplication.

Task-number: QTBUG-21573
Task-number: QTBUG-23331
Change-Id: I0c960bd1c7911d306d274a6e9a1838f158235ed0
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
This commit is contained in:
Samuel Rødal 2011-12-09 17:29:25 +01:00 committed by Qt by Nokia
parent 16696ce493
commit a23a5487eb
2 changed files with 10 additions and 19 deletions

View File

@ -753,9 +753,6 @@ void QGuiApplicationPrivate::processLeaveEvent(QWindowSystemInterfacePrivate::Le
void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e)
{
if (!e->activated)
return;
QWindow *previous = QGuiApplicationPrivate::focus_window;
QGuiApplicationPrivate::focus_window = e->activated.data();
@ -765,10 +762,18 @@ void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate
if (previous) {
QFocusEvent focusOut(QEvent::FocusOut);
QCoreApplication::sendSpontaneousEvent(previous, &focusOut);
} else {
QEvent appActivate(QEvent::ApplicationActivate);
qApp->sendSpontaneousEvent(qApp, &appActivate);
}
QFocusEvent focusIn(QEvent::FocusIn);
QCoreApplication::sendSpontaneousEvent(QGuiApplicationPrivate::focus_window, &focusIn);
if (QGuiApplicationPrivate::focus_window) {
QFocusEvent focusIn(QEvent::FocusIn);
QCoreApplication::sendSpontaneousEvent(QGuiApplicationPrivate::focus_window, &focusIn);
} else {
QEvent appActivate(QEvent::ApplicationDeactivate);
qApp->sendSpontaneousEvent(qApp, &appActivate);
}
if (self)
self->notifyActiveWindowChange(previous);

View File

@ -2326,13 +2326,6 @@ void QApplication::setActiveWindow(QWidget* act)
QEvent windowActivate(QEvent::WindowActivate);
QEvent windowDeactivate(QEvent::WindowDeactivate);
#if !defined(Q_WS_MAC)
if (!previousActiveWindow) {
QEvent appActivate(QEvent::ApplicationActivate);
sendSpontaneousEvent(qApp, &appActivate);
}
#endif
for (int i = 0; i < toBeActivated.size(); ++i) {
QWidget *w = toBeActivated.at(i);
sendSpontaneousEvent(w, &windowActivate);
@ -2352,13 +2345,6 @@ void QApplication::setActiveWindow(QWidget* act)
sendSpontaneousEvent(w, &activationChange);
}
#if !defined(Q_WS_MAC)
if (!QApplicationPrivate::active_window) {
QEvent appDeactivate(QEvent::ApplicationDeactivate);
sendSpontaneousEvent(qApp, &appDeactivate);
}
#endif
if (QApplicationPrivate::popupWidgets == 0) { // !inPopupMode()
// then focus events
if (!QApplicationPrivate::active_window && QApplicationPrivate::focus_widget) {