Port Workspace::topClientOnDesktop() to AbstractOutput

This commit is contained in:
Vlad Zahorodnii 2021-08-28 17:28:54 +03:00 committed by Aleix Pol Gonzalez
parent 95e5f5fc1a
commit 507c5140b7
6 changed files with 18 additions and 18 deletions

View file

@ -757,7 +757,7 @@ void PointerInputTest::testFocusFollowsMouse()
AbstractClient *window2 = workspace()->activeClient();
QVERIFY(window2);
QVERIFY(window1 != window2);
QCOMPARE(workspace()->topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop(), -1), window2);
QCOMPARE(workspace()->topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop()), window2);
// geometry of the two windows should be overlapping
QVERIFY(window1->frameGeometry().intersects(window2->frameGeometry()));
@ -776,18 +776,18 @@ void PointerInputTest::testFocusFollowsMouse()
Cursors::self()->mouse()->setPos(10, 10);
QVERIFY(stackingOrderChangedSpy.wait());
QCOMPARE(stackingOrderChangedSpy.count(), 1);
QCOMPARE(workspace()->topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop(), -1), window1);
QCOMPARE(workspace()->topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop()), window1);
QTRY_VERIFY(window1->isActive());
// move on second window, but move away before active window change delay hits
Cursors::self()->mouse()->setPos(810, 810);
QVERIFY(stackingOrderChangedSpy.wait());
QCOMPARE(stackingOrderChangedSpy.count(), 2);
QCOMPARE(workspace()->topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop(), -1), window2);
QCOMPARE(workspace()->topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop()), window2);
Cursors::self()->mouse()->setPos(10, 10);
QVERIFY(!activeWindowChangedSpy.wait(250));
QVERIFY(window1->isActive());
QCOMPARE(workspace()->topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop(), -1), window1);
QCOMPARE(workspace()->topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop()), window1);
// as we moved back on window 1 that should been raised in the mean time
QCOMPARE(stackingOrderChangedSpy.count(), 3);
@ -843,7 +843,7 @@ void PointerInputTest::testMouseActionInactiveWindow()
AbstractClient *window2 = workspace()->activeClient();
QVERIFY(window2);
QVERIFY(window1 != window2);
QCOMPARE(workspace()->topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop(), -1), window2);
QCOMPARE(workspace()->topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop()), window2);
// geometry of the two windows should be overlapping
QVERIFY(window1->frameGeometry().intersects(window2->frameGeometry()));
@ -872,7 +872,7 @@ void PointerInputTest::testMouseActionInactiveWindow()
// should raise window1 and activate it
QCOMPARE(stackingOrderChangedSpy.count(), 1);
QVERIFY(!activeWindowChangedSpy.isEmpty());
QCOMPARE(workspace()->topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop(), -1), window1);
QCOMPARE(workspace()->topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop()), window1);
QVERIFY(window1->isActive());
QVERIFY(!window2->isActive());
@ -937,12 +937,12 @@ void PointerInputTest::testMouseActionActiveWindow()
QVERIFY(window1 != window2);
QSignalSpy window2DestroyedSpy(window2, &QObject::destroyed);
QVERIFY(window2DestroyedSpy.isValid());
QCOMPARE(workspace()->topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop(), -1), window2);
QCOMPARE(workspace()->topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop()), window2);
// geometry of the two windows should be overlapping
QVERIFY(window1->frameGeometry().intersects(window2->frameGeometry()));
// lower the currently active window
workspace()->lowerClient(window2);
QCOMPARE(workspace()->topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop(), -1), window1);
QCOMPARE(workspace()->topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop()), window1);
// signal spy for stacking order spy
QSignalSpy stackingOrderChangedSpy(workspace(), &Workspace::stackingOrderChanged);
@ -960,11 +960,11 @@ void PointerInputTest::testMouseActionActiveWindow()
QVERIFY(buttonSpy.wait());
if (clickRaise) {
QCOMPARE(stackingOrderChangedSpy.count(), 1);
QTRY_COMPARE_WITH_TIMEOUT(workspace()->topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop(), -1), window2, 200);
QTRY_COMPARE_WITH_TIMEOUT(workspace()->topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop()), window2, 200);
} else {
QCOMPARE(stackingOrderChangedSpy.count(), 0);
QVERIFY(!stackingOrderChangedSpy.wait(100));
QCOMPARE(workspace()->topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop(), -1), window1);
QCOMPARE(workspace()->topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop()), window1);
}
// release again

