diff --git a/useractions.cpp b/useractions.cpp index 1fcde01943..478f14c2dd 100644 --- a/useractions.cpp +++ b/useractions.cpp @@ -96,7 +96,6 @@ UserActionsMenu::UserActionsMenu(QObject *parent) , m_closeOperation(NULL) , m_removeFromTabGroup(NULL) , m_closeTabGroup(NULL) - , m_client(QWeakPointer()) { } @@ -132,8 +131,9 @@ bool UserActionsMenu::isMenuClient(const AbstractClient *c) const return c == m_client.data(); } -void UserActionsMenu::show(const QRect &pos, const QWeakPointer &cl) +void UserActionsMenu::show(const QRect &pos, AbstractClient *client) { + QPointer cl(client); if (!KAuthorized::authorizeAction(QStringLiteral("kwin_rmb"))) return; if (cl.isNull()) @@ -189,7 +189,7 @@ void UserActionsMenu::grabInput() m_menu->windowHandle()->setKeyboardGrabEnabled(true); } -void UserActionsMenu::helperDialog(const QString& message, const QWeakPointer &c) +void UserActionsMenu::helperDialog(const QString& message, AbstractClient* client) { QStringList args; QString type; @@ -226,8 +226,8 @@ void UserActionsMenu::helperDialog(const QString& message, const QWeakPointerwindowId()); + if (client) + args << QStringLiteral("--embed") << QString::number(client->windowId()); QtConcurrent::run([args]() { KProcess::startDetached(QStringLiteral("kdialog"), args); }); @@ -835,17 +835,17 @@ void UserActionsMenu::slotWindowOperation(QAction *action) return; Options::WindowOperation op = static_cast< Options::WindowOperation >(action->data().toInt()); - QWeakPointer c = (!m_client.isNull()) ? m_client : QWeakPointer(Workspace::self()->activeClient()); + QPointer c = m_client ? m_client : QPointer(Workspace::self()->activeClient()); if (c.isNull()) return; QString type; switch(op) { case Options::FullScreenOp: - if (!c.data()->isFullScreen() && c.data()->userCanSetFullScreen()) + if (!c->isFullScreen() && c->userCanSetFullScreen()) type = QStringLiteral("fullscreenaltf3"); break; case Options::NoBorderOp: - if (!c.data()->noBorder() && c.data()->userCanSetNoBorder()) + if (!c->noBorder() && c->userCanSetNoBorder()) type = QStringLiteral("noborderaltf3"); break; default: @@ -858,7 +858,7 @@ void UserActionsMenu::slotWindowOperation(QAction *action) qRegisterMetaType(); QMetaObject::invokeMethod(workspace(), "performWindowOperation", Qt::QueuedConnection, - Q_ARG(KWin::AbstractClient*, c.data()), + Q_ARG(KWin::AbstractClient*, c), Q_ARG(Options::WindowOperation, op)); } diff --git a/useractions.h b/useractions.h index 294cbca779..6ed13401cb 100644 --- a/useractions.h +++ b/useractions.h @@ -26,6 +26,7 @@ along with this program. If not, see . // Qt #include #include +#include class QAction; class QRect; @@ -98,7 +99,7 @@ public: * @param pos The position where the menu should be shown. * @param client The Client for which the Menu has to be shown. */ - void show(const QRect &pos, const QWeakPointer &client); + void show(const QRect &pos, AbstractClient *client); public Q_SLOTS: /** @@ -219,7 +220,7 @@ private: * @param message The message type to be shown * @param c The Client for which the dialog should be shown. */ - void helperDialog(const QString &message, const QWeakPointer &c); + void helperDialog(const QString &message, AbstractClient *c); /** * The actual main context menu which is show when the UserActionsMenu is invoked. */ @@ -274,7 +275,7 @@ private: /** * The Client for which the menu is shown. */ - QWeakPointer m_client; + QPointer m_client; QAction *m_rulesOperation = nullptr; QAction *m_applicationRulesOperation = nullptr; };