Ignore alert on an active window

When QWindow::alert() is called with a duration of 0, it calls
QPlatformWindow::setAlertState(true), and expects the alert state to be
reset when the window is next activated. Other calls to alert are
ignored while alertState is still true.

If alert was called for an active window, it would remain in the alert
state until deactivated and activated again, and on some platforms calls
to alert would be broken while deactivated.

Alerting doesn't make sense for active windows, so we can simply ignore
it, which was the behavior with Qt 4 on some platforms.

Change-Id: Ia3324da4c89db711b63eb31cddf0bf742bb4e3b8
Found-By: Jan Noertemann <jan.noertemann@uni-dortmund.de>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Martin Gräßlin <mgraesslin@kde.org>
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
bb10
John Brooks 2014-10-15 15:55:36 -06:00 committed by Shawn Rutledge
parent 0b49ce2f8e
commit 136ccaa276
1 changed files with 2 additions and 2 deletions

View File

@ -2299,7 +2299,7 @@ QWindow *QWindow::fromWinId(WId id)
/*!
Causes an alert to be shown for \a msec miliseconds. If \a msec is \c 0 (the
default), then the alert is shown indefinitely until the window becomes
active again.
active again. This function has no effect on an active window.
In alert state, the window indicates that it demands attention, for example by
flashing or bouncing the taskbar entry.
@ -2310,7 +2310,7 @@ QWindow *QWindow::fromWinId(WId id)
void QWindow::alert(int msec)
{
Q_D(QWindow);
if (!d->platformWindow || d->platformWindow->isAlertState())
if (!d->platformWindow || d->platformWindow->isAlertState() || isActive())
return;
d->platformWindow->setAlertState(true);
if (d->platformWindow->isAlertState() && msec)