diff --git a/src/ioslaves/http/kcookiejar/kcookieserver.cpp b/src/ioslaves/http/kcookiejar/kcookieserver.cpp --- a/src/ioslaves/http/kcookiejar/kcookieserver.cpp +++ b/src/ioslaves/http/kcookiejar/kcookieserver.cpp @@ -236,7 +236,8 @@ mCookieJar->preferredDefaultPolicy(), mCookieJar->showCookieDetails()); if (windowId > 0) { - KWindowSystem::setMainWindow(kw, windowId); + kw->setAttribute(Qt::WA_NativeWindow, true); + KWindowSystem::setMainWindow(kw->windowHandle(), windowId); } KCookieAdvice userAdvice = kw->advice(mCookieJar, currentCookie); diff --git a/src/ioslaves/http/kcookiejar/kcookiewin.cpp b/src/ioslaves/http/kcookiejar/kcookiewin.cpp --- a/src/ioslaves/http/kcookiejar/kcookiewin.cpp +++ b/src/ioslaves/http/kcookiejar/kcookiewin.cpp @@ -67,7 +67,8 @@ setWindowIcon(QIcon::fromTheme(QStringLiteral("preferences-web-browser-cookies"))); // all cookies in the list should have the same window at this time, so let's take the first if (!cookieList.first().windowIds().isEmpty()) { - KWindowSystem::setMainWindow(this, cookieList.first().windowIds().first()); + setAttribute(Qt::WA_NativeWindow, true); + KWindowSystem::setMainWindow(windowHandle(), cookieList.first().windowIds().first()); } else { // No window associated... make sure the user notices our dialog. KWindowSystem::setState(winId(), NET::KeepAbove); diff --git a/src/kpasswdserver/kpasswdserver.cpp b/src/kpasswdserver/kpasswdserver.cpp --- a/src/kpasswdserver/kpasswdserver.cpp +++ b/src/kpasswdserver/kpasswdserver.cpp @@ -575,11 +575,8 @@ QStringList(), QString(), nullptr, (KMessageBox::Notify | KMessageBox::NoExec)); - #ifndef Q_WS_WIN - KWindowSystem::setMainWindow(dlg, request->windowId); - #else - KWindowSystem::setMainWindow(dlg, (HWND)(long)request->windowId); - #endif + dlg->setAttribute(Qt::WA_NativeWindow, true); + KWindowSystem::setMainWindow(dlg->windowHandle(), request->windowId); qCDebug(category) << "Calling open on retry dialog" << dlg; m_authRetryInProgress.insert(dlg, request.take()); @@ -850,11 +847,7 @@ #endif // instantiate dialog -#ifndef Q_WS_WIN qCDebug(category) << "Widget for" << request->windowId << QWidget::find(request->windowId); -#else - qCDebug(category) << "Widget for" << request->windowId << QWidget::find((HWND)request->windowId); -#endif KPasswordDialog* dlg = new KPasswordDialog(nullptr, dialogFlags); connect(dlg, &QDialog::finished, this, &KPasswdServer::passwordDialogDone); @@ -888,11 +881,8 @@ dlg->setAnonymousMode(info.getExtraField(AUTHINFO_EXTRAFIELD_ANONYMOUS).toBool()); #ifndef Q_OS_MACOS -#ifndef Q_WS_WIN - KWindowSystem::setMainWindow(dlg, request->windowId); -#else - KWindowSystem::setMainWindow(dlg, (HWND)request->windowId); -#endif + dlg->setAttribute(Qt::WA_NativeWindow, true); + KWindowSystem::setMainWindow(dlg->windowHandle(), request->windowId); #else KWindowSystem::forceActiveWindow(dlg->winId(), 0); #endif