mirror of
https://github.com/KDE/krfb
synced 2026-07-01 07:31:16 -07:00
Port framebuffers away from deprecated QDesktopWidget
Use QPlatformNativeInterface to get the WId instead
This commit is contained in:
@@ -24,6 +24,7 @@ target_link_libraries (krfb_framebuffer_qt
|
||||
Qt5::Core
|
||||
Qt5::Gui
|
||||
KF5::CoreAddons
|
||||
Qt::GuiPrivate
|
||||
krfbprivate
|
||||
)
|
||||
|
||||
|
||||
@@ -14,18 +14,19 @@
|
||||
#include <QPixmap>
|
||||
#include <QBitmap>
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QScreen>
|
||||
|
||||
#include <qpa/qplatformnativeinterface.h>
|
||||
|
||||
const int UPDATE_TIME = 500;
|
||||
|
||||
QtFrameBuffer::QtFrameBuffer(QObject *parent)
|
||||
: FrameBuffer(parent)
|
||||
{
|
||||
win = QApplication::desktop()->winId();
|
||||
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()];
|
||||
|
||||
@@ -20,6 +20,7 @@ add_library(krfb_framebuffer_xcb MODULE ${krfb_framebuffer_xcb_SRCS})
|
||||
target_link_libraries (krfb_framebuffer_xcb
|
||||
Qt5::Core
|
||||
Qt5::Gui
|
||||
Qt::GuiPrivate
|
||||
XCB::XCB
|
||||
XCB::RENDER
|
||||
XCB::SHAPE
|
||||
|
||||
@@ -20,10 +20,10 @@
|
||||
|
||||
#include <QX11Info>
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QGuiApplication>
|
||||
#include <QScreen>
|
||||
#include <QAbstractNativeEventFilter>
|
||||
#include <qpa/qplatformnativeinterface.h>
|
||||
|
||||
|
||||
class KrfbXCBEventFilter: public QAbstractNativeEventFilter
|
||||
@@ -159,12 +159,13 @@ XCBFrameBuffer::XCBFrameBuffer(QObject *parent):
|
||||
d->area.setRect(0, 0, 0, 0);
|
||||
d->x11EvtFilter = new KrfbXCBEventFilter(this);
|
||||
d->rootScreen = get_xcb_screen(QX11Info::connection(), QX11Info::appScreen());
|
||||
d->win = QApplication::desktop()->winId();
|
||||
|
||||
this->fb = nullptr;
|
||||
|
||||
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 };
|
||||
|
||||
Reference in New Issue
Block a user