Skip to content

Commit

Permalink
fix: webengineView abnormal in DMainWindow
Browse files Browse the repository at this point in the history
`DPlatformWindowHandle::setWindowSurcetype(QWindow::OpenGLSurface)`
needs to be called before constructing DMainWindow when use
webengineview
  • Loading branch information
kegechen committed Dec 9, 2024
1 parent b3410a0 commit 3ac78ed
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/widgets/dplatformwindowhandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class DPlatformWindowHandle : public DPlatformHandle
static bool setWindowBlurAreaByWM(QWidget *widget, const QList<QPainterPath> &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;
};
Expand Down
13 changes: 13 additions & 0 deletions src/widgets/dplatformwindowhandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@

#include <QWidget>
#include <QApplication>
#include <QWindow>

DWIDGET_BEGIN_NAMESPACE

static int g_surfaceType = -1;

static QWindow *ensureWindowHandle(QWidget *widget)
{
QWidget *window = widget->window();
Expand All @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 3ac78ed

Please sign in to comment.