Compare commits

..

5 Commits

Author SHA1 Message Date
Nicolas Fella
52c5d2248f Fix nativeEventFilter signature when building against Qt6 2022-08-03 21:22:51 +02:00
Nicolas Fella
0ff18b64bc Fix includes for QX11Info when using Qt6 2022-08-03 21:20:32 +02:00
Nicolas Fella
7c367c0fac Adapt build system for building against Qt6 2022-08-03 21:19:35 +02:00
Nicolas Fella
6a4a925a2e Use correct KWallet include 2022-08-03 21:15:07 +02:00
Nicolas Fella
7b3a50e9bf Remove unused include 2022-08-03 21:14:34 +02:00
28 changed files with 97 additions and 66 deletions

View File

@@ -27,7 +27,11 @@ include(CheckIncludeFile)
check_include_file("linux/input.h" HAVE_LINUX_INPUT_H)
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Core DBus Widgets X11Extras)
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED COMPONENTS Core DBus Widgets)
if(QT_MAJOR_VERSION EQUAL "5")
find_package(Qt5X11Extras REQUIRED)
endif()
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
I18n
@@ -81,8 +85,8 @@ find_package(PlasmaWaylandProtocols 1.5.0)
if(PipeWire_FOUND AND PlasmaWaylandProtocols_FOUND)
find_package(KF5Wayland ${KF5_MIN_VERSION})
find_package(QtWaylandScanner REQUIRED)
find_package(Qt5WaylandClient)
find_package(Qt5XkbCommonSupport)
find_package(Qt${QT_MAJOR_VERSION}WaylandClient)
find_package(Qt${QT_MAJOR_VERSION}XkbCommonSupport)
find_package(Wayland REQUIRED COMPONENTS Client)
endif()

View File

