From c35c464b1d96093d5f93159fb0f7022d81ea0d78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 29 Oct 2015 10:41:25 +0100 Subject: [PATCH] [wayland] Add support for move/resize triggered on ShellSurface Welcome to a mostly usable Wayland world! --- shell_client.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/shell_client.cpp b/shell_client.cpp index b466f97cc8..79a1ac532a 100644 --- a/shell_client.cpp +++ b/shell_client.cpp @@ -19,6 +19,7 @@ along with this program. If not, see . *********************************************************************/ #include "shell_client.h" #include "composite.h" +#include "cursor.h" #include "deleted.h" #include "screens.h" #include "wayland_server.h" @@ -27,6 +28,7 @@ along with this program. If not, see . #include "workspace.h" #include +#include #include #include #include @@ -104,6 +106,47 @@ ShellClient::ShellClient(ShellSurfaceInterface *surface) setTransient(); connect(surface, &ShellSurfaceInterface::transientForChanged, this, &ShellClient::setTransient); + connect(surface, &ShellSurfaceInterface::moveRequested, this, + [this] { + // TODO: check the seat and serial + performMouseCommand(Options::MouseMove, Cursor::pos()); + } + ); + connect(surface, &ShellSurfaceInterface::resizeRequested, this, + [this] (SeatInterface *seat, quint32 serial, Qt::Edges edges) { + // TODO: check the seat and serial + Q_UNUSED(seat) + Q_UNUSED(serial) + if (!isResizable() || isShade()) { + return; + } + if (isMoveResize()) { + finishMoveResize(false); + } + setMoveResizePointerButtonDown(true); + setMoveOffset(Cursor::pos() - pos()); // map from global + setInvertedMoveOffset(rect().bottomRight() - moveOffset()); + setUnrestrictedMoveResize(false); + auto toPosition = [edges] { + Position pos = PositionCenter; + if (edges.testFlag(Qt::TopEdge)) { + pos = PositionTop; + } else if (edges.testFlag(Qt::BottomEdge)) { + pos = PositionBottom; + } + if (edges.testFlag(Qt::LeftEdge)) { + pos = Position(pos | PositionLeft); + } else if (edges.testFlag(Qt::RightEdge)) { + pos = Position(pos | PositionRight); + } + return pos; + }; + setMoveResizePointerMode(toPosition()); + if (!startMoveResize()) + setMoveResizePointerButtonDown(false); + updateCursor(); + } + ); } ShellClient::~ShellClient() = default;