Windows: Activate popup when there is no active window.

Port af7d2b2127dadbdf828c60c75255bb1b4f591651 and
9ffdfa58b3ad2ed4100a7d223a85399b72c6deb7 for QTBUG-7386 from
Qt 4.

Task-number: QTBUG-44928
Task-number: QTBUG-7386
Change-Id: I119b75349ff30b19f56ecad7fdecf898ac0797d6
Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>
Reviewed-by: Andy Shaw <andy.shaw@digia.com>
This commit is contained in:
Friedemann Kleint 2015-03-11 17:11:18 +01:00
parent 3e503b197d
commit d425563bac

View File

@ -1074,7 +1074,8 @@ QWindowsWindowData
void QWindowsWindow::setVisible(bool visible)
{
qCDebug(lcQpaWindows) << __FUNCTION__ << this << window() << m_data.hwnd << visible;
const QWindow *win = window();
qCDebug(lcQpaWindows) << __FUNCTION__ << this << win << m_data.hwnd << visible;
if (m_data.hwnd) {
if (visible) {
show_sys();
@ -1082,11 +1083,13 @@ void QWindowsWindow::setVisible(bool visible)
// When the window is layered, we won't get WM_PAINT, and "we" are in control
// over the rendering of the window
// There is nobody waiting for this, so we don't need to flush afterwards.
if (isLayered()) {
QWindow *w = window();
fireExpose(QRect(0, 0, w->width(), w->height()));
}
if (isLayered())
fireExpose(QRect(0, 0, win->width(), win->height()));
// QTBUG-44928, QTBUG-7386: This is to resolve the problem where popups are
// opened from the system tray and not being implicitly activated
if (win->type() == Qt::Popup && !win->parent() && !QGuiApplication::focusWindow())
SetForegroundWindow(m_data.hwnd);
} else {
if (hasMouseCapture())
setMouseGrabEnabled(false);