diff --git a/src/functions.h b/src/functions.h --- a/src/functions.h +++ b/src/functions.h @@ -140,7 +140,7 @@ void outputAlarmWarnings(QWidget* parent, const KAEvent* = nullptr); void refreshAlarms(); void refreshAlarmsIfQueued(); // must only be called from KAlarmApp::processQueue() -QString runKMail(bool minimise); +QString runKMail(); QStringList dontShowErrors(const EventId&); bool dontShowErrors(const EventId&, const QString& tag); diff --git a/src/functions.cpp b/src/functions.cpp --- a/src/functions.cpp +++ b/src/functions.cpp @@ -67,15 +67,6 @@ #include #include -#if KDEPIM_HAVE_X11 -#include -#include -#include -#include -#include -#include -#endif - #include #include #include @@ -87,11 +78,6 @@ #include #include "kalarm_debug.h" -#if KDEPIM_HAVE_X11 -#include -#include -#endif - using namespace Akonadi; @@ -1396,15 +1382,13 @@ * Reply = reason for failure to run KMail (which may be the empty string) * = null string if success. */ -QString runKMail(bool minimise) +QString runKMail() { QDBusReply reply = QDBusConnection::sessionBus().interface()->isServiceRegistered(KMAIL_DBUS_SERVICE); if (!reply.isValid() || !reply.value()) { // Program is not already running, so start it QString errmsg; - if (minimise && Private::startKMailMinimised()) - return QString(); if (KToolInvocation::startServiceByDesktopName(QStringLiteral("org.kde.kmail2"), QString(), &errmsg)) { qCCritical(KALARM_LOG) << "Couldn't start KMail (" << errmsg << ")"; @@ -1414,92 +1398,6 @@ return QString(); } -/****************************************************************************** -* Start KMail, minimised. -* This code is taken from kstart in kdebase. -*/ -bool Private::startKMailMinimised() -{ -#if KDEPIM_HAVE_X11 - NETRootInfo i(QX11Info::connection(), NET::Supported, NET::Properties2()); - if (i.isSupported(NET::WM2KDETemporaryRules)) - { - qCDebug(KALARM_LOG) << "startKMailMinimised: using rules"; - KXMessages msg; - QString message = QLatin1String("wmclass=kmail\nwmclassmatch=1\n" // 1 = exact match - "wmclasscomplete=false\n" - "minimize=true\nminimizerule=3\n" - "type=") + QString().setNum(NET::Normal) + QLatin1String("\ntyperule=2"); - msg.broadcastMessage("_KDE_NET_WM_TEMPORARY_RULES", message, -1); - QCoreApplication::processEvents(); - } - else - { - // Connect to window add to get the NEW windows - qCDebug(KALARM_LOG) << "startKMailMinimised: connecting to window add"; - connect(KWindowSystem::self(), &KWindowSystem::windowAdded, instance(), &Private::windowAdded); - } - // Propagate the app startup notification info to the started app. - // We are not using KApplication, so the env remained set. - KStartupInfoId id = KStartupInfo::currentStartupIdEnv(); - KProcess* proc = new KProcess; - (*proc) << QStringLiteral("kmail"); - int pid = proc->startDetached(); - if (!pid) - { - KStartupInfo::sendFinish(id); // failed to start - return false; - } - KStartupInfoData data; - data.addPid(pid); - data.setName(QLatin1String("kmail")); - data.setBin(QLatin1String("kmail")); - KStartupInfo::sendChange(id, data); - return true; -#else - return false; -#endif -} - -/****************************************************************************** -* Called when a window is created, to minimise it. -* This code is taken from kstart in kdebase. -*/ -void Private::windowAdded(WId w) -{ -#if KDEPIM_HAVE_X11 - static const NET::WindowTypes SUPPORTED_TYPES = - NET::NormalMask | NET::DesktopMask | NET::DockMask - | NET::ToolbarMask | NET::MenuMask | NET::DialogMask - | NET::OverrideMask | NET::TopMenuMask | NET::UtilityMask | NET::SplashMask; - KWindowInfo kwinfo(w, NET::WMWindowType | NET::WMName); - if (kwinfo.windowType(SUPPORTED_TYPES) == NET::TopMenu - || kwinfo.windowType(SUPPORTED_TYPES) == NET::Toolbar - || kwinfo.windowType(SUPPORTED_TYPES) == NET::Desktop) - return; // always ignore these window types - - Display* display = QX11Info::display(); - XWithdrawWindow(display, w, QX11Info::appScreen()); - QCoreApplication::processEvents(); - - NETWinInfo info(QX11Info::connection(), w, QX11Info::appRootWindow(), NET::WMState, NET::Properties2()); - XWMHints* hints = XGetWMHints(display, w); - if (hints) - { - hints->flags |= StateHint; - hints->initial_state = IconicState; - XSetWMHints(display, w, hints); - XFree(hints); - } - info.setWindowType(NET::Normal); - - XSync(display, False); - XMapWindow(display, w); - XSync(display, False); - QCoreApplication::processEvents(); -#endif -} - /****************************************************************************** * The "Don't show again" option for error messages is personal to the user on a * particular computer. For example, he may want to inhibit error messages only diff --git a/src/functions_p.h b/src/functions_p.h --- a/src/functions_p.h +++ b/src/functions_p.h @@ -36,7 +36,6 @@ Q_OBJECT public: explicit Private(QObject* parent = nullptr) : QObject(parent), mMsgParent(nullptr) {} - static bool startKMailMinimised(); static Private* instance() { if (!mInstance) @@ -47,7 +46,6 @@ QWidget* mMsgParent; public Q_SLOTS: - void windowAdded(WId); void cancelRtcWake(); private: diff --git a/src/messagewin.cpp b/src/messagewin.cpp --- a/src/messagewin.cpp +++ b/src/messagewin.cpp @@ -2007,7 +2007,7 @@ qCDebug(KALARM_LOG) << "MessageWin::slotShowKMailMessage"; if (!mKMailSerialNumber) return; - const QString err = KAlarm::runKMail(false); + const QString err = KAlarm::runKMail(); if (!err.isNull()) { KAMessageBox::sorry(this, err);