diff --git a/include/widgets/dplatformwindowhandle.h b/include/widgets/dplatformwindowhandle.h index f6c57fb98..89c56e4ea 100644 --- a/include/widgets/dplatformwindowhandle.h +++ b/include/widgets/dplatformwindowhandle.h @@ -30,6 +30,9 @@ class DPlatformWindowHandle : public DPlatformHandle static bool setWindowBlurAreaByWM(QWidget *widget, const QList &paths); static bool setWindowWallpaperParaByWM(QWidget *widget, const QRect &area, WallpaperScaleMode sMode, WallpaperFillMode fMode); + // for webengineView you may need this to set `QWindow::SurfaceType::OpenGLSurface` + static void setWindowSurceType(int surfaceType); + using DPlatformHandle::setWindowBlurAreaByWM; using DPlatformHandle::setWindowWallpaperParaByWM; }; diff --git a/src/widgets/dplatformwindowhandle.cpp b/src/widgets/dplatformwindowhandle.cpp index 3de8ec6db..6f907a2f7 100644 --- a/src/widgets/dplatformwindowhandle.cpp +++ b/src/widgets/dplatformwindowhandle.cpp @@ -6,9 +6,12 @@ #include #include +#include DWIDGET_BEGIN_NAMESPACE +static int g_surfaceType = -1; + static QWindow *ensureWindowHandle(QWidget *widget) { QWidget *window = widget->window(); @@ -25,6 +28,11 @@ static QWindow *ensureWindowHandle(QWidget *widget) window->setAttribute(Qt::WA_NativeWindow); handle = window->windowHandle(); + + // default type is `RasterSurface` + if (g_surfaceType >= QWindow::RasterSurface && g_surfaceType <= QWindow::Direct3DSurface) + handle->setSurfaceType(QWindow::SurfaceType(g_surfaceType)); + window->setAttribute(Qt::WA_NativeWindow, false); // dxcb version >= 1.1.6 @@ -237,4 +245,9 @@ bool DPlatformWindowHandle::setWindowWallpaperParaByWM(QWidget *widget, const QR return DPlatformHandle::setWindowWallpaperParaByWM(ensureWindowHandle(widget), area, sMode, fMode); } +void DPlatformWindowHandle::setWindowSurceType(int surfaceType) +{ + g_surfaceType = surfaceType; +} + DWIDGET_END_NAMESPACE