@@ -22,7 +22,6 @@
#include "x11events.h"
#include <QApplication>
#include <QX11Info>
#include <QDesktopWidget>
#include <QGlobalStatic>
@@ -30,7 +29,11 @@
#include <X11/keysym.h>
#include <X11/extensions/XTest.h>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QX11Info>
#else
#include <QtGui/private/qtx11extras_p.h>
#endif
enum {
LEFTSHIFT = 1,

View File

@@ -22,7 +22,12 @@
#include "x11events.h"
#include <KPluginFactory>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QX11Info>
#else
#include <QtGui/private/qtx11extras_p.h>
#endif
K_PLUGIN_CLASS(X11EventsPlugin)

View File

@@ -7,7 +7,7 @@ set (krfb_events_xdp_SRCS
xdpeventsplugin.cpp
)
qt5_add_dbus_interface(
qt_add_dbus_interface(
krfb_events_xdp_SRCS
${CMAKE_SOURCE_DIR}/dbus/xdp_dbus_remotedesktop_interface.xml
xdp_dbus_remotedesktop_interface
@@ -18,7 +18,7 @@ add_library (krfb_events_xdp MODULE ${krfb_events_xdp_SRCS})
target_link_libraries (krfb_events_xdp
KF5::CoreAddons
KF5::I18n
Qt5::DBus
Qt::DBus
krfbprivate
)
set_target_properties(krfb_events_xdp PROPERTIES OUTPUT_NAME xdp)

View File

@@ -27,7 +27,6 @@
#include <linux/input.h>
#include <QApplication>
#include <QDesktopWidget>
#include <QGlobalStatic>
class EventData

View File

@@ -22,13 +22,13 @@ ecm_qt_declare_logging_category(krfb_framebuffer_pw_SRCS
EXPORT KRFB
)
qt5_add_dbus_interface(
qt_add_dbus_interface(
krfb_framebuffer_pw_SRCS
${CMAKE_SOURCE_DIR}/dbus/xdp_dbus_screencast_interface.xml
xdp_dbus_screencast_interface
)
qt5_add_dbus_interface(
qt_add_dbus_interface(
krfb_framebuffer_pw_SRCS
${CMAKE_SOURCE_DIR}/dbus/xdp_dbus_remotedesktop_interface.xml
xdp_dbus_remotedesktop_interface
@@ -41,9 +41,9 @@ add_library(krfb_framebuffer_pw
set_property(TARGET krfb_framebuffer_pw PROPERTY C_STANDARD 99)
target_link_libraries(krfb_framebuffer_pw
Qt5::Core
Qt5::Gui
Qt5::DBus
Qt::Core
Qt::Gui
Qt::DBus
KF5::CoreAddons
KF5::WaylandClient
Wayland::Client

View File

@@ -961,8 +961,8 @@ PWFrameBuffer::Private::~Private()
}
}
PWFrameBuffer::PWFrameBuffer(QObject *parent)
: FrameBuffer (parent),
PWFrameBuffer::PWFrameBuffer(WId winid, QObject *parent)
: FrameBuffer (winid, parent),
d(new Private(this))
{
fb = nullptr;

View File

@@ -30,7 +30,7 @@ public:
};
using Streams = QList<Stream>;
PWFrameBuffer(QObject *parent = nullptr);
PWFrameBuffer(WId winid, QObject *parent = nullptr);
virtual ~PWFrameBuffer() override;
void initDBus();

View File

@@ -30,9 +30,11 @@ PWFrameBufferPlugin::PWFrameBufferPlugin(QObject *parent, const QVariantList &ar
}
FrameBuffer *PWFrameBufferPlugin::frameBuffer(const QVariantMap &args)
FrameBuffer *PWFrameBufferPlugin::frameBuffer(WId id, const QVariantMap &args)
{
auto pwfb = new PWFrameBuffer;
//NOTE WId is irrelevant in Wayland
auto pwfb = new PWFrameBuffer(id);
if (args.contains(QLatin1String("name"))) {
pwfb->startVirtualMonitor(args[QStringLiteral("name")].toString(), args[QStringLiteral("resolution")].toSize(), args[QStringLiteral("scale")].toDouble());
} else {

View File

@@ -34,7 +34,7 @@ class PWFrameBufferPlugin: public FrameBufferPlugin
public:
PWFrameBufferPlugin(QObject *parent, const QVariantList &args);
FrameBuffer *frameBuffer(const QVariantMap &args) override;
FrameBuffer *frameBuffer(WId id, const QVariantMap &args) override;
private:
Q_DISABLE_COPY(PWFrameBufferPlugin)

View File

@@ -21,10 +21,9 @@ add_library(krfb_framebuffer_qt
)
target_link_libraries (krfb_framebuffer_qt
Qt5::Core
Qt5::Gui
Qt::Core
Qt::Gui
KF5::CoreAddons
Qt::GuiPrivate
krfbprivate
)

View File

@@ -13,20 +13,17 @@
#include <QRegion>
#include <QPixmap>
#include <QBitmap>
#include <QApplication>
#include <QGuiApplication>
#include <QScreen>
#include <qpa/qplatformnativeinterface.h>
const int UPDATE_TIME = 500;
QtFrameBuffer::QtFrameBuffer(QObject *parent)
: FrameBuffer(parent)
QtFrameBuffer::QtFrameBuffer(WId id, QObject *parent)
: FrameBuffer(id, parent)
{
QScreen *screen = QGuiApplication::primaryScreen();
QPlatformNativeInterface* native = qApp->platformNativeInterface();
if (screen) {
win = reinterpret_cast<WId>(native->nativeResourceForScreen(QByteArrayLiteral("rootwindow"), screen));
primaryScreen = screen;
fbImage = screen->grabWindow(win).toImage();
fb = new char[fbImage.sizeInBytes()];

View File

@@ -22,7 +22,7 @@ class QtFrameBuffer : public FrameBuffer
{
Q_OBJECT
public:
explicit QtFrameBuffer(QObject *parent = nullptr);
explicit QtFrameBuffer(WId id, QObject *parent = nullptr);
~QtFrameBuffer() override;
@@ -38,7 +38,6 @@ public Q_SLOTS:
void updateFrameBuffer();
private:
WId win;
QImage fbImage;
QTimer *t;
QScreen *primaryScreen;

View File

@@ -31,10 +31,10 @@ QtFrameBufferPlugin::QtFrameBufferPlugin(QObject *parent, const QVariantList &ar
{
}
FrameBuffer *QtFrameBufferPlugin::frameBuffer(const QVariantMap &args)
FrameBuffer *QtFrameBufferPlugin::frameBuffer(WId id, const QVariantMap &args)
{
Q_UNUSED(args);
return new QtFrameBuffer;
return new QtFrameBuffer(id);
}
#include "qtframebufferplugin.moc"

View File

@@ -34,7 +34,7 @@ class QtFrameBufferPlugin : public FrameBufferPlugin
public:
QtFrameBufferPlugin(QObject *parent, const QVariantList &args);
FrameBuffer *frameBuffer(const QVariantMap &args) override;
FrameBuffer *frameBuffer(WId id, const QVariantMap &args) override;
private:
Q_DISABLE_COPY(QtFrameBufferPlugin)

View File

@@ -18,9 +18,8 @@ ecm_qt_declare_logging_category(krfb_framebuffer_xcb_SRCS
add_library(krfb_framebuffer_xcb MODULE ${krfb_framebuffer_xcb_SRCS})
target_link_libraries (krfb_framebuffer_xcb
Qt5::Core
Qt5::Gui
Qt::GuiPrivate
Qt::Core
Qt::Gui
XCB::XCB
XCB::RENDER
XCB::SHAPE

View File

@@ -18,13 +18,16 @@
#include <sys/ipc.h>
#include <sys/shm.h>
#include <QX11Info>
#include <QApplication>
#include <QCoreApplication>
#include <QGuiApplication>
#include <QScreen>
#include <QAbstractNativeEventFilter>
#include <qpa/qplatformnativeinterface.h>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QX11Info>
#else
#include <QtGui/private/qtx11extras_p.h>
#endif
class KrfbXCBEventFilter: public QAbstractNativeEventFilter
{
@@ -32,7 +35,11 @@ public:
KrfbXCBEventFilter(XCBFrameBuffer *owner);
public:
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override;
#else
bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result) override;
#endif
public:
int xdamageBaseEvent;
@@ -99,7 +106,11 @@ KrfbXCBEventFilter::KrfbXCBEventFilter(XCBFrameBuffer *owner):
bool KrfbXCBEventFilter::nativeEventFilter(const QByteArray &eventType,
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void *message, long *result) {
#else
void *message, qintptr *result) {
#endif
Q_UNUSED(result); // "result" is only used on windows
if (xdamageBaseEvent == 0) return false; // no xdamage extension
@@ -131,7 +142,6 @@ public:
bool running;
QRect area; // capture area, primary monitor coordinates
WId win;
};
@@ -146,8 +156,8 @@ static xcb_screen_t *get_xcb_screen(xcb_connection_t *conn, int screen_num) {
XCBFrameBuffer::XCBFrameBuffer(QObject *parent):
FrameBuffer(parent), d(new XCBFrameBuffer::P)
XCBFrameBuffer::XCBFrameBuffer(WId winid, QObject *parent):
FrameBuffer(winid, parent), d(new XCBFrameBuffer::P)
{
d->running = false;
d->damage = XCB_NONE;
@@ -164,8 +174,6 @@ XCBFrameBuffer::XCBFrameBuffer(QObject *parent):
QScreen *primaryScreen = QGuiApplication::primaryScreen();
if (primaryScreen) {
QPlatformNativeInterface* native = qApp->platformNativeInterface();
d->win = reinterpret_cast<WId>(native->nativeResourceForScreen(QByteArrayLiteral("rootwindow"), primaryScreen));
qreal scaleFactor = primaryScreen->devicePixelRatio();
d->area = { primaryScreen->geometry().topLeft() * scaleFactor,
primaryScreen->geometry().bottomRight() * scaleFactor };
@@ -181,7 +189,7 @@ XCBFrameBuffer::XCBFrameBuffer(QObject *parent):
}
d->framebufferImage = xcb_image_get(QX11Info::connection(),
d->win,
this->win,
d->area.left(),
d->area.top(),
d->area.width(),
@@ -250,7 +258,7 @@ XCBFrameBuffer::XCBFrameBuffer(QObject *parent):
// will return 1 on success (yes!)
int shmget_res = xcb_image_shm_get(
QX11Info::connection(),
d->win,
this->win,
d->updateTile,
d->shminfo,
d->area.left(), // x
@@ -558,7 +566,7 @@ QList<QRect> XCBFrameBuffer::modifiedTiles() {
// translate whe coordinates
xcb_shm_get_image_cookie_t sgi_cookie = xcb_shm_get_image(
QX11Info::connection(),
d->win,
this->win,
d->area.left() + r.left(),
d->area.top() + r.top(),
r.width(),
@@ -613,7 +621,7 @@ QList<QRect> XCBFrameBuffer::modifiedTiles() {
// need function that copies pixels from one image to another
xcb_image_t *damagedImage = xcb_image_get(
QX11Info::connection(),
d->win,
this->win,
r.left(),
r.top(),
r.width(),
@@ -653,7 +661,7 @@ void XCBFrameBuffer::startMonitor() {
d->running = true;
d->damage = xcb_generate_id(QX11Info::connection());
xcb_damage_create(QX11Info::connection(), d->damage, d->win,
xcb_damage_create(QX11Info::connection(), d->damage, this->win,
XCB_DAMAGE_REPORT_LEVEL_RAW_RECTANGLES);
// (currently) we do not call xcb_damage_subtract() EVER, because

View File

@@ -22,7 +22,7 @@ class XCBFrameBuffer: public FrameBuffer
{
Q_OBJECT
public:
explicit XCBFrameBuffer(QObject *parent = nullptr);
explicit XCBFrameBuffer(WId winid, QObject *parent = nullptr);
~XCBFrameBuffer() override;
public:

View File

@@ -29,10 +29,10 @@ XCBFrameBufferPlugin::XCBFrameBufferPlugin(QObject *parent, const QVariantList &
{
}
FrameBuffer *XCBFrameBufferPlugin::frameBuffer(const QVariantMap &args)
FrameBuffer *XCBFrameBufferPlugin::frameBuffer(WId id, const QVariantMap &args)
{
Q_UNUSED(args);
return new XCBFrameBuffer;
return new XCBFrameBuffer(id);
}
#include "xcb_framebufferplugin.moc"

View File

@@ -34,7 +34,7 @@ class XCBFrameBufferPlugin: public FrameBufferPlugin
public:
XCBFrameBufferPlugin(QObject *parent, const QVariantList &args);
FrameBuffer *frameBuffer(const QVariantMap &args) override;
FrameBuffer *frameBuffer(WId id, const QVariantMap &args) override;
private:
Q_DISABLE_COPY(XCBFrameBufferPlugin)

View File

@@ -23,13 +23,18 @@ generate_export_header(krfbprivate BASE_NAME krfbprivate)
target_link_libraries (krfbprivate
Qt5::Core
Qt5::Widgets
Qt5::X11Extras
Qt::Core
Qt::Widgets
${X11_X11_LIB}
${LIBVNCSERVER_LIBRARIES}
)
if(QT_MAJOR_VERSION EQUAL "5")
target_link_libraries (krfbprivate Qt::X11Extras)
else()
target_link_libraries (krfbprivate Qt::GuiPrivate)
endif()
set_target_properties (krfbprivate PROPERTIES
VERSION 5
SOVERSION 5.0
@@ -80,7 +85,7 @@ ki18n_wrap_ui (krfb_UI_SRCS
ui/mainwidget.ui
)
qt5_add_resources(krfb_SRCS
qt_add_resources(krfb_SRCS
krfb.qrc
)
@@ -95,7 +100,7 @@ target_link_libraries (krfb
${X11_Xext_LIB}
${X11_X11_LIB}
${X11_Xdamage_LIB}
Qt5::Network
Qt::Network
KF5::CoreAddons
KF5::DBusAddons
KF5::DNSSD
@@ -135,8 +140,8 @@ add_executable(krfb-virtualmonitor main-virtualmonitor.cpp ${krfbvm_SRCS} ${krfb
rfbserver.cpp rfbclient.cpp rfbservermanager.cpp eventsmanager.cpp framebuffermanager.cpp sockethelpers.cpp)
target_link_libraries(krfb-virtualmonitor
krfbprivate
Qt5::Gui
Qt5::Network
Qt::Gui
Qt::Network
KF5::ConfigGui
KF5::CoreAddons
KF5::I18n

View File

@@ -13,8 +13,8 @@
#include <QCursor>
FrameBuffer::FrameBuffer(QObject *parent)
: QObject(parent)
FrameBuffer::FrameBuffer(WId id, QObject *parent)
: QObject(parent), win(id)
{
}

View File

@@ -29,7 +29,7 @@ class KRFBPRIVATE_EXPORT FrameBuffer : public QObject
{
Q_OBJECT
public:
explicit FrameBuffer(QObject *parent = nullptr);
explicit FrameBuffer(WId id, QObject *parent = nullptr);
~FrameBuffer() override;
@@ -52,6 +52,7 @@ Q_SIGNALS:
void frameBufferChanged();
protected:
WId win;
char *fb = nullptr;
QList<QRect> tiles;

View File

@@ -81,7 +81,7 @@ QSharedPointer<FrameBuffer> FrameBufferManager::frameBuffer(WId id, const QVaria
if (it.key() == KrfbConfig::preferredFrameBufferPlugin()) {
qCDebug(KRFB) << "Using FrameBuffer:" << KrfbConfig::preferredFrameBufferPlugin();
QSharedPointer<FrameBuffer> frameBuffer(it.value()->frameBuffer(args));
QSharedPointer<FrameBuffer> frameBuffer(it.value()->frameBuffer(id, args));
if (frameBuffer) {
m_frameBuffers.insert(id, frameBuffer.toWeakRef());

View File

@@ -37,7 +37,7 @@ public:
explicit FrameBufferPlugin(QObject *parent, const QVariantList &args);
~FrameBufferPlugin() override;
virtual FrameBuffer *frameBuffer(const QVariantMap &args) = 0;
virtual FrameBuffer *frameBuffer(WId id, const QVariantMap &args) = 0;
};
#endif // Header guard

View File

@@ -30,7 +30,7 @@
#include <KLocalizedString>
#include <KUser>
#include <KStringHandler>
#include <KWallet/KWallet>
#include <KWallet>
#include <kdnssd_version.h>
#if KDNSSD_VERSION >= QT_VERSION_CHECK(5, 84, 0)

View File

@@ -30,7 +30,12 @@
#include <QPixmap>
#include <qwindowdefs.h>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QX11Info>
#else
#include <QtGui/private/qtx11extras_p.h>
#endif
#include <csignal>
#include <X11/extensions/XTest.h>

View File

@@ -24,7 +24,12 @@
#include <QApplication>
#include <QClipboard>
#include <QPointer>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QX11Info>
#else
#include <QtGui/private/qtx11extras_p.h>
#endif
struct RfbServer::Private
{