6#include <QtFbSupport/private/qfbcursor_p.h>
7#include <QtFbSupport/private/qfbwindow_p.h>
9#include <QtCore/QRegularExpression>
10#include <QtGui/QPainter>
12#include <private/qcore_unix_p.h>
28#include <sys/consio.h>
43 int fd =
QT_OPEN(devPath.constData(), O_RDWR);
46 fd =
QT_OPEN(devPath.constData(), O_RDONLY);
58 if (userGeometry.isValid()) {
59 w =
qMin(userGeometry.width(), fb.fb_width);
60 h =
qMin(userGeometry.height(), fb.fb_height);
62 int xxoff = userGeometry.x(), yyoff = userGeometry.y();
63 if (xxoff != 0 || yyoff != 0) {
64 if (xxoff < 0 || xxoff + w > fb.fb_width)
65 xxoff = fb.fb_width -
w;
66 if (yyoff < 0 || yyoff + h > fb.fb_height)
67 yyoff = fb.fb_height -
h;
71 xoff += (fb.fb_width -
w)/2;
72 yoff += (fb.fb_height -
h)/2;
79 if (
w == 0 ||
h == 0) {
80 qWarning(
"Unable to find screen geometry, using 320x240");
90 int mmWidth = mmSize.width();
91 int mmHeight = mmSize.height();
93 if (mmWidth <= 0 && mmHeight <= 0) {
95 mmWidth =
qRound(
res.width() * 25.4 / dpi);
96 mmHeight =
qRound(
res.height() * 25.4 / dpi);
97 }
else if (mmWidth > 0 && mmHeight <= 0) {
98 mmHeight =
res.height() * mmWidth/
res.width();
99 }
else if (mmHeight > 0 && mmWidth <= 0) {
100 mmWidth =
res.width() * mmHeight/
res.height();
103 return QSize(mmWidth, mmHeight);
113 if (m_framebufferFd != -1) {
114 munmap(m_mmap.data - m_mmap.offset, m_mmap.size);
131 for (
const QString &
arg : std::as_const(m_arguments)) {
134 userMmSize =
QSize(
match.captured(1).toInt(),
match.captured(2).toInt());
135 else if (
arg.contains(sizeRx, &
match))
136 userGeometry.setSize(
QSize(
match.captured(1).toInt(),
match.captured(2).toInt()));
137 else if (
arg.contains(offsetRx, &
match))
138 userGeometry.setTopLeft(
QPoint(
match.captured(1).toInt(),
match.captured(2).toInt()));
139 else if (
arg.contains(fbRx, &
match))
140 fbDevice =
match.captured(1);
143 if (!fbDevice.isEmpty()) {
147 m_framebufferFd = STDIN_FILENO;
150 if (m_framebufferFd == -1) {
156 if (ioctl(m_framebufferFd, FBIOGTYPE, &fb) != 0) {
157 qErrnoWarning(errno,
"Error reading framebuffer information");
162 if (ioctl(m_framebufferFd, FBIO_GETLINEWIDTH, &line_length) != 0) {
163 qErrnoWarning(errno,
"Error reading line length information");
169 m_bytesPerLine = line_length;
188 const size_t pagemask = getpagesize() - 1;
189 m_mmap.size = (m_bytesPerLine * fb.fb_height + pagemask) & ~pagemask;
190 uchar *
data =
static_cast<uchar*
>(mmap(
nullptr, m_mmap.size, PROT_READ | PROT_WRITE, MAP_SHARED, m_framebufferFd, 0));
197 m_mmap.data =
data + m_mmap.offset;
211 if (touched.isEmpty())
bool initialize() override
QBsdFbScreen(const QStringList &args)
QRegion doRedraw() override
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.
QFbWindow * windowForId(WId wid) const
QRect geometry() const override
Reimplement in subclass to return the pixel geometry of the screen.
void initializeCompositor()
virtual QRegion doRedraw()
static QByteArray encodeName(const QString &fileName)
Converts fileName to an 8-bit encoding that you can use in native APIs.
int width() const
Returns the width of the image.
int height() const
Returns the height of the image.
The QPainter class performs low-level painting on widgets and other paint devices.
void drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect, Qt::ImageConversionFlags flags=Qt::AutoColor)
Draws the rectangular portion source of the given image into the target rectangle in the paint device...
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
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.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr QPoint topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr QSize size() const noexcept
Returns the size of the rectangle.
constexpr int width() const noexcept
Returns the width of the rectangle.
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
The QRegion class specifies a clip region for a painter.
\inmodule QtCore \reentrant
\inmodule QtCore \reentrant
void reset(T *other=nullptr) noexcept(noexcept(Cleanup::cleanup(std::declval< T * >())))
Deletes the existing object it is pointing to (if any), and sets its pointer to other.
\macro QT_RESTRICTED_CAST_FROM_ASCII
void qErrnoWarning(const char *msg,...)
Combined button and popup list for selecting options.
static QRect determineGeometry(const struct fbtype &fb, const QRect &userGeometry)
static int openFramebufferDevice(const QString &dev)
static QSizeF determinePhysicalSize(const QSize &mmSize, const QSize &res)
static int qt_safe_close(int fd)
int qRound(qfloat16 d) noexcept
constexpr const T & qMin(const T &a, const T &b)
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLfloat GLfloat GLfloat GLfloat h
#define qPrintable(string)
static bool match(const uchar *found, uint foundLen, const char *target, uint targetLen)