File indexing completed on 2024-05-05 05:38:38

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