Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync: from linuxdeepin/dtkwidget #101

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 setWindowSurfaceType(int surfaceType);

using DPlatformHandle::setWindowBlurAreaByWM;
using DPlatformHandle::setWindowWallpaperParaByWM;
};
Expand Down
20 changes: 20 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,18 @@ static QWindow *ensureWindowHandle(QWidget *widget)

window->setAttribute(Qt::WA_NativeWindow);
handle = window->windowHandle();

// default type is `RasterSurface`
if (g_surfaceType >= QWindow::RasterSurface &&
g_surfaceType <=
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QWindow::MetalSurface
#else
QWindow::Direct3DSurface
#endif
)
handle->setSurfaceType(QWindow::SurfaceType(g_surfaceType));

window->setAttribute(Qt::WA_NativeWindow, false);

// dxcb version >= 1.1.6
Expand Down Expand Up @@ -237,4 +252,9 @@ bool DPlatformWindowHandle::setWindowWallpaperParaByWM(QWidget *widget, const QR
return DPlatformHandle::setWindowWallpaperParaByWM(ensureWindowHandle(widget), area, sMode, fMode);
}

void DPlatformWindowHandle::setWindowSurfaceType(int surfaceType)
{
g_surfaceType = surfaceType;
}

DWIDGET_END_NAMESPACE
Loading