View file

@ -390,7 +390,7 @@ void AbstractClient::autoRaise()
bool AbstractClient::isMostRecentlyRaised() const
{
// The last toplevel in the unconstrained stacking order is the most recently raised one.
return workspace()->topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop(), -1, true, false) == this;
return workspace()->topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop(), nullptr, true, false) == this;
}
bool AbstractClient::wantsTabFocus() const
@ -2527,7 +2527,7 @@ void AbstractClient::enterEvent(const QPoint &globalPos)
!isDock() && workspace()->focusChangeEnabled() &&
globalPos != workspace()->focusMousePosition() &&
workspace()->topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop(),
options->isSeparateScreenFocus() ? screen() : -1) != this) {
options->isSeparateScreenFocus() ? output() : nullptr) != this) {
startAutoRaise();
}

View file

@ -223,7 +223,7 @@ void Workspace::propagateClients(bool propagate_new_clients)
* doesn't accept focus it's excluded.
*/
// TODO misleading name for this method, too many slightly different ways to use it
AbstractClient *Workspace::topClientOnDesktop(VirtualDesktop *desktop, int screen, bool unconstrained, bool only_normal) const
AbstractClient *Workspace::topClientOnDesktop(VirtualDesktop *desktop, AbstractOutput *output, bool unconstrained, bool only_normal) const
{
// TODO Q_ASSERT( block_stacking_updates == 0 );
QList<Toplevel *> list;
@ -239,7 +239,7 @@ AbstractClient *Workspace::topClientOnDesktop(VirtualDesktop *desktop, int scree
continue;
}
if (c->isOnDesktop(desktop) && c->isShown(false) && c->isOnCurrentActivity()) {
if (screen != -1 && c->screen() != screen)
if (output && c->output() != output)
continue;
if (!only_normal)
return c;
@ -279,7 +279,7 @@ void Workspace::raiseOrLowerClient(AbstractClient *c)
const AbstractClient *topmost =
topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop(),
options->isSeparateScreenFocus() ? c->screen() : -1);
options->isSeparateScreenFocus() ? c->output() : nullptr);
if (c == topmost)
lowerClient(c);

View file

@ -1423,7 +1423,7 @@ void Workspace::slotWindowLower()
if (next && next != active_client)
requestFocus(next, false);
} else {
activateClient(topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop(), -1));
activateClient(topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop()));
}
}
}

View file

@ -429,7 +429,7 @@ void Workspace::initializeX11()
&& activeClient() == nullptr && should_get_focus.count() == 0) {
// No client activated in manage()
if (new_active_client == nullptr)
new_active_client = topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop(), -1);
new_active_client = topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop());
if (new_active_client == nullptr)
new_active_client = findDesktop(true, VirtualDesktopManager::self()->currentDesktop());
}

View file

@ -277,7 +277,7 @@ public:
QList<X11Client *> ensureStackingOrder(const QList<X11Client *> &clients) const;
QList<AbstractClient*> ensureStackingOrder(const QList<AbstractClient*> &clients) const;
AbstractClient *topClientOnDesktop(VirtualDesktop *desktop, int screen, bool unconstrained = false,
AbstractClient *topClientOnDesktop(VirtualDesktop *desktop, AbstractOutput *output = nullptr, bool unconstrained = false,
bool only_normal = true) const;
AbstractClient *findDesktop(bool topmost, VirtualDesktop *desktop) const;
void sendClientToDesktop(AbstractClient* c, int desktop, bool dont_activate);