File indexing completed on 2024-05-05 17:44:56
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 #include <QMimeData> 0014 #include <qwindowdefs.h> 0015 0016 #include <netwm.h> 0017 0018 namespace TaskManager 0019 { 0020 /** 0021 * @short A tasks model for X Window System windows. 0022 * 0023 * This model presents tasks sourced from window data on the X Windows 0024 * server the host process is connected to. 0025 * 0026 * For the purposes of presentation in a user interface and efficiency, 0027 * certain types of windows (e.g. utility windows, or windows that are 0028 * transients for an otherwise-included window) are omitted from the 0029 * model. 0030 * 0031 * @see WindowTasksModel 0032 * 0033 * @author Eike Hein <hein@kde.org> 0034 */ 0035 0036 class TASKMANAGER_EXPORT XWindowTasksModel : public AbstractWindowTasksModel 0037 { 0038 Q_OBJECT 0039 0040 public: 0041 explicit XWindowTasksModel(QObject *parent = nullptr); 0042 ~XWindowTasksModel() override; 0043 0044 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0045 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0046 0047 /** 0048 * Request activation of the window at the given index. 0049 * 0050 * If the window has a transient demanding attention, it will be 0051 * activated instead. 0052 * 0053 * If the window has a transient in shaded state, it will be 0054 * activated instead. 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 * If the window is not currently the active window, it will be activated. 0090 * 0091 * If the window is not on the current desktop, the current desktop will 0092 * be set to the window's desktop. 0093 * FIXME: Desktop logic should maybe move into proxy. 0094 * 0095 * @param index An index in this window tasks model. 0096 **/ 0097 void requestMove(const QModelIndex &index) override; 0098 0099 /** 0100 * Request starting an interactive resize for the window at the given index. 0101 * 0102 * If the window is not currently the active window, it will be activated. 0103 * 0104 * If the window is not on the current desktop, the current desktop will 0105 * be set to the window's desktop. 0106 * FIXME: Desktop logic should maybe move into proxy. 0107 * 0108 * @param index An index in this window tasks model. 0109 **/ 0110 void requestResize(const QModelIndex &index) override; 0111 0112 /** 0113 * Request toggling the minimized state of the window at the given index. 0114 * 0115 * If the window is not on the current desktop, the current desktop will 0116 * be set to the window's desktop. 0117 * FIXME: Desktop logic should maybe move into proxy. 0118 * 0119 * @param index An index in this window tasks model. 0120 **/ 0121 void requestToggleMinimized(const QModelIndex &index) override; 0122 0123 /** 0124 * Request toggling the maximized state of the task at the given index. 0125 * 0126 * If the window is not on the current desktop, the current desktop will 0127 * be set to the window's desktop. 0128 * FIXME: Desktop logic should maybe move into proxy. 0129 * 0130 * @param index An index in this window tasks model. 0131 **/ 0132 void requestToggleMaximized(const QModelIndex &index) override; 0133 0134 /** 0135 * Request toggling the keep-above state of the task at the given index. 0136 * 0137 * @param index An index in this window tasks model. 0138 **/ 0139 void requestToggleKeepAbove(const QModelIndex &index) override; 0140 0141 /** 0142 * Request toggling the keep-below state of the task at the given index. 0143 * 0144 * @param index An index in this window tasks model. 0145 **/ 0146 void requestToggleKeepBelow(const QModelIndex &index) override; 0147 0148 /** 0149 * Request toggling the fullscreen state of the task at the given index. 0150 * 0151 * @param index An index in this window tasks model. 0152 **/ 0153 void requestToggleFullScreen(const QModelIndex &index) override; 0154 0155 /** 0156 * Request toggling the shaded state of the task at the given index. 0157 * 0158 * @param index An index in this window tasks model. 0159 **/ 0160 void requestToggleShaded(const QModelIndex &index) override; 0161 0162 /** 0163 * Request entering the window at the given index on the specified virtual desktop. 0164 * For compatibility across windowing systems the library supports, the desktops 0165 * parameter is a list; however, on X11 a window can only be on one or all virtual 0166 * desktops. Therefore, only the first list entry is actually used. 0167 * 0168 * An empty list has a special meaning: The window is entered on all virtual desktops 0169 * in the session. 0170 * 0171 * The id 0 has a special meaning: The window is entered on all virtual desktops in 0172 * the session. 0173 * 0174 * @param index An index in this window tasks model. 0175 * @param desktops A list of virtual desktop ids (uint). 0176 **/ 0177 void requestVirtualDesktops(const QModelIndex &index, const QVariantList &desktops) override; 0178 0179 /** 0180 * Request entering the window at the given index on a new virtual desktop, 0181 * which is created in response to this request. 0182 * 0183 * @param index An index in this window tasks model. 0184 **/ 0185 void requestNewVirtualDesktop(const QModelIndex &index) override; 0186 0187 /** 0188 * Request moving the task at the given index to the specified activities. 0189 * 0190 * This is meant for tasks that have an associated window, and may be 0191 * a no-op when there is no window. 0192 * * 0193 * @param index An index in this tasks model. 0194 * @param activities The new list of activities. 0195 **/ 0196 void requestActivities(const QModelIndex &index, const QStringList &activities) override; 0197 0198 /** 0199 * Request informing the window manager of new geometry for a visual 0200 * delegate for the window at the given index. 0201 * 0202 * @param index An index in this window tasks model. 0203 * @param geometry Visual delegate geometry in screen coordinates. 0204 * @param delegate The delegate. Unused in this implementation. 0205 **/ 0206 void requestPublishDelegateGeometry(const QModelIndex &index, const QRect &geometry, QObject *delegate = nullptr) override; 0207 0208 /** 0209 * Tries to extract a X11 window id from supplied mime data. 0210 * 0211 * @param mimeData Some mime data. 0212 * @param @ok Set to true or false on success or failure. 0213 */ 0214 static WId winIdFromMimeData(const QMimeData *mimeData, bool *ok = nullptr); 0215 0216 /** 0217 * Tries to extract X11 window ids from supplied mime data. 0218 * 0219 * @param mimeData Some mime data. 0220 * @param @ok Set to true or false on success or failure. 0221 */ 0222 static QList<WId> winIdsFromMimeData(const QMimeData *mimeData, bool *ok = nullptr); 0223 0224 private: 0225 class Private; 0226 QScopedPointer<Private> d; 0227 }; 0228 0229 }