Skip to content

Commit

Permalink
another clean fix for linuxdeepin#231 (linuxdeepin#232)
Browse files Browse the repository at this point in the history
* feat: attempt to support Qt 6.6.2

QXcbWindow now inherits from QObject, this makes the plain parent() call
ambigious and breaks `VtableHook::callOriginalFun`. I am not sure if the
changes here are correct, but it at least compiles and dde-launchpad
seems to working correctly.

Also accepts QT_XCB_PRIVATE_HEADERS for Qt 6.x builds.

```
-class Q_XCB_EXPORT QXcbWindow : public QXcbObject, public QXcbWindowEventListener, public QPlatformWindow
+class Q_XCB_EXPORT QXcbWindow : public QObject, public QXcbObject, public QXcbWindowEventListener, public QPlatformWindow
                               , public QNativeInterface::Private::QXcbWindow
 {
+    Q_OBJECT
```

* another clean fix on qt 6.6.2

* xcb: improve qt6 private header inclusion handling

---------

Co-authored-by: Felix Yan <[email protected]>
  • Loading branch information
Keeyou and felixonmars authored Feb 20, 2024
1 parent bad4d75 commit f0129fa
Show file tree
Hide file tree
Showing 42 changed files with 3,847 additions and 13 deletions.
4 changes: 2 additions & 2 deletions xcb/dforeignplatformwindow_x11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ void DForeignPlatformWindow::handleConfigureNotifyEvent(const xcb_configure_noti
{
bool fromSendEvent = (event->response_type & 0x80);
QPoint pos(event->x, event->y);
if (!parent() && !fromSendEvent) {
if (!QPlatformWindow::parent() && !fromSendEvent) {
// Do not trust the position, query it instead.
xcb_translate_coordinates_cookie_t cookie = xcb_translate_coordinates(xcb_connection(), xcb_window(),
xcbScreen()->root(), 0, 0);
Expand All @@ -144,7 +144,7 @@ void DForeignPlatformWindow::handleConfigureNotifyEvent(const xcb_configure_noti
}

QRect actualGeometry = QRect(pos, QSize(event->width, event->height));
QPlatformScreen *newScreen = parent() ? parent()->screen() : screenForGeometry(actualGeometry);
QPlatformScreen *newScreen = QPlatformWindow::parent() ? QPlatformWindow::parent()->screen() : screenForGeometry(actualGeometry);
if (!newScreen)
return;

Expand Down
41 changes: 41 additions & 0 deletions xcb/libqt6xcbqpa-dev/6.6.2/gl_integrations/qxcbglintegration.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#ifndef QXCBGLINTEGRATION_H

#include "qxcbexport.h"
#include "qxcbwindow.h"

#include <QtCore/QLoggingCategory>

QT_BEGIN_NAMESPACE

class QPlatformOffscreenSurface;
class QOffscreenSurface;
class QXcbNativeInterfaceHandler;

Q_DECLARE_EXPORTED_LOGGING_CATEGORY(lcQpaGl, Q_XCB_EXPORT)

class Q_XCB_EXPORT QXcbGlIntegration
{
public:
QXcbGlIntegration();
virtual ~QXcbGlIntegration();
virtual bool initialize(QXcbConnection *connection) = 0;

virtual bool supportsThreadedOpenGL() const { return false; }
virtual bool supportsSwitchableWidgetComposition() const { return true; }
virtual bool handleXcbEvent(xcb_generic_event_t *event, uint responseType);

virtual QXcbWindow *createWindow(QWindow *window) const = 0;
#ifndef QT_NO_OPENGL
virtual QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const = 0;
#endif
virtual QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const = 0;

virtual QXcbNativeInterfaceHandler *nativeInterfaceHandler() const { return nullptr; }
};

QT_END_NAMESPACE

#endif //QXCBGLINTEGRATION_H
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#ifndef QXCBGLINTEGRATIONFACTORY_H
#define QXCBGLINTEGRATIONFACTORY_H

#include <QtCore/qstringlist.h>

QT_BEGIN_NAMESPACE

class QXcbGlIntegration;

class QXcbGlIntegrationFactory
{
public:
static QXcbGlIntegration *create(const QString &name);
};

QT_END_NAMESPACE

#endif //QXCBGLINTEGRATIONFACTORY_H

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#ifndef QXCBGLINTEGRATIONPLUGIN_H
#define QXCBGLINTEGRATIONPLUGIN_H

#include "qxcbexport.h"
#include <QtCore/qplugin.h>
#include <QtCore/qfactoryinterface.h>

QT_BEGIN_NAMESPACE

#define QXcbGlIntegrationFactoryInterface_iid "org.qt-project.Qt.QPA.Xcb.QXcbGlIntegrationFactoryInterface.5.5"

class QXcbGlIntegration;

class Q_XCB_EXPORT QXcbGlIntegrationPlugin : public QObject
{
Q_OBJECT
public:
explicit QXcbGlIntegrationPlugin(QObject *parent = nullptr)
: QObject(parent)
{ }

virtual QXcbGlIntegration *create() = 0;
// the pattern expected by qLoadPlugin calls for a QString argument.
// we don't need it, so don't bother subclasses with it:
QXcbGlIntegration *create(const QString &) { return create(); }
};
QT_END_NAMESPACE

#endif //QXCBGLINTEGRATIONPLUGIN_H
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#ifndef QXCBNATIVEINTERFACEHANDLER_H
#define QXCBNATIVEINTERFACEHANDLER_H

#include <QtCore/QByteArray>
#include <QtGui/qpa/qplatformnativeinterface.h>

#include "qxcbexport.h"

QT_BEGIN_NAMESPACE

class QXcbNativeInterface;
class Q_XCB_EXPORT QXcbNativeInterfaceHandler
{
public:
QXcbNativeInterfaceHandler(QXcbNativeInterface *nativeInterface);
virtual ~QXcbNativeInterfaceHandler();

virtual QPlatformNativeInterface::NativeResourceForIntegrationFunction nativeResourceFunctionForIntegration(const QByteArray &resource) const;
virtual QPlatformNativeInterface::NativeResourceForContextFunction nativeResourceFunctionForContext(const QByteArray &resource) const;
virtual QPlatformNativeInterface::NativeResourceForScreenFunction nativeResourceFunctionForScreen(const QByteArray &resource) const;
virtual QPlatformNativeInterface::NativeResourceForWindowFunction nativeResourceFunctionForWindow(const QByteArray &resource) const;
virtual QPlatformNativeInterface::NativeResourceForBackingStoreFunction nativeResourceFunctionForBackingStore(const QByteArray &resource) const;

virtual QFunctionPointer platformFunction(const QByteArray &function) const;
protected:
QXcbNativeInterface *m_native_interface;
};

QT_END_NAMESPACE

#endif //QXCBNATIVEINTERFACEHANDLER_H
40 changes: 40 additions & 0 deletions xcb/libqt6xcbqpa-dev/6.6.2/nativepainting/qbackingstore_x11_p.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#ifndef QBACKINGSTORE_X11_H
#define QBACKINGSTORE_X11_H

#include <qpa/qplatformbackingstore.h>

typedef struct _XDisplay Display;

QT_BEGIN_NAMESPACE

class QXcbWindow;

class QXcbNativeBackingStore : public QPlatformBackingStore
{
public:
QXcbNativeBackingStore(QWindow *window);
~QXcbNativeBackingStore();

QPaintDevice *paintDevice() override;
void flush(QWindow *window, const QRegion &region, const QPoint &offset) override;

QImage toImage() const override;

void resize(const QSize &size, const QRegion &staticContents) override;
bool scroll(const QRegion &area, int dx, int dy) override;

void beginPaint(const QRegion &region) override;

private:
Display *display() const;

QPixmap m_pixmap;
bool m_translucentBackground;
};

QT_END_NAMESPACE

#endif // QBACKINGSTORE_X11_H
45 changes: 45 additions & 0 deletions xcb/libqt6xcbqpa-dev/6.6.2/nativepainting/qcolormap_x11_p.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#ifndef QCOLORMAP_X11_H
#define QCOLORMAP_X11_H

#include <QColor>
#include <QList>

QT_BEGIN_NAMESPACE

class QXcbColormapPrivate;
class QXcbColormap
{
public:
enum Mode { Direct, Indexed, Gray };

static void initialize();
static void cleanup();

static QXcbColormap instance(int screen = -1);

QXcbColormap(const QXcbColormap &colormap);
~QXcbColormap();

QXcbColormap &operator=(const QXcbColormap &colormap);

Mode mode() const;

int depth() const;
int size() const;

uint pixel(const QColor &color) const;
const QColor colorAt(uint pixel) const;

const QList<QColor> colormap() const;

private:
QXcbColormap();
QXcbColormapPrivate *d;
};

QT_END_NAMESPACE

#endif // QCOLORMAP_X11_H
88 changes: 88 additions & 0 deletions xcb/libqt6xcbqpa-dev/6.6.2/nativepainting/qpaintengine_x11_p.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#ifndef QPAINTENGINE_X11_H
#define QPAINTENGINE_X11_H

#include <QtGui/QPaintEngine>

typedef unsigned long XID;
typedef XID Drawable;
typedef struct _XGC *GC;

QT_BEGIN_NAMESPACE

extern "C" {
Drawable qt_x11Handle(const QPaintDevice *pd);
GC qt_x11_get_pen_gc(QPainter *);
GC qt_x11_get_brush_gc(QPainter *);
}

class QX11PaintEnginePrivate;
class QX11PaintEngine : public QPaintEngine
{
Q_DECLARE_PRIVATE(QX11PaintEngine)
public:
QX11PaintEngine();
~QX11PaintEngine();

bool begin(QPaintDevice *pdev) override;
bool end() override;

void updateState(const QPaintEngineState &state) override;

void updatePen(const QPen &pen);
void updateBrush(const QBrush &brush, const QPointF &pt);
void updateRenderHints(QPainter::RenderHints hints);
void updateFont(const QFont &font);
void updateMatrix(const QTransform &matrix);
void updateClipRegion_dev(const QRegion &region, Qt::ClipOperation op);

void drawLines(const QLine *lines, int lineCount) override;
void drawLines(const QLineF *lines, int lineCount) override;

void drawRects(const QRect *rects, int rectCount) override;
void drawRects(const QRectF *rects, int rectCount) override;

void drawPoints(const QPoint *points, int pointCount) override;
void drawPoints(const QPointF *points, int pointCount) override;

void drawEllipse(const QRect &r) override;
void drawEllipse(const QRectF &r) override;

virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) override;
inline void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode) override
{ QPaintEngine::drawPolygon(points, pointCount, mode); }

void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) override;
void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s) override;
void drawPath(const QPainterPath &path) override;
void drawTextItem(const QPointF &p, const QTextItem &textItem) override;
void drawImage(const QRectF &r, const QImage &img, const QRectF &sr,
Qt::ImageConversionFlags flags = Qt::AutoColor) override;

virtual Drawable handle() const;
inline Type type() const override { return QPaintEngine::X11; }

QPainter::RenderHints supportedRenderHints() const;

protected:
QX11PaintEngine(QX11PaintEnginePrivate &dptr);

#if QT_CONFIG(fontconfig)
void drawFreetype(const QPointF &p, const QTextItemInt &ti);
bool drawCachedGlyphs(const QTransform &transform, const QTextItemInt &ti);
#endif // QT_CONFIG(fontconfig)

friend class QPixmap;
friend class QFontEngineBox;
friend GC qt_x11_get_pen_gc(QPainter *);
friend GC qt_x11_get_brush_gc(QPainter *);

private:
Q_DISABLE_COPY_MOVE(QX11PaintEngine)
};

QT_END_NAMESPACE

#endif // QPAINTENGINE_X11_H
Loading

0 comments on commit f0129fa

Please sign in to comment.