feat: three finger move and window Maximize

Signed-off-by: pengwenhao <pengwenhao@uniontech.com>
This commit is contained in:
pengwenhao 2024-07-12 14:01:40 +08:00 committed by groveer
parent 74a9a36765
commit cbdedf4e55
2 changed files with 37 additions and 1 deletions

View File

@ -826,6 +826,39 @@ bool Helper::beforeDisposeEvent(WSeat *seat, QWindow *watched, QInputEvent *even
seat->cursor()->setVisible(false);
}
if (event->type() == QEvent::NativeGesture) {
auto e = static_cast<WGestureEvent*>(event);
switch (e->gestureType()) {
case Qt::BeginNativeGesture:
if (e->fingerCount() == 3)
moveReiszeState.threefingerMove = true;
break;
case Qt::EndNativeGesture: {
if (activatedSurface()
&& e->fingerCount() == 3
&& moveReiszeState.threefingerMove) {
activatedSurface()->requestMove(seat, 0);
moveReiszeState.threefingerMove = false;
}
break;
}
case Qt::PanNativeGesture: {
if (e->delta().y() < 0)
activatedSurface()->requestMaximize();
else
activatedSurface()->requestCancelMaximize();
}
case Qt::ZoomNativeGesture:
case Qt::SmartZoomNativeGesture:
case Qt::RotateNativeGesture:
case Qt::SwipeNativeGesture:
default:
if (e->fingerCount() == 3)
moveReiszeState.threefingerMove = false;
break;
}
}
if (moveReiszeState.surfaceItem
&& (seat == moveReiszeState.seat || moveReiszeState.seat == nullptr)) {
// for move resize
@ -875,7 +908,9 @@ bool Helper::afterHandleEvent(
{
Q_UNUSED(seat)
if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::TouchBegin) {
if (event->type() == QEvent::MouseButtonRelease
|| event->type() == QEvent::TouchBegin
|| (event->type() == QEvent::NativeGesture && moveReiszeState.threefingerMove)) {
// surfaceItem is qml type: XdgSurfaceItem or LayerSurfaceItem
auto toplevelSurface = qobject_cast<WSurfaceItem *>(surfaceItem)->shellSurface();
if (!toplevelSurface)

View File

@ -220,6 +220,7 @@ protected:
QPointF cursorStartMovePosition;
QPointF surfacePosOfStartMoveResize;
QSizeF surfaceSizeOfStartMoveResize;
bool threefingerMove = false;
Qt::Edges resizeEdgets;
WSurfaceItem *resizingItem = nullptr;
WSurfaceItem *movingItem = nullptr;