From 507c5140b76218c0c8a21fa85bf6ab9abd0d6a0c Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Sat, 28 Aug 2021 17:28:54 +0300 Subject: [PATCH] Port Workspace::topClientOnDesktop() to AbstractOutput --- autotests/integration/pointer_input.cpp | 20 ++++++++++---------- src/abstract_client.cpp | 4 ++-- src/layers.cpp | 6 +++--- src/useractions.cpp | 2 +- src/workspace.cpp | 2 +- src/workspace.h | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/autotests/integration/pointer_input.cpp b/autotests/integration/pointer_input.cpp index df666b0a93..29069351c5 100644 --- a/autotests/integration/pointer_input.cpp +++ b/autotests/integration/pointer_input.cpp @@ -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 diff --git a/src/abstract_client.cpp b/src/abstract_client.cpp index f5b877c56f..8e9d5f5d41 100644 --- a/src/abstract_client.cpp +++ b/src/abstract_client.cpp @@ -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(); } diff --git a/src/layers.cpp b/src/layers.cpp index b83c36f71c..39e57f95a8 100644 --- a/src/layers.cpp +++ b/src/layers.cpp @@ -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 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); diff --git a/src/useractions.cpp b/src/useractions.cpp index d012e16534..30aacec8d5 100644 --- a/src/useractions.cpp +++ b/src/useractions.cpp @@ -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())); } } } diff --git a/src/workspace.cpp b/src/workspace.cpp index 6561be99d7..a703456f29 100644 --- a/src/workspace.cpp +++ b/src/workspace.cpp @@ -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()); } diff --git a/src/workspace.h b/src/workspace.h index bd4701cc68..9f464a5db8 100644 --- a/src/workspace.h +++ b/src/workspace.h @@ -277,7 +277,7 @@ public: QList ensureStackingOrder(const QList &clients) const; QList ensureStackingOrder(const QList &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);