mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 22:54:01 +02:00
Make export window and PiP window movable on Wayland with Qt < 5.15
This commit is contained in:
parent
b587328fed
commit
93e78f1565
2 changed files with 47 additions and 34 deletions
|
@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "main/main_account.h"
|
#include "main/main_account.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
|
#include "platform/platform_specific.h"
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
#include "ui/platform/ui_platform_utility.h"
|
#include "ui/platform/ui_platform_utility.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
|
@ -313,6 +314,29 @@ Streaming::FrameRequest UnrotateRequest(
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Qt::Edges RectPartToQtEdges(RectPart rectPart) {
|
||||||
|
switch (rectPart) {
|
||||||
|
case RectPart::TopLeft:
|
||||||
|
return Qt::TopEdge | Qt::LeftEdge;
|
||||||
|
case RectPart::TopRight:
|
||||||
|
return Qt::TopEdge | Qt::RightEdge;
|
||||||
|
case RectPart::BottomRight:
|
||||||
|
return Qt::BottomEdge | Qt::RightEdge;
|
||||||
|
case RectPart::BottomLeft:
|
||||||
|
return Qt::BottomEdge | Qt::LeftEdge;
|
||||||
|
case RectPart::Left:
|
||||||
|
return Qt::LeftEdge;
|
||||||
|
case RectPart::Top:
|
||||||
|
return Qt::TopEdge;
|
||||||
|
case RectPart::Right:
|
||||||
|
return Qt::RightEdge;
|
||||||
|
case RectPart::Bottom:
|
||||||
|
return Qt::BottomEdge;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
QRect RotatedRect(QRect rect, int rotation) {
|
QRect RotatedRect(QRect rect, int rotation) {
|
||||||
|
@ -682,40 +706,23 @@ void PipPanel::mouseMoveEvent(QMouseEvent *e) {
|
||||||
if (!_dragState
|
if (!_dragState
|
||||||
&& (point - _pressPoint).manhattanLength() > distance
|
&& (point - _pressPoint).manhattanLength() > distance
|
||||||
&& !_dragDisabled) {
|
&& !_dragDisabled) {
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) || defined DESKTOP_APP_QT_PATCHED
|
|
||||||
if (Platform::IsWayland()) {
|
if (Platform::IsWayland()) {
|
||||||
switch (*_pressState) {
|
const auto stateEdges = RectPartToQtEdges(*_pressState);
|
||||||
case RectPart::Center:
|
if (stateEdges) {
|
||||||
windowHandle()->startSystemMove();
|
if (!Platform::StartSystemResize(windowHandle(), stateEdges)) {
|
||||||
break;
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) || defined DESKTOP_APP_QT_PATCHED
|
||||||
case RectPart::TopLeft:
|
windowHandle()->startSystemResize(stateEdges);
|
||||||
windowHandle()->startSystemResize(Qt::TopEdge | Qt::LeftEdge);
|
#endif // Qt >= 5.15 || DESKTOP_APP_QT_PATCHED
|
||||||
break;
|
}
|
||||||
case RectPart::TopRight:
|
} else {
|
||||||
windowHandle()->startSystemResize(Qt::TopEdge | Qt::RightEdge);
|
if (!Platform::StartSystemMove(windowHandle())) {
|
||||||
break;
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) || defined DESKTOP_APP_QT_PATCHED
|
||||||
case RectPart::BottomRight:
|
windowHandle()->startSystemMove();
|
||||||
windowHandle()->startSystemResize(Qt::BottomEdge | Qt::RightEdge);
|
#endif // Qt >= 5.15 || DESKTOP_APP_QT_PATCHED
|
||||||
break;
|
}
|
||||||
case RectPart::BottomLeft:
|
|
||||||
windowHandle()->startSystemResize(Qt::BottomEdge | Qt::LeftEdge);
|
|
||||||
break;
|
|
||||||
case RectPart::Left:
|
|
||||||
windowHandle()->startSystemResize(Qt::LeftEdge);
|
|
||||||
break;
|
|
||||||
case RectPart::Top:
|
|
||||||
windowHandle()->startSystemResize(Qt::TopEdge);
|
|
||||||
break;
|
|
||||||
case RectPart::Right:
|
|
||||||
windowHandle()->startSystemResize(Qt::RightEdge);
|
|
||||||
break;
|
|
||||||
case RectPart::Bottom:
|
|
||||||
windowHandle()->startSystemResize(Qt::BottomEdge);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif // Qt >= 5.15 || DESKTOP_APP_QT_PATCHED
|
|
||||||
_dragState = _pressState;
|
_dragState = _pressState;
|
||||||
updateDecorations();
|
updateDecorations();
|
||||||
_dragStartGeometry = geometry().marginsRemoved(_padding);
|
_dragStartGeometry = geometry().marginsRemoved(_padding);
|
||||||
|
|
|
@ -554,11 +554,17 @@ void SeparatePanel::mousePressEvent(QMouseEvent *e) {
|
||||||
st::separatePanelTitleHeight);
|
st::separatePanelTitleHeight);
|
||||||
if (e->button() == Qt::LeftButton) {
|
if (e->button() == Qt::LeftButton) {
|
||||||
if (dragArea.contains(e->pos())) {
|
if (dragArea.contains(e->pos())) {
|
||||||
|
const auto dragViaSystem = [&] {
|
||||||
|
if (::Platform::StartSystemMove(windowHandle())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) || defined DESKTOP_APP_QT_PATCHED
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) || defined DESKTOP_APP_QT_PATCHED
|
||||||
const auto dragViaSystem = windowHandle()->startSystemMove();
|
if (windowHandle()->startSystemMove()) {
|
||||||
#else // Qt >= 5.15 || DESKTOP_APP_QT_PATCHED
|
return true;
|
||||||
const auto dragViaSystem = false;
|
}
|
||||||
#endif // Qt < 5.15 && !DESKTOP_APP_QT_PATCHED
|
#endif // Qt >= 5.15 || DESKTOP_APP_QT_PATCHED
|
||||||
|
return false;
|
||||||
|
}();
|
||||||
if (!dragViaSystem) {
|
if (!dragViaSystem) {
|
||||||
_dragging = true;
|
_dragging = true;
|
||||||
_dragStartMousePosition = e->globalPos();
|
_dragStartMousePosition = e->globalPos();
|
||||||
|
|
Loading…
Add table
Reference in a new issue