1 /* 2 SPDX-FileCopyrightText: 2016 Eike Hein <hein@kde.org> 3 4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 5 */ 6 7 #pragma once 8 9 #include "abstractwindowtasksmodel.h" 10 11 #include "taskmanager_export.h" 12 13 #include <QMimeData> 14 #include <qwindowdefs.h> 15 16 #include <netwm.h> 17 18 namespace TaskManager 19 { 20 /** 21 * @short A tasks model for X Window System windows. 22 * 23 * This model presents tasks sourced from window data on the X Windows 24 * server the host process is connected to. 25 * 26 * For the purposes of presentation in a user interface and efficiency, 27 * certain types of windows (e.g. utility windows, or windows that are 28 * transients for an otherwise-included window) are omitted from the 29 * model. 30 * 31 * @see WindowTasksModel 32 * 33 * @author Eike Hein <hein@kde.org> 34 */ 35 36 class TASKMANAGER_EXPORT XWindowTasksModel : public AbstractWindowTasksModel 37 { 38 Q_OBJECT 39 40 public: 41 explicit XWindowTasksModel(QObject *parent = nullptr); 42 ~XWindowTasksModel() override; 43 44 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 45 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 46 47 /** 48 * Request activation of the window at the given index. 49 * 50 * If the window has a transient demanding attention, it will be 51 * activated instead. 52 * 53 * If the window has a transient in shaded state, it will be 54 * activated instead. 55 * 56 * @param index An index in this window tasks model. 57 **/ 58 void requestActivate(const QModelIndex &index) override; 59 60 /** 61 * Request an additional instance of the application owning the window 62 * at the given index. Success depends on whether a 63 * AbstractTasksModel::LauncherUrl could be derived from window metadata. 64 * 65 * @param index An index in this window tasks model. 66 **/ 67 void requestNewInstance(const QModelIndex &index) override; 68 69 /** 70 * Runs the application backing the launcher at the given index with the given URLs. 71 * Success depends on whether a AbstractTasksModel::LauncherUrl could be 72 * derived from window metadata and a KService could be found from that. 73 * 74 * @param index An index in this launcher tasks model 75 * @param urls The URLs to be passed to the application 76 */ 77 void requestOpenUrls(const QModelIndex &index, const QList<QUrl> &urls) override; 78 79 /** 80 * Request the window at the given index be closed. 81 * 82 * @param index An index in this window tasks model. 83 **/ 84 void requestClose(const QModelIndex &index) override; 85 86 /** 87 * Request starting an interactive move for the window at the given index. 88 * 89 * If the window is not currently the active window, it will be activated. 90 * 91 * If the window is not on the current desktop, the current desktop will 92 * be set to the window's desktop. 93 * FIXME: Desktop logic should maybe move into proxy. 94 * 95 * @param index An index in this window tasks model. 96 **/ 97 void requestMove(const QModelIndex &index) override; 98 99 /** 100 * Request starting an interactive resize for the window at the given index. 101 * 102 * If the window is not currently the active window, it will be activated. 103 * 104 * If the window is not on the current desktop, the current desktop will 105 * be set to the window's desktop. 106 * FIXME: Desktop logic should maybe move into proxy. 107 * 108 * @param index An index in this window tasks model. 109 **/ 110 void requestResize(const QModelIndex &index) override; 111 112 /** 113 * Request toggling the minimized state of the window at the given index. 114 * 115 * If the window is not on the current desktop, the current desktop will 116 * be set to the window's desktop. 117 * FIXME: Desktop logic should maybe move into proxy. 118 * 119 * @param index An index in this window tasks model. 120 **/ 121 void requestToggleMinimized(const QModelIndex &index) override; 122 123 /** 124 * Request toggling the maximized state of the task at the given index. 125 * 126 * If the window is not on the current desktop, the current desktop will 127 * be set to the window's desktop. 128 * FIXME: Desktop logic should maybe move into proxy. 129 * 130 * @param index An index in this window tasks model. 131 **/ 132 void requestToggleMaximized(const QModelIndex &index) override; 133 134 /** 135 * Request toggling the keep-above state of the task at the given index. 136 * 137 * @param index An index in this window tasks model. 138 **/ 139 void requestToggleKeepAbove(const QModelIndex &index) override; 140 141 /** 142 * Request toggling the keep-below state of the task at the given index. 143 * 144 * @param index An index in this window tasks model. 145 **/ 146 void requestToggleKeepBelow(const QModelIndex &index) override; 147 148 /** 149 * Request toggling the fullscreen state of the task at the given index. 150 * 151 * @param index An index in this window tasks model. 152 **/ 153 void requestToggleFullScreen(const QModelIndex &index) override; 154 155 /** 156 * Request toggling the shaded state of the task at the given index. 157 * 158 * @param index An index in this window tasks model. 159 **/ 160 void requestToggleShaded(const QModelIndex &index) override; 161 162 /** 163 * Request entering the window at the given index on the specified virtual desktop. 164 * For compatibility across windowing systems the library supports, the desktops 165 * parameter is a list; however, on X11 a window can only be on one or all virtual 166 * desktops. Therefore, only the first list entry is actually used. 167 * 168 * An empty list has a special meaning: The window is entered on all virtual desktops 169 * in the session. 170 * 171 * The id 0 has a special meaning: The window is entered on all virtual desktops in 172 * the session. 173 * 174 * @param index An index in this window tasks model. 175 * @param desktops A list of virtual desktop ids (uint). 176 **/ 177 void requestVirtualDesktops(const QModelIndex &index, const QVariantList &desktops) override; 178 179 /** 180 * Request entering the window at the given index on a new virtual desktop, 181 * which is created in response to this request. 182 * 183 * @param index An index in this window tasks model. 184 **/ 185 void requestNewVirtualDesktop(const QModelIndex &index) override; 186 187 /** 188 * Request moving the task at the given index to the specified activities. 189 * 190 * This is meant for tasks that have an associated window, and may be 191 * a no-op when there is no window. 192 * * 193 * @param index An index in this tasks model. 194 * @param activities The new list of activities. 195 **/ 196 void requestActivities(const QModelIndex &index, const QStringList &activities) override; 197 198 /** 199 * Request informing the window manager of new geometry for a visual 200 * delegate for the window at the given index. 201 * 202 * @param index An index in this window tasks model. 203 * @param geometry Visual delegate geometry in screen coordinates. 204 * @param delegate The delegate. Unused in this implementation. 205 **/ 206 void requestPublishDelegateGeometry(const QModelIndex &index, const QRect &geometry, QObject *delegate = nullptr) override; 207 208 /** 209 * Tries to extract a X11 window id from supplied mime data. 210 * 211 * @param mimeData Some mime data. 212 * @param @ok Set to true or false on success or failure. 213 */ 214 static WId winIdFromMimeData(const QMimeData *mimeData, bool *ok = nullptr); 215 216 /** 217 * Tries to extract X11 window ids from supplied mime data. 218 * 219 * @param mimeData Some mime data. 220 * @param @ok Set to true or false on success or failure. 221 */ 222 static QList<WId> winIdsFromMimeData(const QMimeData *mimeData, bool *ok = nullptr); 223 224 private: 225 class Private; 226 QScopedPointer<Private> d; 227 }; 228 229 } 230