Commit 2982c7a8 authored by David Redondo's avatar David Redondo 🏎
Browse files

Always show dialog before calling setParentWindow

Instead of having a dodgy connection that relies on timing behavior,
make sure the dialog is visible. A warning is printed if it is not
visible so we know there is a non working case and can fix it.
BUG:450370
parent 5475aeec
Pipeline #138532 passed with stage
in 1 minute and 3 seconds
......@@ -61,6 +61,7 @@ uint AccessPortal::AccessDialog(const QDBusObjectPath &handle,
// TODO choices
accessDialog->createDialog();
accessDialog->windowHandle()->show();
Utils::setParentWindow(accessDialog->windowHandle(), parent_window);
if (options.contains(QStringLiteral("modal"))) {
accessDialog->windowHandle()->setModality(options.value(QStringLiteral("modal")).toBool() ? Qt::WindowModal : Qt::NonModal);
......
......@@ -10,6 +10,7 @@
#include "utils.h"
#include <QLoggingCategory>
#include <QWindow>
Q_LOGGING_CATEGORY(XdgDesktopPortalKdeAccount, "xdp-kde-account")
......@@ -41,6 +42,7 @@ uint AccountPortal::GetUserInformation(const QDBusObjectPath &handle,
}
UserInfoDialog *userInfoDialog = new UserInfoDialog(reason);
userInfoDialog->windowHandle()->show();
Utils::setParentWindow(userInfoDialog->windowHandle(), parent_window);
int result = userInfoDialog->exec();
......
......@@ -10,6 +10,7 @@
#include "utils.h"
#include <QLoggingCategory>
#include <QWindow>
Q_LOGGING_CATEGORY(XdgDesktopPortalKdeAppChooser, "xdp-kde-app-chooser")
......@@ -48,6 +49,7 @@ uint AppChooserPortal::ChooseApplication(const QDBusObjectPath &handle,
}
AppChooserDialog *appDialog = new AppChooserDialog(choices, latestChoice, itemName.toString(), options.value(QStringLiteral("content_type")).toString());
m_appChooserDialogs.insert(handle.path(), appDialog);
appDialog->windowHandle()->show();
Utils::setParentWindow(appDialog->windowHandle(), parent_window);
int result = appDialog->exec();
......
......@@ -270,6 +270,7 @@ uint FileChooserPortal::OpenFile(const QDBusObjectPath &handle,
}
dirDialog.winId(); // Trigger window creation
dirDialog.show();
Utils::setParentWindow(&dirDialog, parent_window);
if (dirDialog.exec() != QDialog::Accepted) {
......@@ -299,6 +300,7 @@ uint FileChooserPortal::OpenFile(const QDBusObjectPath &handle,
}
QScopedPointer<FileDialog, QScopedPointerDeleteLater> fileDialog(new FileDialog());
fileDialog->show();
Utils::setParentWindow(fileDialog.data(), parent_window);
fileDialog->setWindowTitle(title);
fileDialog->setModal(modalDialog);
......@@ -449,6 +451,7 @@ uint FileChooserPortal::SaveFile(const QDBusObjectPath &handle,
}
QScopedPointer<FileDialog, QScopedPointerDeleteLater> fileDialog(new FileDialog());
fileDialog->show();
Utils::setParentWindow(fileDialog.data(), parent_window);
fileDialog->setWindowTitle(title);
fileDialog->setModal(modalDialog);
......
......@@ -506,6 +506,7 @@ uint PrintPortal::PreparePrint(const QDBusObjectPath &handle,
printer->setPageMargins(pageMargins, QPageLayout::Millimeter);
QPrintDialog *printDialog = new QPrintDialog(printer);
printDialog->show();
Utils::setParentWindow(printDialog, parent_window);
// Process options
......
......@@ -13,6 +13,7 @@
#include "waylandintegration.h"
#include <QLoggingCategory>
#include <QWindow>
Q_LOGGING_CATEGORY(XdgDesktopPortalKdeRemoteDesktop, "xdp-kde-remotedesktop")
......@@ -116,6 +117,7 @@ uint RemoteDesktopPortal::Start(const QDBusObjectPath &handle,
QScopedPointer<RemoteDesktopDialog, QScopedPointerDeleteLater> remoteDesktopDialog(
new RemoteDesktopDialog(app_id, session->deviceTypes(), session->screenSharingEnabled(), session->multipleSources()));
remoteDesktopDialog->windowHandle()->show();
Utils::setParentWindow(remoteDesktopDialog->windowHandle(), parent_window);
connect(session, &Session::closed, remoteDesktopDialog.data(), &RemoteDesktopDialog::reject);
......
......@@ -18,6 +18,7 @@
#include <KSharedConfig>
#include <QLoggingCategory>
#include <QWindow>
Q_LOGGING_CATEGORY(XdgDesktopPortalKdeScreenCast, "xdp-kde-screencast")
......@@ -141,6 +142,7 @@ uint ScreenCastPortal::Start(const QDBusObjectPath &handle,
QScopedPointer<ScreenChooserDialog, QScopedPointerDeleteLater> screenDialog(
new ScreenChooserDialog(app_id, session->multipleSources(), SourceTypes(session->types())));
screenDialog->windowHandle()->show();
Utils::setParentWindow(screenDialog->windowHandle(), parent_window);
connect(session, &Session::closed, screenDialog.data(), &ScreenChooserDialog::reject);
......
......@@ -87,6 +87,7 @@ uint ScreenshotPortal::Screenshot(const QDBusObjectPath &handle,
qCDebug(XdgDesktopPortalKdeScreenshot) << " options: " << options;
QPointer<ScreenshotDialog> screenshotDialog = new ScreenshotDialog;
screenshotDialog->windowHandle()->show();
Utils::setParentWindow(screenshotDialog->windowHandle(), parent_window);
const bool modal = options.value(QStringLiteral("modal"), false).toBool();
......
......@@ -406,20 +406,12 @@ void WaylandIntegration::WaylandIntegrationPrivate::setParentWindow(QWindow *win
return;
}
auto importedParent = m_xdgImporter->importTopLevel(parentHandle, window);
if (window->isVisible()) {
importedParent->setParentOf(KWayland::Client::Surface::fromWindow(window));
} else {
connect(
window,
&QWindow::visibleChanged,
this,
[importedParent, window, this] {
importedParent->setParentOf(KWayland::Client::Surface::fromWindow(window));
QObject::disconnect(this);
},
Qt::QueuedConnection);
if (!window->isVisible()) {
qCWarning(XdgDesktopPortalKdeWaylandIntegration) << "setParentWindow called with non-visible window, call show() before";
return;
}
auto importedParent = m_xdgImporter->importTopLevel(parentHandle, window);
importedParent->setParentOf(KWayland::Client::Surface::fromWindow(window));
}
void WaylandIntegration::WaylandIntegrationPrivate::authenticate()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment