Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qvncscreen.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qvncscreen.h"
5#include "qvnc_p.h"
6#include <QtFbSupport/private/qfbwindow_p.h>
7#include <QtFbSupport/private/qfbcursor_p.h>
8
9#include <QtGui/QPainter>
10#include <QtGui/QScreen>
11#include <QtCore/QRegularExpression>
12
13
15
16using namespace Qt::StringLiterals;
17
18
20 : mArgs(args)
21{
22 initialize();
23}
24
26{
27#if QT_CONFIG(cursor)
28 if (clientCursor)
29 delete clientCursor;
30#endif
31}
32
34{
35 QRegularExpression sizeRx("size=(\\d+)x(\\d+)"_L1);
36 QRegularExpression mmSizeRx("mmsize=(?<width>(\\d*\\.)?\\d+)x(?<height>(\\d*\\.)?\\d+)"_L1);
37 QRegularExpression depthRx("depth=(\\d+)"_L1);
38
39 mGeometry = QRect(0, 0, 1024, 768);
41 mDepth = 32;
42 mPhysicalSize = QSizeF(mGeometry.width()/96.*25.4, mGeometry.height()/96.*25.4);
43
44 for (const QString &arg : std::as_const(mArgs)) {
46 if (arg.contains(mmSizeRx, &match)) {
47 mPhysicalSize = QSizeF(match.captured("width").toDouble(), match.captured("height").toDouble());
48 } else if (arg.contains(sizeRx, &match)) {
49 mGeometry.setSize(QSize(match.captured(1).toInt(), match.captured(2).toInt()));
50 } else if (arg.contains(depthRx, &match)) {
51 mDepth = match.captured(1).toInt();
52 }
53 }
54
55 switch (depth()) {
56 case 32:
57 dirty = new QVncDirtyMapOptimized<quint32>(this);
58 break;
59 case 16:
60 dirty = new QVncDirtyMapOptimized<quint16>(this);
62 break;
63 case 8:
64 dirty = new QVncDirtyMapOptimized<quint8>(this);
65 break;
66 default:
67 qWarning("QVNCScreen::initDevice: No support for screen depth %d",
68 depth());
69 dirty = nullptr;
70 return false;
71 }
72
74
76
77 return true;
78}
79
81{
82 QRegion touched = QFbScreen::doRedraw();
83
84 if (touched.isEmpty())
85 return touched;
86 dirtyRegion += touched;
87
89 return touched;
90}
91
92
94{
95#if QT_CONFIG(cursor)
96 delete mCursor;
97 mCursor = nullptr;
98 if (!clientCursor)
99 clientCursor = new QVncClientCursor();
100 clientCursor->addClient(client);
101#else
102 Q_UNUSED(client);
103#endif
104}
105
107{
108#if QT_CONFIG(cursor)
109 if (!clientCursor)
110 return;
111
112 uint clientCount = clientCursor->removeClient(client);
113 if (clientCount == 0) {
114 delete clientCursor;
115 clientCursor = nullptr;
116
117 if (mCursor == nullptr)
118 mCursor = new QFbCursor(this);
119 }
120#else
121 Q_UNUSED(client);
122#endif
123}
124
126{
127#if QT_CONFIG(cursor)
128 return mCursor ? static_cast<QPlatformCursor *>(mCursor) : static_cast<QPlatformCursor *>(clientCursor);
129#else
130 return nullptr;
131#endif
132}
133
134// grabWindow() grabs "from the screen" not from the backingstores.
135// In linuxfb's case it will also include the mouse cursor.
136QPixmap QVncScreen::grabWindow(WId wid, int x, int y, int width, int height) const
137{
138 if (!wid) {
139 if (width < 0)
141 if (height < 0)
144 }
145
147 if (window) {
148 const QRect geom = window->geometry();
149 if (width < 0)
150 width = geom.width() - x;
151 if (height < 0)
152 height = geom.height() - y;
153 QRect rect(geom.topLeft() + QPoint(x, y), QSize(width, height));
154 rect &= window->geometry();
156 }
157
158 return QPixmap();
159}
160
161#if Q_BYTE_ORDER == Q_BIG_ENDIAN
163{
164 return false;
165
166 /* TODO
167 if (depth() != 16)
168 return false;
169
170 if (screen())
171 return screen()->frameBufferLittleEndian();
172 return frameBufferLittleEndian();
173 */
174}
175#endif
176
177QFbScreen::Flags QVncScreen::flags() const
178{
180}
181
183
184#include "moc_qvncscreen.cpp"
185
QImage mScreenImage
Definition qfbscreen_p.h:89
QFbWindow * windowForId(WId wid) const
int depth() const override
Reimplement in subclass to return current depth of the screen.
Definition qfbscreen_p.h:46
@ DontForceFirstWindowToFullScreen
Definition qfbscreen_p.h:36
void initializeCompositor()
Definition qfbscreen.cpp:32
virtual QRegion doRedraw()
QFbCursor * mCursor
Definition qfbscreen_p.h:84
QRect mGeometry
Definition qfbscreen_p.h:85
QImage::Format mFormat
Definition qfbscreen_p.h:87
QSizeF mPhysicalSize
Definition qfbscreen_p.h:88
int width() const
Returns the width of the image.
int height() const
Returns the height of the image.
@ Format_ARGB32_Premultiplied
Definition qimage.h:48
@ Format_RGB16
Definition qimage.h:49
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Converts the given image to a pixmap using the specified flags to control the conversion.
Definition qpixmap.cpp:1437
The QPlatformCursor class provides information about pointer device events (movement,...
virtual void setPowerState(PowerState state)
Sets the power state for this screen.
\inmodule QtCore\reentrant
Definition qpoint.h:25
\inmodule QtCore\reentrant
Definition qrect.h:30
constexpr int height() const noexcept
Returns the height of the rectangle.
Definition qrect.h:239
constexpr QPoint topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
Definition qrect.h:221
constexpr void setSize(const QSize &s) noexcept
Sets the size of the rectangle to the given size.
Definition qrect.h:387
constexpr int width() const noexcept
Returns the width of the rectangle.
Definition qrect.h:236
The QRegion class specifies a clip region for a painter.
Definition qregion.h:27
\inmodule QtCore \reentrant
\inmodule QtCore \reentrant
\inmodule QtCore
Definition qsize.h:208
\inmodule QtCore
Definition qsize.h:25
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
void disableClientCursor(QVncClient *client)
QRegion doRedraw() override
QPlatformCursor * cursor() const override
Reimplement this function in subclass to return the cursor of the screen.
QVncDirtyMap * dirty
Definition qvncscreen.h:49
QVncScreen(const QStringList &args)
QVncServer * vncServer
Definition qvncscreen.h:52
Flags flags() const override
QRegion dirtyRegion
Definition qvncscreen.h:50
bool initialize() override
void enableClientCursor(QVncClient *client)
QStringList mArgs
Definition qvncscreen.h:45
bool swapBytes() const
QPixmap grabWindow(WId wid, int x, int y, int width, int height) const override
This function is called when Qt needs to be able to grab the content of a window.
void setDirty()
Definition qvnc.cpp:614
rect
[4]
Combined button and popup list for selecting options.
#define qWarning
Definition qlogging.h:166
GLint GLint GLint GLint GLint x
[0]
GLint GLsizei GLsizei height
GLint GLsizei width
GLint y
SSL_CTX int void * arg
#define Q_UNUSED(x)
static bool match(const uchar *found, uint foundLen, const char *target, uint targetLen)
unsigned int uint
Definition qtypes.h:34
aWidget window() -> setWindowTitle("New Window Title")
[2]
QJSValueList args