Drop qt framebuffer

It works by grabbing the QDesktopWidget, which doesn't work in Qt6 since there is no QDesktopWidget.

In practice it only really works on xcb anyway, for which we have a dedicated plugin
This commit is contained in:
Nicolas Fella
2024-01-08 00:52:35 +01:00
parent caab08ba15
commit b7a2db5c71
7 changed files with 0 additions and 302 deletions

View File

@@ -1,5 +1,3 @@
add_subdirectory (qt)
if (${XCB_DAMAGE_FOUND} AND ${XCB_SHM_FOUND} AND ${XCB_IMAGE_FOUND})
add_subdirectory (xcb)
endif()

View File

@@ -1,33 +0,0 @@
include_directories (${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
set (krfb_framebuffer_qt_SRCS
qtframebuffer.cpp
qtframebufferplugin.cpp
)
ecm_qt_declare_logging_category(krfb_framebuffer_qt_SRCS
HEADER krfb_fb_qt_debug.h
IDENTIFIER KRFB_FB_QT
CATEGORY_NAME krfb.framebuffer.qt
DESCRIPTION "KRFB Qt framebuffer plugin"
EXPORT KRFB
)
add_library(krfb_framebuffer_qt
MODULE
${krfb_framebuffer_qt_SRCS}
)
target_link_libraries (krfb_framebuffer_qt
Qt5::Core
Qt5::Gui
KF5::CoreAddons
krfbprivate
)
set_target_properties(krfb_framebuffer_qt PROPERTIES OUTPUT_NAME qt)
install (TARGETS krfb_framebuffer_qt
DESTINATION ${KDE_INSTALL_PLUGINDIR}/krfb/framebuffer
)

View File

@@ -1,6 +0,0 @@
{
"X-KDE-OnlyShowOnQtPlatforms": [
"xcb"
]
}

View File

@@ -1,128 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2007 Alessandro Praduroux <pradu@pradu.it>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
*/
#include "qtframebuffer.h"
#include <QTimer>
#include <QRegion>
#include <QPixmap>
#include <QBitmap>
#include <QApplication>
#include <QDesktopWidget>
#include <QScreen>
const int UPDATE_TIME = 500;
QtFrameBuffer::QtFrameBuffer(QObject *parent)
: FrameBuffer(parent)
{
win = QApplication::desktop()->winId();
QScreen *screen = QGuiApplication::primaryScreen();
if (screen) {
primaryScreen = screen;
fbImage = screen->grabWindow(win).toImage();
fb = new char[fbImage.sizeInBytes()];
} else {
fb = nullptr;
primaryScreen = nullptr;
}
t = new QTimer(this);
connect(t, &QTimer::timeout, this, &QtFrameBuffer::updateFrameBuffer);
}
QtFrameBuffer::~QtFrameBuffer()
{
if (fb)
delete [] fb;
fb = nullptr;
}
int QtFrameBuffer::depth()
{
return fbImage.depth();
}
int QtFrameBuffer::height()
{
return fbImage.height();
}
int QtFrameBuffer::width()
{
return fbImage.width();
}
void QtFrameBuffer::getServerFormat(rfbPixelFormat &format)
{
format.bitsPerPixel = 32;
format.depth = 32;
format.trueColour = true;
format.bigEndian = false;
format.redShift = 16;
format.greenShift = 8;
format.blueShift = 0;
format.redMax = 0xff;
format.greenMax = 0xff;
format.blueMax = 0xff;
}
void QtFrameBuffer::updateFrameBuffer()
{
if (!fb || !primaryScreen) return;
QImage img = primaryScreen->grabWindow(win).toImage();
#if 0 // This is actually slower than updating the whole desktop...
QSize imgSize = img.size();
// verify what part of the image need to be marked as changed
// fbImage is the previous version of the image,
// img is the current one
QImage map(imgSize, QImage::Format_Mono);
map.fill(0);
for (int x = 0; x < imgSize.width(); x++) {
for (int y = 0; y < imgSize.height(); y++) {
if (img.pixel(x, y) != fbImage.pixel(x, y)) {
map.setPixel(x, y, 1);
}
}
}
QRegion r(QBitmap::fromImage(map));
tiles = tiles + r.rects();
#else
tiles.append(img.rect());
#endif
memcpy(fb, img.bits(), static_cast<size_t>(img.sizeInBytes()));
fbImage = img;
}
int QtFrameBuffer::paddedWidth()
{
return fbImage.width() * 4;
}
void QtFrameBuffer::startMonitor()
{
t->start(UPDATE_TIME);
}
void QtFrameBuffer::stopMonitor()
{
t->stop();
}

View File

@@ -1,47 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2007 Alessandro Praduroux <pradu@pradu.it>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
*/
#ifndef KRFB_FRAMEBUFFER_QT_QTFRAMEBUFFER_H
#define KRFB_FRAMEBUFFER_QT_QTFRAMEBUFFER_H
#include <QImage>
#include "framebuffer.h"
class QTimer;
class QScreen;
/**
@author Alessandro Praduroux <pradu@pradu.it>
*/
class QtFrameBuffer : public FrameBuffer
{
Q_OBJECT
public:
explicit QtFrameBuffer(QObject *parent = nullptr);
~QtFrameBuffer() override;
int depth() override;
int height() override;
int width() override;
int paddedWidth() override;
void getServerFormat(rfbPixelFormat &format) override;
void startMonitor() override;
void stopMonitor() override;
public Q_SLOTS:
void updateFrameBuffer();
private:
WId win;
QImage fbImage;
QTimer *t;
QScreen *primaryScreen;
};
#endif

View File

@@ -1,41 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2009 Collabora Ltd <info@collabora.co.uk>
@author George Goldberg <george.goldberg@collabora.co.uk>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "qtframebufferplugin.h"
#include "qtframebuffer.h"
#include <KPluginFactory>
K_PLUGIN_CLASS_WITH_JSON(QtFrameBufferPlugin, "qt.json")
QtFrameBufferPlugin::QtFrameBufferPlugin(QObject *parent, const QVariantList &args)
: FrameBufferPlugin(parent, args)
{
}
FrameBuffer *QtFrameBufferPlugin::frameBuffer(const QVariantMap &args)
{
Q_UNUSED(args);
return new QtFrameBuffer;
}
#include "qtframebufferplugin.moc"

View File

@@ -1,45 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2009 Collabora Ltd <info@collabora.co.uk>
@author George Goldberg <george.goldberg@collabora.co.uk>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KRFB_FRAMEBUFFER_QT_QTFRAMEBUFFERPLUGIN_H
#define KRFB_FRAMEBUFFER_QT_QTFRAMEBUFFERPLUGIN_H
#include "framebufferplugin.h"
#include <QWidget>
class FrameBuffer;
class QtFrameBufferPlugin : public FrameBufferPlugin
{
Q_OBJECT
public:
QtFrameBufferPlugin(QObject *parent, const QVariantList &args);
FrameBuffer *frameBuffer(const QVariantMap &args) override;
private:
Q_DISABLE_COPY(QtFrameBufferPlugin)
};
#endif // Header guard