Skip to content

Commit

Permalink
feat: not set AA_DontCreateNativeWidgetSiblings if dxcb version great…
Browse files Browse the repository at this point in the history
…er then 1.1.5

Change-Id: If7b29cbced0af744008457ed1277214940e87ada
  • Loading branch information
zccrs authored and deepin-gerrit committed Jan 16, 2018
1 parent 41ac47a commit 5b3b4b5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/widgets/dplatformwindowhandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ DEFINE_CONST_CHAR(setWmBlurWindowBackgroundArea);
DEFINE_CONST_CHAR(setWmBlurWindowBackgroundPathList);
DEFINE_CONST_CHAR(setWmBlurWindowBackgroundMaskImage);
DEFINE_CONST_CHAR(setWindowProperty);
DEFINE_CONST_CHAR(pluginVersion);

static void setWindowProperty(QWindow *window, const char *name, const QVariant &value)
{
Expand Down Expand Up @@ -89,6 +90,20 @@ DPlatformWindowHandle::DPlatformWindowHandle(QWidget *widget, QObject *parent)
m_window->installEventFilter(this);
}

QString DPlatformWindowHandle::pluginVersion()
{
QFunctionPointer pv = 0;

#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
pv = qApp->platformFunction(_pluginVersion);
#endif

if (Q_UNLIKELY(!pv))
return QString();

return reinterpret_cast<QString(*)()>(pv)();
}

void DPlatformWindowHandle::enableDXcbForWindow(QWidget *widget)
{
Q_ASSERT_X(DApplication::isDXcbPlatform(), "DPlatformWindowHandler:",
Expand All @@ -103,8 +118,12 @@ void DPlatformWindowHandle::enableDXcbForWindow(QWidget *widget)
Q_ASSERT_X(!window->windowHandle(), "DPlatformWindowHandler:",
"Must be called before window handle has been created. See also QWidget::windowHandle()");

/// TODO: Avoid call parentWidget()->enforceNativeChildren().
qApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true);
// dxcb version < 1.1.6
if (pluginVersion().isEmpty()) {
/// TODO: Avoid call parentWidget()->enforceNativeChildren().
qApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true);
}

window->setAttribute(Qt::WA_NativeWindow);

Q_ASSERT_X(window->windowHandle(), "DPlatformWindowHandler:",
Expand Down
2 changes: 2 additions & 0 deletions src/widgets/dplatformwindowhandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class DPlatformWindowHandle : public QObject
explicit DPlatformWindowHandle(QWindow *window, QObject *parent = 0);
explicit DPlatformWindowHandle(QWidget *widget, QObject *parent = 0);

static QString pluginVersion();

static void enableDXcbForWindow(QWidget *widget);
static void enableDXcbForWindow(QWindow *window);
static bool isEnabledDXcb(const QWidget *widget);
Expand Down

0 comments on commit 5b3b4b5

Please sign in to comment.