KWin
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
windowthumbnailitem.h
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2011 Martin Gräßlin <mgraesslin@kde.org>
3 SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
4
5 SPDX-License-Identifier: GPL-2.0-or-later
6*/
7
8#pragma once
9
10#include <QQuickItem>
11#include <QUuid>
12
13#include <epoxy/gl.h>
14
15namespace KWin
16{
17class Window;
18class GLFramebuffer;
19class GLTexture;
20class ThumbnailTextureProvider;
21class WindowThumbnailSource;
22
23class WindowThumbnailSource : public QObject
24{
25 Q_OBJECT
26
27public:
28 WindowThumbnailSource(QQuickWindow *view, Window *handle);
29 ~WindowThumbnailSource() override;
30
31 static std::shared_ptr<WindowThumbnailSource> getOrCreate(QQuickWindow *window, Window *handle);
32
33 struct Frame
34 {
35 std::shared_ptr<GLTexture> texture;
36 GLsync fence;
37 };
38
39 Frame acquire();
40
41Q_SIGNALS:
42 void changed();
43
44private:
45 void update();
46
47 QPointer<QQuickWindow> m_view;
48 QPointer<Window> m_handle;
49
50 std::shared_ptr<GLTexture> m_offscreenTexture;
51 std::unique_ptr<GLFramebuffer> m_offscreenTarget;
52 GLsync m_acquireFence = 0;
53 bool m_dirty = true;
54};
55
56class WindowThumbnailItem : public QQuickItem
57{
58 Q_OBJECT
59 Q_PROPERTY(QUuid wId READ wId WRITE setWId NOTIFY wIdChanged)
60 Q_PROPERTY(KWin::Window *client READ client WRITE setClient NOTIFY clientChanged)
61
62public:
63 explicit WindowThumbnailItem(QQuickItem *parent = nullptr);
65
66 QUuid wId() const;
67 void setWId(const QUuid &wId);
68
69 Window *client() const;
70 void setClient(Window *client);
71
72 QSGTextureProvider *textureProvider() const override;
73 bool isTextureProvider() const override;
74 QSGNode *updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *) override;
75
76protected:
77 void releaseResources() override;
78 void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &value) override;
79
80Q_SIGNALS:
81 void wIdChanged();
83
85 QImage fallbackImage() const;
86 QRectF paintedRect() const;
87 void updateImplicitSize();
88 void updateSource();
89 void resetSource();
90
91 QUuid m_wId;
92 QPointer<Window> m_client;
93
94 mutable ThumbnailTextureProvider *m_provider = nullptr;
95 std::shared_ptr<WindowThumbnailSource> m_source;
96};
97
98} // namespace KWin
void setWId(qulonglong wId)
QSGNode * updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override
QSGTextureProvider * textureProvider() const override
bool isTextureProvider() const override
void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &value) override
WindowThumbnailSource(QQuickWindow *view, Window *handle)
static std::shared_ptr< WindowThumbnailSource > getOrCreate(QQuickWindow *window, Window *handle)
#define private
std::shared_ptr< GLTexture > texture
#define explicit