Move code not really depending on Wayland-specific dependencies out of WaylandIntegration
This commit is contained in:
parent
bcfce982c8
commit
2dd3add5b3
4 changed files with 36 additions and 61 deletions
|
|
@ -85,38 +85,6 @@ bool WaylandIntegration::xdgDecorationSupported() {
|
||||||
return _private->xdgDecoration.has_value();
|
return _private->xdgDecoration.has_value();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WaylandIntegration::windowExtentsSupported() {
|
|
||||||
QWindow window;
|
|
||||||
window.create();
|
|
||||||
return window.nativeInterface<QWaylandWindow>();
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaylandIntegration::setWindowExtents(
|
|
||||||
not_null<QWidget*> widget,
|
|
||||||
const QMargins &extents) {
|
|
||||||
const auto window = widget->windowHandle();
|
|
||||||
Expects(window != nullptr);
|
|
||||||
|
|
||||||
const auto native = window->nativeInterface<QWaylandWindow>();
|
|
||||||
if (!native) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
native->setCustomMargins(extents);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaylandIntegration::unsetWindowExtents(not_null<QWidget*> widget) {
|
|
||||||
const auto window = widget->windowHandle();
|
|
||||||
Expects(window != nullptr);
|
|
||||||
|
|
||||||
const auto native = window->nativeInterface<QWaylandWindow>();
|
|
||||||
if (!native) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
native->setCustomMargins(QMargins());
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaylandIntegration::showWindowMenu(
|
void WaylandIntegration::showWindowMenu(
|
||||||
not_null<QWidget*> widget,
|
not_null<QWidget*> widget,
|
||||||
const QPoint &point) {
|
const QPoint &point) {
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,6 @@ public:
|
||||||
[[nodiscard]] static WaylandIntegration *Instance();
|
[[nodiscard]] static WaylandIntegration *Instance();
|
||||||
|
|
||||||
[[nodiscard]] bool xdgDecorationSupported();
|
[[nodiscard]] bool xdgDecorationSupported();
|
||||||
[[nodiscard]] bool windowExtentsSupported();
|
|
||||||
void setWindowExtents(not_null<QWidget*> widget, const QMargins &extents);
|
|
||||||
void unsetWindowExtents(not_null<QWidget*> widget);
|
|
||||||
void showWindowMenu(not_null<QWidget*> widget, const QPoint &point);
|
void showWindowMenu(not_null<QWidget*> widget, const QPoint &point);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -30,18 +30,6 @@ bool WaylandIntegration::xdgDecorationSupported() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WaylandIntegration::windowExtentsSupported() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaylandIntegration::setWindowExtents(
|
|
||||||
not_null<QWidget*> widget,
|
|
||||||
const QMargins &extents) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaylandIntegration::unsetWindowExtents(not_null<QWidget*> widget) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaylandIntegration::showWindowMenu(
|
void WaylandIntegration::showWindowMenu(
|
||||||
not_null<QWidget*> widget,
|
not_null<QWidget*> widget,
|
||||||
const QPoint &point) {
|
const QPoint &point) {
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
#include <QtCore/QPoint>
|
#include <QtCore/QPoint>
|
||||||
#include <QtGui/QWindow>
|
#include <QtGui/QWindow>
|
||||||
#include <QtWidgets/QApplication>
|
#include <QtWidgets/QApplication>
|
||||||
|
#include <qpa/qplatformwindow_p.h>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
namespace Platform {
|
namespace Platform {
|
||||||
|
|
@ -467,9 +468,14 @@ std::optional<bool> IsOverlapped(
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WindowExtentsSupported() {
|
bool WindowExtentsSupported() {
|
||||||
if (const auto integration = WaylandIntegration::Instance()) {
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
|
||||||
return integration->windowExtentsSupported();
|
using namespace QNativeInterface::Private;
|
||||||
|
QWindow window;
|
||||||
|
window.create();
|
||||||
|
if (window.nativeInterface<QWaylandWindow>()) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
#endif // Qt >= 6.5.0
|
||||||
|
|
||||||
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
|
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
|
||||||
namespace XCB = base::Platform::XCB;
|
namespace XCB = base::Platform::XCB;
|
||||||
|
|
@ -485,23 +491,39 @@ bool WindowExtentsSupported() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetWindowExtents(not_null<QWidget*> widget, const QMargins &extents) {
|
void SetWindowExtents(not_null<QWidget*> widget, const QMargins &extents) {
|
||||||
if (const auto integration = WaylandIntegration::Instance()) {
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
|
||||||
integration->setWindowExtents(widget, extents);
|
using namespace QNativeInterface::Private;
|
||||||
} else if (::Platform::IsX11()) {
|
if (const auto native = not_null(widget->windowHandle())
|
||||||
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
|
->nativeInterface<QWaylandWindow>()) {
|
||||||
SetXCBFrameExtents(widget, extents);
|
native->setCustomMargins(extents);
|
||||||
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
|
return;
|
||||||
}
|
}
|
||||||
|
#endif // Qt >= 6.5.0
|
||||||
|
|
||||||
|
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
|
||||||
|
if (::Platform::IsX11()) {
|
||||||
|
SetXCBFrameExtents(widget, extents);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnsetWindowExtents(not_null<QWidget*> widget) {
|
void UnsetWindowExtents(not_null<QWidget*> widget) {
|
||||||
if (const auto integration = WaylandIntegration::Instance()) {
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
|
||||||
integration->unsetWindowExtents(widget);
|
using namespace QNativeInterface::Private;
|
||||||
} else if (::Platform::IsX11()) {
|
if (const auto native = not_null(widget->windowHandle())
|
||||||
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
|
->nativeInterface<QWaylandWindow>()) {
|
||||||
UnsetXCBFrameExtents(widget);
|
native->setCustomMargins(QMargins());
|
||||||
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
|
return;
|
||||||
}
|
}
|
||||||
|
#endif // Qt >= 6.5.0
|
||||||
|
|
||||||
|
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
|
||||||
|
if (::Platform::IsX11()) {
|
||||||
|
UnsetXCBFrameExtents(widget);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowWindowMenu(not_null<QWidget*> widget, const QPoint &point) {
|
void ShowWindowMenu(not_null<QWidget*> widget, const QPoint &point) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue