Merge branch 'Plasma/5.12'

This commit is contained in:
Martin Flöser 2018-02-21 18:07:41 +01:00
commit a0c91c6e19
5 changed files with 99 additions and 8 deletions

View file

@ -28,8 +28,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "shell_client.h"
#include "scripting/scripting.h"
#include <KDecoration2/Decoration>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/server_decoration.h>
#include <KWayland/Client/shell.h>
#include <KWayland/Client/surface.h>
#include <KWayland/Client/xdgshell.h>
@ -70,6 +73,8 @@ private Q_SLOTS:
void testQuickTilingPointerMove();
void testQuickTilingPointerMoveXdgShell_data();
void testQuickTilingPointerMoveXdgShell();
void testQuickTilingTouchMoveXdgShell_data();
void testQuickTilingTouchMoveXdgShell();
void testX11QuickTiling_data();
void testX11QuickTiling();
void testX11QuickTilingAfterVertMaximize_data();
@ -115,7 +120,7 @@ void QuickTilingTest::initTestCase()
void QuickTilingTest::init()
{
QVERIFY(Test::setupWaylandConnection());
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Decoration));
m_connection = Test::waylandConnection();
m_compositor = Test::waylandCompositor();
m_shell = Test::waylandShell();
@ -496,6 +501,69 @@ void QuickTilingTest::testQuickTilingPointerMoveXdgShell()
QCOMPARE(false, configureRequestedSpy.last().first().toSize().isEmpty());
}
void QuickTilingTest::testQuickTilingTouchMoveXdgShell_data()
{
QTest::addColumn<QPoint>("targetPos");
QTest::addColumn<QuickTileMode>("expectedMode");
QTest::newRow("topRight") << QPoint(2559, 24) << QuickTileMode(QuickTileFlag::Top | QuickTileFlag::Right);
QTest::newRow("right") << QPoint(2559, 512) << QuickTileMode(QuickTileFlag::Right);
QTest::newRow("bottomRight") << QPoint(2559, 1023) << QuickTileMode(QuickTileFlag::Bottom | QuickTileFlag::Right);
QTest::newRow("bottomLeft") << QPoint(0, 1023) << QuickTileMode(QuickTileFlag::Bottom | QuickTileFlag::Left);
QTest::newRow("Left") << QPoint(0, 512) << QuickTileMode(QuickTileFlag::Left);
QTest::newRow("topLeft") << QPoint(0, 24) << QuickTileMode(QuickTileFlag::Top | QuickTileFlag::Left);
}
void QuickTilingTest::testQuickTilingTouchMoveXdgShell()
{
// test verifies that touch on decoration also allows quick tiling
// see BUG: 390113
using namespace KWayland::Client;
QScopedPointer<Surface> surface(Test::createSurface());
QVERIFY(!surface.isNull());
QScopedPointer<ServerSideDecoration> deco(Test::waylandServerSideDecoration()->create(surface.data()));
QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellV6Surface(surface.data()));
QVERIFY(!shellSurface.isNull());
QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested);
QVERIFY(configureRequestedSpy.isValid());
// let's render
auto c = Test::renderAndWaitForShown(surface.data(), QSize(1000, 50), Qt::blue);
QVERIFY(c);
QVERIFY(c->isDecorated());
const auto decoration = c->decoration();
QCOMPARE(workspace()->activeClient(), c);
QCOMPARE(c->geometry(), QRect(-decoration->borderLeft(), 0,
1000 + decoration->borderLeft() + decoration->borderRight(),
50 + decoration->borderTop() + decoration->borderBottom()));
QCOMPARE(c->quickTileMode(), QuickTileMode(QuickTileFlag::None));
QCOMPARE(c->maximizeMode(), MaximizeRestore);
QVERIFY(configureRequestedSpy.wait());
QTRY_COMPARE(configureRequestedSpy.count(), 2);
QSignalSpy quickTileChangedSpy(c, &AbstractClient::quickTileModeChanged);
QVERIFY(quickTileChangedSpy.isValid());
quint32 timestamp = 1;
kwinApp()->platform()->touchDown(0, QPointF(c->geometry().center().x(), c->geometry().y() + decoration->borderTop() / 2), timestamp++);
QVERIFY(configureRequestedSpy.wait());
QCOMPARE(c, workspace()->getMovingClient());
QCOMPARE(configureRequestedSpy.count(), 3);
QFETCH(QPoint, targetPos);
kwinApp()->platform()->touchMotion(0, targetPos, timestamp++);
kwinApp()->platform()->touchUp(0, timestamp++);
QVERIFY(!workspace()->getMovingClient());
QCOMPARE(quickTileChangedSpy.count(), 1);
QTEST(c->quickTileMode(), "expectedMode");
QVERIFY(configureRequestedSpy.wait());
QCOMPARE(configureRequestedSpy.count(), 5);
QCOMPARE(false, configureRequestedSpy.last().first().toSize().isEmpty());
}
struct XcbConnectionDeleter
{
static inline void cleanup(xcb_connection_t *pointer)

View file

@ -1096,9 +1096,13 @@ public:
}
m_lastGlobalTouchPos = pos;
m_lastLocalTouchPos = pos - decoration->client()->pos();
if (auto c = workspace()->getMovingClient()) {
c->updateMoveResize(pos);
} else {
QHoverEvent e(QEvent::HoverMove, m_lastLocalTouchPos, m_lastLocalTouchPos);
QCoreApplication::instance()->sendEvent(decoration->decoration(), &e);
decoration->client()->processDecorationMove(m_lastLocalTouchPos.toPoint(), pos.toPoint());
}
return true;
}
bool touchUp(quint32 id, quint32 time) override {
@ -1115,10 +1119,14 @@ public:
return true;
}
// send mouse up
if (auto c = workspace()->getMovingClient()) {
c->endMoveResize();
} else {
QMouseEvent e(QEvent::MouseButtonRelease, m_lastLocalTouchPos, m_lastGlobalTouchPos, Qt::LeftButton, Qt::MouseButtons(), input()->keyboardModifiers());
e.setAccepted(false);
QCoreApplication::sendEvent(decoration->decoration(), &e);
decoration->client()->processDecorationButtonRelease(&e);
}
m_lastGlobalTouchPos = QPointF();
m_lastLocalTouchPos = QPointF();

