KWin
Loading...
Searching...
No Matches
x11_windowed_output.h
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2019 Roman Gilg <subdiff@gmail.com>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9#pragma once
10
11#include "core/output.h"
12#include <kwin_export.h>
13
14#include <QObject>
15#include <QSize>
16#include <QString>
17
18#include <unordered_map>
19
20#include <xcb/xcb.h>
21#include <xcb/present.h>
22
23class NETWinInfo;
24
25namespace KWin
26{
27
28class GraphicsBuffer;
29class X11WindowedBackend;
30class X11WindowedOutput;
31class OutputFrame;
32
33struct DmaBufAttributes;
34struct ShmAttributes;
35
36class X11WindowedBuffer : public QObject
37{
38 Q_OBJECT
39
40public:
42 ~X11WindowedBuffer() override;
43
44 GraphicsBuffer *buffer() const;
45 xcb_pixmap_t pixmap() const;
46
47 void lock();
48 void unlock();
49
50Q_SIGNALS:
51 void defunct();
52
53private:
54 X11WindowedOutput *m_output;
55 GraphicsBuffer *m_buffer;
56 xcb_pixmap_t m_pixmap;
57 bool m_locked = false;
58};
59
61{
62public:
63 explicit X11WindowedCursor(X11WindowedOutput *output);
65
66 void update(const QImage &image, const QPointF &hotspot);
67
68private:
69 X11WindowedOutput *m_output;
70 xcb_cursor_t m_handle = XCB_CURSOR_NONE;
71};
72
76class KWIN_EXPORT X11WindowedOutput : public Output
77{
78 Q_OBJECT
79public:
80 explicit X11WindowedOutput(X11WindowedBackend *backend);
81 ~X11WindowedOutput() override;
82
83 RenderLoop *renderLoop() const override;
84
85 void init(const QSize &pixelSize, qreal scale);
86 void resize(const QSize &pixelSize);
87
88 X11WindowedBackend *backend() const;
89 X11WindowedCursor *cursor() const;
90 xcb_window_t window() const;
91 int depth() const;
92
93 xcb_pixmap_t importBuffer(GraphicsBuffer *buffer);
94
95 QPoint internalPosition() const;
96 QPoint hostPosition() const;
97 void setHostPosition(const QPoint &pos);
98
99 void setWindowTitle(const QString &title);
100
104 QPointF mapFromGlobal(const QPointF &pos) const;
105
106 bool updateCursorLayer() override;
107
108 QRegion exposedArea() const;
109 void addExposedArea(const QRect &rect);
110 void clearExposedArea();
111
112 void updateEnabled(bool enabled);
113
114 void handlePresentCompleteNotify(xcb_present_complete_notify_event_t *event);
115 void handlePresentIdleNotify(xcb_present_idle_notify_event_t *event);
116 void framePending(const std::shared_ptr<OutputFrame> &frame);
117
118private:
119 void initXInputForWindow();
120
121 xcb_pixmap_t importDmaBufBuffer(const DmaBufAttributes *attributes);
122 xcb_pixmap_t importShmBuffer(const ShmAttributes *attributes);
123
124 xcb_window_t m_window = XCB_WINDOW_NONE;
125 xcb_present_event_t m_presentEvent = XCB_NONE;
126 std::unique_ptr<NETWinInfo> m_winInfo;
127 std::unique_ptr<RenderLoop> m_renderLoop;
128 std::unique_ptr<X11WindowedCursor> m_cursor;
129 std::unordered_map<GraphicsBuffer *, std::unique_ptr<X11WindowedBuffer>> m_buffers;
130 QPoint m_hostPosition;
131 QRegion m_exposedArea;
132 std::shared_ptr<OutputFrame> m_frame;
133
134 X11WindowedBackend *m_backend;
135};
136
137} // namespace KWin
GraphicsBuffer * buffer() const
X11WindowedBuffer(X11WindowedOutput *output, xcb_pixmap_t pixmap, GraphicsBuffer *buffer)
xcb_pixmap_t pixmap() const
X11WindowedCursor(X11WindowedOutput *output)
void update(const QImage &image, const QPointF &hotspot)