Skip to content

Commit

Permalink
Use new Platform::IsX11
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-fedin authored and john-preston committed Feb 24, 2021
1 parent 7d18c86 commit db65fca
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions ui/platform/linux/ui_utility_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,23 +161,27 @@ bool TranslucentWindowsSupported(QPoint globalPosition) {
if (::Platform::IsWayland()) {
return true;
}
if (const auto native = QGuiApplication::platformNativeInterface()) {
if (const auto desktop = QApplication::desktop()) {
if (const auto screen = base::QScreenNearestTo(globalPosition)) {
if (native->nativeResourceForScreen(QByteArray("compositingEnabled"), screen)) {
return true;
}
const auto index = QGuiApplication::screens().indexOf(screen);
static auto WarnedAbout = base::flat_set<int>();
if (!WarnedAbout.contains(index)) {
WarnedAbout.emplace(index);
UI_LOG(("WARNING: Compositing is disabled for screen index %1 (for position %2,%3)").arg(index).arg(globalPosition.x()).arg(globalPosition.y()));

if (::Platform::IsX11()) {
if (const auto native = QGuiApplication::platformNativeInterface()) {
if (const auto desktop = QApplication::desktop()) {
if (const auto screen = base::QScreenNearestTo(globalPosition)) {
if (native->nativeResourceForScreen(QByteArray("compositingEnabled"), screen)) {
return true;
}
const auto index = QGuiApplication::screens().indexOf(screen);
static auto WarnedAbout = base::flat_set<int>();
if (!WarnedAbout.contains(index)) {
WarnedAbout.emplace(index);
UI_LOG(("WARNING: Compositing is disabled for screen index %1 (for position %2,%3)").arg(index).arg(globalPosition.x()).arg(globalPosition.y()));
}
} else {
UI_LOG(("WARNING: Could not get screen for position %1,%2").arg(globalPosition.x()).arg(globalPosition.y()));
}
} else {
UI_LOG(("WARNING: Could not get screen for position %1,%2").arg(globalPosition.x()).arg(globalPosition.y()));
}
}
}

return false;
}

Expand All @@ -193,7 +197,7 @@ bool WindowExtentsSupported() {

#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
namespace XCB = base::Platform::XCB;
if (!::Platform::IsWayland()
if (::Platform::IsX11()
&& XCB::IsSupportedByWM(kXCBFrameExtentsAtomName.utf16())) {
return true;
}
Expand All @@ -210,13 +214,15 @@ bool SetWindowExtents(QWindow *window, const QMargins &extents) {
#else // DESKTOP_APP_QT_PATCHED
return false;
#endif // !DESKTOP_APP_QT_PATCHED
} else {
} else if (::Platform::IsX11()) {
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
return SetXCBFrameExtents(window, extents);
#else // !DESKTOP_APP_DISABLE_X11_INTEGRATION
return false;
#endif // DESKTOP_APP_DISABLE_X11_INTEGRATION
}

return false;
}

bool UnsetWindowExtents(QWindow *window) {
Expand All @@ -227,13 +233,15 @@ bool UnsetWindowExtents(QWindow *window) {
#else // DESKTOP_APP_QT_PATCHED
return false;
#endif // !DESKTOP_APP_QT_PATCHED
} else {
} else if (::Platform::IsX11()) {
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
return UnsetXCBFrameExtents(window);
#else // !DESKTOP_APP_DISABLE_X11_INTEGRATION
return false;
#endif // DESKTOP_APP_DISABLE_X11_INTEGRATION
}

return false;
}

bool ShowWindowMenu(QWindow *window) {
Expand Down

0 comments on commit db65fca

Please sign in to comment.