View file

@ -248,6 +248,7 @@ static int edit(Window wid, bool whole_app)
extern "C"
KWIN_EXPORT int kdemain(int argc, char* argv[])
{
qputenv("QT_QPA_PLATFORM", "xcb");
QApplication app(argc, argv);
app.setApplicationDisplayName(i18n("KWin"));
app.setApplicationName("kwin_rules_dialog");

View file

@ -40,6 +40,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "effects.h"
#include "platform.h"
#include "screens.h"
#include "shell_client.h"
#include "virtualdesktops.h"
#include "scripting/scripting.h"
@ -318,10 +319,12 @@ void UserActionsMenu::init()
QAction *action = advancedMenu->addAction(i18n("Special &Window Settings..."));
action->setIcon(QIcon::fromTheme(QStringLiteral("preferences-system-windows-actions")));
action->setData(Options::WindowRulesOp);
m_rulesOperation = action;
action = advancedMenu->addAction(i18n("S&pecial Application Settings..."));
action->setIcon(QIcon::fromTheme(QStringLiteral("preferences-system-windows-actions")));
action->setData(Options::ApplicationRulesOp);
m_applicationRulesOperation = action;
if (!kwinApp()->config()->isImmutable() &&
!KAuthorized::authorizeControlModules(configModules(true)).isEmpty()) {
advancedMenu->addSeparator();
@ -465,6 +468,15 @@ void UserActionsMenu::menuAboutToShow()
action->setText(i18n("&Extensions"));
}
// disable rules for Wayland windows - dialog is X11 only
if (qobject_cast<ShellClient*>(m_client.data())) {
m_rulesOperation->setEnabled(false);
m_applicationRulesOperation->setEnabled(false);
} else {
m_rulesOperation->setEnabled(true);
m_applicationRulesOperation->setEnabled(true);
}
showHideActivityMenu();
}

View file

@ -260,6 +260,8 @@ private:
* The Client for which the menu is shown.
**/
QWeakPointer<AbstractClient> m_client;
QAction *m_rulesOperation = nullptr;
QAction *m_applicationRulesOperation = nullptr;
};
class ShortcutDialog