mirror of
https://github.com/KDE/krfb
synced 2026-07-01 07:41:17 -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::Core
|
||||||
Qt5::Gui
|
Qt5::Gui
|
||||||
KF5::CoreAddons
|
KF5::CoreAddons
|
||||||
|
Qt::GuiPrivate
|
||||||
krfbprivate
|
krfbprivate
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -14,18 +14,19 @@
|
|||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QBitmap>
|
#include <QBitmap>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDesktopWidget>
|
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
|
#include <qpa/qplatformnativeinterface.h>
|
||||||
|
|
||||||
const int UPDATE_TIME = 500;
|
const int UPDATE_TIME = 500;
|
||||||
|
|
||||||
QtFrameBuffer::QtFrameBuffer(QObject *parent)
|
QtFrameBuffer::QtFrameBuffer(QObject *parent)
|
||||||
: FrameBuffer(parent)
|
: FrameBuffer(parent)
|
||||||
{
|
{
|
||||||
win = QApplication::desktop()->winId();
|
|
||||||
QScreen *screen = QGuiApplication::primaryScreen();
|
QScreen *screen = QGuiApplication::primaryScreen();
|
||||||
|
QPlatformNativeInterface* native = qApp->platformNativeInterface();
|
||||||
|
|
||||||
if (screen) {
|
if (screen) {
|
||||||
|
win = reinterpret_cast<WId>(native->nativeResourceForScreen(QByteArrayLiteral("rootwindow"), screen));
|
||||||
primaryScreen = screen;
|
primaryScreen = screen;
|
||||||
fbImage = screen->grabWindow(win).toImage();
|
fbImage = screen->grabWindow(win).toImage();
|
||||||
fb = new char[fbImage.sizeInBytes()];
|
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
|
target_link_libraries (krfb_framebuffer_xcb
|
||||||
Qt5::Core
|
Qt5::Core
|
||||||
Qt5::Gui
|
Qt5::Gui
|
||||||
|
Qt::GuiPrivate
|
||||||
XCB::XCB
|
XCB::XCB
|
||||||
XCB::RENDER
|
XCB::RENDER
|
||||||
XCB::SHAPE
|
XCB::SHAPE
|
||||||
|
|||||||
@@ -20,10 +20,10 @@
|
|||||||
|
|
||||||
#include <QX11Info>
|
#include <QX11Info>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDesktopWidget>
|
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
#include <QAbstractNativeEventFilter>
|
#include <QAbstractNativeEventFilter>
|
||||||
|
#include <qpa/qplatformnativeinterface.h>
|
||||||
|
|
||||||
|
|
||||||
class KrfbXCBEventFilter: public QAbstractNativeEventFilter
|
class KrfbXCBEventFilter: public QAbstractNativeEventFilter
|
||||||
@@ -159,12 +159,13 @@ XCBFrameBuffer::XCBFrameBuffer(QObject *parent):
|
|||||||
d->area.setRect(0, 0, 0, 0);
|
d->area.setRect(0, 0, 0, 0);
|
||||||
d->x11EvtFilter = new KrfbXCBEventFilter(this);
|
d->x11EvtFilter = new KrfbXCBEventFilter(this);
|
||||||
d->rootScreen = get_xcb_screen(QX11Info::connection(), QX11Info::appScreen());
|
d->rootScreen = get_xcb_screen(QX11Info::connection(), QX11Info::appScreen());
|
||||||
d->win = QApplication::desktop()->winId();
|
|
||||||
|
|
||||||
this->fb = nullptr;
|
this->fb = nullptr;
|
||||||
|
|
||||||
QScreen *primaryScreen = QGuiApplication::primaryScreen();
|
QScreen *primaryScreen = QGuiApplication::primaryScreen();
|
||||||
if (primaryScreen) {
|
if (primaryScreen) {
|
||||||
|
QPlatformNativeInterface* native = qApp->platformNativeInterface();
|
||||||
|
d->win = reinterpret_cast<WId>(native->nativeResourceForScreen(QByteArrayLiteral("rootwindow"), primaryScreen));
|
||||||
qreal scaleFactor = primaryScreen->devicePixelRatio();
|
qreal scaleFactor = primaryScreen->devicePixelRatio();
|
||||||
d->area = { primaryScreen->geometry().topLeft() * scaleFactor,
|
d->area = { primaryScreen->geometry().topLeft() * scaleFactor,
|
||||||
primaryScreen->geometry().bottomRight() * scaleFactor };
|
primaryScreen->geometry().bottomRight() * scaleFactor };
|
||||||
|
|||||||
Reference in New Issue
Block a user