mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 07:33:52 +02:00
Add UnsetWindowExtents method
This commit is contained in:
parent
3c8c059447
commit
c77f1bf082
4 changed files with 60 additions and 5 deletions
|
@ -720,6 +720,35 @@ bool SetXCBFrameExtents(QWindow *window, const QMargins &extents) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UnsetXCBFrameExtents(QWindow *window) {
|
||||||
|
const auto native = QGuiApplication::platformNativeInterface();
|
||||||
|
if (!native) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto connection = reinterpret_cast<xcb_connection_t*>(
|
||||||
|
native->nativeResourceForIntegration(QByteArray("connection")));
|
||||||
|
|
||||||
|
if (!connection) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto frameExtentsAtom = GetXCBAtom(
|
||||||
|
connection,
|
||||||
|
kXCBFrameExtentsAtomName.utf16());
|
||||||
|
|
||||||
|
if (!frameExtentsAtom.has_value()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
xcb_delete_property(
|
||||||
|
connection,
|
||||||
|
window->winId(),
|
||||||
|
*frameExtentsAtom);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool SetWaylandWindowGeometry(QWindow *window, const QRect &geometry) {
|
bool SetWaylandWindowGeometry(QWindow *window, const QRect &geometry) {
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) || defined DESKTOP_APP_QT_PATCHED
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) || defined DESKTOP_APP_QT_PATCHED
|
||||||
if (const auto waylandWindow = static_cast<QWaylandWindow*>(
|
if (const auto waylandWindow = static_cast<QWaylandWindow*>(
|
||||||
|
@ -1091,6 +1120,15 @@ bool SetWindowExtents(QWindow *window, const QMargins &extents) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UnsetWindowExtents(QWindow *window) {
|
||||||
|
if (IsWayland()) {
|
||||||
|
const auto geometry = QRect(QPoint(), window->size());
|
||||||
|
return SetWaylandWindowGeometry(window, geometry);
|
||||||
|
} else {
|
||||||
|
return UnsetXCBFrameExtents(window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool WindowsNeedShadow() {
|
bool WindowsNeedShadow() {
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) || defined DESKTOP_APP_QT_PATCHED
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) || defined DESKTOP_APP_QT_PATCHED
|
||||||
if (IsWayland()) {
|
if (IsWayland()) {
|
||||||
|
|
|
@ -58,6 +58,7 @@ bool StartSystemResize(QWindow *window, Qt::Edges edges);
|
||||||
bool ShowWindowMenu(QWindow *window);
|
bool ShowWindowMenu(QWindow *window);
|
||||||
bool WindowsNeedShadow();
|
bool WindowsNeedShadow();
|
||||||
bool SetWindowExtents(QWindow *window, const QMargins &extents);
|
bool SetWindowExtents(QWindow *window, const QMargins &extents);
|
||||||
|
bool UnsetWindowExtents(QWindow *window);
|
||||||
Window::ControlsLayout WindowControlsLayout();
|
Window::ControlsLayout WindowControlsLayout();
|
||||||
|
|
||||||
namespace ThirdParty {
|
namespace ThirdParty {
|
||||||
|
|
|
@ -85,10 +85,14 @@ TitleWidgetQt::TitleWidgetQt(QWidget *parent)
|
||||||
|
|
||||||
TitleWidgetQt::~TitleWidgetQt() {
|
TitleWidgetQt::~TitleWidgetQt() {
|
||||||
restoreCursor();
|
restoreCursor();
|
||||||
|
|
||||||
if (!_windowWasFrameless) {
|
if (!_windowWasFrameless) {
|
||||||
toggleFramelessWindow(false);
|
toggleFramelessWindow(false);
|
||||||
}
|
}
|
||||||
Platform::SetWindowExtents(window()->windowHandle(), QMargins());
|
|
||||||
|
if (_extentsSet) {
|
||||||
|
Platform::UnsetWindowExtents(window()->windowHandle());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TitleWidgetQt::toggleFramelessWindow(bool enabled) {
|
void TitleWidgetQt::toggleFramelessWindow(bool enabled) {
|
||||||
|
@ -137,10 +141,21 @@ void TitleWidgetQt::paintEvent(QPaintEvent *e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TitleWidgetQt::updateWindowExtents() {
|
void TitleWidgetQt::updateWindowExtents() {
|
||||||
if (hasShadow() && !_maximizedState) {
|
if (hasShadow()) {
|
||||||
Platform::SetWindowExtents(window()->windowHandle(), ShadowExtents());
|
if (!_maximizedState) {
|
||||||
} else {
|
Platform::SetWindowExtents(
|
||||||
Platform::SetWindowExtents(window()->windowHandle(), QMargins());
|
window()->windowHandle(),
|
||||||
|
ShadowExtents());
|
||||||
|
} else {
|
||||||
|
Platform::SetWindowExtents(
|
||||||
|
window()->windowHandle(),
|
||||||
|
QMargins());
|
||||||
|
}
|
||||||
|
|
||||||
|
_extentsSet = true;
|
||||||
|
} else if (_extentsSet) {
|
||||||
|
Platform::UnsetWindowExtents(window()->windowHandle());
|
||||||
|
_extentsSet = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,7 @@ private:
|
||||||
bool _activeState = false;
|
bool _activeState = false;
|
||||||
bool _windowWasFrameless = false;
|
bool _windowWasFrameless = false;
|
||||||
bool _cursorOverriden = false;
|
bool _cursorOverriden = false;
|
||||||
|
bool _extentsSet = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue