Changeset View
Changeset View
Standalone View
Standalone View
libtaskmanager/xwindowtasksmodel.cpp
Show First 20 Lines • Show All 84 Lines • ▼ Show 20 Line(s) | 61 | public: | |||
---|---|---|---|---|---|
85 | 85 | | |||
86 | QIcon icon(WId window); | 86 | QIcon icon(WId window); | ||
87 | static QString mimeType(); | 87 | static QString mimeType(); | ||
88 | static QString groupMimeType(); | 88 | static QString groupMimeType(); | ||
89 | QUrl windowUrl(WId window); | 89 | QUrl windowUrl(WId window); | ||
90 | QUrl launcherUrl(WId window, bool encodeFallbackIcon = true); | 90 | QUrl launcherUrl(WId window, bool encodeFallbackIcon = true); | ||
91 | QUrl serviceUrl(int pid, const QString &type, const QStringList &cmdRemovals); | 91 | QUrl serviceUrl(int pid, const QString &type, const QStringList &cmdRemovals); | ||
92 | KService::List servicesFromPid(int pid); | 92 | KService::List servicesFromPid(int pid); | ||
93 | KService::List servicesFromCmdLine(const QString &cmdLine, const QString &processName); | ||||
93 | bool demandsAttention(WId window); | 94 | bool demandsAttention(WId window); | ||
94 | 95 | | |||
95 | private: | 96 | private: | ||
96 | XWindowTasksModel *q; | 97 | XWindowTasksModel *q; | ||
97 | }; | 98 | }; | ||
98 | 99 | | |||
99 | XWindowTasksModel::Private::Private(XWindowTasksModel *q) | 100 | XWindowTasksModel::Private::Private(XWindowTasksModel *q) | ||
100 | : q(q) | 101 | : q(q) | ||
▲ Show 20 Lines • Show All 682 Lines • ▼ Show 20 Line(s) | 773 | if (!services.isEmpty()) { | |||
783 | } | 784 | } | ||
784 | } | 785 | } | ||
785 | 786 | | |||
786 | return QUrl(); | 787 | return QUrl(); | ||
787 | } | 788 | } | ||
788 | 789 | | |||
789 | KService::List XWindowTasksModel::Private::servicesFromPid(int pid) | 790 | KService::List XWindowTasksModel::Private::servicesFromPid(int pid) | ||
790 | { | 791 | { | ||
791 | // Attempt to find using commandline... | | |||
792 | KService::List services; | | |||
793 | | ||||
794 | if (pid == 0) { | 792 | if (pid == 0) { | ||
795 | return services; | 793 | return KService::List(); | ||
796 | } | 794 | } | ||
797 | 795 | | |||
798 | KSysGuard::Processes procs; | 796 | KSysGuard::Processes procs; | ||
799 | procs.updateOrAddProcess(pid); | 797 | procs.updateOrAddProcess(pid); | ||
800 | 798 | | |||
801 | KSysGuard::Process *proc = procs.getProcess(pid); | 799 | KSysGuard::Process *proc = procs.getProcess(pid); | ||
802 | QString cmdline = proc ? proc->command().simplified() : QString(); // proc->command has a trailing space??? | 800 | const QString &cmdLine = proc ? proc->command().simplified() : QString(); // proc->command has a trailing space??? | ||
803 | 801 | | |||
804 | if (cmdline.isEmpty()) { | 802 | if (cmdLine.isEmpty()) { | ||
805 | return services; | 803 | return KService::List(); | ||
804 | } | ||||
805 | | ||||
806 | return servicesFromCmdLine(cmdLine, proc->name()); | ||||
806 | } | 807 | } | ||
807 | 808 | | |||
808 | const int firstSpace = cmdline.indexOf(' '); | 809 | KService::List XWindowTasksModel::Private::servicesFromCmdLine(const QString &_cmdLine, const QString &processName) | ||
810 | { | ||||
811 | QString cmdLine = _cmdLine; | ||||
812 | KService::List services; | ||||
813 | | ||||
814 | const int firstSpace = cmdLine.indexOf(' '); | ||||
815 | int slash = 0; | ||||
816 | | ||||
817 | services = KServiceTypeTrader::self()->query(QStringLiteral("Application"), QStringLiteral("exist Exec and ('%1' =~ Exec)").arg(cmdLine)); | ||||
809 | 818 | | |||
810 | services = KServiceTypeTrader::self()->query(QStringLiteral("Application"), QStringLiteral("exist Exec and ('%1' =~ Exec)").arg(cmdline)); | | |||
811 | if (services.empty()) { | 819 | if (services.empty()) { | ||
812 | // Could not find with complete commandline, so strip out path part... | 820 | // Could not find with complete command line, so strip out the path part ... | ||
813 | int slash = cmdline.lastIndexOf('/', firstSpace); | 821 | slash = cmdLine.lastIndexOf('/', firstSpace); | ||
822 | | ||||
814 | if (slash > 0) { | 823 | if (slash > 0) { | ||
815 | services = KServiceTypeTrader::self()->query(QStringLiteral("Application"), QStringLiteral("exist Exec and ('%1' =~ Exec)").arg(cmdline.mid(slash + 1))); | 824 | services = KServiceTypeTrader::self()->query(QStringLiteral("Application"), QStringLiteral("exist Exec and ('%1' =~ Exec)").arg(cmdLine.mid(slash + 1))); | ||
816 | } | 825 | } | ||
817 | } | 826 | } | ||
818 | 827 | | |||
819 | if (services.empty() && firstSpace > 0) { | 828 | if (services.empty() && firstSpace > 0) { | ||
820 | // Could not find with arguments, so try without... | 829 | // Could not find with arguments, so try without ... | ||
821 | cmdline = cmdline.left(firstSpace); | 830 | cmdLine = cmdLine.left(firstSpace); | ||
822 | services = KServiceTypeTrader::self()->query(QStringLiteral("Application"), QStringLiteral("exist Exec and ('%1' =~ Exec)").arg(cmdline)); | 831 | | ||
832 | services = KServiceTypeTrader::self()->query(QStringLiteral("Application"), QStringLiteral("exist Exec and ('%1' =~ Exec)").arg(cmdLine)); | ||||
833 | | ||||
834 | if (services.empty()) { | ||||
835 | slash = cmdLine.lastIndexOf('/'); | ||||
823 | 836 | | |||
824 | int slash = cmdline.lastIndexOf('/'); | | |||
825 | if (slash > 0) { | 837 | if (slash > 0) { | ||
826 | services = KServiceTypeTrader::self()->query(QStringLiteral("Application"), QStringLiteral("exist Exec and ('%1' =~ Exec)").arg(cmdline.mid(slash + 1))); | 838 | services = KServiceTypeTrader::self()->query(QStringLiteral("Application"), QStringLiteral("exist Exec and ('%1' =~ Exec)").arg(cmdLine.mid(slash + 1))); | ||
839 | } | ||||
840 | } | ||||
841 | } | ||||
842 | | ||||
843 | if (services.empty()) { | ||||
844 | KConfigGroup set(rulesConfig, "Settings"); | ||||
845 | const QStringList &runtimes = set.readEntry("TryIgnoreRuntimes", QStringList()); | ||||
846 | | ||||
847 | bool ignore = runtimes.contains(cmdLine); | ||||
848 | | ||||
849 | if (!ignore && slash > 0) { | ||||
850 | ignore = runtimes.contains(cmdLine.mid(slash + 1)); | ||||
851 | } | ||||
852 | | ||||
853 | if (ignore) { | ||||
854 | return servicesFromCmdLine(_cmdLine.mid(firstSpace + 1), processName); | ||||
827 | } | 855 | } | ||
828 | } | 856 | } | ||
829 | 857 | | |||
830 | if (services.empty() && proc && !QStandardPaths::findExecutable(cmdline).isEmpty()) { | 858 | if (services.empty() && !processName.isEmpty() && !QStandardPaths::findExecutable(cmdLine).isEmpty()) { | ||
831 | // cmdline now exists without arguments if there were any | 859 | // cmdLine now exists without arguments if there were any. | ||
832 | services << QExplicitlySharedDataPointer<KService>(new KService(proc->name(), cmdline, QString())); | 860 | services << QExplicitlySharedDataPointer<KService>(new KService(processName, cmdLine, QString())); | ||
833 | } | 861 | } | ||
862 | | ||||
834 | return services; | 863 | return services; | ||
835 | } | 864 | } | ||
836 | 865 | | |||
837 | bool XWindowTasksModel::Private::demandsAttention(WId window) | 866 | bool XWindowTasksModel::Private::demandsAttention(WId window) | ||
838 | { | 867 | { | ||
839 | if (windows.contains(window)) { | 868 | if (windows.contains(window)) { | ||
840 | return ((windowInfo(window)->hasState(NET::DemandsAttention)) | 869 | return ((windowInfo(window)->hasState(NET::DemandsAttention)) | ||
841 | || transientsDemandingAttention.contains(window)); | 870 | || transientsDemandingAttention.contains(window)); | ||
▲ Show 20 Lines • Show All 531 Lines • Show Last 20 Lines |