Commit 64da6c8d authored by Martin Flöser's avatar Martin Flöser

Replace Workspace::slotWindowQuickTileFoo by a quickTileWindow with argument

Summary:
Thanks to std::bind we don't need that many different slots to setup the
global shortcut connections. Instead we can have one shared
implementation which takes the argument and passes it to the window.

To support std::bind arguments in kwinbindings the initShortcut method
and dependencies are adjusted as well as a new macro is added.

As I don't want to include abstract_client.h in workspace.h a new enum
is created for the quick tiling flags used in Workspace. This caused a
larger refactoring as the change to an enum class also caused quite some
changes.

Test Plan: Affected test cases still pass

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D6783
parent f1454048
......@@ -1281,7 +1281,7 @@ void AbstractClient::doResizeSync()
void AbstractClient::checkQuickTilingMaximizationZones(int xroot, int yroot)
{
QuickTileMode mode = QuickTileNone;
QuickTileMode mode = QuickTileFlag::None;
bool innerBorder = false;
for (int i=0; i < screens()->count(); ++i) {
......@@ -1302,21 +1302,21 @@ void AbstractClient::checkQuickTilingMaximizationZones(int xroot, int yroot)
QRect area = workspace()->clientArea(MaximizeArea, QPoint(xroot, yroot), desktop());
if (options->electricBorderTiling()) {
if (xroot <= area.x() + 20) {
mode |= QuickTileLeft;
mode |= QuickTileFlag::Left;
innerBorder = isInScreen(QPoint(area.x() - 1, yroot));
} else if (xroot >= area.x() + area.width() - 20) {
mode |= QuickTileRight;
mode |= QuickTileFlag::Right;
innerBorder = isInScreen(QPoint(area.right() + 1, yroot));
}
}
if (mode != QuickTileNone) {
if (mode != QuickTileMode(QuickTileFlag::None)) {
if (yroot <= area.y() + area.height() * options->electricBorderCornerRatio())
mode |= QuickTileTop;
mode |= QuickTileFlag::Top;
else if (yroot >= area.y() + area.height() - area.height() * options->electricBorderCornerRatio())
mode |= QuickTileBottom;
mode |= QuickTileFlag::Bottom;
} else if (options->electricBorderMaximize() && yroot <= area.y() + 5 && isMaximizable()) {
mode = QuickTileMaximize;
mode = QuickTileFlag::Maximize;
innerBorder = isInScreen(QPoint(xroot, area.y() - 1));
}
break; // no point in checking other screens to contain this... "point"...
......@@ -1330,12 +1330,12 @@ void AbstractClient::checkQuickTilingMaximizationZones(int xroot, int yroot)
m_electricMaximizingDelay->setSingleShot(true);
connect(m_electricMaximizingDelay, &QTimer::timeout, [this]() {
if (isMove())
setElectricBorderMaximizing(electricBorderMode() != QuickTileNone);
setElectricBorderMaximizing(electricBorderMode() != QuickTileMode(QuickTileFlag::None));
});
}
m_electricMaximizingDelay->start();
} else {
setElectricBorderMaximizing(mode != QuickTileNone);
setElectricBorderMaximizing(mode != QuickTileMode(QuickTileFlag::None));
}
}
}
......
......@@ -498,17 +498,6 @@ public:
// a helper for the workspace window packing. tests for screen validity and updates since in maximization case as with normal moving
void packTo(int left, int top);
enum QuickTileFlag {
QuickTileNone = 0,
QuickTileLeft = 1,
QuickTileRight = 1<<1,
QuickTileTop = 1<<2,
QuickTileBottom = 1<<3,
QuickTileHorizontal = QuickTileLeft|QuickTileRight,
QuickTileVertical = QuickTileTop|QuickTileBottom,
QuickTileMaximize = QuickTileLeft|QuickTileRight|QuickTileTop|QuickTileBottom
};
Q_DECLARE_FLAGS(QuickTileMode, QuickTileFlag)
/** Set the quick tile mode ("snap") of this window.
* This will also handle preserving and restoring of window geometry as necessary.
* @param mode The tile mode (left/right) to give this window.
......@@ -1028,11 +1017,11 @@ private:
Layer m_layer = UnknownLayer;
// electric border/quick tiling
QuickTileMode m_electricMode = QuickTileNone;
QuickTileMode m_electricMode = QuickTileFlag::None;
bool m_electricMaximizing = false;
/** The quick tile mode of this window.
*/
int m_quickTileMode = QuickTileNone;
int m_quickTileMode = int(QuickTileFlag::None);
QTimer *m_electricMaximizingDelay = nullptr;
// geometry
......@@ -1141,6 +1130,5 @@ inline void AbstractClient::setPendingGeometryUpdate(PendingGeometry_t update)
Q_DECLARE_METATYPE(KWin::AbstractClient*)
Q_DECLARE_METATYPE(QList<KWin::AbstractClient*>)
Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::AbstractClient::QuickTileMode)
#endif
......@@ -41,7 +41,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <linux/input.h>
#include <xcb/xcb_icccm.h>
Q_DECLARE_METATYPE(KWin::AbstractClient::QuickTileMode)
Q_DECLARE_METATYPE(KWin::QuickTileMode)
Q_DECLARE_METATYPE(KWin::MaximizeMode)
namespace KWin
......
......@@ -44,7 +44,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <linux/input.h>
Q_DECLARE_METATYPE(KWin::AbstractClient::QuickTileMode)
Q_DECLARE_METATYPE(KWin::QuickTileMode)
Q_DECLARE_METATYPE(KWin::MaximizeMode)
namespace KWin
......@@ -125,24 +125,24 @@ void QuickTilingTest::cleanup()
void QuickTilingTest::testQuickTiling_data()
{
QTest::addColumn<AbstractClient::QuickTileMode>("mode");
QTest::addColumn<QuickTileMode>("mode");
QTest::addColumn<QRect>("expectedGeometry");
QTest::addColumn<QRect>("secondScreen");
QTest::addColumn<AbstractClient::QuickTileMode>("expectedModeAfterToggle");
QTest::addColumn<QuickTileMode>("expectedModeAfterToggle");
#define FLAG(name) AbstractClient::QuickTileMode(AbstractClient::QuickTile##name)
#define FLAG(name) QuickTileMode(QuickTileFlag::name)
QTest::newRow("left") << FLAG(Left) << QRect(0, 0, 640, 1024) << QRect(1280, 0, 640, 1024) << FLAG(Right);
QTest::newRow("top") << FLAG(Top) << QRect(0, 0, 1280, 512) << QRect(1280, 0, 1280, 512) << FLAG(Top);
QTest::newRow("right") << FLAG(Right) << QRect(640, 0, 640, 1024) << QRect(1920, 0, 640, 1024) << AbstractClient::QuickTileMode();
QTest::newRow("right") << FLAG(Right) << QRect(640, 0, 640, 1024) << QRect(1920, 0, 640, 1024) << QuickTileMode();
QTest::newRow("bottom") << FLAG(Bottom) << QRect(0, 512, 1280, 512) << QRect(1280, 512, 1280, 512) << FLAG(Bottom);
QTest::newRow("top left") << (FLAG(Left) | FLAG(Top)) << QRect(0, 0, 640, 512) << QRect(1280, 0, 640, 512) << (FLAG(Right) | FLAG(Top));
QTest::newRow("top right") << (FLAG(Right) | FLAG(Top)) << QRect(640, 0, 640, 512) << QRect(1920, 0, 640, 512) << AbstractClient::QuickTileMode();
QTest::newRow("top right") << (FLAG(Right) | FLAG(Top)) << QRect(640, 0, 640, 512) << QRect(1920, 0, 640, 512) << QuickTileMode();
QTest::newRow("bottom left") << (FLAG(Left) | FLAG(Bottom)) << QRect(0, 512, 640, 512) << QRect(1280, 512, 640, 512) << (FLAG(Right) | FLAG(Bottom));
QTest::newRow("bottom right") << (FLAG(Right) | FLAG(Bottom)) << QRect(640, 512, 640, 512) << QRect(1920, 512, 640, 512) << AbstractClient::QuickTileMode();
QTest::newRow("bottom right") << (FLAG(Right) | FLAG(Bottom)) << QRect(640, 512, 640, 512) << QRect(1920, 512, 640, 512) << QuickTileMode();
QTest::newRow("maximize") << FLAG(Maximize) << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024) << AbstractClient::QuickTileMode();
QTest::newRow("maximize") << FLAG(Maximize) << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024) << QuickTileMode();
#undef FLAG
}
......@@ -164,13 +164,13 @@ void QuickTilingTest::testQuickTiling()
QVERIFY(c);
QCOMPARE(workspace()->activeClient(), c);
QCOMPARE(c->geometry(), QRect(0, 0, 100, 50));
QCOMPARE(c->quickTileMode(), AbstractClient::QuickTileNone);
QCOMPARE(c->quickTileMode(), QuickTileMode(QuickTileFlag::None));
QSignalSpy quickTileChangedSpy(c, &AbstractClient::quickTileModeChanged);
QVERIFY(quickTileChangedSpy.isValid());
QSignalSpy geometryChangedSpy(c, &AbstractClient::geometryChanged);
QVERIFY(geometryChangedSpy.isValid());
QFETCH(AbstractClient::QuickTileMode, mode);
QFETCH(QuickTileMode, mode);
QFETCH(QRect, expectedGeometry);
c->setQuickTileMode(mode, true);
QCOMPARE(quickTileChangedSpy.count(), 1);
......@@ -208,9 +208,9 @@ void QuickTilingTest::testQuickTiling()
void QuickTilingTest::testQuickMaximizing_data()
{
QTest::addColumn<AbstractClient::QuickTileMode>("mode");
QTest::addColumn<QuickTileMode>("mode");
#define FLAG(name) AbstractClient::QuickTileMode(AbstractClient::QuickTile##name)
#define FLAG(name) QuickTileMode(QuickTileFlag::name)
QTest::newRow("maximize") << FLAG(Maximize);
QTest::newRow("none") << FLAG(None);
......@@ -235,7 +235,7 @@ void QuickTilingTest::testQuickMaximizing()
QVERIFY(c);
QCOMPARE(workspace()->activeClient(), c);
QCOMPARE(c->geometry(), QRect(0, 0, 100, 50));
QCOMPARE(c->quickTileMode(), AbstractClient::QuickTileNone);
QCOMPARE(c->quickTileMode(), QuickTileMode(QuickTileFlag::None));
QCOMPARE(c->maximizeMode(), MaximizeRestore);
QSignalSpy quickTileChangedSpy(c, &AbstractClient::quickTileModeChanged);
QVERIFY(quickTileChangedSpy.isValid());
......@@ -246,7 +246,7 @@ void QuickTilingTest::testQuickMaximizing()
QSignalSpy maximizeChangedSpy2(c, SIGNAL(clientMaximizedStateChanged(KWin::AbstractClient*,bool,bool)));
QVERIFY(maximizeChangedSpy2.isValid());
c->setQuickTileMode(AbstractClient::QuickTileMaximize, true);
c->setQuickTileMode(QuickTileFlag::Maximize, true);
QCOMPARE(quickTileChangedSpy.count(), 1);
QCOMPARE(maximizeChangedSpy1.count(), 1);
QCOMPARE(maximizeChangedSpy1.first().first().value<KWin::AbstractClient*>(), c);
......@@ -258,7 +258,7 @@ void QuickTilingTest::testQuickMaximizing()
// at this point the geometry did not yet change
QCOMPARE(c->geometry(), QRect(0, 0, 100, 50));
// but quick tile mode already changed
QCOMPARE(c->quickTileMode(), AbstractClient::QuickTileMaximize);
QCOMPARE(c->quickTileMode(), QuickTileFlag::Maximize);
QCOMPARE(c->maximizeMode(), MaximizeFull);
QCOMPARE(c->geometryRestore(), QRect(0, 0, 100, 50));
......@@ -277,7 +277,7 @@ void QuickTilingTest::testQuickMaximizing()
QCOMPARE(c->geometryRestore(), QRect(0, 0, 100, 50));
// go back to quick tile none
QFETCH(AbstractClient::QuickTileMode, mode);
QFETCH(QuickTileMode, mode);
c->setQuickTileMode(mode, true);
QCOMPARE(quickTileChangedSpy.count(), 2);
QCOMPARE(maximizeChangedSpy1.count(), 2);
......@@ -287,7 +287,7 @@ void QuickTilingTest::testQuickMaximizing()
QCOMPARE(maximizeChangedSpy2.last().first().value<KWin::AbstractClient*>(), c);
QCOMPARE(maximizeChangedSpy2.last().at(1).toBool(), false);
QCOMPARE(maximizeChangedSpy2.last().at(2).toBool(), false);
QCOMPARE(c->quickTileMode(), AbstractClient::QuickTileNone);
QCOMPARE(c->quickTileMode(), QuickTileMode(QuickTileFlag::None));
QCOMPARE(c->maximizeMode(), MaximizeRestore);
// geometry not yet changed
QCOMPARE(c->geometry(), QRect(0, 0, 1280, 1024));
......@@ -310,14 +310,14 @@ void QuickTilingTest::testQuickMaximizing()
void QuickTilingTest::testQuickTilingKeyboardMove_data()
{
QTest::addColumn<QPoint>("targetPos");
QTest::addColumn<AbstractClient::QuickTileMode>("expectedMode");
QTest::newRow("topRight") << QPoint(2559, 24) << AbstractClient::QuickTileMode(AbstractClient::QuickTileTop | AbstractClient::QuickTileRight);
QTest::newRow("right") << QPoint(2559, 512) << AbstractClient::QuickTileMode(AbstractClient::QuickTileRight);
QTest::newRow("bottomRight") << QPoint(2559, 1023) << AbstractClient::QuickTileMode(AbstractClient::QuickTileBottom | AbstractClient::QuickTileRight);
QTest::newRow("bottomLeft") << QPoint(0, 1023) << AbstractClient::QuickTileMode(AbstractClient::QuickTileBottom | AbstractClient::QuickTileLeft);
QTest::newRow("Left") << QPoint(0, 512) << AbstractClient::QuickTileMode(AbstractClient::QuickTileLeft);
QTest::newRow("topLeft") << QPoint(0, 24) << AbstractClient::QuickTileMode(AbstractClient::QuickTileTop | AbstractClient::QuickTileLeft);
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::testQuickTilingKeyboardMove()
......@@ -337,7 +337,7 @@ void QuickTilingTest::testQuickTilingKeyboardMove()
QVERIFY(c);
QCOMPARE(workspace()->activeClient(), c);
QCOMPARE(c->geometry(), QRect(0, 0, 100, 50));
QCOMPARE(c->quickTileMode(), AbstractClient::QuickTileNone);
QCOMPARE(c->quickTileMode(), QuickTileMode(QuickTileFlag::None));
QCOMPARE(c->maximizeMode(), MaximizeRestore);
QSignalSpy quickTileChangedSpy(c, &AbstractClient::quickTileModeChanged);
......@@ -381,14 +381,14 @@ void QuickTilingTest::testQuickTilingKeyboardMove()
void QuickTilingTest::testQuickTilingPointerMove_data()
{
QTest::addColumn<QPoint>("targetPos");
QTest::addColumn<AbstractClient::QuickTileMode>("expectedMode");
QTest::newRow("topRight") << QPoint(2559, 24) << AbstractClient::QuickTileMode(AbstractClient::QuickTileTop | AbstractClient::QuickTileRight);
QTest::newRow("right") << QPoint(2559, 512) << AbstractClient::QuickTileMode(AbstractClient::QuickTileRight);
QTest::newRow("bottomRight") << QPoint(2559, 1023) << AbstractClient::QuickTileMode(AbstractClient::QuickTileBottom | AbstractClient::QuickTileRight);
QTest::newRow("bottomLeft") << QPoint(0, 1023) << AbstractClient::QuickTileMode(AbstractClient::QuickTileBottom | AbstractClient::QuickTileLeft);
QTest::newRow("Left") << QPoint(0, 512) << AbstractClient::QuickTileMode(AbstractClient::QuickTileLeft);
QTest::newRow("topLeft") << QPoint(0, 24) << AbstractClient::QuickTileMode(AbstractClient::QuickTileTop | AbstractClient::QuickTileLeft);
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::testQuickTilingPointerMove()
......@@ -408,7 +408,7 @@ void QuickTilingTest::testQuickTilingPointerMove()
QVERIFY(c);
QCOMPARE(workspace()->activeClient(), c);
QCOMPARE(c->geometry(), QRect(0, 0, 100, 50));
QCOMPARE(c->quickTileMode(), AbstractClient::QuickTileNone);
QCOMPARE(c->quickTileMode(), QuickTileMode(QuickTileFlag::None));
QCOMPARE(c->maximizeMode(), MaximizeRestore);
QSignalSpy quickTileChangedSpy(c, &AbstractClient::quickTileModeChanged);
......@@ -440,24 +440,24 @@ struct XcbConnectionDeleter
void QuickTilingTest::testX11QuickTiling_data()
{
QTest::addColumn<AbstractClient::QuickTileMode>("mode");
QTest::addColumn<QuickTileMode>("mode");
QTest::addColumn<QRect>("expectedGeometry");
QTest::addColumn<int>("screen");
QTest::addColumn<AbstractClient::QuickTileMode>("modeAfterToggle");
QTest::addColumn<QuickTileMode>("modeAfterToggle");
#define FLAG(name) AbstractClient::QuickTileMode(AbstractClient::QuickTile##name)
#define FLAG(name) QuickTileMode(QuickTileFlag::name)
QTest::newRow("left") << FLAG(Left) << QRect(0, 0, 640, 1024) << 0 << AbstractClient::QuickTileMode();
QTest::newRow("left") << FLAG(Left) << QRect(0, 0, 640, 1024) << 0 << QuickTileMode();
QTest::newRow("top") << FLAG(Top) << QRect(0, 0, 1280, 512) << 1 << FLAG(Top);
QTest::newRow("right") << FLAG(Right) << QRect(640, 0, 640, 1024) << 1 << FLAG(Left);
QTest::newRow("bottom") << FLAG(Bottom) << QRect(0, 512, 1280, 512) << 1 << FLAG(Bottom);
QTest::newRow("top left") << (FLAG(Left) | FLAG(Top)) << QRect(0, 0, 640, 512) << 0 << AbstractClient::QuickTileMode();
QTest::newRow("top left") << (FLAG(Left) | FLAG(Top)) << QRect(0, 0, 640, 512) << 0 << QuickTileMode();
QTest::newRow("top right") << (FLAG(Right) | FLAG(Top)) << QRect(640, 0, 640, 512) << 1 << (FLAG(Left) | FLAG(Top));
QTest::newRow("bottom left") << (FLAG(Left) | FLAG(Bottom)) << QRect(0, 512, 640, 512) << 0 << AbstractClient::QuickTileMode();
QTest::newRow("bottom left") << (FLAG(Left) | FLAG(Bottom)) << QRect(0, 512, 640, 512) << 0 << QuickTileMode();
QTest::newRow("bottom right") << (FLAG(Right) | FLAG(Bottom)) << QRect(640, 512, 640, 512) << 1 << (FLAG(Left) | FLAG(Bottom));
QTest::newRow("maximize") << FLAG(Maximize) << QRect(0, 0, 1280, 1024) << 0 << AbstractClient::QuickTileMode();
QTest::newRow("maximize") << FLAG(Maximize) << QRect(0, 0, 1280, 1024) << 0 << QuickTileMode();
#undef FLAG
}
......@@ -493,7 +493,7 @@ void QuickTilingTest::testX11QuickTiling()
QSignalSpy quickTileChangedSpy(client, &AbstractClient::quickTileModeChanged);
QVERIFY(quickTileChangedSpy.isValid());
const QRect origGeo = client->geometry();
QFETCH(AbstractClient::QuickTileMode, mode);
QFETCH(QuickTileMode, mode);
client->setQuickTileMode(mode, true);
QCOMPARE(client->quickTileMode(), mode);
QTEST(client->geometry(), "expectedGeometry");
......@@ -521,10 +521,10 @@ void QuickTilingTest::testX11QuickTiling()
void QuickTilingTest::testX11QuickTilingAfterVertMaximize_data()
{
QTest::addColumn<AbstractClient::QuickTileMode>("mode");
QTest::addColumn<QuickTileMode>("mode");
QTest::addColumn<QRect>("expectedGeometry");
#define FLAG(name) AbstractClient::QuickTileMode(AbstractClient::QuickTile##name)
#define FLAG(name) QuickTileMode(QuickTileFlag::name)
QTest::newRow("left") << FLAG(Left) << QRect(0, 0, 640, 1024);
QTest::newRow("top") << FLAG(Top) << QRect(0, 0, 1280, 512);
......@@ -580,7 +580,7 @@ void QuickTilingTest::testX11QuickTilingAfterVertMaximize()
// now quick tile
QSignalSpy quickTileChangedSpy(client, &AbstractClient::quickTileModeChanged);
QVERIFY(quickTileChangedSpy.isValid());
QFETCH(AbstractClient::QuickTileMode, mode);
QFETCH(QuickTileMode, mode);
client->setQuickTileMode(mode, true);
QEXPECT_FAIL("left", "Quick tiling not working", Continue);
QEXPECT_FAIL("right", "Quick tiling not working", Continue);
......@@ -617,10 +617,10 @@ void QuickTilingTest::testX11QuickTilingAfterVertMaximize()
void QuickTilingTest::testShortcut_data()
{
QTest::addColumn<QString>("shortcut");
QTest::addColumn<AbstractClient::QuickTileMode>("expectedMode");
QTest::addColumn<QuickTileMode>("expectedMode");
QTest::addColumn<QRect>("expectedGeometry");
#define FLAG(name) AbstractClient::QuickTileMode(AbstractClient::QuickTile##name)
#define FLAG(name) QuickTileMode(QuickTileFlag::name)
QTest::newRow("top") << QStringLiteral("Window Quick Tile Top") << FLAG(Top) << QRect(0, 0, 1280, 512);
QTest::newRow("left") << QStringLiteral("Window Quick Tile Left") << FLAG(Left) << QRect(0, 0, 640, 1024);
QTest::newRow("bottom") << QStringLiteral("Window Quick Tile Bottom") << FLAG(Bottom) << QRect(0, 512, 1280, 512);
......@@ -651,14 +651,14 @@ void QuickTilingTest::testShortcut()
QVERIFY(c);
QCOMPARE(workspace()->activeClient(), c);
QCOMPARE(c->geometry(), QRect(0, 0, 100, 50));
QCOMPARE(c->quickTileMode(), AbstractClient::QuickTileNone);
QCOMPARE(c->quickTileMode(), QuickTileMode(QuickTileFlag::None));
QSignalSpy quickTileChangedSpy(c, &AbstractClient::quickTileModeChanged);
QVERIFY(quickTileChangedSpy.isValid());
QSignalSpy geometryChangedSpy(c, &AbstractClient::geometryChanged);
QVERIFY(geometryChangedSpy.isValid());
QFETCH(QString, shortcut);
QFETCH(AbstractClient::QuickTileMode, expectedMode);
QFETCH(QuickTileMode, expectedMode);
QFETCH(QRect, expectedGeometry);
// invoke global shortcut through dbus
......@@ -695,10 +695,10 @@ void QuickTilingTest::testShortcut()
void QuickTilingTest::testScript_data()
{
QTest::addColumn<QString>("action");
QTest::addColumn<AbstractClient::QuickTileMode>("expectedMode");
QTest::addColumn<QuickTileMode>("expectedMode");
QTest::addColumn<QRect>("expectedGeometry");
#define FLAG(name) AbstractClient::QuickTileMode(AbstractClient::QuickTile##name)
#define FLAG(name) QuickTileMode(QuickTileFlag::name)
QTest::newRow("top") << QStringLiteral("Top") << FLAG(Top) << QRect(0, 0, 1280, 512);
QTest::newRow("left") << QStringLiteral("Left") << FLAG(Left) << QRect(0, 0, 640, 1024);
QTest::newRow("bottom") << QStringLiteral("Bottom") << FLAG(Bottom) << QRect(0, 512, 1280, 512);
......@@ -729,7 +729,7 @@ void QuickTilingTest::testScript()
QVERIFY(c);
QCOMPARE(workspace()->activeClient(), c);
QCOMPARE(c->geometry(), QRect(0, 0, 100, 50));
QCOMPARE(c->quickTileMode(), AbstractClient::QuickTileNone);
QCOMPARE(c->quickTileMode(), QuickTileMode(QuickTileFlag::None));
QSignalSpy quickTileChangedSpy(c, &AbstractClient::quickTileModeChanged);
QVERIFY(quickTileChangedSpy.isValid());
QSignalSpy geometryChangedSpy(c, &AbstractClient::geometryChanged);
......@@ -744,7 +744,7 @@ void QuickTilingTest::testScript()
out << "workspace.slotWindowQuickTile" << action << "()";
out.flush();
QFETCH(AbstractClient::QuickTileMode, expectedMode);
QFETCH(QuickTileMode, expectedMode);
QFETCH(QRect, expectedGeometry);
const int id = Scripting::self()->loadScript(tmpFile.fileName());
......
......@@ -1585,9 +1585,9 @@ bool Client::untab(const QRect &toGeometry, bool clientRemoved)
setClientShown(!(isMinimized() || isShade()));
bool keepSize = toGeometry.size() == size();
bool changedSize = false;
if (quickTileMode() != QuickTileNone) {
if (quickTileMode() != QuickTileMode(QuickTileFlag::None)) {
changedSize = true;
setQuickTileMode(QuickTileNone); // if we leave a quicktiled group, assume that the user wants to untile
setQuickTileMode(QuickTileFlag::None); // if we leave a quicktiled group, assume that the user wants to untile
}
if (toGeometry.isValid()) {
if (maximizeMode() != MaximizeRestore) {
......
......@@ -254,25 +254,25 @@ bool DecoratedClientImpl::isMaximizedHorizontally() const
Qt::Edges DecoratedClientImpl::adjacentScreenEdges() const
{
Qt::Edges edges;
const AbstractClient::QuickTileMode mode = m_client->quickTileMode();
if (mode.testFlag(AbstractClient::QuickTileLeft)) {
const QuickTileMode mode = m_client->quickTileMode();
if (mode.testFlag(QuickTileFlag::Left)) {
edges |= Qt::LeftEdge;
if (!mode.testFlag(AbstractClient::QuickTileTop) && !mode.testFlag(AbstractClient::QuickTileBottom)) {
if (!mode.testFlag(QuickTileFlag::Top) && !mode.testFlag(QuickTileFlag::Bottom)) {
// using complete side
edges |= Qt::TopEdge | Qt::BottomEdge;
}
}
if (mode.testFlag(AbstractClient::QuickTileTop)) {
if (mode.testFlag(QuickTileFlag::Top)) {
edges |= Qt::TopEdge;
}
if (mode.testFlag(AbstractClient::QuickTileRight)) {
if (mode.testFlag(QuickTileFlag::Right)) {
edges |= Qt::RightEdge;
if (!mode.testFlag(AbstractClient::QuickTileTop) && !mode.testFlag(AbstractClient::QuickTileBottom)) {
if (!mode.testFlag(QuickTileFlag::Top) && !mode.testFlag(QuickTileFlag::Bottom)) {
// using complete side
edges |= Qt::TopEdge | Qt::BottomEdge;
}
}
if (mode.testFlag(AbstractClient::QuickTileBottom)) {
if (mode.testFlag(QuickTileFlag::Bottom)) {
edges |= Qt::BottomEdge;
}
return edges;
......
......@@ -1125,7 +1125,7 @@ void AbstractClient::checkWorkspacePosition(QRect oldGeometry, int oldDesktop, Q
return;
}
if (quickTileMode() != QuickTileNone) {
if (quickTileMode() != QuickTileMode(QuickTileFlag::None)) {
setGeometry(electricBorderMaximizeGeometry(geometry().center(), desktop()));
return;
}
......@@ -1677,14 +1677,14 @@ void Client::configureRequest(int value_mask, int rx, int ry, int rw, int rh, in
bool(maximizeMode() & MaximizeHorizontal);
// we want to (partially) ignore the request when the window is somehow maximized or quicktiled
bool ignore = !app_noborder && (quickTileMode() != QuickTileNone || maximizeMode() != MaximizeRestore);
bool ignore = !app_noborder && (quickTileMode() != QuickTileMode(QuickTileFlag::None) || maximizeMode() != MaximizeRestore);
// however, the user shall be able to force obedience despite and also disobedience in general
ignore = rules()->checkIgnoreGeometry(ignore);
if (!ignore) { // either we're not max'd / q'tiled or the user allowed the client to break that - so break it.
updateQuickTileMode(QuickTileNone);
updateQuickTileMode(QuickTileFlag::None);
max_mode = MaximizeRestore;
emit quickTileModeChanged();
} else if (!app_noborder && quickTileMode() == QuickTileNone &&
} else if (!app_noborder && quickTileMode() == QuickTileMode(QuickTileFlag::None) &&
(maximizeMode() == MaximizeVertical || maximizeMode() == MaximizeHorizontal)) {
// ignoring can be, because either we do, or the user does explicitly not want it.
// for partially maximized windows we want to allow configures in the other dimension.
......@@ -2281,7 +2281,7 @@ void Client::changeMaximize(bool vertical, bool horizontal, bool adjust)
else
sz = size();
if (quickTileMode() == QuickTileNone) {
if (quickTileMode() == QuickTileMode(QuickTileFlag::None)) {
if (!adjust && !(old_mode & MaximizeVertical)) {
geom_restore.setTop(y());
geom_restore.setHeight(sz.height());
......@@ -2319,16 +2319,16 @@ void Client::changeMaximize(bool vertical, bool horizontal, bool adjust)
const ForceGeometry_t geom_mode = isDecorated() ? ForceGeometrySet : NormalGeometrySet;
// Conditional quick tiling exit points
if (quickTileMode() != QuickTileNone) {
if (quickTileMode() != QuickTileMode(QuickTileFlag::None)) {
if (old_mode == MaximizeFull &&
!clientArea.contains(geom_restore.center())) {
// Not restoring on the same screen
// TODO: The following doesn't work for some reason
//quick_tile_mode = QuickTileNone; // And exit quick tile mode manually
//quick_tile_mode = QuickTileFlag::None; // And exit quick tile mode manually
} else if ((old_mode == MaximizeVertical && max_mode == MaximizeRestore) ||
(old_mode == MaximizeFull && max_mode == MaximizeHorizontal)) {
// Modifying geometry of a tiled window
updateQuickTileMode(QuickTileNone); // Exit quick tile mode without restoring geometry
updateQuickTileMode(QuickTileFlag::None); // Exit quick tile mode without restoring geometry
}
}
......@@ -2407,7 +2407,7 @@ void Client::changeMaximize(bool vertical, bool horizontal, bool adjust)
if (!clientArea.contains(geom_restore.center())) // Not restoring to the same screen
Placement::self()->place(this, clientArea);
info->setState(0, NET::Max);
updateQuickTileMode(QuickTileNone);
updateQuickTileMode(QuickTileFlag::None);
break;
}
......@@ -2455,9 +2455,9 @@ void Client::changeMaximize(bool vertical, bool horizontal, bool adjust)
}
setGeometry(r, geom_mode);
if (options->electricBorderMaximize() && r.top() == clientArea.top())
updateQuickTileMode(QuickTileMaximize);
updateQuickTileMode(QuickTileFlag::Maximize);
else
updateQuickTileMode(QuickTileNone);
updateQuickTileMode(QuickTileFlag::None);
info->setState(NET::Max, NET::Max);
break;
}
......@@ -2688,9 +2688,9 @@ bool AbstractClient::startMoveResize()
}
}
if (quickTileMode() != QuickTileNone && mode != PositionCenter) { // Cannot use isResize() yet
if (quickTileMode() != QuickTileMode(QuickTileFlag::None) && mode != PositionCenter) { // Cannot use isResize() yet
// Exit quick tile mode when the user attempts to resize a tiled window
updateQuickTileMode(QuickTileNone); // Do so without restoring original geometry
updateQuickTileMode(QuickTileFlag::None); // Do so without restoring original geometry
setGeometryRestore(geometry());
emit quickTileModeChanged();
}
......@@ -2881,16 +2881,16 @@ void AbstractClient::handleMoveResize(const QPoint &local, const QPoint &global)
const QRect oldGeo = geometry();
handleMoveResize(local.x(), local.y(), global.x(), global.y());
if (!isFullScreen() && isMove()) {
if (quickTileMode() != QuickTileNone && oldGeo != geometry()) {
if (quickTileMode() != QuickTileMode(QuickTileFlag::None) && oldGeo != geometry()) {
GeometryUpdatesBlocker blocker(this);
setQuickTileMode(QuickTileNone);
setQuickTileMode(QuickTileFlag::None);
const QRect &geom_restore = geometryRestore();
setMoveOffset(QPoint(double(moveOffset().x()) / double(oldGeo.width()) * double(geom_restore.width()),
double(moveOffset().y()) / double(oldGeo.height()) * double(geom_restore.height())));
if (rules()->checkMaximize(MaximizeRestore) == MaximizeRestore)
setMoveResizeGeometry(geom_restore);
handleMoveResize(local.x(), local.y(), global.x(), global.y()); // fix position
} else if (quickTileMode() == QuickTileNone && isResizable()) {
} else if (quickTileMode() == QuickTileMode(QuickTileFlag::None) && isResizable()) {
checkQuickTilingMaximizationZones(global.x(), global.y());
}
}
......@@ -3262,12 +3262,12 @@ void Client::doPerformMoveResize()
void AbstractClient::setElectricBorderMode(QuickTileMode mode)
{
if (mode != QuickTileMaximize) {
if (mode != QuickTileMode(QuickTileFlag::Maximize)) {
// sanitize the mode, ie. simplify "invalid" combinations
if ((mode & QuickTileHorizontal) == QuickTileHorizontal)
mode &= ~QuickTileHorizontal;
if ((mode & QuickTileVertical) == QuickTileVertical)
mode &= ~QuickTileVertical;
if ((mode & QuickTileFlag::Horizontal) == QuickTileMode(QuickTileFlag::Horizontal))
mode &= ~QuickTileMode(QuickTileFlag::Horizontal);
if ((mode & QuickTileFlag::Vertical) == QuickTileMode(QuickTileFlag::Vertical))
mode &= ~QuickTileMode(QuickTileFlag::Vertical);
}
m_electricMode = mode;
}
......@@ -3284,7 +3284,7 @@ void AbstractClient::setElectricBorderMaximizing(bool maximizing)
QRect AbstractClient::electricBorderMaximizeGeometry(QPoint pos, int desktop)
{
if (electricBorderMode() == QuickTileMaximize) {
if (electricBorderMode() == QuickTileMode(QuickTileFlag::Maximize)) {
if (maximizeMode() == MaximizeFull)
return geometryRestore();
else
......@@ -3292,13 +3292,13 @@ QRect AbstractClient::electricBorderMaximizeGeometry(QPoint pos, int desktop)
}
QRect ret = workspace()->clientArea(MaximizeArea, pos, desktop);
if (electricBorderMode() & QuickTileLeft)
if (electricBorderMode() & QuickTileFlag::Left)
ret.setRight(ret.left()+ret.width()/2 - 1);
else if (electricBorderMode() & QuickTileRight)
else if (electricBorderMode() & QuickTileFlag::Right)
ret.setLeft(ret.right()-(ret.width()-ret.width()/2) + 1);
if (electricBorderMode() & QuickTileTop)
if (electricBorderMode() & QuickTileFlag::Top)
ret.setBottom(ret.top()+ret.height()/2 - 1);
else if (electricBorderMode() & QuickTileBottom)
else if (electricBorderMode() & QuickTileFlag::Bottom)
ret.setTop(ret.bottom()-(ret.height()-ret.height()/2) + 1);
return ret;
......@@ -3314,14 +3314,14 @@ void AbstractClient::setQuickTileMode(QuickTileMode mode, bool keyboard)