File indexing completed on 2024-05-05 17:44:55
0001 /* 0002 SPDX-FileCopyrightText: 2016 Eike Hein <hein@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #pragma once 0008 0009 #include "abstractwindowtasksmodel.h" 0010 0011 #include "taskmanager_export.h" 0012 0013 namespace KWayland 0014 { 0015 namespace Client 0016 { 0017 class PlasmaWindowManagement; 0018 class Surface; 0019 } 0020 0021 } 0022 0023 namespace TaskManager 0024 { 0025 /** 0026 * @short A tasks model for Wayland windows. 0027 * 0028 * This model presents tasks sourced from window data on the Wayland 0029 * server the host process is connected to. 0030 * 0031 * FIXME: Filtering by window type still needed. 0032 * 0033 * @see WindowTasksModel 0034 * 0035 * @author Eike Hein <hein@kde.org> 0036 */ 0037 0038 class TASKMANAGER_EXPORT WaylandTasksModel : public AbstractWindowTasksModel 0039 { 0040 Q_OBJECT 0041 0042 public: 0043 explicit WaylandTasksModel(QObject *parent = nullptr); 0044 ~WaylandTasksModel() override; 0045 0046 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0047 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0048 0049 QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const override; 0050 0051 /** 0052 * Request activation of the window at the given index. 0053 * 0054 * FIXME: Lacks transient handling of X Windows version. 0055 * 0056 * @param index An index in this window tasks model. 0057 **/ 0058 void requestActivate(const QModelIndex &index) override; 0059 0060 /** 0061 * Request an additional instance of the application owning the window 0062 * at the given index. Success depends on whether a 0063 * AbstractTasksModel::LauncherUrl could be derived from window metadata. 0064 * 0065 * @param index An index in this window tasks model. 0066 **/ 0067 void requestNewInstance(const QModelIndex &index) override; 0068 0069 /** 0070 * Runs the application backing the launcher at the given index with the given URLs. 0071 * Success depends on whether a AbstractTasksModel::LauncherUrl could be 0072 * derived from window metadata and a KService could be found from that. 0073 * 0074 * @param index An index in this launcher tasks model 0075 * @param urls The URLs to be passed to the application 0076 */ 0077 void requestOpenUrls(const QModelIndex &index, const QList<QUrl> &urls) override; 0078 0079 /** 0080 * Request the window at the given index be closed. 0081 * 0082 * @param index An index in this window tasks model. 0083 **/ 0084 void requestClose(const QModelIndex &index) override; 0085 0086 /** 0087 * Request starting an interactive move for the window at the given index. 0088 * 0089 * FIXME: X Windows version has extra virtual desktop logic. 0090 * 0091 * @param index An index in this window tasks model. 0092 **/ 0093 void requestMove(const QModelIndex &index) override; 0094 0095 /** 0096 * Request starting an interactive move for the window at the given index. 0097 * 0098 * FIXME: X Windows version has extra virtual desktop logic. 0099 * 0100 * @param index An index in this window tasks model. 0101 **/ 0102 void requestResize(const QModelIndex &index) override; 0103 0104 /** 0105 * Request toggling the minimized state of the window at the given index. 0106 * 0107 * FIXME: X Windows version has extra virtual desktop logic. 0108 * 0109 * @param index An index in this window tasks model. 0110 **/ 0111 void requestToggleMinimized(const QModelIndex &index) override; 0112 0113 /** 0114 * Request toggling the maximized state of the task at the given index. 0115 * 0116 * FIXME: X Windows version has extra virtual desktop logic. 0117 * 0118 * @param index An index in this window tasks model. 0119 **/ 0120 void requestToggleMaximized(const QModelIndex &index) override; 0121 0122 /** 0123 * Request toggling the keep-above state of the task at the given index. 0124 * 0125 * @param index An index in this window tasks model. 0126 **/ 0127 void requestToggleKeepAbove(const QModelIndex &index) override; 0128 0129 /** 0130 * Request toggling the keep-below state of the task at the given index. 0131 * 0132 * @param index An index in this window tasks model. 0133 **/ 0134 void requestToggleKeepBelow(const QModelIndex &index) override; 0135 0136 /** 0137 * Request toggling the fullscreen state of the task at the given index. 0138 * 0139 * @param index An index in this window tasks model. 0140 **/ 0141 void requestToggleFullScreen(const QModelIndex &index) override; 0142 0143 /** 0144 * Request toggling the shaded state of the task at the given index. 0145 * 0146 * @param index An index in this window tasks model. 0147 **/ 0148 void requestToggleShaded(const QModelIndex &index) override; 0149 0150 /** 0151 * Request entering the window at the given index on the specified virtual desktops, 0152 * leaving any other desktops. 0153 * 0154 * Virtual desktop ids are QStrings. 0155 * 0156 * An empty list has a special meaning: The window is entered on all virtual desktops 0157 * in the session. 0158 * 0159 * @param index An index in this window tasks model. 0160 * @param desktops A list of virtual desktop ids. 0161 **/ 0162 void requestVirtualDesktops(const QModelIndex &index, const QVariantList &desktops) override; 0163 0164 /** 0165 * Request entering the window at the given index on a new virtual desktop, 0166 * which is created in response to this request. 0167 * 0168 * @param index An index in this window tasks model. 0169 **/ 0170 void requestNewVirtualDesktop(const QModelIndex &index) override; 0171 0172 /** 0173 * Request moving the window at the given index to the specified activities 0174 * 0175 * FIXME: This currently does nothing as activities is not implemented in kwin/kwayland 0176 * 0177 * @param index An index in this window tasks model. 0178 * @param desktop A virtual desktop number. 0179 **/ 0180 void requestActivities(const QModelIndex &index, const QStringList &activities) override; 0181 0182 /** 0183 * Request informing the window manager of new geometry for a visual 0184 * delegate for the window at the given index. The geometry is retrieved 0185 * from the delegate object passed. Right now, QQuickItem is the only 0186 * supported delegate object type. 0187 * 0188 * FIXME: This introduces the dependency on Qt::Quick. I might prefer 0189 * reversing this and publishing the window pointer through the model, 0190 * then calling PlasmaWindow::setMinimizeGeometry in the applet backend, 0191 * rather than hand delegate items into the lib, keeping the lib more UI- 0192 * agnostic. 0193 * 0194 * @param index An index in this window tasks model. 0195 * @param geometry Visual delegate geometry in screen coordinates. Unused 0196 * in this implementation. 0197 * @param delegate The delegate. This implementation will attempt to cast 0198 * it to QQuickItem, map its coordinates to its window and find the Wayland 0199 * Surface for the window. 0200 **/ 0201 void requestPublishDelegateGeometry(const QModelIndex &index, const QRect &geometry, QObject *delegate = nullptr) override; 0202 0203 /** 0204 * Tries to extract a process-internal Wayland window id from supplied mime data. 0205 * 0206 * @param mimeData Some mime data. 0207 * @param @ok Set to true or false on success or failure. 0208 */ 0209 static QUuid winIdFromMimeData(const QMimeData *mimeData, bool *ok = nullptr); 0210 0211 /** 0212 * Tries to extract process-internal Wayland window ids from supplied mime data. 0213 * 0214 * @param mimeData Some mime data. 0215 * @param @ok Set to true or false on success or failure. 0216 */ 0217 static QList<QUuid> winIdsFromMimeData(const QMimeData *mimeData, bool *ok = nullptr); 0218 0219 private: 0220 class Private; 0221 QScopedPointer<Private> d; 0222 }; 0223 0224 }