Split system drag to a separate method in PiP
This commit is contained in:
parent
44c24f9fff
commit
b8018f5a7f
|
@ -706,8 +706,23 @@ void PipPanel::mouseMoveEvent(QMouseEvent *e) {
|
|||
if (!_dragState
|
||||
&& (point - _pressPoint).manhattanLength() > distance
|
||||
&& !_dragDisabled) {
|
||||
_dragState = _pressState;
|
||||
updateDecorations();
|
||||
_dragStartGeometry = geometry().marginsRemoved(_padding);
|
||||
}
|
||||
if (_dragState) {
|
||||
if (Platform::IsWayland()) {
|
||||
const auto stateEdges = RectPartToQtEdges(*_pressState);
|
||||
startSystemDrag();
|
||||
} else {
|
||||
processDrag(point);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PipPanel::startSystemDrag() {
|
||||
Expects(_dragState.has_value());
|
||||
|
||||
const auto stateEdges = RectPartToQtEdges(*_dragState);
|
||||
if (stateEdges) {
|
||||
if (!Platform::StartSystemResize(windowHandle(), stateEdges)) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) || defined DESKTOP_APP_QT_PATCHED
|
||||
|
@ -721,15 +736,6 @@ void PipPanel::mouseMoveEvent(QMouseEvent *e) {
|
|||
#endif // Qt >= 5.15 || DESKTOP_APP_QT_PATCHED
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
_dragState = _pressState;
|
||||
updateDecorations();
|
||||
_dragStartGeometry = geometry().marginsRemoved(_padding);
|
||||
}
|
||||
if (_dragState) {
|
||||
processDrag(point);
|
||||
}
|
||||
}
|
||||
|
||||
void PipPanel::processDrag(QPoint point) {
|
||||
|
@ -783,6 +789,9 @@ void PipPanel::finishDrag(QPoint point) {
|
|||
const auto position = pos();
|
||||
const auto clamped = [&] {
|
||||
auto result = position;
|
||||
if (Platform::IsWayland()) {
|
||||
return result;
|
||||
}
|
||||
if (result.x() > screen.x() + screen.width() - inner.width()) {
|
||||
result.setX(screen.x() + screen.width() - inner.width());
|
||||
}
|
||||
|
|
|
@ -83,6 +83,7 @@ private:
|
|||
void setPositionOnScreen(Position position, QRect available);
|
||||
|
||||
QScreen *myScreen() const;
|
||||
void startSystemDrag();
|
||||
void processDrag(QPoint point);
|
||||
void finishDrag(QPoint point);
|
||||
void updatePositionAnimated();
|
||||
|
|
Loading…
Reference in New Issue