Merge Toplevel into AbstractClient

References issue #81
This commit is contained in:
Nils Fenner 2022-04-18 07:42:11 +00:00 committed by Vlad Zahorodnii
parent 5acf8aa792
commit aaa429ee0a
93 changed files with 2078 additions and 2206 deletions

View file

@ -393,7 +393,7 @@ void ActivationTest::testSwitchToWindowMaximized()
Test::render(surface2.data(), toplevelConfigureRequestedSpy2.last().at(0).toSize(), Qt::red);
QVERIFY(frameGeometryChangedSpy2.wait());
const QList<Toplevel *> stackingOrder = workspace()->stackingOrder();
const QList<AbstractClient *> stackingOrder = workspace()->stackingOrder();
QVERIFY(stackingOrder.indexOf(client1) < stackingOrder.indexOf(client2));
QCOMPARE(client1->maximizeMode(), MaximizeFull);
QCOMPARE(client2->maximizeMode(), MaximizeFull);
@ -480,7 +480,7 @@ void ActivationTest::testSwitchToWindowFullScreen()
Test::render(surface2.data(), toplevelConfigureRequestedSpy2.last().at(0).toSize(), Qt::red);
QVERIFY(frameGeometryChangedSpy2.wait());
const QList<Toplevel *> stackingOrder = workspace()->stackingOrder();
const QList<AbstractClient *> stackingOrder = workspace()->stackingOrder();
QVERIFY(stackingOrder.indexOf(client1) < stackingOrder.indexOf(client2));
QVERIFY(client1->isFullScreen());
QVERIFY(client2->isFullScreen());

View file

@ -151,7 +151,7 @@ void InputStackingOrderTest::testPointerFocusUpdatesOnStackingOrderChange()
QCOMPARE(waylandServer()->seat()->focusedPointerSurface(), window1->surface());
// let's destroy window1, that should pass focus to window2 again
QSignalSpy windowClosedSpy(window1, &Toplevel::windowClosed);
QSignalSpy windowClosedSpy(window1, &AbstractClient::windowClosed);
QVERIFY(windowClosedSpy.isValid());
surface1->deleteLater();
QVERIFY(windowClosedSpy.wait());

View file

@ -576,7 +576,7 @@ void InternalWindowTest::testSkipCloseAnimation()
auto internalClient = clientAddedSpy.first().first().value<InternalClient *>();
QVERIFY(internalClient);
QCOMPARE(internalClient->skipsCloseAnimation(), initial);
QSignalSpy skipCloseChangedSpy(internalClient, &Toplevel::skipCloseAnimationChanged);
QSignalSpy skipCloseChangedSpy(internalClient, &AbstractClient::skipCloseAnimationChanged);
QVERIFY(skipCloseChangedSpy.isValid());
win.setProperty("KWIN_SKIP_CLOSE_ANIMATION", !initial);
QCOMPARE(skipCloseChangedSpy.count(), 1);

View file

@ -318,13 +318,13 @@ void TestMaximized::testMaximizedGainFocusAndBeActivated()
QVERIFY(!client->isActive());
QVERIFY(client2->isActive());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{client, client2}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{client, client2}));
workspace()->performWindowOperation(client, Options::MaximizeOp);
QVERIFY(client->isActive());
QVERIFY(!client2->isActive());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{client2, client}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{client2, client}));
xdgShellSurface.reset();
QVERIFY(Test::waitForWindowDestroyed(client));

View file

@ -366,7 +366,7 @@ void TestPlacement::testFullscreen()
client->setFullScreen(true);
QSignalSpy geometryChangedSpy(client, &Toplevel::frameGeometryChanged);
QSignalSpy geometryChangedSpy(client, &AbstractClient::frameGeometryChanged);
QVERIFY(surfaceConfigureRequestedSpy.wait());
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
Test::render(surface.data(), toplevelConfigureRequestedSpy.last().at(0).toSize(), Qt::red);

View file

@ -303,7 +303,7 @@ struct XcbConnectionDeleter
}
};
static bool waitForXwaylandBuffer(Toplevel *window, const QSize &size)
static bool waitForXwaylandBuffer(AbstractClient *window, const QSize &size)
{
// Usually, when an Xwayland surface is created, it has a buffer of size 1x1,
// a buffer with the correct size will be committed a bit later.

View file

@ -94,7 +94,7 @@ void StackingOrderTest::testTransientIsAboveParent()
QVERIFY(!parent->isTransient());
// Initially, the stacking order should contain only the parent window.
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{parent}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{parent}));
// Create the transient.
KWayland::Client::Surface *transientSurface =
@ -111,13 +111,13 @@ void StackingOrderTest::testTransientIsAboveParent()
QVERIFY(transient->isTransient());
// The transient should be above the parent.
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{parent, transient}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{parent, transient}));
// The transient still stays above the parent if we activate the latter.
workspace()->activateClient(parent);
QTRY_VERIFY(parent->isActive());
QTRY_VERIFY(!transient->isActive());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{parent, transient}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{parent, transient}));
}
void StackingOrderTest::testRaiseTransient()
@ -138,7 +138,7 @@ void StackingOrderTest::testRaiseTransient()
QVERIFY(!parent->isTransient());
// Initially, the stacking order should contain only the parent window.
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{parent}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{parent}));
// Create the transient.
KWayland::Client::Surface *transientSurface =
@ -155,7 +155,7 @@ void StackingOrderTest::testRaiseTransient()
QVERIFY(transient->isTransient());
// The transient should be above the parent.
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{parent, transient}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{parent, transient}));
// Create a window that doesn't have any relationship to the parent or the transient.
KWayland::Client::Surface *anotherSurface =
@ -170,28 +170,28 @@ void StackingOrderTest::testRaiseTransient()
QVERIFY(!anotherClient->isTransient());
// The newly created surface has to be above both the parent and the transient.
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{parent, transient, anotherClient}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{parent, transient, anotherClient}));
// If we activate the parent, the transient should be raised too.
workspace()->activateClient(parent);
QTRY_VERIFY(parent->isActive());
QTRY_VERIFY(!transient->isActive());
QTRY_VERIFY(!anotherClient->isActive());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{anotherClient, parent, transient}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{anotherClient, parent, transient}));
// Go back to the initial setup.
workspace()->activateClient(anotherClient);
QTRY_VERIFY(!parent->isActive());
QTRY_VERIFY(!transient->isActive());
QTRY_VERIFY(anotherClient->isActive());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{parent, transient, anotherClient}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{parent, transient, anotherClient}));
// If we activate the transient, the parent should be raised too.
workspace()->activateClient(transient);
QTRY_VERIFY(!parent->isActive());
QTRY_VERIFY(transient->isActive());
QTRY_VERIFY(!anotherClient->isActive());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{anotherClient, parent, transient}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{anotherClient, parent, transient}));
}
struct WindowUnrefDeleter
@ -221,7 +221,7 @@ void StackingOrderTest::testDeletedTransient()
QVERIFY(parent->isActive());
QVERIFY(!parent->isTransient());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{parent}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{parent}));
// Create the first transient.
KWayland::Client::Surface *transient1Surface =
@ -238,7 +238,7 @@ void StackingOrderTest::testDeletedTransient()
QVERIFY(transient1->isTransient());
QCOMPARE(transient1->transientFor(), parent);
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{parent, transient1}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{parent, transient1}));
// Create the second transient.
KWayland::Client::Surface *transient2Surface =
@ -255,7 +255,7 @@ void StackingOrderTest::testDeletedTransient()
QVERIFY(transient2->isTransient());
QCOMPARE(transient2->transientFor(), transient1);
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{parent, transient1, transient2}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{parent, transient1, transient2}));
// Activate the parent, both transients have to be above it.
workspace()->activateClient(parent);
@ -265,7 +265,7 @@ void StackingOrderTest::testDeletedTransient()
// Close the top-most transient.
connect(transient2, &AbstractClient::windowClosed, this,
[](Toplevel *toplevel, Deleted *deleted) {
[](AbstractClient *toplevel, Deleted *deleted) {
Q_UNUSED(toplevel)
deleted->refWindow();
});
@ -283,7 +283,7 @@ void StackingOrderTest::testDeletedTransient()
// The deleted transient still has to be above its old parent (transient1).
QTRY_VERIFY(parent->isActive());
QTRY_VERIFY(!transient1->isActive());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{parent, transient1, deletedTransient.data()}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{parent, transient1, deletedTransient.data()}));
}
static xcb_window_t createGroupWindow(xcb_connection_t *conn,
@ -363,7 +363,7 @@ void StackingOrderTest::testGroupTransientIsAboveWindowGroup()
QCOMPARE(leader->window(), leaderWid);
QVERIFY(!leader->isTransient());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{leader}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{leader}));
// Create another group member.
windowCreatedSpy.clear();
@ -379,7 +379,7 @@ void StackingOrderTest::testGroupTransientIsAboveWindowGroup()
QCOMPARE(member1->group(), leader->group());
QVERIFY(!member1->isTransient());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{leader, member1}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{leader, member1}));
// Create yet another group member.
windowCreatedSpy.clear();
@ -395,7 +395,7 @@ void StackingOrderTest::testGroupTransientIsAboveWindowGroup()
QCOMPARE(member2->group(), leader->group());
QVERIFY(!member2->isTransient());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{leader, member1, member2}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{leader, member1, member2}));
// Create a group transient.
windowCreatedSpy.clear();
@ -435,24 +435,24 @@ void StackingOrderTest::testGroupTransientIsAboveWindowGroup()
QVERIFY(transient->groupTransient());
QVERIFY(!transient->isDialog()); // See above why
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{leader, member1, member2, transient}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{leader, member1, member2, transient}));
// If we activate any member of the window group, the transient will be above it.
workspace()->activateClient(leader);
QTRY_VERIFY(leader->isActive());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{member1, member2, leader, transient}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{member1, member2, leader, transient}));
workspace()->activateClient(member1);
QTRY_VERIFY(member1->isActive());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{member2, leader, member1, transient}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{member2, leader, member1, transient}));
workspace()->activateClient(member2);
QTRY_VERIFY(member2->isActive());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{leader, member1, member2, transient}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{leader, member1, member2, transient}));
workspace()->activateClient(transient);
QTRY_VERIFY(transient->isActive());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{leader, member1, member2, transient}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{leader, member1, member2, transient}));
}
void StackingOrderTest::testRaiseGroupTransient()
@ -477,7 +477,7 @@ void StackingOrderTest::testRaiseGroupTransient()
QCOMPARE(leader->window(), leaderWid);
QVERIFY(!leader->isTransient());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{leader}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{leader}));
// Create another group member.
windowCreatedSpy.clear();
@ -493,7 +493,7 @@ void StackingOrderTest::testRaiseGroupTransient()
QCOMPARE(member1->group(), leader->group());
QVERIFY(!member1->isTransient());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{leader, member1}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{leader, member1}));
// Create yet another group member.
windowCreatedSpy.clear();
@ -509,7 +509,7 @@ void StackingOrderTest::testRaiseGroupTransient()
QCOMPARE(member2->group(), leader->group());
QVERIFY(!member2->isTransient());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{leader, member1, member2}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{leader, member1, member2}));
// Create a group transient.
windowCreatedSpy.clear();
@ -549,7 +549,7 @@ void StackingOrderTest::testRaiseGroupTransient()
QVERIFY(transient->groupTransient());
QVERIFY(!transient->isDialog()); // See above why
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{leader, member1, member2, transient}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{leader, member1, member2, transient}));
// Create a Wayland client that is not a member of the window group.
KWayland::Client::Surface *anotherSurface =
@ -563,27 +563,27 @@ void StackingOrderTest::testRaiseGroupTransient()
QVERIFY(anotherClient->isActive());
QVERIFY(!anotherClient->isTransient());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{leader, member1, member2, transient, anotherClient}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{leader, member1, member2, transient, anotherClient}));
// If we activate the leader, then only it and the transient have to be raised.
workspace()->activateClient(leader);
QTRY_VERIFY(leader->isActive());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{member1, member2, anotherClient, leader, transient}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{member1, member2, anotherClient, leader, transient}));
// If another member of the window group is activated, then the transient will
// be above that member and the leader.
workspace()->activateClient(member2);
QTRY_VERIFY(member2->isActive());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{member1, anotherClient, leader, member2, transient}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{member1, anotherClient, leader, member2, transient}));
// FIXME: If we activate the transient, only it will be raised.
workspace()->activateClient(anotherClient);
QTRY_VERIFY(anotherClient->isActive());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{member1, leader, member2, transient, anotherClient}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{member1, leader, member2, transient, anotherClient}));
workspace()->activateClient(transient);
QTRY_VERIFY(transient->isActive());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{member1, leader, member2, anotherClient, transient}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{member1, leader, member2, anotherClient, transient}));
}
void StackingOrderTest::testDeletedGroupTransient()
@ -611,7 +611,7 @@ void StackingOrderTest::testDeletedGroupTransient()
QCOMPARE(leader->window(), leaderWid);
QVERIFY(!leader->isTransient());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{leader}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{leader}));
// Create another group member.
windowCreatedSpy.clear();
@ -627,7 +627,7 @@ void StackingOrderTest::testDeletedGroupTransient()
QCOMPARE(member1->group(), leader->group());
QVERIFY(!member1->isTransient());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{leader, member1}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{leader, member1}));
// Create yet another group member.
windowCreatedSpy.clear();
@ -643,7 +643,7 @@ void StackingOrderTest::testDeletedGroupTransient()
QCOMPARE(member2->group(), leader->group());
QVERIFY(!member2->isTransient());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{leader, member1, member2}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{leader, member1, member2}));
// Create a group transient.
windowCreatedSpy.clear();
@ -683,11 +683,11 @@ void StackingOrderTest::testDeletedGroupTransient()
QVERIFY(transient->groupTransient());
QVERIFY(!transient->isDialog()); // See above why
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{leader, member1, member2, transient}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{leader, member1, member2, transient}));
// Unmap the transient.
connect(transient, &X11Client::windowClosed, this,
[](Toplevel *toplevel, Deleted *deleted) {
[](AbstractClient *toplevel, Deleted *deleted) {
Q_UNUSED(toplevel)
deleted->refWindow();
});
@ -703,7 +703,7 @@ void StackingOrderTest::testDeletedGroupTransient()
QVERIFY(deletedTransient.data());
// The transient has to be above each member of the window group.
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{leader, member1, member2, deletedTransient.data()}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{leader, member1, member2, deletedTransient.data()}));
}
void StackingOrderTest::testDontKeepAboveNonModalDialogGroupTransients()
@ -730,7 +730,7 @@ void StackingOrderTest::testDontKeepAboveNonModalDialogGroupTransients()
QCOMPARE(leader->window(), leaderWid);
QVERIFY(!leader->isTransient());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{leader}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{leader}));
// Create another group member.
windowCreatedSpy.clear();
@ -746,7 +746,7 @@ void StackingOrderTest::testDontKeepAboveNonModalDialogGroupTransients()
QCOMPARE(member1->group(), leader->group());
QVERIFY(!member1->isTransient());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{leader, member1}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{leader, member1}));
// Create yet another group member.
windowCreatedSpy.clear();
@ -762,7 +762,7 @@ void StackingOrderTest::testDontKeepAboveNonModalDialogGroupTransients()
QCOMPARE(member2->group(), leader->group());
QVERIFY(!member2->isTransient());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{leader, member1, member2}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{leader, member1, member2}));
// Create a group transient.
windowCreatedSpy.clear();
@ -782,23 +782,23 @@ void StackingOrderTest::testDontKeepAboveNonModalDialogGroupTransients()
QVERIFY(transient->isDialog());
QVERIFY(!transient->isModal());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{leader, member1, member2, transient}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{leader, member1, member2, transient}));
workspace()->activateClient(leader);
QTRY_VERIFY(leader->isActive());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{member1, member2, transient, leader}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{member1, member2, transient, leader}));
workspace()->activateClient(member1);
QTRY_VERIFY(member1->isActive());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{member2, transient, leader, member1}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{member2, transient, leader, member1}));
workspace()->activateClient(member2);
QTRY_VERIFY(member2->isActive());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{transient, leader, member1, member2}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{transient, leader, member1, member2}));
workspace()->activateClient(transient);
QTRY_VERIFY(transient->isActive());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{leader, member1, member2, transient}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{leader, member1, member2, transient}));
}
void StackingOrderTest::testKeepAbove()
@ -817,7 +817,7 @@ void StackingOrderTest::testKeepAbove()
QVERIFY(clientA->isActive());
QVERIFY(!clientA->keepAbove());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{clientA}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{clientA}));
// Create the second client.
KWayland::Client::Surface *clientBSurface =
@ -831,12 +831,12 @@ void StackingOrderTest::testKeepAbove()
QVERIFY(clientB->isActive());
QVERIFY(!clientB->keepAbove());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{clientA, clientB}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{clientA, clientB}));
// Go to the initial test position.
workspace()->activateClient(clientA);
QTRY_VERIFY(clientA->isActive());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{clientB, clientA}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{clientB, clientA}));
// Set the "keep-above" flag on the client B, it should go above other clients.
{
@ -846,7 +846,7 @@ void StackingOrderTest::testKeepAbove()
QVERIFY(clientB->keepAbove());
QVERIFY(!clientB->isActive());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{clientA, clientB}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{clientA, clientB}));
}
void StackingOrderTest::testKeepBelow()
@ -865,7 +865,7 @@ void StackingOrderTest::testKeepBelow()
QVERIFY(clientA->isActive());
QVERIFY(!clientA->keepBelow());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{clientA}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{clientA}));
// Create the second client.
KWayland::Client::Surface *clientBSurface =
@ -879,7 +879,7 @@ void StackingOrderTest::testKeepBelow()
QVERIFY(clientB->isActive());
QVERIFY(!clientB->keepBelow());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{clientA, clientB}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{clientA, clientB}));
// Set the "keep-below" flag on the client B, it should go below other clients.
{
@ -889,7 +889,7 @@ void StackingOrderTest::testKeepBelow()
QVERIFY(clientB->isActive());
QVERIFY(clientB->keepBelow());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{clientB, clientA}));
QCOMPARE(workspace()->stackingOrder(), (QList<AbstractClient *>{clientB, clientA}));
}
WAYLANDTEST_MAIN(StackingOrderTest)

View file

@ -651,7 +651,7 @@ bool waitForWaylandSurface(AbstractClient *client)
if (client->surface()) {
return true;
}
QSignalSpy surfaceChangedSpy(client, &Toplevel::surfaceChanged);
QSignalSpy surfaceChangedSpy(client, &AbstractClient::surfaceChanged);
return surfaceChangedSpy.wait();
}

View file

@ -107,8 +107,8 @@ void TestWindowSelection::testSelectOnWindowPointer()
QCOMPARE(input()->pointer()->focus(), client);
QVERIFY(pointerEnteredSpy.wait());
Toplevel *selectedWindow = nullptr;
auto callback = [&selectedWindow](Toplevel *t) {
AbstractClient *selectedWindow = nullptr;
auto callback = [&selectedWindow](AbstractClient *t) {
selectedWindow = t;
};
@ -191,8 +191,8 @@ void TestWindowSelection::testSelectOnWindowKeyboard()
QVERIFY(keyboardEnteredSpy.wait());
QVERIFY(!client->frameGeometry().contains(KWin::Cursors::self()->mouse()->pos()));
Toplevel *selectedWindow = nullptr;
auto callback = [&selectedWindow](Toplevel *t) {
AbstractClient *selectedWindow = nullptr;
auto callback = [&selectedWindow](AbstractClient *t) {
selectedWindow = t;
};
@ -255,8 +255,8 @@ void TestWindowSelection::testSelectOnWindowTouch()
auto client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
QVERIFY(client);
Toplevel *selectedWindow = nullptr;
auto callback = [&selectedWindow](Toplevel *t) {
AbstractClient *selectedWindow = nullptr;
auto callback = [&selectedWindow](AbstractClient *t) {
selectedWindow = t;
};
@ -328,8 +328,8 @@ void TestWindowSelection::testCancelOnWindowPointer()
QCOMPARE(input()->pointer()->focus(), client);
QVERIFY(pointerEnteredSpy.wait());
Toplevel *selectedWindow = nullptr;
auto callback = [&selectedWindow](Toplevel *t) {
AbstractClient *selectedWindow = nullptr;
auto callback = [&selectedWindow](AbstractClient *t) {
selectedWindow = t;
};
@ -387,8 +387,8 @@ void TestWindowSelection::testCancelOnWindowKeyboard()
QCOMPARE(input()->pointer()->focus(), client);
QVERIFY(pointerEnteredSpy.wait());
Toplevel *selectedWindow = nullptr;
auto callback = [&selectedWindow](Toplevel *t) {
AbstractClient *selectedWindow = nullptr;
auto callback = [&selectedWindow](AbstractClient *t) {
selectedWindow = t;
};

View file

@ -727,7 +727,7 @@ void X11ClientTest::testX11WindowId()
QUuid deletedUuid;
QCOMPARE(deletedUuid.isNull(), true);
connect(client, &X11Client::windowClosed, this, [&deletedUuid](Toplevel *, Deleted *d) {
connect(client, &X11Client::windowClosed, this, [&deletedUuid](AbstractClient *, Deleted *d) {
deletedUuid = d->internalId();
});

View file

@ -130,7 +130,6 @@ target_sources(kwin PRIVATE
surfaceitem_x11.cpp
syncalarmx11filter.cpp
tablet_input.cpp
toplevel.cpp
hide_cursor_spy.cpp
touch_input.cpp
udev.cpp

View file

@ -14,9 +14,13 @@
#include "activities.h"
#endif
#include "appmenu.h"
#include "atoms.h"
#include "client_machine.h"
#include "composite.h"
#include "decorations/decoratedclient.h"
#include "decorations/decorationbridge.h"
#include "decorations/decorationpalette.h"
#include "effects.h"
#include "focuschain.h"
#include "outline.h"
#include "platform.h"
@ -25,19 +29,25 @@
#include "tabbox.h"
#endif
#include "screenedge.h"
#include "shadow.h"
#include "shadowitem.h"
#include "surfaceitem_x11.h"
#include "useractions.h"
#include "virtualdesktops.h"
#include "windowitem.h"
#include "workspace.h"
#include "wayland_server.h"
#include <KWaylandServer/output_interface.h>
#include <KWaylandServer/plasmawindowmanagement_interface.h>
#include <KWaylandServer/surface_interface.h>
#include <KDecoration2/DecoratedClient>
#include <KDecoration2/Decoration>
#include <KDesktopFile>
#include <QDebug>
#include <QDir>
#include <QMouseEvent>
#include <QStyleHints>
@ -54,12 +64,30 @@ QHash<QString, std::weak_ptr<Decoration::DecorationPalette>> AbstractClient::s_p
std::shared_ptr<Decoration::DecorationPalette> AbstractClient::s_defaultPalette;
AbstractClient::AbstractClient()
: Toplevel()
: m_output(workspace()->activeOutput())
, m_visual(XCB_NONE)
, bit_depth(24)
, info(nullptr)
, ready_for_painting(false)
, m_internalId(QUuid::createUuid())
, m_client()
, is_shape(false)
, effect_window(nullptr)
, m_clientMachine(new ClientMachine(this))
, m_wmClientLeader(XCB_WINDOW_NONE)
, m_skipCloseAnimation(false)
#if KWIN_BUILD_TABBOX
, m_tabBoxClient(QSharedPointer<TabBox::TabBoxClientImpl>(new TabBox::TabBoxClientImpl(this)))
#endif
, m_colorScheme(QStringLiteral("kdeglobals"))
{
connect(screens(), &Screens::changed, this, &AbstractClient::screenChanged);
connect(this, &AbstractClient::bufferGeometryChanged, this, &AbstractClient::inputTransformationChanged);
// Only for compatibility reasons, drop in the next major release.
connect(this, &AbstractClient::frameGeometryChanged, this, &AbstractClient::geometryChanged);
connect(this, &AbstractClient::geometryShapeChanged, this, &AbstractClient::discardShapeRegion);
connect(this, &AbstractClient::clientStartUserMovedResized, this, &AbstractClient::moveResizedChanged);
connect(this, &AbstractClient::clientFinishUserMovedResized, this, &AbstractClient::moveResizedChanged);
@ -80,7 +108,7 @@ AbstractClient::AbstractClient()
});
// replace on-screen-display on size changes
connect(this, &AbstractClient::frameGeometryChanged, this, [this](Toplevel *c, const QRect &old) {
connect(this, &AbstractClient::frameGeometryChanged, this, [this](AbstractClient *c, const QRect &old) {
Q_UNUSED(c)
if (isOnScreenDisplay() && !frameGeometry().isEmpty() && old.size() != frameGeometry().size() && isPlaceable()) {
GeometryUpdatesBlocker blocker(this);
@ -97,6 +125,659 @@ AbstractClient::~AbstractClient()
{
Q_ASSERT(m_blockGeometryUpdates == 0);
Q_ASSERT(m_decoration.decoration == nullptr);
delete info;
}
QDebug operator<<(QDebug debug, const AbstractClient *toplevel)
{
QDebugStateSaver saver(debug);
debug.nospace();
if (toplevel) {
debug << toplevel->metaObject()->className() << '(' << static_cast<const void *>(toplevel);
if (toplevel->window()) {
debug << ", windowId=0x" << Qt::hex << toplevel->window() << Qt::dec;
}
if (const KWaylandServer::SurfaceInterface *surface = toplevel->surface()) {
debug << ", surface=" << surface;
}
if (toplevel->isClient()) {
if (!toplevel->isPopupWindow()) {
debug << ", caption=" << toplevel->caption();
}
if (toplevel->transientFor()) {
debug << ", transientFor=" << toplevel->transientFor();
}
}
if (debug.verbosity() > 2) {
debug << ", frameGeometry=" << toplevel->frameGeometry();
debug << ", resourceName=" << toplevel->resourceName();
debug << ", resourceClass=" << toplevel->resourceClass();
}
debug << ')';
} else {
debug << "AbstractClient(0x0)";
}
return debug;
}
void AbstractClient::detectShape(xcb_window_t id)
{
const bool wasShape = is_shape;
is_shape = Xcb::Extensions::self()->hasShape(id);
if (wasShape != is_shape) {
Q_EMIT shapedChanged();
}
}
// used only by Deleted::copy()
void AbstractClient::copyToDeleted(AbstractClient *c)
{
m_internalId = c->internalId();
m_bufferGeometry = c->m_bufferGeometry;
m_frameGeometry = c->m_frameGeometry;
m_clientGeometry = c->m_clientGeometry;
m_visual = c->m_visual;
bit_depth = c->bit_depth;
info = c->info;
m_client.reset(c->m_client, false);
ready_for_painting = c->ready_for_painting;
is_shape = c->is_shape;
effect_window = c->effect_window;
if (effect_window != nullptr) {
effect_window->setWindow(this);
}
m_shadow = c->m_shadow;
if (m_shadow) {
m_shadow->setToplevel(this);
}
resource_name = c->resourceName();
resource_class = c->resourceClass();
m_clientMachine = c->m_clientMachine;
m_clientMachine->setParent(this);
m_wmClientLeader = c->wmClientLeader();
opaque_region = c->opaqueRegion();
m_output = c->m_output;
m_skipCloseAnimation = c->m_skipCloseAnimation;
m_internalFBO = c->m_internalFBO;
m_internalImage = c->m_internalImage;
m_opacity = c->m_opacity;
m_shapeRegionIsValid = c->m_shapeRegionIsValid;
m_shapeRegion = c->m_shapeRegion;
m_stackingOrder = c->m_stackingOrder;
}
// before being deleted, remove references to everything that's now
// owner by Deleted
void AbstractClient::disownDataPassedToDeleted()
{
info = nullptr;
}
QRect AbstractClient::visibleGeometry() const
{
if (const WindowItem *item = windowItem()) {
return item->mapToGlobal(item->boundingRect());
}
return QRect();
}
Xcb::Property AbstractClient::fetchWmClientLeader() const
{
return Xcb::Property(false, window(), atoms->wm_client_leader, XCB_ATOM_WINDOW, 0, 10000);
}
void AbstractClient::readWmClientLeader(Xcb::Property &prop)
{
m_wmClientLeader = prop.value<xcb_window_t>(window());
}
void AbstractClient::getWmClientLeader()
{
auto prop = fetchWmClientLeader();
readWmClientLeader(prop);
}
/**
* Returns sessionId for this client,
* taken either from its window or from the leader window.
*/
QByteArray AbstractClient::sessionId() const
{
QByteArray result = Xcb::StringProperty(window(), atoms->sm_client_id);
if (result.isEmpty() && m_wmClientLeader && m_wmClientLeader != window()) {
result = Xcb::StringProperty(m_wmClientLeader, atoms->sm_client_id);
}
return result;
}
/**
* Returns command property for this client,
* taken either from its window or from the leader window.
*/
QByteArray AbstractClient::wmCommand()
{
QByteArray result = Xcb::StringProperty(window(), XCB_ATOM_WM_COMMAND);
if (result.isEmpty() && m_wmClientLeader && m_wmClientLeader != window()) {
result = Xcb::StringProperty(m_wmClientLeader, XCB_ATOM_WM_COMMAND);
}
result.replace(0, ' ');
return result;
}
void AbstractClient::getWmClientMachine()
{
m_clientMachine->resolve(window(), wmClientLeader());
}
/**
* Returns client machine for this client,
* taken either from its window or from the leader window.
*/
QByteArray AbstractClient::wmClientMachine(bool use_localhost) const
{
if (!m_clientMachine) {
// this should never happen
return QByteArray();
}
if (use_localhost && m_clientMachine->isLocal()) {
// special name for the local machine (localhost)
return ClientMachine::localhost();
}
return m_clientMachine->hostName();
}
/**
* Returns client leader window for this client.
* Returns the client window itself if no leader window is defined.
*/
xcb_window_t AbstractClient::wmClientLeader() const
{
if (m_wmClientLeader != XCB_WINDOW_NONE) {
return m_wmClientLeader;
}
return window();
}
void AbstractClient::getResourceClass()
{
if (!info) {
return;
}
setResourceClass(QByteArray(info->windowClassName()).toLower(), QByteArray(info->windowClassClass()).toLower());
}
void AbstractClient::setResourceClass(const QByteArray &name, const QByteArray &className)
{
resource_name = name;
resource_class = className;
Q_EMIT windowClassChanged();
}
bool AbstractClient::resourceMatch(const AbstractClient *c1, const AbstractClient *c2)
{
return c1->resourceClass() == c2->resourceClass();
}
qreal AbstractClient::opacity() const
{
return m_opacity;
}
void AbstractClient::setOpacity(qreal opacity)
{
opacity = qBound(0.0, opacity, 1.0);
if (m_opacity == opacity) {
return;
}
const qreal oldOpacity = m_opacity;
m_opacity = opacity;
if (Compositor::compositing()) {
addRepaintFull();
Q_EMIT opacityChanged(this, oldOpacity);
}
}
bool AbstractClient::setupCompositing()
{
if (!Compositor::compositing()) {
return false;
}
effect_window = new EffectWindowImpl(this);
updateShadow();
Compositor::self()->scene()->addToplevel(this);
connect(windowItem(), &WindowItem::positionChanged, this, &AbstractClient::visibleGeometryChanged);
connect(windowItem(), &WindowItem::boundingRectChanged, this, &AbstractClient::visibleGeometryChanged);
return true;
}
void AbstractClient::finishCompositing(ReleaseReason releaseReason)
{
// If the X11 window has been destroyed, avoid calling XDamageDestroy.
if (releaseReason != ReleaseReason::Destroyed) {
if (SurfaceItemX11 *item = qobject_cast<SurfaceItemX11 *>(surfaceItem())) {
item->destroyDamage();
}
}
if (m_shadow && m_shadow->toplevel() == this) { // otherwise it's already passed to Deleted, don't free data
deleteShadow();
}
if (effect_window && effect_window->window() == this) { // otherwise it's already passed to Deleted, don't free data
deleteEffectWindow();
}
}
void AbstractClient::addRepaint(const QRect &rect)
{
addRepaint(QRegion(rect));
}
void AbstractClient::addRepaint(int x, int y, int width, int height)
{
addRepaint(QRegion(x, y, width, height));
}
void AbstractClient::addRepaint(const QRegion &region)
{
if (auto item = windowItem()) {
item->scheduleRepaint(region);
}
}
void AbstractClient::addLayerRepaint(const QRect &rect)
{
addLayerRepaint(QRegion(rect));
}
void AbstractClient::addLayerRepaint(int x, int y, int width, int height)
{
addLayerRepaint(QRegion(x, y, width, height));
}
void AbstractClient::addLayerRepaint(const QRegion &region)
{
addRepaint(region.translated(-pos()));
}
void AbstractClient::addRepaintFull()
{
addLayerRepaint(visibleGeometry());
}
void AbstractClient::addWorkspaceRepaint(int x, int y, int w, int h)
{
addWorkspaceRepaint(QRect(x, y, w, h));
}
void AbstractClient::addWorkspaceRepaint(const QRect &r2)
{
if (Compositor::compositing()) {
Compositor::self()->scene()->addRepaint(r2);
}
}
void AbstractClient::addWorkspaceRepaint(const QRegion &region)
{
if (Compositor::compositing()) {
Compositor::self()->scene()->addRepaint(region);
}
}
void AbstractClient::setReadyForPainting()
{
if (!ready_for_painting) {
ready_for_painting = true;
if (Compositor::compositing()) {
addRepaintFull();
Q_EMIT windowShown(this);
}
}
}
void AbstractClient::deleteShadow()
{
delete m_shadow;
m_shadow = nullptr;
}
void AbstractClient::deleteEffectWindow()
{
delete effect_window;
effect_window = nullptr;
}
int AbstractClient::screen() const
{
return kwinApp()->platform()->enabledOutputs().indexOf(m_output);
}
Output *AbstractClient::output() const
{
return m_output;
}
void AbstractClient::setOutput(Output *output)
{
if (m_output != output) {
m_output = output;
Q_EMIT screenChanged();
}
}
bool AbstractClient::isOnActiveOutput() const
{
return isOnOutput(workspace()->activeOutput());
}
bool AbstractClient::isOnOutput(Output *output) const
{
return output->geometry().intersects(frameGeometry());
}
Shadow *AbstractClient::shadow() const
{
return m_shadow;
}
void AbstractClient::updateShadow()
{
if (!Compositor::compositing()) {
return;
}
if (m_shadow) {
if (!m_shadow->updateShadow()) {
deleteShadow();
}
Q_EMIT shadowChanged();
} else {
m_shadow = Shadow::createShadow(this);
if (m_shadow) {
Q_EMIT shadowChanged();
}
}
}
SurfaceItem *AbstractClient::surfaceItem() const
{
if (effectWindow() && effectWindow()->sceneWindow()) {
return effectWindow()->sceneWindow()->surfaceItem();
}
return nullptr;
}
WindowItem *AbstractClient::windowItem() const
{
if (effectWindow() && effectWindow()->sceneWindow()) {
return effectWindow()->sceneWindow()->windowItem();
}
return nullptr;
}
bool AbstractClient::wantsShadowToBeRendered() const
{
return !isFullScreen() && maximizeMode() != MaximizeFull;
}
void AbstractClient::getWmOpaqueRegion()
{
if (!info) {
return;
}
const auto rects = info->opaqueRegion();
QRegion new_opaque_region;
for (const auto &r : rects) {
new_opaque_region += QRect(r.pos.x, r.pos.y, r.size.width, r.size.height);
}
opaque_region = new_opaque_region;
}
QRegion AbstractClient::shapeRegion() const
{
if (m_shapeRegionIsValid) {
return m_shapeRegion;
}
const QRect bufferGeometry = this->bufferGeometry();
if (shape()) {
auto cookie = xcb_shape_get_rectangles_unchecked(kwinApp()->x11Connection(), frameId(), XCB_SHAPE_SK_BOUNDING);
ScopedCPointer<xcb_shape_get_rectangles_reply_t> reply(xcb_shape_get_rectangles_reply(kwinApp()->x11Connection(), cookie, nullptr));
if (!reply.isNull()) {
m_shapeRegion = QRegion();
const xcb_rectangle_t *rects = xcb_shape_get_rectangles_rectangles(reply.data());
const int rectCount = xcb_shape_get_rectangles_rectangles_length(reply.data());
for (int i = 0; i < rectCount; ++i) {
m_shapeRegion += QRegion(rects[i].x, rects[i].y, rects[i].width, rects[i].height);
}
// make sure the shape is sane (X is async, maybe even XShape is broken)
m_shapeRegion &= QRegion(0, 0, bufferGeometry.width(), bufferGeometry.height());
} else {
m_shapeRegion = QRegion();
}
} else {
m_shapeRegion = QRegion(0, 0, bufferGeometry.width(), bufferGeometry.height());
}
m_shapeRegionIsValid = true;
return m_shapeRegion;
}
void AbstractClient::discardShapeRegion()
{
m_shapeRegionIsValid = false;
m_shapeRegion = QRegion();
}
bool AbstractClient::isClient() const
{
return false;
}
bool AbstractClient::isDeleted() const
{
return false;
}
bool AbstractClient::isOnCurrentActivity() const
{
#if KWIN_BUILD_ACTIVITIES
if (!Activities::self()) {
return true;
}
return isOnActivity(Activities::self()->current());
#else
return true;
#endif
}
void AbstractClient::elevate(bool elevate)
{
if (!effectWindow()) {
return;
}
effectWindow()->elevate(elevate);
addWorkspaceRepaint(visibleGeometry());
}
pid_t AbstractClient::pid() const
{
if (!info) {
return -1;
}
return info->pid();
}
xcb_window_t AbstractClient::frameId() const
{
return m_client;
}
Xcb::Property AbstractClient::fetchSkipCloseAnimation() const
{
return Xcb::Property(false, window(), atoms->kde_skip_close_animation, XCB_ATOM_CARDINAL, 0, 1);
}
void AbstractClient::readSkipCloseAnimation(Xcb::Property &property)
{
setSkipCloseAnimation(property.toBool());
}
void AbstractClient::getSkipCloseAnimation()
{
Xcb::Property property = fetchSkipCloseAnimation();
readSkipCloseAnimation(property);
}
bool AbstractClient::skipsCloseAnimation() const
{
return m_skipCloseAnimation;
}
void AbstractClient::setSkipCloseAnimation(bool set)
{
if (set == m_skipCloseAnimation) {
return;
}
m_skipCloseAnimation = set;
Q_EMIT skipCloseAnimationChanged();
}
KWaylandServer::SurfaceInterface *AbstractClient::surface() const
{
return m_surface;
}
void AbstractClient::setSurface(KWaylandServer::SurfaceInterface *surface)
{
if (m_surface == surface) {
return;
}
m_surface = surface;
m_pendingSurfaceId = 0;
Q_EMIT surfaceChanged();
}
int AbstractClient::stackingOrder() const
{
return m_stackingOrder;
}
void AbstractClient::setStackingOrder(int order)
{
if (m_stackingOrder != order) {
m_stackingOrder = order;
Q_EMIT stackingOrderChanged();
}
}
QByteArray AbstractClient::windowRole() const
{
if (!info) {
return {};
}
return QByteArray(info->windowRole());
}
void AbstractClient::setDepth(int depth)
{
if (bit_depth == depth) {
return;
}
const bool oldAlpha = hasAlpha();
bit_depth = depth;
if (oldAlpha != hasAlpha()) {
Q_EMIT hasAlphaChanged();
}
}
QRegion AbstractClient::inputShape() const
{
if (m_surface) {
return m_surface->input();
} else {
// TODO: maybe also for X11?
return QRegion();
}
}
QMatrix4x4 AbstractClient::inputTransformation() const
{
QMatrix4x4 m;
m.translate(-x(), -y());
return m;
}
bool AbstractClient::hitTest(const QPoint &point) const
{
if (isDecorated()) {
if (m_decoration.inputRegion.contains(mapToFrame(point))) {
return true;
}
}
if (m_surface && m_surface->isMapped()) {
return m_surface->inputSurfaceAt(mapToLocal(point));
}
return inputGeometry().contains(point);
}
QPoint AbstractClient::mapToFrame(const QPoint &point) const
{
return point - frameGeometry().topLeft();
}
QPoint AbstractClient::mapToLocal(const QPoint &point) const
{
return point - bufferGeometry().topLeft();
}
QPointF AbstractClient::mapToLocal(const QPointF &point) const
{
return point - bufferGeometry().topLeft();
}
QPointF AbstractClient::mapFromLocal(const QPointF &point) const
{
return point + bufferGeometry().topLeft();
}
QRect AbstractClient::inputGeometry() const
{
if (isDecorated()) {
return frameGeometry() + decoration()->resizeOnlyBorders();
}
return frameGeometry();
}
bool AbstractClient::isLocalhost() const
{
if (!m_clientMachine) {
return true;
}
return m_clientMachine->isLocal();
}
QMargins AbstractClient::frameMargins() const
{
return QMargins(borderLeft(), borderTop(), borderRight(), borderBottom());
}
bool AbstractClient::isOnDesktop(VirtualDesktop *desktop) const
{
return isOnAllDesktops() || desktops().contains(desktop);
}
bool AbstractClient::isOnDesktop(int d) const
{
return isOnDesktop(VirtualDesktopManager::self()->desktopForX11Id(d));
}
bool AbstractClient::isOnCurrentDesktop() const
{
return isOnDesktop(VirtualDesktopManager::self()->currentDesktop());
}
void AbstractClient::updateMouseGrab()
@ -575,6 +1256,11 @@ int AbstractClient::desktop() const
return m_desktops.isEmpty() ? (int)NET::OnAllDesktops : m_desktops.last()->x11DesktopNumber();
}
QVector<VirtualDesktop *> AbstractClient::desktops() const
{
return m_desktops;
}
QVector<uint> AbstractClient::x11DesktopIds() const
{
const auto desks = desktops();
@ -2344,7 +3030,7 @@ void AbstractClient::setDecoration(QSharedPointer<KDecoration2::Decoration> deco
}
if (decoration) {
QMetaObject::invokeMethod(decoration.data(), QOverload<>::of(&KDecoration2::Decoration::update), Qt::QueuedConnection);
connect(decoration.data(), &KDecoration2::Decoration::shadowChanged, this, &Toplevel::updateShadow);
connect(decoration.data(), &KDecoration2::Decoration::shadowChanged, this, &AbstractClient::updateShadow);
connect(decoration.data(), &KDecoration2::Decoration::bordersChanged,
this, &AbstractClient::updateDecorationInputShape);
connect(decoration.data(), &KDecoration2::Decoration::resizeOnlyBordersChanged,
@ -2594,24 +3280,6 @@ QRect AbstractClient::iconGeometry() const
return candidateGeom.translated(candidatePanel->pos());
}
QRect AbstractClient::inputGeometry() const
{
if (isDecorated()) {
return Toplevel::inputGeometry() + decoration()->resizeOnlyBorders();
}
return Toplevel::inputGeometry();
}
bool AbstractClient::hitTest(const QPoint &point) const
{
if (isDecorated()) {
if (m_decoration.inputRegion.contains(mapToFrame(point))) {
return true;
}
}
return Toplevel::hitTest(point);
}
QRect AbstractClient::virtualKeyboardGeometry() const
{
return m_virtualKeyboardGeometry;
@ -2825,7 +3493,7 @@ void AbstractClient::evaluateWindowRules()
/**
* Returns the list of activities the client window is on.
* if it's on all activities, the list will be empty.
* Don't use this, use isOnActivity() and friends (from class Toplevel)
* Don't use this, use isOnActivity() and friends (from class AbstractClient)
*/
QStringList AbstractClient::activities() const
{
@ -2981,11 +3649,6 @@ bool AbstractClient::supportsWindowRules() const
return false;
}
QMargins AbstractClient::frameMargins() const
{
return QMargins(borderLeft(), borderTop(), borderRight(), borderBottom());
}
QPoint AbstractClient::framePosToClientPos(const QPoint &point) const
{
return point + QPoint(borderLeft(), borderTop());
@ -3820,11 +4483,6 @@ void AbstractClient::cleanTabBox()
#endif
}
bool AbstractClient::wantsShadowToBeRendered() const
{
return !isFullScreen() && maximizeMode() != MaximizeFull;
}
void AbstractClient::setupWindowRules(bool ignore_temporary)
{
disconnect(this, &AbstractClient::captionChanged, this, &AbstractClient::evaluateWindowRules);

File diff suppressed because it is too large Load diff

View file

@ -44,7 +44,7 @@ WindowSelector::~WindowSelector()
{
}
void WindowSelector::start(std::function<void(KWin::Toplevel *)> callback, const QByteArray &cursorName)
void WindowSelector::start(std::function<void(KWin::AbstractClient *)> callback, const QByteArray &cursorName)
{
if (m_active) {
callback(nullptr);
@ -215,7 +215,7 @@ void WindowSelector::release()
xcb_ungrab_pointer(connection(), XCB_TIME_CURRENT_TIME);
ungrabXServer();
m_active = false;
m_callback = std::function<void(KWin::Toplevel *)>();
m_callback = std::function<void(KWin::AbstractClient *)>();
m_pointSelectionFallback = std::function<void(const QPoint &)>();
}

View file

@ -22,7 +22,7 @@ class QPoint;
namespace KWin
{
class Toplevel;
class AbstractClient;
class WindowSelector : public X11EventFilter
{
@ -30,7 +30,7 @@ public:
WindowSelector();
~WindowSelector() override;
void start(std::function<void(KWin::Toplevel *)> callback, const QByteArray &cursorName);
void start(std::function<void(KWin::AbstractClient *)> callback, const QByteArray &cursorName);
void start(std::function<void(const QPoint &)> callback);
bool isActive() const
{
@ -50,7 +50,7 @@ private:
bool activate(const QByteArray &cursorName = QByteArray());
void cancelCallback();
bool m_active;
std::function<void(KWin::Toplevel *)> m_callback;
std::function<void(KWin::AbstractClient *)> m_callback;
std::function<void(const QPoint &)> m_pointSelectionFallback;
};

View file

@ -350,7 +350,7 @@ void X11StandalonePlatform::updateCursor()
}
}
void X11StandalonePlatform::startInteractiveWindowSelection(std::function<void(KWin::Toplevel *)> callback, const QByteArray &cursorName)
void X11StandalonePlatform::startInteractiveWindowSelection(std::function<void(KWin::AbstractClient *)> callback, const QByteArray &cursorName)
{
if (m_windowSelector.isNull()) {
m_windowSelector.reset(new WindowSelector);

View file

@ -46,7 +46,7 @@ public:
QString compositingNotPossibleReason() const override;
bool openGLCompositingIsBroken() const override;
void createOpenGLSafePoint(OpenGLSafePoint safePoint) override;
void startInteractiveWindowSelection(std::function<void(KWin::Toplevel *)> callback, const QByteArray &cursorName = QByteArray()) override;
void startInteractiveWindowSelection(std::function<void(KWin::AbstractClient *)> callback, const QByteArray &cursorName = QByteArray()) override;
void startInteractivePositionSelection(std::function<void(const QPoint &)> callback) override;
PlatformCursorImage cursorImage() const override;

View file

@ -905,12 +905,12 @@ void X11Compositor::composite(RenderLoop *renderLoop)
return;
}
QList<Toplevel *> windows = Workspace::self()->xStackingOrder();
QList<AbstractClient *> windows = Workspace::self()->xStackingOrder();
QList<SurfaceItemX11 *> dirtyItems;
// Reset the damage state of each window and fetch the damage region
// without waiting for a reply
for (Toplevel *window : qAsConst(windows)) {
for (AbstractClient *window : qAsConst(windows)) {
SurfaceItemX11 *surfaceItem = static_cast<SurfaceItemX11 *>(window->surfaceItem());
if (surfaceItem->fetchDamage()) {
dirtyItems.append(surfaceItem);

View file

@ -26,7 +26,7 @@ class RenderLayer;
class RenderLoop;
class RenderTarget;
class Scene;
class Toplevel;
class AbstractClient;
class X11Client;
class X11SyncManager;

View file

@ -234,7 +234,7 @@ QVariantMap DBusInterface::queryWindowInfo()
m_replyQueryWindowInfo = message();
setDelayedReply(true);
kwinApp()->platform()->startInteractiveWindowSelection(
[this](Toplevel *t) {
[this](AbstractClient *t) {
if (auto c = static_cast<AbstractClient *>(t->isClient() ? t : nullptr)) {
QDBusConnection::sessionBus().send(m_replyQueryWindowInfo.createReply(clientToVariantMap(c)));
} else if (qobject_cast<Unmanaged *>(t)) {

View file

@ -82,7 +82,7 @@ public Q_SLOTS: // METHODS
*
* The map includes entries such as position, size, status, and more.
*
* @param uuid is a QUuid from Toplevel::internalId().
* @param uuid is a QUuid from AbstractClient::internalId().
*/
QVariantMap getWindowInfo(const QString &uuid);

View file

@ -130,11 +130,11 @@ DecorationItem::DecorationItem(KDecoration2::Decoration *decoration, AbstractCli
{
m_renderer.reset(Compositor::self()->scene()->createDecorationRenderer(window->decoratedClient()));
connect(window, &Toplevel::frameGeometryChanged,
connect(window, &AbstractClient::frameGeometryChanged,
this, &DecorationItem::handleFrameGeometryChanged);
connect(window, &Toplevel::windowClosed,
connect(window, &AbstractClient::windowClosed,
this, &DecorationItem::handleWindowClosed);
connect(window, &Toplevel::screenChanged,
connect(window, &AbstractClient::screenChanged,
this, &DecorationItem::handleOutputChanged);
connect(decoration, &KDecoration2::Decoration::bordersChanged,
@ -184,7 +184,7 @@ void DecorationItem::handleFrameGeometryChanged()
setSize(m_window->size());
}
void DecorationItem::handleWindowClosed(Toplevel *original, Deleted *deleted)
void DecorationItem::handleWindowClosed(AbstractClient *original, Deleted *deleted)
{
Q_UNUSED(original)
m_window = deleted;

View file

@ -18,7 +18,6 @@ namespace KWin
class AbstractClient;
class Deleted;
class Toplevel;
namespace Decoration
{
@ -85,7 +84,7 @@ public:
private Q_SLOTS:
void handleFrameGeometryChanged();
void handleWindowClosed(Toplevel *original, Deleted *deleted);
void handleWindowClosed(AbstractClient *original, Deleted *deleted);
void handleOutputChanged();
void handleOutputScaleChanged();
@ -94,7 +93,7 @@ protected:
WindowQuadList buildQuads() const override;
private:
Toplevel *m_window;
AbstractClient *m_window;
QPointer<Output> m_output;
QPointer<KDecoration2::Decoration> m_decoration;
QScopedPointer<DecorationRenderer> m_renderer;

View file

@ -51,7 +51,7 @@ Deleted::~Deleted()
deleteShadow();
}
Deleted *Deleted::create(Toplevel *c)
Deleted *Deleted::create(AbstractClient *c)
{
Deleted *d = new Deleted();
d->copyToDeleted(c);
@ -66,10 +66,10 @@ void Deleted::discard()
delete this;
}
void Deleted::copyToDeleted(Toplevel *c)
void Deleted::copyToDeleted(AbstractClient *c)
{
Q_ASSERT(dynamic_cast<Deleted *>(c) == nullptr);
Toplevel::copyToDeleted(c);
AbstractClient::copyToDeleted(c);
m_frameMargins = c->frameMargins();
desk = c->desktop();
m_desktops = c->desktops();
@ -171,7 +171,7 @@ NET::WindowType Deleted::windowType(bool direct, int supportedTypes) const
return m_type;
}
void Deleted::mainClientClosed(Toplevel *client)
void Deleted::mainClientClosed(AbstractClient *client)
{
if (AbstractClient *c = dynamic_cast<AbstractClient *>(client)) {
m_mainClients.removeAll(c);

View file

@ -20,7 +20,7 @@ class KWIN_EXPORT Deleted : public AbstractClient
Q_OBJECT
public:
static Deleted *create(Toplevel *c);
static Deleted *create(AbstractClient *c);
// used by effects to keep the window around for e.g. fadeout effects when it's destroyed
void refWindow();
void unrefWindow();
@ -126,11 +126,11 @@ public:
}
private Q_SLOTS:
void mainClientClosed(KWin::Toplevel *client);
void mainClientClosed(KWin::AbstractClient *client);
private:
Deleted(); // use create()
void copyToDeleted(Toplevel *c);
void copyToDeleted(AbstractClient *c);
~Deleted() override; // deleted only using unrefWindow()
QMargins m_frameMargins;

View file

@ -168,12 +168,12 @@ EffectsHandlerImpl::EffectsHandlerImpl(Compositor *compositor, Scene *scene)
if (c->readyForPainting()) {
slotClientShown(c);
} else {
connect(c, &Toplevel::windowShown, this, &EffectsHandlerImpl::slotClientShown);
connect(c, &AbstractClient::windowShown, this, &EffectsHandlerImpl::slotClientShown);
}
});
connect(ws, &Workspace::unmanagedAdded, this, [this](Unmanaged *u) {
// it's never initially ready but has synthetic 50ms delay
connect(u, &Toplevel::windowShown, this, &EffectsHandlerImpl::slotUnmanagedShown);
connect(u, &AbstractClient::windowShown, this, &EffectsHandlerImpl::slotUnmanagedShown);
});
connect(ws, &Workspace::internalClientAdded, this, [this](InternalClient *client) {
setupClientConnections(client);
@ -240,7 +240,7 @@ EffectsHandlerImpl::EffectsHandlerImpl(Compositor *compositor, Scene *scene)
if (client->readyForPainting()) {
setupClientConnections(client);
} else {
connect(client, &Toplevel::windowShown, this, &EffectsHandlerImpl::slotClientShown);
connect(client, &AbstractClient::windowShown, this, &EffectsHandlerImpl::slotClientShown);
}
}
for (Unmanaged *u : ws->unmanagedList()) {
@ -314,10 +314,10 @@ void EffectsHandlerImpl::setupClientConnections(AbstractClient *c)
connect(c, &AbstractClient::unresponsiveChanged, this, [this, c](bool unresponsive) {
Q_EMIT windowUnresponsiveChanged(c->effectWindow(), unresponsive);
});
connect(c, &AbstractClient::windowShown, this, [this](Toplevel *c) {
connect(c, &AbstractClient::windowShown, this, [this](AbstractClient *c) {
Q_EMIT windowShown(c->effectWindow());
});
connect(c, &AbstractClient::windowHidden, this, [this](Toplevel *c) {
connect(c, &AbstractClient::windowHidden, this, [this](AbstractClient *c) {
Q_EMIT windowHidden(c->effectWindow());
});
connect(c, &AbstractClient::keepAboveChanged, this, [this, c](bool above) {
@ -511,7 +511,7 @@ void EffectsHandlerImpl::slotClientMaximized(KWin::AbstractClient *c, MaximizeMo
}
}
void EffectsHandlerImpl::slotOpacityChanged(Toplevel *t, qreal oldOpacity)
void EffectsHandlerImpl::slotOpacityChanged(AbstractClient *t, qreal oldOpacity)
{
if (t->opacity() == oldOpacity || !t->effectWindow()) {
return;
@ -519,16 +519,16 @@ void EffectsHandlerImpl::slotOpacityChanged(Toplevel *t, qreal oldOpacity)
Q_EMIT windowOpacityChanged(t->effectWindow(), oldOpacity, (qreal)t->opacity());
}
void EffectsHandlerImpl::slotClientShown(KWin::Toplevel *t)
void EffectsHandlerImpl::slotClientShown(KWin::AbstractClient *t)
{
Q_ASSERT(t->isClient());
auto c = static_cast<AbstractClient *>(t->isClient() ? t : nullptr);
disconnect(c, &Toplevel::windowShown, this, &EffectsHandlerImpl::slotClientShown);
disconnect(c, &AbstractClient::windowShown, this, &EffectsHandlerImpl::slotClientShown);
setupClientConnections(c);
Q_EMIT windowAdded(c->effectWindow());
}
void EffectsHandlerImpl::slotUnmanagedShown(KWin::Toplevel *t)
void EffectsHandlerImpl::slotUnmanagedShown(KWin::AbstractClient *t)
{ // regardless, unmanaged windows are -yet?- not synced anyway
Q_ASSERT(qobject_cast<Unmanaged *>(t));
Unmanaged *u = static_cast<Unmanaged *>(t);
@ -536,7 +536,7 @@ void EffectsHandlerImpl::slotUnmanagedShown(KWin::Toplevel *t)
Q_EMIT windowAdded(u->effectWindow());
}
void EffectsHandlerImpl::slotWindowClosed(KWin::Toplevel *c, KWin::Deleted *d)
void EffectsHandlerImpl::slotWindowClosed(KWin::AbstractClient *c, KWin::Deleted *d)
{
c->disconnect(this);
if (d) {
@ -564,7 +564,7 @@ void EffectsHandlerImpl::slotTabRemoved(EffectWindow *w, EffectWindow *leaderOfF
Q_EMIT tabRemoved(w, leaderOfFormerGroup);
}
void EffectsHandlerImpl::slotWindowDamaged(Toplevel *t, const QRegion &r)
void EffectsHandlerImpl::slotWindowDamaged(AbstractClient *t, const QRegion &r)
{
if (!t->effectWindow()) {
// can happen during tear down of window
@ -573,7 +573,7 @@ void EffectsHandlerImpl::slotWindowDamaged(Toplevel *t, const QRegion &r)
Q_EMIT windowDamaged(t->effectWindow(), r);
}
void EffectsHandlerImpl::slotGeometryShapeChanged(Toplevel *t, const QRect &old)
void EffectsHandlerImpl::slotGeometryShapeChanged(AbstractClient *t, const QRect &old)
{
// during late cleanup effectWindow() may be already NULL
// in some functions that may still call this
@ -583,7 +583,7 @@ void EffectsHandlerImpl::slotGeometryShapeChanged(Toplevel *t, const QRect &old)
Q_EMIT windowGeometryShapeChanged(t->effectWindow(), old);
}
void EffectsHandlerImpl::slotFrameGeometryChanged(Toplevel *toplevel, const QRect &oldGeometry)
void EffectsHandlerImpl::slotFrameGeometryChanged(AbstractClient *toplevel, const QRect &oldGeometry)
{
// effectWindow() might be nullptr during tear down of the client.
if (toplevel->effectWindow()) {
@ -1122,7 +1122,7 @@ EffectWindow *EffectsHandlerImpl::findWindow(KWaylandServer::SurfaceInterface *s
EffectWindow *EffectsHandlerImpl::findWindow(QWindow *w) const
{
if (Toplevel *toplevel = workspace()->findInternal(w)) {
if (AbstractClient *toplevel = workspace()->findInternal(w)) {
return toplevel->effectWindow();
}
return nullptr;
@ -1145,9 +1145,9 @@ EffectWindow *EffectsHandlerImpl::findWindow(const QUuid &id) const
EffectWindowList EffectsHandlerImpl::stackingOrder() const
{
QList<Toplevel *> list = Workspace::self()->xStackingOrder();
QList<AbstractClient *> list = Workspace::self()->xStackingOrder();
EffectWindowList ret;
for (Toplevel *t : list) {
for (AbstractClient *t : list) {
if (EffectWindow *w = effectWindow(t)) {
ret.append(w);
}
@ -1292,7 +1292,7 @@ QRect EffectsHandlerImpl::clientArea(clientAreaOption opt, const EffectScreen *s
QRect EffectsHandlerImpl::clientArea(clientAreaOption opt, const EffectWindow *c) const
{
const Toplevel *t = static_cast<const EffectWindowImpl *>(c)->window();
const AbstractClient *t = static_cast<const EffectWindowImpl *>(c)->window();
return Workspace::self()->clientArea(opt, t);
}
@ -1705,7 +1705,7 @@ void EffectsHandlerImpl::showCursor()
void EffectsHandlerImpl::startInteractiveWindowSelection(std::function<void(KWin::EffectWindow *)> callback)
{
kwinApp()->platform()->startInteractiveWindowSelection([callback](KWin::Toplevel *t) {
kwinApp()->platform()->startInteractiveWindowSelection([callback](KWin::AbstractClient *t) {
if (t && t->effectWindow()) {
callback(t->effectWindow());
} else {
@ -1923,7 +1923,7 @@ EffectScreen::Transform EffectScreenImpl::transform() const
// EffectWindowImpl
//****************************************
EffectWindowImpl::EffectWindowImpl(Toplevel *toplevel)
EffectWindowImpl::EffectWindowImpl(AbstractClient *toplevel)
: EffectWindow(toplevel)
, toplevel(toplevel)
, sw(nullptr)
@ -2134,7 +2134,7 @@ QSize EffectWindowImpl::basicUnit() const
return QSize(1, 1);
}
void EffectWindowImpl::setWindow(Toplevel *w)
void EffectWindowImpl::setWindow(AbstractClient *w)
{
toplevel = w;
setParent(w);
@ -2256,7 +2256,7 @@ QVariant EffectWindowImpl::data(int role) const
return dataMap.value(role);
}
EffectWindow *effectWindow(Toplevel *w)
EffectWindow *effectWindow(AbstractClient *w)
{
EffectWindowImpl *ret = w->effectWindow();
return ret;

View file

@ -43,7 +43,6 @@ class Compositor;
class Deleted;
class EffectLoader;
class Group;
class Toplevel;
class Unmanaged;
class WindowPropertyNotifyX11Filter;
class TabletEvent;
@ -303,15 +302,15 @@ public Q_SLOTS:
Q_SCRIPTABLE QString debug(const QString &name, const QString &parameter = QString()) const;
protected Q_SLOTS:
void slotClientShown(KWin::Toplevel *);
void slotUnmanagedShown(KWin::Toplevel *);
void slotWindowClosed(KWin::Toplevel *c, KWin::Deleted *d);
void slotClientShown(KWin::AbstractClient *);
void slotUnmanagedShown(KWin::AbstractClient *);
void slotWindowClosed(KWin::AbstractClient *c, KWin::Deleted *d);
void slotClientMaximized(KWin::AbstractClient *c, MaximizeMode maxMode);
void slotOpacityChanged(KWin::Toplevel *t, qreal oldOpacity);
void slotOpacityChanged(KWin::AbstractClient *t, qreal oldOpacity);
void slotClientModalityChanged();
void slotGeometryShapeChanged(KWin::Toplevel *t, const QRect &old);
void slotFrameGeometryChanged(Toplevel *toplevel, const QRect &oldGeometry);
void slotWindowDamaged(KWin::Toplevel *t, const QRegion &r);
void slotGeometryShapeChanged(KWin::AbstractClient *t, const QRect &old);
void slotFrameGeometryChanged(AbstractClient *toplevel, const QRect &oldGeometry);
void slotWindowDamaged(KWin::AbstractClient *t, const QRegion &r);
void slotOutputEnabled(Output *output);
void slotOutputDisabled(Output *output);
@ -403,7 +402,7 @@ class EffectWindowImpl : public EffectWindow
{
Q_OBJECT
public:
explicit EffectWindowImpl(Toplevel *toplevel);
explicit EffectWindowImpl(AbstractClient *toplevel);
~EffectWindowImpl() override;
void enablePainting(int reason) override;
@ -520,10 +519,10 @@ public:
QWindow *internalWindow() const override;
const Toplevel *window() const;
Toplevel *window();
const AbstractClient *window() const;
AbstractClient *window();
void setWindow(Toplevel *w); // internal
void setWindow(AbstractClient *w); // internal
void setSceneWindow(Scene::Window *w); // internal
const Scene::Window *sceneWindow() const; // internal
Scene::Window *sceneWindow(); // internal
@ -534,7 +533,7 @@ public:
QVariant data(int role) const override;
private:
Toplevel *toplevel;
AbstractClient *toplevel;
Scene::Window *sw; // This one is used only during paint pass.
QHash<int, QVariant> dataMap;
bool managed = false;
@ -667,7 +666,7 @@ inline EffectWindowGroupImpl::EffectWindowGroupImpl(Group *g)
{
}
EffectWindow *effectWindow(Toplevel *w);
EffectWindow *effectWindow(AbstractClient *w);
EffectWindow *effectWindow(Scene::Window *w);
inline const Scene::Window *EffectWindowImpl::sceneWindow() const
@ -680,12 +679,12 @@ inline Scene::Window *EffectWindowImpl::sceneWindow()
return sw;
}
inline const Toplevel *EffectWindowImpl::window() const
inline const AbstractClient *EffectWindowImpl::window() const
{
return toplevel;
}
inline Toplevel *EffectWindowImpl::window()
inline AbstractClient *EffectWindowImpl::window()
{
return toplevel;
}

View file

@ -587,7 +587,7 @@ void X11Client::destroyNotifyEvent(xcb_destroy_notify_event_t *e)
*/
void X11Client::clientMessageEvent(xcb_client_message_event_t *e)
{
Toplevel::clientMessageEvent(e);
AbstractClient::clientMessageEvent(e);
if (e->window != window()) {
return; // ignore frame/wrapper
}
@ -651,7 +651,7 @@ void X11Client::configureRequestEvent(xcb_configure_request_event_t *e)
*/
void X11Client::propertyNotifyEvent(xcb_property_notify_event_t *e)
{
Toplevel::propertyNotifyEvent(e);
AbstractClient::propertyNotifyEvent(e);
if (e->window != window()) {
return; // ignore frame/wrapper
}
@ -1315,10 +1315,10 @@ void Unmanaged::configureNotifyEvent(xcb_configure_notify_event_t *e)
}
// ****************************************
// Toplevel
// AbstractClient
// ****************************************
void Toplevel::propertyNotifyEvent(xcb_property_notify_event_t *e)
void AbstractClient::propertyNotifyEvent(xcb_property_notify_event_t *e)
{
if (e->window != window()) {
return; // ignore frame/wrapper
@ -1336,7 +1336,7 @@ void Toplevel::propertyNotifyEvent(xcb_property_notify_event_t *e)
}
}
void Toplevel::clientMessageEvent(xcb_client_message_event_t *e)
void AbstractClient::clientMessageEvent(xcb_client_message_event_t *e)
{
if (e->type == atoms->wl_surface_id) {
m_pendingSurfaceId = e->data.data32[0];

View file

@ -542,7 +542,7 @@ private:
bool surfaceAllowed(KWaylandServer::SurfaceInterface *(KWaylandServer::SeatInterface::*method)() const) const
{
if (KWaylandServer::SurfaceInterface *s = (waylandServer()->seat()->*method)()) {
if (Toplevel *t = waylandServer()->findClient(s)) {
if (AbstractClient *t = waylandServer()->findClient(s)) {
return t->isLockScreen() || t->isInputMethod();
}
return false;
@ -882,7 +882,7 @@ public:
{
return m_active;
}
void start(std::function<void(KWin::Toplevel *)> callback)
void start(std::function<void(KWin::AbstractClient *)> callback)
{
Q_ASSERT(!m_active);
m_active = true;
@ -903,7 +903,7 @@ private:
void deactivate()
{
m_active = false;
m_callback = std::function<void(KWin::Toplevel *)>();
m_callback = std::function<void(KWin::AbstractClient *)>();
m_pointSelectionFallback = std::function<void(const QPoint &)>();
input()->pointer()->removeWindowSelectionCursor();
input()->keyboard()->update();
@ -935,7 +935,7 @@ private:
accept(pos.toPoint());
}
bool m_active = false;
std::function<void(KWin::Toplevel *)> m_callback;
std::function<void(KWin::AbstractClient *)> m_callback;
std::function<void(const QPoint &)> m_pointSelectionFallback;
QMap<quint32, QPointF> m_touchPoints;
};
@ -2181,7 +2181,7 @@ public:
// may still happen (e.g. Release or ProximityOut events)
auto tablet = static_cast<KWaylandServer::TabletV2Interface *>(event->tabletId().m_deviceGroupData);
Toplevel *toplevel = input()->findToplevel(event->globalPos());
AbstractClient *toplevel = input()->findToplevel(event->globalPos());
if (!toplevel || !toplevel->surface()) {
return false;
}
@ -2274,7 +2274,7 @@ public:
KWaylandServer::TabletPadV2Interface *findAndAdoptPad(const TabletPadId &tabletPadId) const
{
Toplevel *toplevel = workspace()->activeClient();
AbstractClient *toplevel = workspace()->activeClient();
auto seat = findTabletSeat();
if (!toplevel || !toplevel->surface() || !seat->isClientSupported(toplevel->surface()->client())) {
return nullptr;
@ -2335,7 +2335,7 @@ public:
QHash<KWaylandServer::TabletToolV2Interface *, Cursor *> m_cursorByTool;
};
static KWaylandServer::AbstractDropHandler *dropHandler(Toplevel *toplevel)
static KWaylandServer::AbstractDropHandler *dropHandler(AbstractClient *toplevel)
{
auto surface = toplevel->surface();
if (!surface) {
@ -2383,7 +2383,7 @@ public:
const auto eventPos = event->globalPos();
// TODO: use InputDeviceHandler::at() here and check isClient()?
Toplevel *t = input()->findManagedToplevel(eventPos);
AbstractClient *t = input()->findManagedToplevel(eventPos);
const auto dragTarget = static_cast<AbstractClient *>(t && t->isClient() ? t : nullptr);
if (dragTarget) {
if (dragTarget != m_dragTarget) {
@ -2474,7 +2474,7 @@ public:
seat->setTimestamp(time);
seat->notifyTouchMotion(id, pos);
if (Toplevel *t = input()->findToplevel(pos.toPoint())) {
if (AbstractClient *t = input()->findToplevel(pos.toPoint())) {
// TODO: consider decorations
if (t->surface() != seat->dragSurface()) {
if ((m_dragTarget = static_cast<AbstractClient *>(t->isClient() ? t : nullptr))) {
@ -3076,7 +3076,7 @@ Qt::MouseButtons InputRedirection::qtButtonStates() const
return m_pointer->buttons();
}
Toplevel *InputRedirection::findToplevel(const QPoint &pos)
AbstractClient *InputRedirection::findToplevel(const QPoint &pos)
{
if (!Workspace::self()) {
return nullptr;
@ -3098,20 +3098,20 @@ Toplevel *InputRedirection::findToplevel(const QPoint &pos)
return findManagedToplevel(pos);
}
Toplevel *InputRedirection::findManagedToplevel(const QPoint &pos)
AbstractClient *InputRedirection::findManagedToplevel(const QPoint &pos)
{
if (!Workspace::self()) {
return nullptr;
}
const bool isScreenLocked = waylandServer() && waylandServer()->isScreenLocked();
const QList<Toplevel *> &stacking = Workspace::self()->stackingOrder();
const QList<AbstractClient *> &stacking = Workspace::self()->stackingOrder();
if (stacking.isEmpty()) {
return nullptr;
}
auto it = stacking.end();
do {
--it;
Toplevel *t = (*it);
AbstractClient *t = (*it);
if (t->isDeleted()) {
// a deleted window doesn't get mouse events
continue;
@ -3207,7 +3207,7 @@ QPointF InputRedirection::globalPointer() const
return m_pointer->pos();
}
void InputRedirection::startInteractiveWindowSelection(std::function<void(KWin::Toplevel *)> callback, const QByteArray &cursorName)
void InputRedirection::startInteractiveWindowSelection(std::function<void(KWin::AbstractClient *)> callback, const QByteArray &cursorName)
{
if (!m_windowSelector || m_windowSelector->isActive()) {
callback(nullptr);
@ -3246,7 +3246,7 @@ void InputDeviceHandler::init()
connect(VirtualDesktopManager::self(), &VirtualDesktopManager::currentChanged, this, &InputDeviceHandler::update);
}
bool InputDeviceHandler::setHover(Toplevel *toplevel)
bool InputDeviceHandler::setHover(AbstractClient *toplevel)
{
if (m_hover.window == toplevel) {
return false;
@ -3259,10 +3259,10 @@ bool InputDeviceHandler::setHover(Toplevel *toplevel)
return true;
}
void InputDeviceHandler::setFocus(Toplevel *toplevel)
void InputDeviceHandler::setFocus(AbstractClient *toplevel)
{
if (m_focus.window != toplevel) {
Toplevel *oldFocus = m_focus.window;
AbstractClient *oldFocus = m_focus.window;
m_focus.window = toplevel;
focusUpdate(oldFocus, m_focus.window);
}
@ -3280,7 +3280,7 @@ void InputDeviceHandler::setDecoration(Decoration::DecoratedClientImpl *decorati
void InputDeviceHandler::updateFocus()
{
Toplevel *focus = m_hover.window;
AbstractClient *focus = m_hover.window;
if (m_focus.decoration) {
focus = nullptr;
@ -3288,7 +3288,7 @@ void InputDeviceHandler::updateFocus()
// The surface has not yet been created (special XWayland case).
// Therefore listen for its creation.
if (!m_hover.surfaceCreatedConnection) {
m_hover.surfaceCreatedConnection = connect(m_hover.window, &Toplevel::surfaceChanged,
m_hover.surfaceCreatedConnection = connect(m_hover.window, &AbstractClient::surfaceChanged,
this, &InputDeviceHandler::update);
}
focus = nullptr;
@ -3318,7 +3318,7 @@ void InputDeviceHandler::update()
return;
}
Toplevel *toplevel = nullptr;
AbstractClient *toplevel = nullptr;
if (positionValid()) {
toplevel = input()->findToplevel(position().toPoint());
}
@ -3336,12 +3336,12 @@ void InputDeviceHandler::update()
workspace()->updateFocusMousePosition(position().toPoint());
}
Toplevel *InputDeviceHandler::hover() const
AbstractClient *InputDeviceHandler::hover() const
{
return m_hover.window.data();
}
Toplevel *InputDeviceHandler::focus() const
AbstractClient *InputDeviceHandler::focus() const
{
return m_focus.window.data();
}

View file

@ -32,8 +32,8 @@ class QWheelEvent;
namespace KWin
{
class AbstractClient;
class GlobalShortcutsManager;
class Toplevel;
class InputEventFilter;
class InputEventSpy;
class KeyboardInputRedirection;
@ -165,8 +165,8 @@ public:
*/
void uninstallInputEventSpy(InputEventSpy *spy);
Toplevel *findToplevel(const QPoint &pos);
Toplevel *findManagedToplevel(const QPoint &pos);
AbstractClient *findToplevel(const QPoint &pos);
AbstractClient *findManagedToplevel(const QPoint &pos);
GlobalShortcutsManager *shortcuts() const
{
return m_shortcuts;
@ -241,7 +241,7 @@ public:
bool hasTouch() const;
bool hasTabletModeSwitch();
void startInteractiveWindowSelection(std::function<void(KWin::Toplevel *)> callback, const QByteArray &cursorName);
void startInteractiveWindowSelection(std::function<void(KWin::AbstractClient *)> callback, const QByteArray &cursorName);
void startInteractivePositionSelection(std::function<void(const QPoint &)> callback);
bool isSelectingWindow() const;
@ -439,21 +439,21 @@ public:
void update();
/**
* @brief First Toplevel currently at the position of the input device
* @brief First AbstractClient currently at the position of the input device
* according to the stacking order.
* @return Toplevel* at device position.
* @return AbstractClient* at device position.
*
* This will be null if no toplevel is at the position
*/
Toplevel *hover() const;
AbstractClient *hover() const;
/**
* @brief Toplevel currently having pointer input focus (this might
* be different from the Toplevel at the position of the pointer).
* @return Toplevel* with pointer focus.
* @brief AbstractClient currently having pointer input focus (this might
* be different from the AbstractClient at the position of the pointer).
* @return AbstractClient* with pointer focus.
*
* This will be null if no toplevel has focus
*/
Toplevel *focus() const;
AbstractClient *focus() const;
/**
* @brief The Decoration currently receiving events.
@ -463,7 +463,7 @@ public:
virtual QPointF position() const = 0;
void setFocus(Toplevel *toplevel);
void setFocus(AbstractClient *toplevel);
void setDecoration(Decoration::DecoratedClientImpl *decoration);
Q_SIGNALS:
@ -474,7 +474,7 @@ protected:
virtual void cleanupDecoration(Decoration::DecoratedClientImpl *old, Decoration::DecoratedClientImpl *now) = 0;
virtual void focusUpdate(Toplevel *old, Toplevel *now) = 0;
virtual void focusUpdate(AbstractClient *old, AbstractClient *now) = 0;
/**
* Certain input devices can be in a state of having no valid
@ -500,19 +500,19 @@ protected:
}
private:
bool setHover(Toplevel *toplevel);
bool setHover(AbstractClient *toplevel);
void updateFocus();
void updateDecoration();
struct
{
QPointer<Toplevel> window;
QPointer<AbstractClient> window;
QMetaObject::Connection surfaceCreatedConnection;
} m_hover;
struct
{
QPointer<Toplevel> window;
QPointer<AbstractClient> window;
QPointer<Decoration::DecoratedClientImpl> decoration;
} m_focus;

View file

@ -17,7 +17,7 @@
#include "keyboard_layout.h"
#include "keyboard_repeat.h"
#include "modifier_only_shortcuts.h"
#include "toplevel.h"
#include "abstract_client.h"
#include "utils/common.h"
#include "wayland_server.h"
#include "workspace.h"
@ -141,7 +141,7 @@ void KeyboardInputRedirection::init()
connect(workspace(), &Workspace::clientActivated, this, [this] {
disconnect(m_activeClientSurfaceChangedConnection);
if (auto c = workspace()->activeClient()) {
m_activeClientSurfaceChangedConnection = connect(c, &Toplevel::surfaceChanged, this, &KeyboardInputRedirection::update);
m_activeClientSurfaceChangedConnection = connect(c, &AbstractClient::surfaceChanged, this, &KeyboardInputRedirection::update);
} else {
m_activeClientSurfaceChangedConnection = QMetaObject::Connection();
}
@ -178,14 +178,14 @@ void KeyboardInputRedirection::update()
}
auto seat = waylandServer()->seat();
// TODO: this needs better integration
Toplevel *found = nullptr;
AbstractClient *found = nullptr;
if (waylandServer()->isScreenLocked()) {
const QList<Toplevel *> &stacking = Workspace::self()->stackingOrder();
const QList<AbstractClient *> &stacking = Workspace::self()->stackingOrder();
if (!stacking.isEmpty()) {
auto it = stacking.end();
do {
--it;
Toplevel *t = (*it);
AbstractClient *t = (*it);
if (t->isDeleted()) {
// a deleted window doesn't get mouse events
continue;

View file

@ -32,11 +32,11 @@ typedef uint32_t xkb_layout_index_t;
namespace KWin
{
class AbstractClient;
class InputDevice;
class InputRedirection;
class KeyboardLayout;
class ModifiersChangedSpy;
class Toplevel;
class KWIN_EXPORT KeyboardInputRedirection : public QObject
{

View file

@ -33,7 +33,7 @@ void KillWindow::start()
OSD::show(i18n("Select window to force close with left click or enter.\nEscape or right click to cancel."),
QStringLiteral("window-close"));
kwinApp()->platform()->startInteractiveWindowSelection(
[](KWin::Toplevel *t) {
[](KWin::AbstractClient *t) {
OSD::hide();
if (!t) {
return;

View file

@ -102,7 +102,7 @@ void Workspace::updateStackingOrder(bool propagate_new_clients)
}
return;
}
QList<Toplevel *> new_stacking_order = constrainedStackingOrder();
QList<AbstractClient *> new_stacking_order = constrainedStackingOrder();
bool changed = (force_restacking || new_stacking_order != stacking_order);
force_restacking = false;
stacking_order = new_stacking_order;
@ -230,7 +230,7 @@ void Workspace::propagateClients(bool propagate_new_clients)
AbstractClient *Workspace::topClientOnDesktop(VirtualDesktop *desktop, Output *output, bool unconstrained, bool only_normal) const
{
// TODO Q_ASSERT( block_stacking_updates == 0 );
QList<Toplevel *> list;
QList<AbstractClient *> list;
if (!unconstrained) {
list = stacking_order;
} else {
@ -269,7 +269,7 @@ AbstractClient *Workspace::findDesktop(bool topmost, VirtualDesktop *desktop) co
}
}
} else { // bottom-most
for (Toplevel *c : qAsConst(stacking_order)) {
for (AbstractClient *c : qAsConst(stacking_order)) {
auto client = static_cast<AbstractClient *>(c->isClient() ? c : nullptr);
if (client && c->isOnDesktop(desktop) && c->isDesktop() && client->isShown()) {
return client;
@ -514,7 +514,7 @@ static Layer layerForClient(const X11Client *client)
return layer;
}
static Layer computeLayer(const Toplevel *toplevel)
static Layer computeLayer(const AbstractClient *toplevel)
{
if (auto client = qobject_cast<const X11Client *>(toplevel)) {
return layerForClient(client);
@ -526,17 +526,17 @@ static Layer computeLayer(const Toplevel *toplevel)
/**
* Returns a stacking order based upon \a list that fulfills certain contained.
*/
QList<Toplevel *> Workspace::constrainedStackingOrder()
QList<AbstractClient *> Workspace::constrainedStackingOrder()
{
// Sort the windows based on their layers while preserving their relative order in the
// unconstrained stacking order.
std::array<QList<Toplevel *>, NumLayers> windows;
for (Toplevel *window : qAsConst(unconstrained_stacking_order)) {
std::array<QList<AbstractClient *>, NumLayers> windows;
for (AbstractClient *window : qAsConst(unconstrained_stacking_order)) {
const Layer layer = computeLayer(window);
windows[layer] << window;
}
QList<Toplevel *> stacking;
QList<AbstractClient *> stacking;
stacking.reserve(unconstrained_stacking_order.count());
for (uint layer = FirstLayer; layer < NumLayers; ++layer) {
stacking += windows[layer];
@ -600,9 +600,9 @@ void Workspace::blockStackingUpdates(bool block)
namespace
{
template<class T>
QList<T *> ensureStackingOrderInList(const QList<Toplevel *> &stackingOrder, const QList<T *> &list)
QList<T *> ensureStackingOrderInList(const QList<AbstractClient *> &stackingOrder, const QList<T *> &list)
{
static_assert(std::is_base_of<Toplevel, T>::value,
static_assert(std::is_base_of<AbstractClient, T>::value,
"U must be derived from T");
// TODO Q_ASSERT( block_stacking_updates == 0 );
if (list.count() < 2) {
@ -635,7 +635,7 @@ QList<AbstractClient *> Workspace::ensureStackingOrder(const QList<AbstractClien
}
// Returns all windows in their stacking order on the root window.
QList<Toplevel *> Workspace::xStackingOrder() const
QList<AbstractClient *> Workspace::xStackingOrder() const
{
if (m_xStackingDirty) {
const_cast<Workspace *>(this)->updateXStackingOrder();
@ -643,7 +643,7 @@ QList<Toplevel *> Workspace::xStackingOrder() const
return x_stacking;
}
QList<Toplevel *> Workspace::unconstrainedStackingOrder() const
QList<AbstractClient *> Workspace::unconstrainedStackingOrder() const
{
return unconstrained_stacking_order;
}

View file

@ -1166,7 +1166,7 @@ public:
*/
Q_SCRIPTABLE virtual KWin::EffectWindow *findWindow(QWindow *w) const = 0;
/**
* Finds the EffectWindow for the Toplevel with KWin internal @p id.
* Finds the EffectWindow for the AbstractClient with KWin internal @p id.
* If there is no such window @c null is returned.
*
* @since 5.16
@ -2421,7 +2421,7 @@ public:
/**
* Returns the geometry of the pixmap or buffer attached to this window.
*
* For X11 clients, this method returns server-side geometry of the Toplevel.
* For X11 clients, this method returns server-side geometry of the AbstractClient.
*
* For Wayland clients, this method returns rectangle that the main surface
* occupies on the screen, in global screen coordinates.

View file

@ -635,7 +635,7 @@ void Placement::cascadeDesktop()
const int desktop = VirtualDesktopManager::self()->current();
reinitCascading(desktop);
const auto stackingOrder = ws->stackingOrder();
for (Toplevel *toplevel : stackingOrder) {
for (AbstractClient *toplevel : stackingOrder) {
auto client = static_cast<AbstractClient *>(toplevel->isClient() ? toplevel : nullptr);
if (!client || (!client->isOnCurrentDesktop()) || (client->isMinimized()) || (client->isOnAllDesktops()) || (!client->isMovable())) {
continue;

View file

@ -302,7 +302,7 @@ void Platform::createOpenGLSafePoint(OpenGLSafePoint safePoint)
Q_UNUSED(safePoint)
}
void Platform::startInteractiveWindowSelection(std::function<void(KWin::Toplevel *)> callback, const QByteArray &cursorName)
void Platform::startInteractiveWindowSelection(std::function<void(KWin::AbstractClient *)> callback, const QByteArray &cursorName)
{
if (!input()) {
callback(nullptr);

View file

@ -27,6 +27,7 @@ class OutputConfigurationV2Interface;
namespace KWin
{
class AbstractClient;
class Output;
class Edge;
class Compositor;
@ -40,7 +41,6 @@ class QPainterBackend;
class Scene;
class ScreenEdges;
class Session;
class Toplevel;
class OutputConfiguration;
class KWIN_EXPORT Outputs : public QVector<Output *>
@ -173,7 +173,7 @@ public:
/**
* Starts an interactive window selection process.
*
* Once the user selected a window the @p callback is invoked with the selected Toplevel as
* Once the user selected a window the @p callback is invoked with the selected AbstractClient as
* argument. In case the user cancels the interactive window selection or selecting a window is currently
* not possible (e.g. screen locked) the @p callback is invoked with a @c nullptr argument.
*
@ -186,7 +186,7 @@ public:
* @param callback The function to invoke once the interactive window selection ends
* @param cursorName The optional name of the cursor shape to use, default is crosshair
*/
virtual void startInteractiveWindowSelection(std::function<void(KWin::Toplevel *)> callback, const QByteArray &cursorName = QByteArray());
virtual void startInteractiveWindowSelection(std::function<void(KWin::AbstractClient *)> callback, const QByteArray &cursorName = QByteArray());
/**
* Starts an interactive position selection process.

View file

@ -44,7 +44,7 @@ ScreencastManager::ScreencastManager(QObject *parent)
class WindowStream : public ScreenCastStream
{
public:
WindowStream(Toplevel *toplevel, QObject *parent)
WindowStream(AbstractClient *toplevel, QObject *parent)
: ScreenCastStream(new WindowScreenCastSource(toplevel), parent)
, m_toplevel(toplevel)
{
@ -60,7 +60,7 @@ private:
{
connect(Compositor::self()->scene(), &Scene::frameRendered, this, &WindowStream::bufferToStream);
connect(m_toplevel, &Toplevel::damaged, this, &WindowStream::includeDamage);
connect(m_toplevel, &AbstractClient::damaged, this, &WindowStream::includeDamage);
m_damagedRegion = m_toplevel->visibleGeometry();
m_toplevel->addRepaintFull();
}
@ -70,7 +70,7 @@ private:
disconnect(Compositor::self()->scene(), &Scene::frameRendered, this, &WindowStream::bufferToStream);
}
void includeDamage(Toplevel *toplevel, const QRegion &damage)
void includeDamage(AbstractClient *toplevel, const QRegion &damage)
{
Q_ASSERT(m_toplevel == toplevel);
m_damagedRegion |= damage;
@ -85,7 +85,7 @@ private:
}
QRegion m_damagedRegion;
Toplevel *m_toplevel;
AbstractClient *m_toplevel;
};
void ScreencastManager::streamWindow(KWaylandServer::ScreencastStreamV1Interface *waylandStream, const QString &winid)

View file

@ -15,16 +15,16 @@
#include "output.h"
#include "renderloop.h"
#include "scene.h"
#include "toplevel.h"
#include "abstract_client.h"
namespace KWin
{
WindowScreenCastSource::WindowScreenCastSource(Toplevel *window, QObject *parent)
WindowScreenCastSource::WindowScreenCastSource(AbstractClient *window, QObject *parent)
: ScreenCastSource(parent)
, m_window(window)
{
connect(m_window, &Toplevel::windowClosed, this, &ScreenCastSource::closed);
connect(m_window, &AbstractClient::windowClosed, this, &ScreenCastSource::closed);
}
bool WindowScreenCastSource::hasAlphaChannel() const

View file

@ -13,14 +13,14 @@
namespace KWin
{
class Toplevel;
class AbstractClient;
class WindowScreenCastSource : public ScreenCastSource
{
Q_OBJECT
public:
explicit WindowScreenCastSource(Toplevel *window, QObject *parent = nullptr);
explicit WindowScreenCastSource(AbstractClient *window, QObject *parent = nullptr);
bool hasAlphaChannel() const override;
QSize textureSize() const override;
@ -30,7 +30,7 @@ public:
std::chrono::nanoseconds clock() const override;
private:
QPointer<Toplevel> m_window;
QPointer<AbstractClient> m_window;
};
} // namespace KWin

View file

@ -556,7 +556,7 @@ void PointerInputRedirection::cleanupDecoration(Decoration::DecoratedClientImpl
m_decorationDestroyedConnection = connect(now, &QObject::destroyed, this, &PointerInputRedirection::update, Qt::QueuedConnection);
}
void PointerInputRedirection::focusUpdate(Toplevel *focusOld, Toplevel *focusNow)
void PointerInputRedirection::focusUpdate(AbstractClient *focusOld, AbstractClient *focusNow)
{
if (auto ac = static_cast<AbstractClient *>(focusOld && focusOld->isClient() ? focusOld : nullptr)) {
ac->pointerLeaveEvent();
@ -578,7 +578,7 @@ void PointerInputRedirection::focusUpdate(Toplevel *focusOld, Toplevel *focusNow
seat->notifyPointerEnter(focusNow->surface(), m_pos, focusNow->inputTransformation());
m_focusGeometryConnection = connect(focusNow, &Toplevel::inputTransformationChanged, this, [this]() {
m_focusGeometryConnection = connect(focusNow, &AbstractClient::inputTransformationChanged, this, [this]() {
// TODO: why no assert possible?
if (!focus()) {
return;
@ -642,7 +642,7 @@ void PointerInputRedirection::disconnectPointerConstraintsConnection()
}
template<typename T>
static QRegion getConstraintRegion(Toplevel *t, T *constraint)
static QRegion getConstraintRegion(AbstractClient *t, T *constraint)
{
const QRegion windowShape = t->inputShape();
const QRegion intersected = constraint->region().isEmpty() ? windowShape : windowShape.intersected(constraint->region());

View file

@ -29,10 +29,10 @@ class SurfaceInterface;
namespace KWin
{
class AbstractClient;
class CursorImage;
class InputDevice;
class InputRedirection;
class Toplevel;
class CursorShape;
namespace Decoration
@ -147,7 +147,7 @@ private:
void processMotionInternal(const QPointF &pos, const QSizeF &delta, const QSizeF &deltaNonAccelerated, uint32_t time, quint64 timeUsec, InputDevice *device);
void cleanupDecoration(Decoration::DecoratedClientImpl *old, Decoration::DecoratedClientImpl *now) override;
void focusUpdate(Toplevel *focusOld, Toplevel *focusNow) override;
void focusUpdate(AbstractClient *focusOld, AbstractClient *focusNow) override;
QPointF position() const override;

View file

@ -24,20 +24,20 @@ PopupInputFilter::PopupInputFilter()
connect(workspace(), &Workspace::internalClientAdded, this, &PopupInputFilter::handleClientAdded);
}
void PopupInputFilter::handleClientAdded(Toplevel *client)
void PopupInputFilter::handleClientAdded(AbstractClient *client)
{
if (m_popupClients.contains(client)) {
return;
}
if (client->hasPopupGrab()) {
// TODO: verify that the Toplevel is allowed as a popup
connect(client, &Toplevel::windowShown, this, &PopupInputFilter::handleClientAdded, Qt::UniqueConnection);
connect(client, &Toplevel::windowClosed, this, &PopupInputFilter::handleClientRemoved, Qt::UniqueConnection);
// TODO: verify that the AbstractClient is allowed as a popup
connect(client, &AbstractClient::windowShown, this, &PopupInputFilter::handleClientAdded, Qt::UniqueConnection);
connect(client, &AbstractClient::windowClosed, this, &PopupInputFilter::handleClientRemoved, Qt::UniqueConnection);
m_popupClients << client;
}
}
void PopupInputFilter::handleClientRemoved(Toplevel *client)
void PopupInputFilter::handleClientRemoved(AbstractClient *client)
{
m_popupClients.removeOne(client);
}

View file

@ -14,7 +14,7 @@
namespace KWin
{
class Toplevel;
class AbstractClient;
class PopupInputFilter : public QObject, public InputEventFilter
{
@ -26,12 +26,12 @@ public:
bool touchDown(qint32 id, const QPointF &pos, quint32 time) override;
private:
void handleClientAdded(Toplevel *client);
void handleClientRemoved(Toplevel *client);
void disconnectClient(Toplevel *client);
void handleClientAdded(AbstractClient *client);
void handleClientRemoved(AbstractClient *client);
void disconnectClient(AbstractClient *client);
void cancelPopups();
QVector<Toplevel *> m_popupClients;
QVector<AbstractClient *> m_popupClients;
};
}

View file

@ -235,7 +235,7 @@ SurfaceItem *Scene::scanoutCandidate() const
if (!static_cast<EffectsHandlerImpl *>(effects)->blocksDirectScanout()) {
for (int i = stacking_order.count() - 1; i >= 0; i--) {
Window *window = stacking_order[i];
Toplevel *toplevel = window->window();
AbstractClient *toplevel = window->window();
if (toplevel->isOnOutput(painted_screen) && window->isVisible() && toplevel->opacity() > 0) {
AbstractClient *c = dynamic_cast<AbstractClient *>(toplevel);
if (!c || !c->isFullScreen() || c->opacity() != 1.0) {
@ -361,7 +361,7 @@ void Scene::preparePaintGenericScreen()
void Scene::preparePaintSimpleScreen()
{
for (Window *sceneWindow : std::as_const(stacking_order)) {
const Toplevel *toplevel = sceneWindow->window();
const AbstractClient *toplevel = sceneWindow->window();
WindowPrePaintData data;
data.mask = m_paintContext.mask;
accumulateRepaints(sceneWindow->windowItem(), painted_screen, &data.paint);
@ -415,7 +415,7 @@ void Scene::postPaint()
std::chrono::duration_cast<std::chrono::milliseconds>(painted_screen->renderLoop()->lastPresentationTimestamp());
for (Window *window : std::as_const(m_windows)) {
Toplevel *toplevel = window->window();
AbstractClient *toplevel = window->window();
if (!toplevel->isOnOutput(painted_screen)) {
continue;
}
@ -558,25 +558,25 @@ void Scene::paintSimpleScreen(int, const QRegion &region)
}
}
void Scene::addToplevel(Toplevel *c)
void Scene::addToplevel(AbstractClient *c)
{
Q_ASSERT(!m_windows.contains(c));
Scene::Window *w = createWindow(c);
m_windows[c] = w;
connect(c, &Toplevel::windowClosed, this, &Scene::windowClosed);
connect(c, &AbstractClient::windowClosed, this, &Scene::windowClosed);
c->effectWindow()->setSceneWindow(w);
}
void Scene::removeToplevel(Toplevel *toplevel)
void Scene::removeToplevel(AbstractClient *toplevel)
{
Q_ASSERT(m_windows.contains(toplevel));
delete m_windows.take(toplevel);
toplevel->effectWindow()->setSceneWindow(nullptr);
}
void Scene::windowClosed(Toplevel *toplevel, Deleted *deleted)
void Scene::windowClosed(AbstractClient *toplevel, Deleted *deleted)
{
if (!deleted) {
removeToplevel(toplevel);
@ -592,12 +592,12 @@ void Scene::windowClosed(Toplevel *toplevel, Deleted *deleted)
void Scene::createStackingOrder()
{
// Create a list of all windows in the stacking order
QList<Toplevel *> windows = Workspace::self()->xStackingOrder();
QList<AbstractClient *> windows = Workspace::self()->xStackingOrder();
// Move elevated windows to the top of the stacking order
const QList<EffectWindow *> elevatedList = static_cast<EffectsHandlerImpl *>(effects)->elevatedWindows();
for (EffectWindow *c : elevatedList) {
Toplevel *t = static_cast<EffectWindowImpl *>(c)->window();
AbstractClient *t = static_cast<EffectWindowImpl *>(c)->window();
windows.removeAll(t);
windows.append(t);
}
@ -608,7 +608,7 @@ void Scene::createStackingOrder()
// TODO? This cannot be used so carelessly - needs protections against broken clients, the
// window should not get focus before it's displayed, handle unredirected windows properly and
// so on.
for (Toplevel *win : windows) {
for (AbstractClient *win : windows) {
if (!win->readyForPainting()) {
windows.removeAll(win);
}
@ -618,7 +618,7 @@ void Scene::createStackingOrder()
}
// TODO: cache the stacking_order in case it has not changed
for (Toplevel *c : std::as_const(windows)) {
for (AbstractClient *c : std::as_const(windows)) {
Q_ASSERT(m_windows.contains(c));
stacking_order.append(m_windows[c]);
}
@ -710,7 +710,7 @@ SurfaceTexture *Scene::createSurfaceTextureWayland(SurfacePixmapWayland *pixmap)
// Scene::Window
//****************************************
Scene::Window::Window(Toplevel *client, QObject *parent)
Scene::Window::Window(AbstractClient *client, QObject *parent)
: QObject(parent)
, toplevel(client)
, disable_painting(0)
@ -725,7 +725,7 @@ Scene::Window::Window(Toplevel *client, QObject *parent)
Q_UNREACHABLE();
}
connect(toplevel, &Toplevel::frameGeometryChanged, this, &Window::updateWindowPosition);
connect(toplevel, &AbstractClient::frameGeometryChanged, this, &Window::updateWindowPosition);
updateWindowPosition();
}
@ -881,7 +881,7 @@ ScreenLockerFilter::ScreenLockerFilter(Scene *s)
ScreenLockerFilter::~ScreenLockerFilter() = default;
bool ScreenLockerFilter::filterAcceptsWindow(KWin::Toplevel *w) const
bool ScreenLockerFilter::filterAcceptsWindow(KWin::AbstractClient *w) const
{
return !waylandServer() || !waylandServer()->isScreenLocked() || (w->isLockScreen() || w->isInputMethod());
}

View file

@ -12,7 +12,7 @@
#include "kwineffects.h"
#include "renderlayerdelegate.h"
#include "toplevel.h"
#include "abstract_client.h"
#include "utils/common.h"
#include <optional>
@ -52,7 +52,7 @@ public:
ScreenLockerFilter(Scene *scene);
~ScreenLockerFilter();
bool filterAcceptsWindow(KWin::Toplevel *w) const;
bool filterAcceptsWindow(KWin::AbstractClient *w) const;
};
class SceneDelegate : public RenderLayerDelegate
@ -113,7 +113,7 @@ public:
virtual void paint(RenderTarget *renderTarget, const QRegion &region) = 0;
/**
* Adds the Toplevel to the Scene.
* Adds the AbstractClient to the Scene.
*
* If the toplevel gets deleted, then the scene will try automatically
* to re-bind an underlying scene window to the corresponding Deleted.
@ -121,15 +121,15 @@ public:
* @param toplevel The window to be added.
* @note You can add a toplevel to scene only once.
*/
void addToplevel(Toplevel *toplevel);
void addToplevel(AbstractClient *toplevel);
/**
* Removes the Toplevel from the Scene.
* Removes the AbstractClient from the Scene.
*
* @param toplevel The window to be removed.
* @note You can remove a toplevel from the scene only once.
*/
void removeToplevel(Toplevel *toplevel);
void removeToplevel(AbstractClient *toplevel);
/**
* @brief Creates the Scene backend of an EffectFrame.
@ -143,9 +143,9 @@ public:
* An implementing class has to create a proper instance. It is not allowed to
* return @c null.
*
* @param toplevel The Toplevel for which the Shadow needs to be created.
* @param toplevel The AbstractClient for which the Shadow needs to be created.
*/
virtual Shadow *createShadow(Toplevel *toplevel) = 0;
virtual Shadow *createShadow(AbstractClient *toplevel) = 0;
// Flags controlling how painting is done.
enum {
// Window (or at least part of it) will be painted opaque.
@ -225,10 +225,10 @@ Q_SIGNALS:
public Q_SLOTS:
// a window has been closed
void windowClosed(KWin::Toplevel *c, KWin::Deleted *deleted);
void windowClosed(KWin::AbstractClient *c, KWin::Deleted *deleted);
protected:
virtual Window *createWindow(Toplevel *toplevel) = 0;
virtual Window *createWindow(AbstractClient *toplevel) = 0;
void createStackingOrder();
void clearStackingOrder();
// shared implementation, starts painting the screen
@ -280,7 +280,7 @@ protected:
private:
std::chrono::milliseconds m_expectedPresentTimestamp = std::chrono::milliseconds::zero();
QList<SceneDelegate *> m_delegates;
QHash<Toplevel *, Window *> m_windows;
QHash<AbstractClient *, Window *> m_windows;
QRect m_geometry;
QMatrix4x4 m_renderTargetProjectionMatrix;
QRect m_renderTargetRect;
@ -296,7 +296,7 @@ class Scene::Window : public QObject
Q_OBJECT
public:
explicit Window(Toplevel *client, QObject *parent = nullptr);
explicit Window(AbstractClient *client, QObject *parent = nullptr);
~Window() override;
// perform the actual painting of the window
virtual void performPaint(int mask, const QRegion &region, const WindowPaintData &data) = 0;
@ -310,7 +310,7 @@ public:
QRect rect() const;
// access to the internal window class
// TODO eventually get rid of this
Toplevel *window() const;
AbstractClient *window() const;
// should the window be painted
bool isPaintingEnabled() const;
void resetPaintingEnabled();
@ -340,7 +340,7 @@ public:
ShadowItem *shadowItem() const;
protected:
Toplevel *toplevel;
AbstractClient *toplevel;
private:
void referencePreviousPixmap_helper(SurfaceItem *item);
@ -410,7 +410,7 @@ inline QRect Scene::Window::rect() const
return toplevel->rect();
}
inline Toplevel *Scene::Window::window() const
inline AbstractClient *Scene::Window::window() const
{
return toplevel;
}

View file

@ -399,7 +399,7 @@ void LanczosFilter::timerEvent(QTimerEvent *event)
m_offscreenTarget = nullptr;
m_offscreenTex = nullptr;
workspace()->forEachToplevel([this](Toplevel *toplevel) {
workspace()->forEachToplevel([this](AbstractClient *toplevel) {
discardCacheTexture(toplevel->effectWindow());
});

View file

@ -215,7 +215,7 @@ Scene::EffectFrame *SceneOpenGL::createEffectFrame(EffectFrameImpl *frame)
return new SceneOpenGL::EffectFrame(frame, this);
}
Shadow *SceneOpenGL::createShadow(Toplevel *toplevel)
Shadow *SceneOpenGL::createShadow(AbstractClient *toplevel)
{
return new SceneOpenGLShadow(toplevel);
}
@ -306,7 +306,7 @@ void SceneOpenGL::doPaintBackground(const QVector<float> &vertices)
vbo->render(GL_TRIANGLES);
}
Scene::Window *SceneOpenGL::createWindow(Toplevel *t)
Scene::Window *SceneOpenGL::createWindow(AbstractClient *t)
{
return new OpenGLWindow(t, this);
}
@ -335,7 +335,7 @@ void SceneOpenGL::performPaintWindow(EffectWindowImpl *w, int mask, const QRegio
// OpenGLWindow
//****************************************
OpenGLWindow::OpenGLWindow(Toplevel *toplevel, SceneOpenGL *scene)
OpenGLWindow::OpenGLWindow(AbstractClient *toplevel, SceneOpenGL *scene)
: Scene::Window(toplevel)
, m_scene(scene)
{
@ -1191,7 +1191,7 @@ QSharedPointer<GLTexture> DecorationShadowTextureCache::getTexture(SceneOpenGLSh
return d.texture;
}
SceneOpenGLShadow::SceneOpenGLShadow(Toplevel *toplevel)
SceneOpenGLShadow::SceneOpenGLShadow(AbstractClient *toplevel)
: Shadow(toplevel)
{
}

View file

@ -35,7 +35,7 @@ public:
bool initFailed() const override;
void paint(RenderTarget *renderTarget, const QRegion &region) override;
Scene::EffectFrame *createEffectFrame(EffectFrameImpl *frame) override;
Shadow *createShadow(Toplevel *toplevel) override;
Shadow *createShadow(AbstractClient *toplevel) override;
bool makeOpenGLContextCurrent() override;
void doneOpenGLContextCurrent() override;
bool supportsNativeFence() const override;
@ -69,7 +69,7 @@ protected:
void paintSimpleScreen(int mask, const QRegion &region) override;
void paintGenericScreen(int mask, const ScreenPaintData &data) override;
Scene::Window *createWindow(Toplevel *t) override;
Scene::Window *createWindow(AbstractClient *t) override;
void finalDrawWindow(EffectWindowImpl *w, int mask, const QRegion &region, WindowPaintData &data) override;
private:
@ -109,7 +109,7 @@ public:
const bool hardwareClipping;
};
OpenGLWindow(Toplevel *toplevel, SceneOpenGL *scene);
OpenGLWindow(AbstractClient *toplevel, SceneOpenGL *scene);
~OpenGLWindow() override;
void performPaint(int mask, const QRegion &region, const WindowPaintData &data) override;
@ -172,7 +172,7 @@ class SceneOpenGLShadow
: public Shadow
{
public:
explicit SceneOpenGLShadow(Toplevel *toplevel);
explicit SceneOpenGLShadow(AbstractClient *toplevel);
~SceneOpenGLShadow() override;
GLTexture *shadowTexture()

View file

@ -21,7 +21,7 @@
#include "renderloop.h"
#include "screens.h"
#include "surfaceitem.h"
#include "toplevel.h"
#include "abstract_client.h"
#include "windowitem.h"
#include <kwinoffscreenquickview.h>
@ -99,7 +99,7 @@ void SceneQPainter::paintOffscreenQuickView(OffscreenQuickView *w)
painter->restore();
}
Scene::Window *SceneQPainter::createWindow(Toplevel *toplevel)
Scene::Window *SceneQPainter::createWindow(AbstractClient *toplevel)
{
return new SceneQPainter::Window(this, toplevel);
}
@ -109,7 +109,7 @@ Scene::EffectFrame *SceneQPainter::createEffectFrame(EffectFrameImpl *frame)
return new QPainterEffectFrame(frame, this);
}
Shadow *SceneQPainter::createShadow(Toplevel *toplevel)
Shadow *SceneQPainter::createShadow(AbstractClient *toplevel)
{
return new SceneQPainterShadow(toplevel);
}
@ -117,7 +117,7 @@ Shadow *SceneQPainter::createShadow(Toplevel *toplevel)
//****************************************
// SceneQPainter::Window
//****************************************
SceneQPainter::Window::Window(SceneQPainter *scene, Toplevel *c)
SceneQPainter::Window::Window(SceneQPainter *scene, AbstractClient *c)
: Scene::Window(c)
, m_scene(scene)
{
@ -355,7 +355,7 @@ void QPainterEffectFrame::render(const QRegion &region, double opacity, double f
//****************************************
// QPainterShadow
//****************************************
SceneQPainterShadow::SceneQPainterShadow(Toplevel *toplevel)
SceneQPainterShadow::SceneQPainterShadow(AbstractClient *toplevel)
: Shadow(toplevel)
{
}

View file

@ -28,7 +28,7 @@ public:
void paintGenericScreen(int mask, const ScreenPaintData &data) override;
bool initFailed() const override;
EffectFrame *createEffectFrame(EffectFrameImpl *frame) override;
Shadow *createShadow(Toplevel *toplevel) override;
Shadow *createShadow(AbstractClient *toplevel) override;
DecorationRenderer *createDecorationRenderer(Decoration::DecoratedClientImpl *impl) override;
SurfaceTexture *createSurfaceTextureInternal(SurfacePixmapInternal *pixmap) override;
SurfaceTexture *createSurfaceTextureWayland(SurfacePixmapWayland *pixmap) override;
@ -49,7 +49,7 @@ public:
protected:
void paintBackground(const QRegion &region) override;
Scene::Window *createWindow(Toplevel *toplevel) override;
Scene::Window *createWindow(AbstractClient *toplevel) override;
void paintOffscreenQuickView(OffscreenQuickView *w) override;
private:
@ -64,7 +64,7 @@ class SceneQPainter::Window : public Scene::Window
Q_OBJECT
public:
Window(SceneQPainter *scene, Toplevel *c);
Window(SceneQPainter *scene, AbstractClient *c);
~Window() override;
void performPaint(int mask, const QRegion &region, const WindowPaintData &data) override;
@ -107,7 +107,7 @@ private:
class SceneQPainterShadow : public Shadow
{
public:
SceneQPainterShadow(Toplevel *toplevel);
SceneQPainterShadow(AbstractClient *toplevel);
~SceneQPainterShadow() override;
protected:

View file

@ -14,7 +14,7 @@
#include "composite.h"
#include "internal_client.h"
#include "scene.h"
#include "toplevel.h"
#include "abstract_client.h"
#include "wayland_server.h"
#include <KDecoration2/Decoration>
@ -31,19 +31,19 @@ Q_DECLARE_METATYPE(QMargins)
namespace KWin
{
Shadow::Shadow(Toplevel *toplevel)
Shadow::Shadow(AbstractClient *toplevel)
: m_topLevel(toplevel)
, m_cachedSize(toplevel->size())
, m_decorationShadow(nullptr)
{
connect(m_topLevel, &Toplevel::frameGeometryChanged, this, &Shadow::geometryChanged);
connect(m_topLevel, &AbstractClient::frameGeometryChanged, this, &Shadow::geometryChanged);
}
Shadow::~Shadow()
{
}
Shadow *Shadow::createShadow(Toplevel *toplevel)
Shadow *Shadow::createShadow(AbstractClient *toplevel)
{
Shadow *shadow = createShadowFromDecoration(toplevel);
if (!shadow && waylandServer()) {
@ -58,7 +58,7 @@ Shadow *Shadow::createShadow(Toplevel *toplevel)
return shadow;
}
Shadow *Shadow::createShadowFromX11(Toplevel *toplevel)
Shadow *Shadow::createShadowFromX11(AbstractClient *toplevel)
{
auto data = Shadow::readX11ShadowProperty(toplevel->window());
if (!data.isEmpty()) {
@ -74,7 +74,7 @@ Shadow *Shadow::createShadowFromX11(Toplevel *toplevel)
}
}
Shadow *Shadow::createShadowFromDecoration(Toplevel *toplevel)
Shadow *Shadow::createShadowFromDecoration(AbstractClient *toplevel)
{
auto c = static_cast<AbstractClient *>(toplevel->isClient() ? toplevel : nullptr);
if (!c) {
@ -91,7 +91,7 @@ Shadow *Shadow::createShadowFromDecoration(Toplevel *toplevel)
return shadow;
}
Shadow *Shadow::createShadowFromWayland(Toplevel *toplevel)
Shadow *Shadow::createShadowFromWayland(AbstractClient *toplevel)
{
auto surface = toplevel->surface();
if (!surface) {
@ -109,7 +109,7 @@ Shadow *Shadow::createShadowFromWayland(Toplevel *toplevel)
return shadow;
}
Shadow *Shadow::createShadowFromInternalWindow(Toplevel *toplevel)
Shadow *Shadow::createShadowFromInternalWindow(AbstractClient *toplevel)
{
const InternalClient *client = qobject_cast<InternalClient *>(toplevel);
if (!client) {
@ -192,18 +192,18 @@ bool Shadow::init(KDecoration2::Decoration *decoration)
{
if (m_decorationShadow) {
// disconnect previous connections
disconnect(m_decorationShadow.data(), &KDecoration2::DecorationShadow::innerShadowRectChanged, m_topLevel, &Toplevel::updateShadow);
disconnect(m_decorationShadow.data(), &KDecoration2::DecorationShadow::shadowChanged, m_topLevel, &Toplevel::updateShadow);
disconnect(m_decorationShadow.data(), &KDecoration2::DecorationShadow::paddingChanged, m_topLevel, &Toplevel::updateShadow);
disconnect(m_decorationShadow.data(), &KDecoration2::DecorationShadow::innerShadowRectChanged, m_topLevel, &AbstractClient::updateShadow);
disconnect(m_decorationShadow.data(), &KDecoration2::DecorationShadow::shadowChanged, m_topLevel, &AbstractClient::updateShadow);
disconnect(m_decorationShadow.data(), &KDecoration2::DecorationShadow::paddingChanged, m_topLevel, &AbstractClient::updateShadow);
}
m_decorationShadow = decoration->shadow();
if (!m_decorationShadow) {
return false;
}
// setup connections - all just mapped to recreate
connect(m_decorationShadow.data(), &KDecoration2::DecorationShadow::innerShadowRectChanged, m_topLevel, &Toplevel::updateShadow);
connect(m_decorationShadow.data(), &KDecoration2::DecorationShadow::shadowChanged, m_topLevel, &Toplevel::updateShadow);
connect(m_decorationShadow.data(), &KDecoration2::DecorationShadow::paddingChanged, m_topLevel, &Toplevel::updateShadow);
connect(m_decorationShadow.data(), &KDecoration2::DecorationShadow::innerShadowRectChanged, m_topLevel, &AbstractClient::updateShadow);
connect(m_decorationShadow.data(), &KDecoration2::DecorationShadow::shadowChanged, m_topLevel, &AbstractClient::updateShadow);
connect(m_decorationShadow.data(), &KDecoration2::DecorationShadow::paddingChanged, m_topLevel, &AbstractClient::updateShadow);
m_offset = m_decorationShadow->padding();
Q_EMIT offsetChanged();
@ -325,15 +325,15 @@ bool Shadow::updateShadow()
return true;
}
Toplevel *Shadow::toplevel() const
AbstractClient *Shadow::toplevel() const
{
return m_topLevel;
}
void Shadow::setToplevel(Toplevel *topLevel)
void Shadow::setToplevel(AbstractClient *topLevel)
{
m_topLevel = topLevel;
connect(m_topLevel, &Toplevel::frameGeometryChanged, this, &Shadow::geometryChanged);
connect(m_topLevel, &AbstractClient::frameGeometryChanged, this, &Shadow::geometryChanged);
}
void Shadow::geometryChanged()
{

View file

@ -28,7 +28,7 @@ class ShadowInterface;
namespace KWin
{
class Toplevel;
class AbstractClient;
/**
* @short Class representing a Window's Shadow to be rendered by the Compositor.
@ -40,10 +40,10 @@ class Toplevel;
* To create a Shadow instance use the static factory method createShadow which will
* create an instance for the currently used Compositing Backend. It will read the X11 Property
* and create the Shadow and all required data (such as WindowQuads). If there is no Shadow
* defined for the Toplevel the factory method returns @c NULL.
* defined for the AbstractClient the factory method returns @c NULL.
*
* @author Martin Gräßlin <mgraesslin@kde.org>
* @todo React on Toplevel size changes.
* @todo React on AbstractClient size changes.
*/
class KWIN_EXPORT Shadow : public QObject
{
@ -69,18 +69,18 @@ public:
*
* If there is no shadow defined for @p toplevel this method
* will return @c NULL.
* @param toplevel The Toplevel for which the shadow should be created
* @param toplevel The AbstractClient for which the shadow should be created
* @return Created Shadow or @c NULL in case there is no shadow defined.
*/
static Shadow *createShadow(Toplevel *toplevel);
static Shadow *createShadow(AbstractClient *toplevel);
Toplevel *toplevel() const;
AbstractClient *toplevel() const;
/**
* Reparents the shadow to @p toplevel.
* Used when a window is deleted.
* @param toplevel The new parent
*/
void setToplevel(Toplevel *toplevel);
void setToplevel(AbstractClient *toplevel);
bool hasDecorationShadow() const
{
@ -124,7 +124,7 @@ public Q_SLOTS:
void geometryChanged();
protected:
Shadow(Toplevel *toplevel);
Shadow(AbstractClient *toplevel);
inline const QPixmap &shadowPixmap(ShadowElements element) const
{
@ -135,16 +135,16 @@ protected:
void setShadowElement(const QPixmap &shadow, ShadowElements element);
private:
static Shadow *createShadowFromX11(Toplevel *toplevel);
static Shadow *createShadowFromDecoration(Toplevel *toplevel);
static Shadow *createShadowFromWayland(Toplevel *toplevel);
static Shadow *createShadowFromInternalWindow(Toplevel *toplevel);
static Shadow *createShadowFromX11(AbstractClient *toplevel);
static Shadow *createShadowFromDecoration(AbstractClient *toplevel);
static Shadow *createShadowFromWayland(AbstractClient *toplevel);
static Shadow *createShadowFromInternalWindow(AbstractClient *toplevel);
static QVector<uint32_t> readX11ShadowProperty(xcb_window_t id);
bool init(const QVector<uint32_t> &data);
bool init(KDecoration2::Decoration *decoration);
bool init(const QPointer<KWaylandServer::ShadowInterface> &shadow);
bool init(const QWindow *window);
Toplevel *m_topLevel;
AbstractClient *m_topLevel;
// shadow pixmaps
QPixmap m_shadowElements[ShadowElementsCount];
// shadow offsets

View file

@ -11,12 +11,12 @@
namespace KWin
{
ShadowItem::ShadowItem(Shadow *shadow, Toplevel *window, Item *parent)
ShadowItem::ShadowItem(Shadow *shadow, AbstractClient *window, Item *parent)
: Item(parent)
, m_window(window)
, m_shadow(shadow)
{
connect(window, &Toplevel::windowClosed, this, &ShadowItem::handleWindowClosed);
connect(window, &AbstractClient::windowClosed, this, &ShadowItem::handleWindowClosed);
connect(shadow, &Shadow::offsetChanged, this, &ShadowItem::updateGeometry);
connect(shadow, &Shadow::rectChanged, this, &ShadowItem::updateGeometry);
@ -50,7 +50,7 @@ void ShadowItem::handleTextureChanged()
discardQuads();
}
void ShadowItem::handleWindowClosed(Toplevel *original, Deleted *deleted)
void ShadowItem::handleWindowClosed(AbstractClient *original, Deleted *deleted)
{
Q_UNUSED(original)
m_window = deleted;

View file

@ -13,7 +13,7 @@ namespace KWin
class Deleted;
class Shadow;
class Toplevel;
class AbstractClient;
/**
* The ShadowItem class represents a nine-tile patch server-side drop-shadow.
@ -23,7 +23,7 @@ class KWIN_EXPORT ShadowItem : public Item
Q_OBJECT
public:
explicit ShadowItem(Shadow *shadow, Toplevel *window, Item *parent = nullptr);
explicit ShadowItem(Shadow *shadow, AbstractClient *window, Item *parent = nullptr);
~ShadowItem() override;
Shadow *shadow() const;
@ -34,10 +34,10 @@ protected:
private Q_SLOTS:
void handleTextureChanged();
void updateGeometry();
void handleWindowClosed(Toplevel *original, Deleted *deleted);
void handleWindowClosed(AbstractClient *original, Deleted *deleted);
private:
Toplevel *m_window;
AbstractClient *m_window;
Shadow *m_shadow = nullptr;
};

View file

@ -10,19 +10,19 @@
namespace KWin
{
SurfaceItem::SurfaceItem(Toplevel *window, Item *parent)
SurfaceItem::SurfaceItem(AbstractClient *window, Item *parent)
: Item(parent)
, m_window(window)
{
connect(window, &Toplevel::windowClosed, this, &SurfaceItem::handleWindowClosed);
connect(window, &AbstractClient::windowClosed, this, &SurfaceItem::handleWindowClosed);
}
Toplevel *SurfaceItem::window() const
AbstractClient *SurfaceItem::window() const
{
return m_window;
}
void SurfaceItem::handleWindowClosed(Toplevel *original, Deleted *deleted)
void SurfaceItem::handleWindowClosed(AbstractClient *original, Deleted *deleted)
{
Q_UNUSED(original)
m_window = deleted;

View file

@ -13,7 +13,7 @@ namespace KWin
class Deleted;
class SurfacePixmap;
class Toplevel;
class AbstractClient;
/**
* The SurfaceItem class represents a surface with some contents.
@ -26,7 +26,7 @@ public:
QMatrix4x4 surfaceToBufferMatrix() const;
void setSurfaceToBufferMatrix(const QMatrix4x4 &matrix);
Toplevel *window() const;
AbstractClient *window() const;
virtual QRegion shape() const;
virtual QRegion opaque() const;
@ -45,15 +45,15 @@ public:
void unreferencePreviousPixmap();
protected:
explicit SurfaceItem(Toplevel *window, Item *parent = nullptr);
explicit SurfaceItem(AbstractClient *window, Item *parent = nullptr);
virtual SurfacePixmap *createPixmap() = 0;
void preprocess() override;
WindowQuadList buildQuads() const override;
void handleWindowClosed(Toplevel *original, Deleted *deleted);
void handleWindowClosed(AbstractClient *original, Deleted *deleted);
Toplevel *m_window;
AbstractClient *m_window;
QRegion m_damage;
QScopedPointer<SurfacePixmap> m_pixmap;
QScopedPointer<SurfacePixmap> m_previousPixmap;

View file

@ -15,7 +15,7 @@ namespace KWin
SurfaceItemInternal::SurfaceItemInternal(InternalClient *window, Item *parent)
: SurfaceItem(window, parent)
{
connect(window, &Toplevel::bufferGeometryChanged,
connect(window, &AbstractClient::bufferGeometryChanged,
this, &SurfaceItemInternal::handleBufferGeometryChanged);
setSize(window->bufferGeometry().size());
@ -36,7 +36,7 @@ SurfacePixmap *SurfaceItemInternal::createPixmap()
return new SurfacePixmapInternal(this);
}
void SurfaceItemInternal::handleBufferGeometryChanged(Toplevel *toplevel, const QRect &old)
void SurfaceItemInternal::handleBufferGeometryChanged(AbstractClient *toplevel, const QRect &old)
{
if (toplevel->bufferGeometry().size() != old.size()) {
discardPixmap();
@ -67,7 +67,7 @@ void SurfacePixmapInternal::create()
void SurfacePixmapInternal::update()
{
const Toplevel *window = m_item->window();
const AbstractClient *window = m_item->window();
if (window->internalFramebufferObject()) {
m_fbo = window->internalFramebufferObject();

View file

@ -28,7 +28,7 @@ public:
QRegion shape() const override;
private Q_SLOTS:
void handleBufferGeometryChanged(Toplevel *toplevel, const QRect &old);
void handleBufferGeometryChanged(AbstractClient *toplevel, const QRect &old);
protected:
SurfacePixmap *createPixmap() override;

View file

@ -16,7 +16,7 @@ namespace KWin
{
SurfaceItemWayland::SurfaceItemWayland(KWaylandServer::SurfaceInterface *surface,
Toplevel *window, Item *parent)
AbstractClient *window, Item *parent)
: SurfaceItem(window, parent)
, m_surface(surface)
{
@ -197,10 +197,10 @@ void SurfacePixmapWayland::setBuffer(KWaylandServer::ClientBuffer *buffer)
}
}
SurfaceItemXwayland::SurfaceItemXwayland(Toplevel *window, Item *parent)
SurfaceItemXwayland::SurfaceItemXwayland(AbstractClient *window, Item *parent)
: SurfaceItemWayland(window->surface(), window, parent)
{
connect(window, &Toplevel::geometryShapeChanged, this, &SurfaceItemXwayland::discardQuads);
connect(window, &AbstractClient::geometryShapeChanged, this, &SurfaceItemXwayland::discardQuads);
}
QRegion SurfaceItemXwayland::shape() const

View file

@ -27,7 +27,7 @@ class KWIN_EXPORT SurfaceItemWayland : public SurfaceItem
public:
explicit SurfaceItemWayland(KWaylandServer::SurfaceInterface *surface,
Toplevel *window, Item *parent = nullptr);
AbstractClient *window, Item *parent = nullptr);
QRegion shape() const override;
QRegion opaque() const override;
@ -85,7 +85,7 @@ class KWIN_EXPORT SurfaceItemXwayland : public SurfaceItemWayland
Q_OBJECT
public:
explicit SurfaceItemXwayland(Toplevel *window, Item *parent = nullptr);
explicit SurfaceItemXwayland(AbstractClient *window, Item *parent = nullptr);
QRegion shape() const override;
};

View file

@ -12,12 +12,12 @@
namespace KWin
{
SurfaceItemX11::SurfaceItemX11(Toplevel *window, Item *parent)
SurfaceItemX11::SurfaceItemX11(AbstractClient *window, Item *parent)
: SurfaceItem(window, parent)
{
connect(window, &Toplevel::bufferGeometryChanged,
connect(window, &AbstractClient::bufferGeometryChanged,
this, &SurfaceItemX11::handleBufferGeometryChanged);
connect(window, &Toplevel::geometryShapeChanged,
connect(window, &AbstractClient::geometryShapeChanged,
this, &SurfaceItemX11::discardQuads);
m_damageHandle = xcb_generate_id(kwinApp()->x11Connection());
@ -29,7 +29,7 @@ SurfaceItemX11::SurfaceItemX11(Toplevel *window, Item *parent)
SurfaceItemX11::~SurfaceItemX11()
{
// destroyDamage() will be called by the associated Toplevel.
// destroyDamage() will be called by the associated AbstractClient.
}
void SurfaceItemX11::preprocess()
@ -115,7 +115,7 @@ void SurfaceItemX11::destroyDamage()
}
}
void SurfaceItemX11::handleBufferGeometryChanged(Toplevel *toplevel, const QRect &old)
void SurfaceItemX11::handleBufferGeometryChanged(AbstractClient *toplevel, const QRect &old)
{
if (toplevel->bufferGeometry().size() != old.size()) {
discardPixmap();
@ -171,7 +171,7 @@ xcb_visualid_t SurfacePixmapX11::visual() const
void SurfacePixmapX11::create()
{
const Toplevel *toplevel = m_item->window();
const AbstractClient *toplevel = m_item->window();
if (toplevel->isDeleted()) {
return;
}

View file

@ -22,7 +22,7 @@ class KWIN_EXPORT SurfaceItemX11 : public SurfaceItem
Q_OBJECT
public:
explicit SurfaceItemX11(Toplevel *window, Item *parent = nullptr);
explicit SurfaceItemX11(AbstractClient *window, Item *parent = nullptr);
~SurfaceItemX11() override;
void preprocess() override;
@ -36,7 +36,7 @@ public:
QRegion opaque() const override;
private Q_SLOTS:
void handleBufferGeometryChanged(Toplevel *toplevel, const QRect &old);
void handleBufferGeometryChanged(AbstractClient *toplevel, const QRect &old);
protected:
SurfacePixmap *createPixmap() override;

View file

@ -280,9 +280,9 @@ QWeakPointer<TabBoxClient> TabBoxHandlerImpl::clientToAddToList(TabBoxClient *cl
TabBoxClientList TabBoxHandlerImpl::stackingOrder() const
{
const QList<Toplevel *> stacking = Workspace::self()->stackingOrder();
const QList<AbstractClient *> stacking = Workspace::self()->stackingOrder();
TabBoxClientList ret;
for (Toplevel *toplevel : stacking) {
for (AbstractClient *toplevel : stacking) {
if (auto client = static_cast<AbstractClient *>(toplevel->isClient() ? toplevel : nullptr)) {
ret.append(qWeakPointerCast<TabBoxClient, TabBoxClientImpl>(client->tabBoxClient()));
}
@ -310,7 +310,7 @@ void TabBoxHandlerImpl::elevateClient(TabBoxClient *c, QWindow *tabbox, bool b)
{
auto cl = static_cast<TabBoxClientImpl *>(c)->client();
cl->elevate(b);
if (Toplevel *w = Workspace::self()->findInternal(tabbox)) {
if (AbstractClient *w = Workspace::self()->findInternal(tabbox)) {
w->elevate(b);
}
}
@ -329,7 +329,7 @@ void TabBoxHandlerImpl::shadeClient(TabBoxClient *c, bool b) const
QWeakPointer<TabBoxClient> TabBoxHandlerImpl::desktopClient() const
{
const auto stackingOrder = Workspace::self()->stackingOrder();
for (Toplevel *toplevel : stackingOrder) {
for (AbstractClient *toplevel : stackingOrder) {
auto client = static_cast<AbstractClient *>(toplevel->isClient() ? toplevel : nullptr);
if (client && client->isDesktop() && client->isOnCurrentDesktop() && client->output() == workspace()->activeOutput()) {
return qWeakPointerCast<TabBoxClient, TabBoxClientImpl>(client->tabBoxClient());
@ -352,7 +352,7 @@ void TabBoxHandlerImpl::highlightWindows(TabBoxClient *window, QWindow *controll
if (window) {
windows << static_cast<TabBoxClientImpl *>(window)->client()->effectWindow();
}
if (Toplevel *t = workspace()->findInternal(controller)) {
if (AbstractClient *t = workspace()->findInternal(controller)) {
windows << t->effectWindow();
}
static_cast<EffectsHandlerImpl *>(effects)->highlightWindows(windows);
@ -1042,7 +1042,7 @@ void TabBox::navigatingThroughWindows(bool forward, const QKeySequence &shortcut
// CDE style raise / lower
CDEWalkThroughWindows(forward);
} else {
workspace()->forEachAbstractClient([](Toplevel *toplevel) {
workspace()->forEachAbstractClient([](AbstractClient *toplevel) {
if (toplevel->isPopupWindow()) {
toplevel->popupDone();
}

View file

@ -12,7 +12,7 @@
#include "input_event.h"
#include "input_event_spy.h"
#include "pointer_input.h"
#include "toplevel.h"
#include "abstract_client.h"
#include "wayland_server.h"
#include "workspace.h"
// KDecoration
@ -177,7 +177,7 @@ void TabletInputRedirection::cleanupDecoration(Decoration::DecoratedClientImpl *
m_decorationDestroyedConnection = connect(now, &QObject::destroyed, this, &TabletInputRedirection::update, Qt::QueuedConnection);
}
void TabletInputRedirection::focusUpdate(Toplevel *focusOld, Toplevel *focusNow)
void TabletInputRedirection::focusUpdate(AbstractClient *focusOld, AbstractClient *focusNow)
{
Q_UNUSED(focusOld)
Q_UNUSED(focusNow)

View file

@ -18,7 +18,7 @@
namespace KWin
{
class Toplevel;
class AbstractClient;
class TabletToolId;
namespace Decoration
@ -65,7 +65,7 @@ public:
private:
void cleanupDecoration(Decoration::DecoratedClientImpl *old,
Decoration::DecoratedClientImpl *now) override;
void focusUpdate(Toplevel *focusOld, Toplevel *focusNow) override;
void focusUpdate(AbstractClient *focusOld, AbstractClient *focusNow) override;
bool m_tipDown = false;
bool m_tipNear = false;

View file

@ -1,710 +0,0 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2006 Lubos Lunak <l.lunak@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "toplevel.h"
#include "abstract_client.h"
#include "output.h"
#if KWIN_BUILD_ACTIVITIES
#include "activities.h"
#endif
#include "atoms.h"
#include "client_machine.h"
#include "composite.h"
#include "effects.h"
#include "platform.h"
#include "screens.h"
#include "shadow.h"
#include "shadowitem.h"
#include "surfaceitem_x11.h"
#include "virtualdesktops.h"
#include "windowitem.h"
#include "workspace.h"
#include <KWaylandServer/surface_interface.h>
#include <QDebug>
namespace KWin
{
Toplevel::Toplevel()
: m_output(workspace()->activeOutput())
, m_visual(XCB_NONE)
, bit_depth(24)
, info(nullptr)
, ready_for_painting(false)
, m_internalId(QUuid::createUuid())
, m_client()
, is_shape(false)
, effect_window(nullptr)
, m_clientMachine(new ClientMachine(this))
, m_wmClientLeader(XCB_WINDOW_NONE)
, m_skipCloseAnimation(false)
{
connect(screens(), &Screens::changed, this, &Toplevel::screenChanged);
connect(this, &Toplevel::bufferGeometryChanged, this, &Toplevel::inputTransformationChanged);
// Only for compatibility reasons, drop in the next major release.
connect(this, &Toplevel::frameGeometryChanged, this, &Toplevel::geometryChanged);
connect(this, &Toplevel::geometryShapeChanged, this, &Toplevel::discardShapeRegion);
}
Toplevel::~Toplevel()
{
delete info;
}
QDebug operator<<(QDebug debug, const Toplevel *toplevel)
{
QDebugStateSaver saver(debug);
debug.nospace();
if (toplevel) {
debug << toplevel->metaObject()->className() << '(' << static_cast<const void *>(toplevel);
if (toplevel->window()) {
debug << ", windowId=0x" << Qt::hex << toplevel->window() << Qt::dec;
}
if (const KWaylandServer::SurfaceInterface *surface = toplevel->surface()) {
debug << ", surface=" << surface;
}
const AbstractClient *client = qobject_cast<const AbstractClient *>(toplevel);
if (client) {
if (!client->isPopupWindow()) {
debug << ", caption=" << client->caption();
}
if (client->transientFor()) {
debug << ", transientFor=" << client->transientFor();
}
}
if (debug.verbosity() > 2) {
debug << ", frameGeometry=" << toplevel->frameGeometry();
debug << ", resourceName=" << toplevel->resourceName();
debug << ", resourceClass=" << toplevel->resourceClass();
}
debug << ')';
} else {
debug << "Toplevel(0x0)";
}
return debug;
}
void Toplevel::detectShape(xcb_window_t id)
{
const bool wasShape = is_shape;
is_shape = Xcb::Extensions::self()->hasShape(id);
if (wasShape != is_shape) {
Q_EMIT shapedChanged();
}
}
// used only by Deleted::copy()
void Toplevel::copyToDeleted(Toplevel *c)
{
m_internalId = c->internalId();
m_bufferGeometry = c->m_bufferGeometry;
m_frameGeometry = c->m_frameGeometry;
m_clientGeometry = c->m_clientGeometry;
m_visual = c->m_visual;
bit_depth = c->bit_depth;
info = c->info;
m_client.reset(c->m_client, false);
ready_for_painting = c->ready_for_painting;
is_shape = c->is_shape;
effect_window = c->effect_window;
if (effect_window != nullptr) {
effect_window->setWindow(this);
}
m_shadow = c->m_shadow;
if (m_shadow) {
m_shadow->setToplevel(this);
}
resource_name = c->resourceName();
resource_class = c->resourceClass();
m_clientMachine = c->m_clientMachine;
m_clientMachine->setParent(this);
m_wmClientLeader = c->wmClientLeader();
opaque_region = c->opaqueRegion();
m_output = c->m_output;
m_skipCloseAnimation = c->m_skipCloseAnimation;
m_internalFBO = c->m_internalFBO;
m_internalImage = c->m_internalImage;
m_opacity = c->m_opacity;
m_shapeRegionIsValid = c->m_shapeRegionIsValid;
m_shapeRegion = c->m_shapeRegion;
m_stackingOrder = c->m_stackingOrder;
}
// before being deleted, remove references to everything that's now
// owner by Deleted
void Toplevel::disownDataPassedToDeleted()
{
info = nullptr;
}
QRect Toplevel::visibleGeometry() const
{
if (const WindowItem *item = windowItem()) {
return item->mapToGlobal(item->boundingRect());
}
return QRect();
}
Xcb::Property Toplevel::fetchWmClientLeader() const
{
return Xcb::Property(false, window(), atoms->wm_client_leader, XCB_ATOM_WINDOW, 0, 10000);
}
void Toplevel::readWmClientLeader(Xcb::Property &prop)
{
m_wmClientLeader = prop.value<xcb_window_t>(window());
}
void Toplevel::getWmClientLeader()
{
auto prop = fetchWmClientLeader();
readWmClientLeader(prop);
}
/**
* Returns sessionId for this client,
* taken either from its window or from the leader window.
*/
QByteArray Toplevel::sessionId() const
{
QByteArray result = Xcb::StringProperty(window(), atoms->sm_client_id);
if (result.isEmpty() && m_wmClientLeader && m_wmClientLeader != window()) {
result = Xcb::StringProperty(m_wmClientLeader, atoms->sm_client_id);
}
return result;
}
/**
* Returns command property for this client,
* taken either from its window or from the leader window.
*/
QByteArray Toplevel::wmCommand()
{
QByteArray result = Xcb::StringProperty(window(), XCB_ATOM_WM_COMMAND);
if (result.isEmpty() && m_wmClientLeader && m_wmClientLeader != window()) {
result = Xcb::StringProperty(m_wmClientLeader, XCB_ATOM_WM_COMMAND);
}
result.replace(0, ' ');
return result;
}
void Toplevel::getWmClientMachine()
{
m_clientMachine->resolve(window(), wmClientLeader());
}
/**
* Returns client machine for this client,
* taken either from its window or from the leader window.
*/
QByteArray Toplevel::wmClientMachine(bool use_localhost) const
{
if (!m_clientMachine) {
// this should never happen
return QByteArray();
}
if (use_localhost && m_clientMachine->isLocal()) {
// special name for the local machine (localhost)
return ClientMachine::localhost();
}
return m_clientMachine->hostName();
}
/**
* Returns client leader window for this client.
* Returns the client window itself if no leader window is defined.
*/
xcb_window_t Toplevel::wmClientLeader() const
{
if (m_wmClientLeader != XCB_WINDOW_NONE) {
return m_wmClientLeader;
}
return window();
}
void Toplevel::getResourceClass()
{
if (!info) {
return;
}
setResourceClass(QByteArray(info->windowClassName()).toLower(), QByteArray(info->windowClassClass()).toLower());
}
void Toplevel::setResourceClass(const QByteArray &name, const QByteArray &className)
{
resource_name = name;
resource_class = className;
Q_EMIT windowClassChanged();
}
bool Toplevel::resourceMatch(const Toplevel *c1, const Toplevel *c2)
{
return c1->resourceClass() == c2->resourceClass();
}
qreal Toplevel::opacity() const
{
return m_opacity;
}
void Toplevel::setOpacity(qreal opacity)
{
opacity = qBound(0.0, opacity, 1.0);
if (m_opacity == opacity) {
return;
}
const qreal oldOpacity = m_opacity;
m_opacity = opacity;
if (Compositor::compositing()) {
addRepaintFull();
Q_EMIT opacityChanged(this, oldOpacity);
}
}
bool Toplevel::setupCompositing()
{
if (!Compositor::compositing()) {
return false;
}
effect_window = new EffectWindowImpl(this);
updateShadow();
Compositor::self()->scene()->addToplevel(this);
connect(windowItem(), &WindowItem::positionChanged, this, &Toplevel::visibleGeometryChanged);
connect(windowItem(), &WindowItem::boundingRectChanged, this, &Toplevel::visibleGeometryChanged);
return true;
}
void Toplevel::finishCompositing(ReleaseReason releaseReason)
{
// If the X11 window has been destroyed, avoid calling XDamageDestroy.
if (releaseReason != ReleaseReason::Destroyed) {
if (SurfaceItemX11 *item = qobject_cast<SurfaceItemX11 *>(surfaceItem())) {
item->destroyDamage();
}
}
if (m_shadow && m_shadow->toplevel() == this) { // otherwise it's already passed to Deleted, don't free data
deleteShadow();
}
if (effect_window && effect_window->window() == this) { // otherwise it's already passed to Deleted, don't free data
deleteEffectWindow();
}
}
void Toplevel::addRepaint(const QRect &rect)
{
addRepaint(QRegion(rect));
}
void Toplevel::addRepaint(int x, int y, int width, int height)
{
addRepaint(QRegion(x, y, width, height));
}
void Toplevel::addRepaint(const QRegion &region)
{
if (auto item = windowItem()) {
item->scheduleRepaint(region);
}
}
void Toplevel::addLayerRepaint(const QRect &rect)
{
addLayerRepaint(QRegion(rect));
}
void Toplevel::addLayerRepaint(int x, int y, int width, int height)
{
addLayerRepaint(QRegion(x, y, width, height));
}
void Toplevel::addLayerRepaint(const QRegion &region)
{
addRepaint(region.translated(-pos()));
}
void Toplevel::addRepaintFull()
{
addLayerRepaint(visibleGeometry());
}
void Toplevel::addWorkspaceRepaint(int x, int y, int w, int h)
{
addWorkspaceRepaint(QRect(x, y, w, h));
}
void Toplevel::addWorkspaceRepaint(const QRect &r2)
{
if (Compositor::compositing()) {
Compositor::self()->scene()->addRepaint(r2);
}
}
void Toplevel::addWorkspaceRepaint(const QRegion &region)
{
if (Compositor::compositing()) {
Compositor::self()->scene()->addRepaint(region);
}
}
void Toplevel::setReadyForPainting()
{
if (!ready_for_painting) {
ready_for_painting = true;
if (Compositor::compositing()) {
addRepaintFull();
Q_EMIT windowShown(this);
}
}
}
void Toplevel::deleteShadow()
{
delete m_shadow;
m_shadow = nullptr;
}
void Toplevel::deleteEffectWindow()
{
delete effect_window;
effect_window = nullptr;
}
int Toplevel::screen() const
{
return kwinApp()->platform()->enabledOutputs().indexOf(m_output);
}
Output *Toplevel::output() const
{
return m_output;
}
void Toplevel::setOutput(Output *output)
{
if (m_output != output) {
m_output = output;
Q_EMIT screenChanged();
}
}
bool Toplevel::isOnActiveOutput() const
{
return isOnOutput(workspace()->activeOutput());
}
bool Toplevel::isOnOutput(Output *output) const
{
return output->geometry().intersects(frameGeometry());
}
Shadow *Toplevel::shadow() const
{
return m_shadow;
}
void Toplevel::updateShadow()
{
if (!Compositor::compositing()) {
return;
}
if (m_shadow) {
if (!m_shadow->updateShadow()) {
deleteShadow();
}
Q_EMIT shadowChanged();
} else {
m_shadow = Shadow::createShadow(this);
if (m_shadow) {
Q_EMIT shadowChanged();
}
}
}
SurfaceItem *Toplevel::surfaceItem() const
{
if (effectWindow() && effectWindow()->sceneWindow()) {
return effectWindow()->sceneWindow()->surfaceItem();
}
return nullptr;
}
WindowItem *Toplevel::windowItem() const
{
if (effectWindow() && effectWindow()->sceneWindow()) {
return effectWindow()->sceneWindow()->windowItem();
}
return nullptr;
}
bool Toplevel::wantsShadowToBeRendered() const
{
return true;
}
void Toplevel::getWmOpaqueRegion()
{
if (!info) {
return;
}
const auto rects = info->opaqueRegion();
QRegion new_opaque_region;
for (const auto &r : rects) {
new_opaque_region += QRect(r.pos.x, r.pos.y, r.size.width, r.size.height);
}
opaque_region = new_opaque_region;
}
QRegion Toplevel::shapeRegion() const
{
if (m_shapeRegionIsValid) {
return m_shapeRegion;
}
const QRect bufferGeometry = this->bufferGeometry();
if (shape()) {
auto cookie = xcb_shape_get_rectangles_unchecked(kwinApp()->x11Connection(), frameId(), XCB_SHAPE_SK_BOUNDING);
ScopedCPointer<xcb_shape_get_rectangles_reply_t> reply(xcb_shape_get_rectangles_reply(kwinApp()->x11Connection(), cookie, nullptr));
if (!reply.isNull()) {
m_shapeRegion = QRegion();
const xcb_rectangle_t *rects = xcb_shape_get_rectangles_rectangles(reply.data());
const int rectCount = xcb_shape_get_rectangles_rectangles_length(reply.data());
for (int i = 0; i < rectCount; ++i) {
m_shapeRegion += QRegion(rects[i].x, rects[i].y, rects[i].width, rects[i].height);
}
// make sure the shape is sane (X is async, maybe even XShape is broken)
m_shapeRegion &= QRegion(0, 0, bufferGeometry.width(), bufferGeometry.height());
} else {
m_shapeRegion = QRegion();
}
} else {
m_shapeRegion = QRegion(0, 0, bufferGeometry.width(), bufferGeometry.height());
}
m_shapeRegionIsValid = true;
return m_shapeRegion;
}
void Toplevel::discardShapeRegion()
{
m_shapeRegionIsValid = false;
m_shapeRegion = QRegion();
}
bool Toplevel::isClient() const
{
return false;
}
bool Toplevel::isDeleted() const
{
return false;
}
bool Toplevel::isOnCurrentActivity() const
{
#if KWIN_BUILD_ACTIVITIES
if (!Activities::self()) {
return true;
}
return isOnActivity(Activities::self()->current());
#else
return true;
#endif
}
void Toplevel::elevate(bool elevate)
{
if (!effectWindow()) {
return;
}
effectWindow()->elevate(elevate);
addWorkspaceRepaint(visibleGeometry());
}
pid_t Toplevel::pid() const
{
if (!info) {
return -1;
}
return info->pid();
}
xcb_window_t Toplevel::frameId() const
{
return m_client;
}
Xcb::Property Toplevel::fetchSkipCloseAnimation() const
{
return Xcb::Property(false, window(), atoms->kde_skip_close_animation, XCB_ATOM_CARDINAL, 0, 1);
}
void Toplevel::readSkipCloseAnimation(Xcb::Property &property)
{
setSkipCloseAnimation(property.toBool());
}
void Toplevel::getSkipCloseAnimation()
{
Xcb::Property property = fetchSkipCloseAnimation();
readSkipCloseAnimation(property);
}
bool Toplevel::skipsCloseAnimation() const
{
return m_skipCloseAnimation;
}
void Toplevel::setSkipCloseAnimation(bool set)
{
if (set == m_skipCloseAnimation) {
return;
}
m_skipCloseAnimation = set;
Q_EMIT skipCloseAnimationChanged();
}
KWaylandServer::SurfaceInterface *Toplevel::surface() const
{
return m_surface;
}
void Toplevel::setSurface(KWaylandServer::SurfaceInterface *surface)
{
if (m_surface == surface) {
return;
}
m_surface = surface;
m_pendingSurfaceId = 0;
Q_EMIT surfaceChanged();
}
int Toplevel::stackingOrder() const
{
return m_stackingOrder;
}
void Toplevel::setStackingOrder(int order)
{
if (m_stackingOrder != order) {
m_stackingOrder = order;
Q_EMIT stackingOrderChanged();
}
}
QByteArray Toplevel::windowRole() const
{
if (!info) {
return {};
}
return QByteArray(info->windowRole());
}
void Toplevel::setDepth(int depth)
{
if (bit_depth == depth) {
return;
}
const bool oldAlpha = hasAlpha();
bit_depth = depth;
if (oldAlpha != hasAlpha()) {
Q_EMIT hasAlphaChanged();
}
}
QRegion Toplevel::inputShape() const
{
if (m_surface) {
return m_surface->input();
} else {
// TODO: maybe also for X11?
return QRegion();
}
}
QMatrix4x4 Toplevel::inputTransformation() const
{
QMatrix4x4 m;
m.translate(-x(), -y());
return m;
}
bool Toplevel::hitTest(const QPoint &point) const
{
if (m_surface && m_surface->isMapped()) {
return m_surface->inputSurfaceAt(mapToLocal(point));
}
return inputGeometry().contains(point);
}
QPoint Toplevel::mapToFrame(const QPoint &point) const
{
return point - frameGeometry().topLeft();
}
QPoint Toplevel::mapToLocal(const QPoint &point) const
{
return point - bufferGeometry().topLeft();
}
QPointF Toplevel::mapToLocal(const QPointF &point) const
{
return point - bufferGeometry().topLeft();
}
QPointF Toplevel::mapFromLocal(const QPointF &point) const
{
return point + bufferGeometry().topLeft();
}
QRect Toplevel::inputGeometry() const
{
return frameGeometry();
}
bool Toplevel::isLocalhost() const
{
if (!m_clientMachine) {
return true;
}
return m_clientMachine->isLocal();
}
QMargins Toplevel::frameMargins() const
{
return QMargins();
}
bool Toplevel::isOnDesktop(VirtualDesktop *desktop) const
{
return isOnAllDesktops() || desktops().contains(desktop);
}
bool Toplevel::isOnDesktop(int d) const
{
return isOnDesktop(VirtualDesktopManager::self()->desktopForX11Id(d));
}
bool Toplevel::isOnCurrentDesktop() const
{
return isOnDesktop(VirtualDesktopManager::self()->currentDesktop());
}
} // namespace
#include "moc_toplevel.cpp"

View file

@ -1,992 +0,0 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2006 Lubos Lunak <l.lunak@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef KWIN_TOPLEVEL_H
#define KWIN_TOPLEVEL_H
// kwin
#include "utils/common.h"
#include "utils/xcbutils.h"
// KDE
#include <NETWM>
// Qt
#include <QMatrix4x4>
#include <QObject>
#include <QPointer>
#include <QRect>
#include <QUuid>
// c++
#include <functional>
class QOpenGLFramebufferObject;
namespace KWaylandServer
{
class SurfaceInterface;
}
namespace KWin
{
class Output;
class ClientMachine;
class Deleted;
class EffectWindowImpl;
class Shadow;
class SurfaceItem;
class VirtualDesktop;
class WindowItem;
/**
* Enum to describe the reason why a Toplevel has to be released.
*/
enum class ReleaseReason {
Release, ///< Normal Release after e.g. an Unmap notify event (window still valid)
Destroyed, ///< Release after an Destroy notify event (window no longer valid)
KWinShutsDown ///< Release on KWin Shutdown (window still valid)
};
/**
* Represents a window.
*/
class KWIN_EXPORT Toplevel : public QObject
{
Q_OBJECT
Q_PROPERTY(bool alpha READ hasAlpha NOTIFY hasAlphaChanged)
Q_PROPERTY(qulonglong frameId READ frameId)
/**
* This property holds the geometry of the Toplevel, excluding invisible
* portions, e.g. client-side and server-side drop-shadows, etc.
*
* @deprecated Use frameGeometry property instead.
*/
Q_PROPERTY(QRect geometry READ frameGeometry NOTIFY frameGeometryChanged)
/**
* This property holds rectangle that the pixmap or buffer of this Toplevel
* occupies on the screen. This rectangle includes invisible portions of the
* client, e.g. client-side drop shadows, etc.
*/
Q_PROPERTY(QRect bufferGeometry READ bufferGeometry)
/**
* This property holds the geometry of the Toplevel, excluding invisible
* portions, e.g. server-side and client-side drop-shadows, etc.
*/
Q_PROPERTY(QRect frameGeometry READ frameGeometry NOTIFY frameGeometryChanged)
/**
* This property holds the position of the Toplevel's frame geometry.
*/
Q_PROPERTY(QPoint pos READ pos)
/**
* This property holds the size of the Toplevel's frame geometry.
*/
Q_PROPERTY(QSize size READ size)
/**
* This property holds the x position of the Toplevel's frame geometry.
*/
Q_PROPERTY(int x READ x NOTIFY frameGeometryChanged)
/**
* This property holds the y position of the Toplevel's frame geometry.
*/
Q_PROPERTY(int y READ y NOTIFY frameGeometryChanged)
/**
* This property holds the width of the Toplevel's frame geometry.
*/
Q_PROPERTY(int width READ width NOTIFY frameGeometryChanged)
/**
* This property holds the height of the Toplevel's frame geometry.
*/
Q_PROPERTY(int height READ height NOTIFY frameGeometryChanged)
Q_PROPERTY(QRect visibleRect READ visibleGeometry)
Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged)
Q_PROPERTY(int screen READ screen NOTIFY screenChanged)
Q_PROPERTY(qulonglong windowId READ window CONSTANT)
Q_PROPERTY(int desktop READ desktop)
/**
* Whether the window is on all desktops. That is desktop is -1.
*/
Q_PROPERTY(bool onAllDesktops READ isOnAllDesktops)
Q_PROPERTY(QRect rect READ rect)
Q_PROPERTY(QPoint clientPos READ clientPos)
Q_PROPERTY(QSize clientSize READ clientSize)
Q_PROPERTY(QByteArray resourceName READ resourceName NOTIFY windowClassChanged)
Q_PROPERTY(QByteArray resourceClass READ resourceClass NOTIFY windowClassChanged)
Q_PROPERTY(QByteArray windowRole READ windowRole NOTIFY windowRoleChanged)
/**
* Returns whether the window is a desktop background window (the one with wallpaper).
* See _NET_WM_WINDOW_TYPE_DESKTOP at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
*/
Q_PROPERTY(bool desktopWindow READ isDesktop)
/**
* Returns whether the window is a dock (i.e. a panel).
* See _NET_WM_WINDOW_TYPE_DOCK at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
*/
Q_PROPERTY(bool dock READ isDock)
/**
* Returns whether the window is a standalone (detached) toolbar window.
* See _NET_WM_WINDOW_TYPE_TOOLBAR at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
*/
Q_PROPERTY(bool toolbar READ isToolbar)
/**
* Returns whether the window is a torn-off menu.
* See _NET_WM_WINDOW_TYPE_MENU at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
*/
Q_PROPERTY(bool menu READ isMenu)
/**
* Returns whether the window is a "normal" window, i.e. an application or any other window
* for which none of the specialized window types fit.
* See _NET_WM_WINDOW_TYPE_NORMAL at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
*/
Q_PROPERTY(bool normalWindow READ isNormalWindow)
/**
* Returns whether the window is a dialog window.
* See _NET_WM_WINDOW_TYPE_DIALOG at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
*/
Q_PROPERTY(bool dialog READ isDialog)
/**
* Returns whether the window is a splashscreen. Note that many (especially older) applications
* do not support marking their splash windows with this type.
* See _NET_WM_WINDOW_TYPE_SPLASH at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
*/
Q_PROPERTY(bool splash READ isSplash)
/**
* Returns whether the window is a utility window, such as a tool window.
* See _NET_WM_WINDOW_TYPE_UTILITY at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
*/
Q_PROPERTY(bool utility READ isUtility)
/**
* Returns whether the window is a dropdown menu (i.e. a popup directly or indirectly open
* from the applications menubar).
* See _NET_WM_WINDOW_TYPE_DROPDOWN_MENU at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
*/
Q_PROPERTY(bool dropdownMenu READ isDropdownMenu)
/**
* Returns whether the window is a popup menu (that is not a torn-off or dropdown menu).
* See _NET_WM_WINDOW_TYPE_POPUP_MENU at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
*/
Q_PROPERTY(bool popupMenu READ isPopupMenu)
/**
* Returns whether the window is a tooltip.
* See _NET_WM_WINDOW_TYPE_TOOLTIP at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
*/
Q_PROPERTY(bool tooltip READ isTooltip)
/**
* Returns whether the window is a window with a notification.
* See _NET_WM_WINDOW_TYPE_NOTIFICATION at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
*/
Q_PROPERTY(bool notification READ isNotification)
/**
* Returns whether the window is a window with a critical notification.
*/
Q_PROPERTY(bool criticalNotification READ isCriticalNotification)
/**
* Returns whether the window is an On Screen Display.
*/
Q_PROPERTY(bool onScreenDisplay READ isOnScreenDisplay)
/**
* Returns whether the window is a combobox popup.
* See _NET_WM_WINDOW_TYPE_COMBO at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
*/
Q_PROPERTY(bool comboBox READ isComboBox)
/**
* Returns whether the window is a Drag&Drop icon.
* See _NET_WM_WINDOW_TYPE_DND at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
*/
Q_PROPERTY(bool dndIcon READ isDNDIcon)
/**
* Returns the NETWM window type
* See https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
*/
Q_PROPERTY(int windowType READ windowType)
Q_PROPERTY(QStringList activities READ activities)
/**
* Whether this Toplevel is managed by KWin (it has control over its placement and other
* aspects, as opposed to override-redirect windows that are entirely handled by the application).
*/
Q_PROPERTY(bool managed READ isClient CONSTANT)
/**
* Whether this Toplevel represents an already deleted window and only kept for the compositor for animations.
*/
Q_PROPERTY(bool deleted READ isDeleted CONSTANT)
/**
* Whether the window has an own shape
*/
Q_PROPERTY(bool shaped READ shape NOTIFY shapedChanged)
/**
* Whether the window does not want to be animated on window close.
* There are legit reasons for this like a screenshot application which does not want it's
* window being captured.
*/
Q_PROPERTY(bool skipsCloseAnimation READ skipsCloseAnimation WRITE setSkipCloseAnimation NOTIFY skipCloseAnimationChanged)
/**
* Interface to the Wayland Surface.
* Relevant only in Wayland, in X11 it will be nullptr
*/
Q_PROPERTY(KWaylandServer::SurfaceInterface *surface READ surface)
/**
* Whether the window is a popup.
*/
Q_PROPERTY(bool popupWindow READ isPopupWindow)
/**
* Whether this Toplevel represents the outline.
*
* @note It's always @c false if compositing is turned off.
*/
Q_PROPERTY(bool outline READ isOutline)
/**
* This property holds a UUID to uniquely identify this Toplevel.
*/
Q_PROPERTY(QUuid internalId READ internalId CONSTANT)
/**
* The pid of the process owning this window.
*
* @since 5.20
*/
Q_PROPERTY(int pid READ pid CONSTANT)
/**
* The position of this window within Workspace's window stack.
*/
Q_PROPERTY(int stackingOrder READ stackingOrder NOTIFY stackingOrderChanged)
public:
explicit Toplevel();
virtual xcb_window_t frameId() const;
xcb_window_t window() const;
/**
* Returns the geometry of the pixmap or buffer attached to this Toplevel.
*
* For X11 clients, this method returns server-side geometry of the Toplevel.
*
* For Wayland clients, this method returns rectangle that the main surface
* occupies on the screen, in global screen coordinates.
*/
QRect bufferGeometry() const;
/**
* Returns the geometry of the Toplevel, excluding invisible portions, e.g.
* server-side and client-side drop shadows, etc.
*/
QRect frameGeometry() const;
/**
* Returns the geometry of the client window, in global screen coordinates.
*/
QRect clientGeometry() const;
/**
* Returns the extents of the server-side decoration.
*
* Note that the returned margins object will have all margins set to 0 if
* the client doesn't have a server-side decoration.
*
* Default implementation returns a margins object with all margins set to 0.
*/
virtual QMargins frameMargins() const;
/**
* The geometry of the Toplevel which accepts input events. This might be larger
* than the actual geometry, e.g. to support resizing outside the window.
*
* Default implementation returns same as geometry.
*/
virtual QRect inputGeometry() const;
QSize size() const;
QPoint pos() const;
QRect rect() const;
int x() const;
int y() const;
int width() const;
int height() const;
bool isOnOutput(Output *output) const;
bool isOnActiveOutput() const;
int screen() const; // the screen where the center is
Output *output() const;
void setOutput(Output *output);
virtual QPoint clientPos() const = 0; // inside of geometry()
QSize clientSize() const;
/**
* Returns a rectangle that the window occupies on the screen, including drop-shadows.
*/
QRect visibleGeometry() const;
virtual bool isClient() const;
virtual bool isDeleted() const;
/**
* Maps the specified @a point from the global screen coordinates to the frame coordinates.
*/
QPoint mapToFrame(const QPoint &point) const;
/**
* Maps the specified @a point from the global screen coordinates to the surface-local
* coordinates of the main surface. For X11 clients, this function maps the specified point
* from the global screen coordinates to the buffer-local coordinates.
*/
QPoint mapToLocal(const QPoint &point) const;
QPointF mapToLocal(const QPointF &point) const;
QPointF mapFromLocal(const QPointF &point) const;
// prefer isXXX() instead
// 0 for supported types means default for managed/unmanaged types
virtual NET::WindowType windowType(bool direct = false, int supported_types = 0) const = 0;
bool hasNETSupport() const;
bool isDesktop() const;
bool isDock() const;
bool isToolbar() const;
bool isMenu() const;
bool isNormalWindow() const; // normal as in 'NET::Normal or NET::Unknown non-transient'
bool isDialog() const;
bool isSplash() const;
bool isUtility() const;
bool isDropdownMenu() const;
bool isPopupMenu() const; // a context popup, not dropdown, not torn-off
bool isTooltip() const;
bool isNotification() const;
bool isCriticalNotification() const;
bool isOnScreenDisplay() const;
bool isComboBox() const;
bool isDNDIcon() const;
virtual bool isLockScreen() const;
virtual bool isInputMethod() const;
virtual bool isOutline() const;
virtual bool isInternal() const;
/**
* Returns the virtual desktop within the workspace() the client window
* is located in, 0 if it isn't located on any special desktop (not mapped yet),
* or NET::OnAllDesktops. Do not use desktop() directly, use
* isOnDesktop() instead.
*/
virtual int desktop() const = 0;
virtual QVector<VirtualDesktop *> desktops() const = 0;
virtual QStringList activities() const = 0;
bool isOnDesktop(VirtualDesktop *desktop) const;
bool isOnDesktop(int d) const;
bool isOnActivity(const QString &activity) const;
bool isOnCurrentDesktop() const;
bool isOnCurrentActivity() const;
bool isOnAllDesktops() const;
bool isOnAllActivities() const;
virtual QByteArray windowRole() const;
QByteArray sessionId() const;
QByteArray resourceName() const;
QByteArray resourceClass() const;
QByteArray wmCommand();
QByteArray wmClientMachine(bool use_localhost) const;
const ClientMachine *clientMachine() const;
virtual bool isLocalhost() const;
xcb_window_t wmClientLeader() const;
virtual pid_t pid() const;
static bool resourceMatch(const Toplevel *c1, const Toplevel *c2);
bool readyForPainting() const; // true if the window has been already painted its contents
xcb_visualid_t visual() const;
bool shape() const;
QRegion inputShape() const;
void setOpacity(qreal opacity);
qreal opacity() const;
int depth() const;
bool hasAlpha() const;
virtual bool setupCompositing();
virtual void finishCompositing(ReleaseReason releaseReason = ReleaseReason::Release);
Q_INVOKABLE void addRepaint(const QRect &r);
Q_INVOKABLE void addRepaint(const QRegion &r);
Q_INVOKABLE void addRepaint(int x, int y, int w, int h);
Q_INVOKABLE void addLayerRepaint(const QRect &r);
Q_INVOKABLE void addLayerRepaint(const QRegion &r);
Q_INVOKABLE void addLayerRepaint(int x, int y, int w, int h);
Q_INVOKABLE virtual void addRepaintFull();
// these call workspace->addRepaint(), but first transform the damage if needed
void addWorkspaceRepaint(const QRect &r);
void addWorkspaceRepaint(int x, int y, int w, int h);
void addWorkspaceRepaint(const QRegion &region);
EffectWindowImpl *effectWindow();
const EffectWindowImpl *effectWindow() const;
SurfaceItem *surfaceItem() const;
WindowItem *windowItem() const;
/**
* Window will be temporarily painted as if being at the top of the stack.
* Only available if Compositor is active, if not active, this method is a no-op.
*/
void elevate(bool elevate);
/**
* Returns the Shadow associated with this Toplevel or @c null if it has no shadow.
*/
Shadow *shadow() const;
/**
* Updates the Shadow associated with this Toplevel from X11 Property.
* Call this method when the Property changes or Compositing is started.
*/
void updateShadow();
/**
* Whether the Toplevel currently wants the shadow to be rendered. Default
* implementation always returns @c true.
*/
virtual bool wantsShadowToBeRendered() const;
/**
* This method returns the area that the Toplevel window reports to be opaque.
* It is supposed to only provide valuable information if hasAlpha is @c true .
* @see hasAlpha
*/
const QRegion &opaqueRegion() const;
QRegion shapeRegion() const;
virtual Layer layer() const = 0;
bool skipsCloseAnimation() const;
void setSkipCloseAnimation(bool set);
quint32 pendingSurfaceId() const;
KWaylandServer::SurfaceInterface *surface() const;
void setSurface(KWaylandServer::SurfaceInterface *surface);
const QSharedPointer<QOpenGLFramebufferObject> &internalFramebufferObject() const;
QImage internalImageObject() const;
/**
* @returns Transformation to map from global to window coordinates.
*
* Default implementation returns a translation on negative pos().
* @see pos
*/
virtual QMatrix4x4 inputTransformation() const;
/**
* Returns @c true if the toplevel can accept input at the specified position @a point.
*/
virtual bool hitTest(const QPoint &point) const;
/**
* The window has a popup grab. This means that when it got mapped the
* parent window had an implicit (pointer) grab.
*
* Normally this is only relevant for transient windows.
*
* Once the popup grab ends (e.g. pointer press outside of any Toplevel of
* the client), the method popupDone should be invoked.
*
* The default implementation returns @c false.
* @see popupDone
* @since 5.10
*/
virtual bool hasPopupGrab() const
{
return false;
}
/**
* This method should be invoked for Toplevels with a popup grab when
* the grab ends.
*
* The default implementation does nothing.
* @see hasPopupGrab
* @since 5.10
*/
virtual void popupDone(){};
/**
* @brief Finds the Toplevel matching the condition expressed in @p func in @p list.
*
* The method is templated to operate on either a list of Toplevels or on a list of
* a subclass type of Toplevel.
* @param list The list to search in
* @param func The condition function (compare std::find_if)
* @return T* The found Toplevel or @c null if there is no matching Toplevel
*/
template<class T, class U>
static T *findInList(const QList<T *> &list, std::function<bool(const U *)> func);
/**
* Whether the window is a popup.
*
* Popups can be used to implement popup menus, tooltips, combo boxes, etc.
*
* @since 5.15
*/
virtual bool isPopupWindow() const;
/**
* A UUID to uniquely identify this Toplevel independent of windowing system.
*/
QUuid internalId() const
{
return m_internalId;
}
/**
* Returns @c true if the window is shaded; otherwise returns @c false.
*/
virtual bool isShade() const
{
return false;
}
int stackingOrder() const;
void setStackingOrder(int order); ///< @internal
Q_SIGNALS:
void stackingOrderChanged();
void shadeChanged();
void opacityChanged(KWin::Toplevel *toplevel, qreal oldOpacity);
void damaged(KWin::Toplevel *toplevel, const QRegion &damage);
void inputTransformationChanged();
/**
* This signal is emitted when the Toplevel's frame geometry changes.
* @deprecated since 5.19, use frameGeometryChanged instead
*/
void geometryChanged();
void geometryShapeChanged(KWin::Toplevel *toplevel, const QRect &old);
void windowClosed(KWin::Toplevel *toplevel, KWin::Deleted *deleted);
void windowShown(KWin::Toplevel *toplevel);
void windowHidden(KWin::Toplevel *toplevel);
/**
* Signal emitted when the window's shape state changed. That is if it did not have a shape
* and received one or if the shape was withdrawn. Think of Chromium enabling/disabling KWin's
* decoration.
*/
void shapedChanged();
/**
* Emitted whenever the Toplevel's screen changes. This can happen either in consequence to
* a screen being removed/added or if the Toplevel's geometry changes.
* @since 4.11
*/
void screenChanged();
void skipCloseAnimationChanged();
/**
* Emitted whenever the window role of the window changes.
* @since 5.0
*/
void windowRoleChanged();
/**
* Emitted whenever the window class name or resource name of the window changes.
* @since 5.0
*/
void windowClassChanged();
/**
* @since 5.4
*/
void hasAlphaChanged();
/**
* Emitted whenever the Surface for this Toplevel changes.
*/
void surfaceChanged();
/**
* Emitted whenever the client's shadow changes.
* @since 5.15
*/
void shadowChanged();
/**
* This signal is emitted when the Toplevel's buffer geometry changes.
*/
void bufferGeometryChanged(KWin::Toplevel *toplevel, const QRect &oldGeometry);
/**
* This signal is emitted when the Toplevel's frame geometry changes.
*/
void frameGeometryChanged(KWin::Toplevel *toplevel, const QRect &oldGeometry);
/**
* This signal is emitted when the Toplevel's client geometry has changed.
*/
void clientGeometryChanged(KWin::Toplevel *toplevel, const QRect &oldGeometry);
/**
* This signal is emitted when the visible geometry has changed.
*/
void visibleGeometryChanged();
protected Q_SLOTS:
void setReadyForPainting();
protected:
~Toplevel() override;
void setWindowHandles(xcb_window_t client);
void detectShape(xcb_window_t id);
virtual void propertyNotifyEvent(xcb_property_notify_event_t *e);
virtual void clientMessageEvent(xcb_client_message_event_t *e);
Xcb::Property fetchWmClientLeader() const;
void readWmClientLeader(Xcb::Property &p);
void getWmClientLeader();
void getWmClientMachine();
/**
* This function fetches the opaque region from this Toplevel.
* Will only be called on corresponding property changes and for initialization.
*/
void getWmOpaqueRegion();
void discardShapeRegion();
void getResourceClass();
void setResourceClass(const QByteArray &name, const QByteArray &className = QByteArray());
Xcb::Property fetchSkipCloseAnimation() const;
void readSkipCloseAnimation(Xcb::Property &prop);
void getSkipCloseAnimation();
void copyToDeleted(Toplevel *c);
void disownDataPassedToDeleted();
void deleteShadow();
void deleteEffectWindow();
void setDepth(int depth);
Output *m_output = nullptr;
QRect m_frameGeometry;
QRect m_clientGeometry;
QRect m_bufferGeometry;
xcb_visualid_t m_visual;
int bit_depth;
NETWinInfo *info;
bool ready_for_painting;
/**
* An FBO object KWin internal windows might render to.
*/
QSharedPointer<QOpenGLFramebufferObject> m_internalFBO;
QImage m_internalImage;
private:
// when adding new data members, check also copyToDeleted()
QUuid m_internalId;
Xcb::Window m_client;
bool is_shape;
EffectWindowImpl *effect_window;
Shadow *m_shadow = nullptr;
QByteArray resource_name;
QByteArray resource_class;
ClientMachine *m_clientMachine;
xcb_window_t m_wmClientLeader;
QRegion opaque_region;
mutable QRegion m_shapeRegion;
mutable bool m_shapeRegionIsValid = false;
bool m_skipCloseAnimation;
quint32 m_pendingSurfaceId = 0;
QPointer<KWaylandServer::SurfaceInterface> m_surface;
// when adding new data members, check also copyToDeleted()
qreal m_opacity = 1.0;
int m_stackingOrder = 0;
};
inline xcb_window_t Toplevel::window() const
{
return m_client;
}
inline void Toplevel::setWindowHandles(xcb_window_t w)
{
Q_ASSERT(!m_client.isValid() && w != XCB_WINDOW_NONE);
m_client.reset(w, false);
}
inline QRect Toplevel::bufferGeometry() const
{
return m_bufferGeometry;
}
inline QRect Toplevel::clientGeometry() const
{
return m_clientGeometry;
}
inline QSize Toplevel::clientSize() const
{
return m_clientGeometry.size();
}
inline QRect Toplevel::frameGeometry() const
{
return m_frameGeometry;
}
inline QSize Toplevel::size() const
{
return m_frameGeometry.size();
}
inline QPoint Toplevel::pos() const
{
return m_frameGeometry.topLeft();
}
inline int Toplevel::x() const
{
return m_frameGeometry.x();
}
inline int Toplevel::y() const
{
return m_frameGeometry.y();
}
inline int Toplevel::width() const
{
return m_frameGeometry.width();
}
inline int Toplevel::height() const
{
return m_frameGeometry.height();
}
inline QRect Toplevel::rect() const
{
return QRect(0, 0, width(), height());
}
inline bool Toplevel::readyForPainting() const
{
return ready_for_painting;
}
inline xcb_visualid_t Toplevel::visual() const
{
return m_visual;
}
inline bool Toplevel::isDesktop() const
{
return windowType() == NET::Desktop;
}
inline bool Toplevel::isDock() const
{
return windowType() == NET::Dock;
}
inline bool Toplevel::isMenu() const
{
return windowType() == NET::Menu;
}
inline bool Toplevel::isToolbar() const
{
return windowType() == NET::Toolbar;
}
inline bool Toplevel::isSplash() const
{
return windowType() == NET::Splash;
}
inline bool Toplevel::isUtility() const
{
return windowType() == NET::Utility;
}
inline bool Toplevel::isDialog() const
{
return windowType() == NET::Dialog;
}
inline bool Toplevel::isNormalWindow() const
{
return windowType() == NET::Normal;
}
inline bool Toplevel::isDropdownMenu() const
{
return windowType() == NET::DropdownMenu;
}
inline bool Toplevel::isPopupMenu() const
{
return windowType() == NET::PopupMenu;
}
inline bool Toplevel::isTooltip() const
{
return windowType() == NET::Tooltip;
}
inline bool Toplevel::isNotification() const
{
return windowType() == NET::Notification;
}
inline bool Toplevel::isCriticalNotification() const
{
return windowType() == NET::CriticalNotification;
}
inline bool Toplevel::isOnScreenDisplay() const
{
return windowType() == NET::OnScreenDisplay;
}
inline bool Toplevel::isComboBox() const
{
return windowType() == NET::ComboBox;
}
inline bool Toplevel::isDNDIcon() const
{
return windowType() == NET::DNDIcon;
}
inline bool Toplevel::isLockScreen() const
{
return false;
}
inline bool Toplevel::isInputMethod() const
{
return false;
}
inline bool Toplevel::isOutline() const
{
return false;
}
inline bool Toplevel::isInternal() const
{
return false;
}
inline bool Toplevel::shape() const
{
return is_shape;
}
inline int Toplevel::depth() const
{
return bit_depth;
}
inline bool Toplevel::hasAlpha() const
{
return depth() == 32;
}
inline const QRegion &Toplevel::opaqueRegion() const
{
return opaque_region;
}
inline EffectWindowImpl *Toplevel::effectWindow()
{
return effect_window;
}
inline const EffectWindowImpl *Toplevel::effectWindow() const
{
return effect_window;
}
inline bool Toplevel::isOnAllDesktops() const
{
return desktops().isEmpty();
}
inline bool Toplevel::isOnAllActivities() const
{
return activities().isEmpty();
}
inline bool Toplevel::isOnActivity(const QString &activity) const
{
return activities().isEmpty() || activities().contains(activity);
}
inline QByteArray Toplevel::resourceName() const
{
return resource_name; // it is always lowercase
}
inline QByteArray Toplevel::resourceClass() const
{
return resource_class; // it is always lowercase
}
inline const ClientMachine *Toplevel::clientMachine() const
{
return m_clientMachine;
}
inline quint32 Toplevel::pendingSurfaceId() const
{
return m_pendingSurfaceId;
}
inline const QSharedPointer<QOpenGLFramebufferObject> &Toplevel::internalFramebufferObject() const
{
return m_internalFBO;
}
inline QImage Toplevel::internalImageObject() const
{
return m_internalImage;
}
template<class T, class U>
inline T *Toplevel::findInList(const QList<T *> &list, std::function<bool(const U *)> func)
{
static_assert(std::is_base_of<U, T>::value,
"U must be derived from T");
const auto it = std::find_if(list.begin(), list.end(), func);
if (it == list.end()) {
return nullptr;
}
return *it;
}
inline bool Toplevel::isPopupWindow() const
{
switch (windowType()) {
case NET::ComboBox:
case NET::DropdownMenu:
case NET::PopupMenu:
case NET::Tooltip:
return true;
default:
return false;
}
}
KWIN_EXPORT QDebug operator<<(QDebug debug, const Toplevel *toplevel);
} // namespace
Q_DECLARE_METATYPE(KWin::Toplevel *)
#endif

View file

@ -15,7 +15,7 @@
#include "decorations/decoratedclient.h"
#include "input_event_spy.h"
#include "pointer_input.h"
#include "toplevel.h"
#include "abstract_client.h"
#include "wayland_server.h"
#include "workspace.h"
// KDecoration
@ -89,7 +89,7 @@ bool TouchInputRedirection::positionValid() const
return !m_activeTouchPoints.isEmpty();
}
void TouchInputRedirection::focusUpdate(Toplevel *focusOld, Toplevel *focusNow)
void TouchInputRedirection::focusUpdate(AbstractClient *focusOld, AbstractClient *focusNow)
{
// TODO: handle pointer grab aka popups
@ -113,7 +113,7 @@ void TouchInputRedirection::focusUpdate(Toplevel *focusOld, Toplevel *focusNow)
// FIXME: add input transformation API to KWaylandServer::SeatInterface for touch input
seat->setFocusedTouchSurface(focusNow->surface(), -1 * focusNow->inputTransformation().map(focusNow->pos()) + focusNow->pos());
m_focusGeometryConnection = connect(focusNow, &Toplevel::frameGeometryChanged, this, [this]() {
m_focusGeometryConnection = connect(focusNow, &AbstractClient::frameGeometryChanged, this, [this]() {
if (!focus()) {
return;
}

View file

@ -21,7 +21,7 @@ namespace KWin
class InputDevice;
class InputRedirection;
class Toplevel;
class AbstractClient;
namespace Decoration
{
@ -75,7 +75,7 @@ public:
private:
void cleanupDecoration(Decoration::DecoratedClientImpl *old, Decoration::DecoratedClientImpl *now) override;
void focusUpdate(Toplevel *focusOld, Toplevel *focusNow) override;
void focusUpdate(AbstractClient *focusOld, AbstractClient *focusNow) override;
QSet<qint32> m_activeTouchPoints;
bool m_inited = false;

View file

@ -56,7 +56,7 @@ Unmanaged::Unmanaged()
switch (kwinApp()->operationMode()) {
case Application::OperationModeXwayland:
// The wayland surface is associated with the override-redirect window asynchronously.
connect(this, &Toplevel::surfaceChanged, this, &Unmanaged::associate);
connect(this, &AbstractClient::surfaceChanged, this, &Unmanaged::associate);
break;
case Application::OperationModeX11:
// We have no way knowing whether the override-redirect window can be painted. Mark it

View file

@ -1677,7 +1677,7 @@ bool Workspace::switchWindow(AbstractClient *c, Direction direction, QPoint curP
AbstractClient *switchTo = nullptr;
int bestScore = 0;
QList<Toplevel *> clist = stackingOrder();
QList<AbstractClient *> clist = stackingOrder();
for (auto i = clist.rbegin(); i != clist.rend(); ++i) {
auto t = *i;
auto client = static_cast<AbstractClient *>(t->isClient() ? t : nullptr);

View file

@ -360,7 +360,7 @@ bool WaylandServer::init(InitializationFlags flags)
m_initFlags = flags;
m_compositor = new CompositorInterface(m_display, m_display);
connect(m_compositor, &CompositorInterface::surfaceCreated, this, [this](SurfaceInterface *surface) {
// check whether we have a Toplevel with the Surface's id
// check whether we have a AbstractClient with the Surface's id
Workspace *ws = Workspace::self();
if (!ws) {
// it's possible that a Surface gets created before Workspace is created
@ -521,7 +521,7 @@ SurfaceInterface *WaylandServer::findForeignTransientForSurface(SurfaceInterface
return m_XdgForeign->transientFor(surface);
}
void WaylandServer::shellClientShown(Toplevel *toplevel)
void WaylandServer::shellClientShown(AbstractClient *toplevel)
{
auto client = static_cast<AbstractClient *>(toplevel->isClient() ? toplevel : nullptr);
if (!client) {
@ -550,7 +550,7 @@ void WaylandServer::initWorkspace()
auto f = [this]() {
QVector<quint32> ids;
QVector<QString> uuids;
for (Toplevel *toplevel : workspace()->stackingOrder()) {
for (AbstractClient *toplevel : workspace()->stackingOrder()) {
auto *client = static_cast<AbstractClient *>(toplevel->isClient() ? toplevel : nullptr);
if (client && client->windowManagementInterface()) {
ids << client->windowManagementInterface()->internalId();

View file

@ -55,7 +55,6 @@ namespace KWin
class AbstractClient;
class Output;
class Toplevel;
class XdgPopupClient;
class XdgSurfaceClient;
class XdgToplevelClient;
@ -242,7 +241,7 @@ Q_SIGNALS:
private:
int createScreenLockerConnection();
void shellClientShown(Toplevel *t);
void shellClientShown(AbstractClient *t);
void initScreenLocker();
void registerXdgGenericClient(AbstractClient *client);
void registerXdgToplevelClient(XdgToplevelClient *client);

View file

@ -17,7 +17,7 @@
namespace KWin
{
WindowItem::WindowItem(Toplevel *window, Item *parent)
WindowItem::WindowItem(AbstractClient *window, Item *parent)
: Item(parent)
, m_window(window)
{
@ -26,10 +26,10 @@ WindowItem::WindowItem(Toplevel *window, Item *parent)
connect(client, &AbstractClient::decorationChanged, this, &WindowItem::updateDecorationItem);
updateDecorationItem();
}
connect(window, &Toplevel::shadowChanged, this, &WindowItem::updateShadowItem);
connect(window, &AbstractClient::shadowChanged, this, &WindowItem::updateShadowItem);
updateShadowItem();
connect(window, &Toplevel::windowClosed, this, &WindowItem::handleWindowClosed);
connect(window, &AbstractClient::windowClosed, this, &WindowItem::handleWindowClosed);
}
SurfaceItem *WindowItem::surfaceItem() const
@ -47,12 +47,12 @@ ShadowItem *WindowItem::shadowItem() const
return m_shadowItem.data();
}
Toplevel *WindowItem::window() const
AbstractClient *WindowItem::window() const
{
return m_window;
}
void WindowItem::handleWindowClosed(Toplevel *original, Deleted *deleted)
void WindowItem::handleWindowClosed(AbstractClient *original, Deleted *deleted)
{
Q_UNUSED(original)
m_window = deleted;
@ -63,16 +63,16 @@ void WindowItem::updateSurfaceItem(SurfaceItem *surfaceItem)
m_surfaceItem.reset(surfaceItem);
if (m_surfaceItem) {
connect(m_window, &Toplevel::shadeChanged, this, &WindowItem::updateSurfaceVisibility);
connect(m_window, &Toplevel::bufferGeometryChanged, this, &WindowItem::updateSurfacePosition);
connect(m_window, &Toplevel::frameGeometryChanged, this, &WindowItem::updateSurfacePosition);
connect(m_window, &AbstractClient::shadeChanged, this, &WindowItem::updateSurfaceVisibility);
connect(m_window, &AbstractClient::bufferGeometryChanged, this, &WindowItem::updateSurfacePosition);
connect(m_window, &AbstractClient::frameGeometryChanged, this, &WindowItem::updateSurfacePosition);
updateSurfacePosition();
updateSurfaceVisibility();
} else {
disconnect(m_window, &Toplevel::shadeChanged, this, &WindowItem::updateSurfaceVisibility);
disconnect(m_window, &Toplevel::bufferGeometryChanged, this, &WindowItem::updateSurfacePosition);
disconnect(m_window, &Toplevel::frameGeometryChanged, this, &WindowItem::updateSurfacePosition);
disconnect(m_window, &AbstractClient::shadeChanged, this, &WindowItem::updateSurfaceVisibility);
disconnect(m_window, &AbstractClient::bufferGeometryChanged, this, &WindowItem::updateSurfacePosition);
disconnect(m_window, &AbstractClient::frameGeometryChanged, this, &WindowItem::updateSurfacePosition);
}
}
@ -124,13 +124,13 @@ void WindowItem::updateDecorationItem()
}
}
WindowItemX11::WindowItemX11(Toplevel *window, Item *parent)
WindowItemX11::WindowItemX11(AbstractClient *window, Item *parent)
: WindowItem(window, parent)
{
initialize();
// Xwayland windows and Wayland surfaces are associated asynchronously.
connect(window, &Toplevel::surfaceChanged, this, &WindowItemX11::initialize);
connect(window, &AbstractClient::surfaceChanged, this, &WindowItemX11::initialize);
}
void WindowItemX11::initialize()
@ -151,7 +151,7 @@ void WindowItemX11::initialize()
}
}
WindowItemWayland::WindowItemWayland(Toplevel *window, Item *parent)
WindowItemWayland::WindowItemWayland(AbstractClient *window, Item *parent)
: WindowItem(window, parent)
{
updateSurfaceItem(new SurfaceItemWayland(window->surface(), window, this));

View file

@ -15,13 +15,13 @@ class Decoration;
namespace KWin
{
class AbstractClient;
class DecorationItem;
class Deleted;
class InternalClient;
class Shadow;
class ShadowItem;
class SurfaceItem;
class Toplevel;
/**
* The WindowItem class represents a window in the scene.
@ -37,21 +37,21 @@ public:
SurfaceItem *surfaceItem() const;
DecorationItem *decorationItem() const;
ShadowItem *shadowItem() const;
Toplevel *window() const;
AbstractClient *window() const;
protected:
explicit WindowItem(Toplevel *window, Item *parent = nullptr);
explicit WindowItem(AbstractClient *window, Item *parent = nullptr);
void updateSurfaceItem(SurfaceItem *surfaceItem);
private Q_SLOTS:
void handleWindowClosed(Toplevel *original, Deleted *deleted);
void handleWindowClosed(AbstractClient *original, Deleted *deleted);
void updateDecorationItem();
void updateShadowItem();
void updateSurfacePosition();
void updateSurfaceVisibility();
private:
Toplevel *m_window;
AbstractClient *m_window;
QScopedPointer<SurfaceItem> m_surfaceItem;
QScopedPointer<DecorationItem> m_decorationItem;
QScopedPointer<ShadowItem> m_shadowItem;
@ -68,7 +68,7 @@ class KWIN_EXPORT WindowItemX11 : public WindowItem
Q_OBJECT
public:
explicit WindowItemX11(Toplevel *window, Item *parent = nullptr);
explicit WindowItemX11(AbstractClient *window, Item *parent = nullptr);
private Q_SLOTS:
void initialize();
@ -82,7 +82,7 @@ class KWIN_EXPORT WindowItemWayland : public WindowItem
Q_OBJECT
public:
explicit WindowItemWayland(Toplevel *window, Item *parent = nullptr);
explicit WindowItemWayland(AbstractClient *window, Item *parent = nullptr);
};
/**

View file

@ -581,7 +581,7 @@ void Workspace::unconstrain(AbstractClient *below, AbstractClient *above)
updateStackingOrder();
}
void Workspace::addToStack(Toplevel *toplevel)
void Workspace::addToStack(AbstractClient *toplevel)
{
// If the stacking order of a window has been restored from the session, that
// toplevel will already be in the stack when Workspace::addClient() is called.
@ -593,7 +593,7 @@ void Workspace::addToStack(Toplevel *toplevel)
}
}
void Workspace::replaceInStack(Toplevel *original, Deleted *deleted)
void Workspace::replaceInStack(AbstractClient *original, Deleted *deleted)
{
const int unconstraintedIndex = unconstrained_stacking_order.indexOf(original);
if (unconstraintedIndex != -1) {
@ -620,7 +620,7 @@ void Workspace::replaceInStack(Toplevel *original, Deleted *deleted)
}
}
void Workspace::removeFromStack(Toplevel *toplevel)
void Workspace::removeFromStack(AbstractClient *toplevel)
{
unconstrained_stacking_order.removeAll(toplevel);
stacking_order.removeAll(toplevel);
@ -759,7 +759,7 @@ void Workspace::removeUnmanaged(Unmanaged *c)
markXStackingOrderAsDirty();
}
void Workspace::addDeleted(Deleted *c, Toplevel *orig)
void Workspace::addDeleted(Deleted *c, AbstractClient *orig)
{
Q_ASSERT(!deleted.contains(c));
deleted.append(c);
@ -1244,7 +1244,7 @@ void Workspace::slotOutputDisabled(Output *output)
desktopResized();
const auto stack = xStackingOrder();
for (Toplevel *toplevel : stack) {
for (AbstractClient *toplevel : stack) {
if (toplevel->output() == output) {
toplevel->setOutput(kwinApp()->platform()->outputAt(toplevel->frameGeometry().center()));
}
@ -1782,7 +1782,7 @@ QString Workspace::supportInformation() const
X11Client *Workspace::findClient(std::function<bool(const X11Client *)> func) const
{
if (X11Client *ret = Toplevel::findInList(m_x11Clients, func)) {
if (X11Client *ret = AbstractClient::findInList(m_x11Clients, func)) {
return ret;
}
return nullptr;
@ -1790,10 +1790,10 @@ X11Client *Workspace::findClient(std::function<bool(const X11Client *)> func) co
AbstractClient *Workspace::findAbstractClient(std::function<bool(const AbstractClient *)> func) const
{
if (AbstractClient *ret = Toplevel::findInList(m_allClients, func)) {
if (AbstractClient *ret = AbstractClient::findInList(m_allClients, func)) {
return ret;
}
if (InternalClient *ret = Toplevel::findInList(m_internalClients, func)) {
if (InternalClient *ret = AbstractClient::findInList(m_internalClients, func)) {
return ret;
}
return nullptr;
@ -1807,7 +1807,7 @@ AbstractClient *Workspace::findAbstractClient(const QUuid &internalId) const
Unmanaged *Workspace::findUnmanaged(std::function<bool(const Unmanaged *)> func) const
{
return Toplevel::findInList(m_unmanaged, func);
return AbstractClient::findInList(m_unmanaged, func);
}
Unmanaged *Workspace::findUnmanaged(xcb_window_t w) const
@ -1840,28 +1840,28 @@ X11Client *Workspace::findClient(Predicate predicate, xcb_window_t w) const
return nullptr;
}
Toplevel *Workspace::findToplevel(std::function<bool(const Toplevel *)> func) const
AbstractClient *Workspace::findToplevel(std::function<bool(const AbstractClient *)> func) const
{
if (auto *ret = Toplevel::findInList(m_allClients, func)) {
if (auto *ret = AbstractClient::findInList(m_allClients, func)) {
return ret;
}
if (Unmanaged *ret = Toplevel::findInList(m_unmanaged, func)) {
if (Unmanaged *ret = AbstractClient::findInList(m_unmanaged, func)) {
return ret;
}
if (InternalClient *ret = Toplevel::findInList(m_internalClients, func)) {
if (InternalClient *ret = AbstractClient::findInList(m_internalClients, func)) {
return ret;
}
return nullptr;
}
Toplevel *Workspace::findToplevel(const QUuid &internalId) const
AbstractClient *Workspace::findToplevel(const QUuid &internalId) const
{
return findToplevel([internalId](const KWin::Toplevel *l) -> bool {
return findToplevel([internalId](const KWin::AbstractClient *l) -> bool {
return internalId == l->internalId();
});
}
void Workspace::forEachToplevel(std::function<void(Toplevel *)> func)
void Workspace::forEachToplevel(std::function<void(AbstractClient *)> func)
{
std::for_each(m_allClients.constBegin(), m_allClients.constEnd(), func);
std::for_each(deleted.constBegin(), deleted.constEnd(), func);
@ -1883,7 +1883,7 @@ void Workspace::forEachAbstractClient(std::function<void(AbstractClient *)> func
std::for_each(m_internalClients.constBegin(), m_internalClients.constEnd(), func);
}
Toplevel *Workspace::findInternal(QWindow *w) const
AbstractClient *Workspace::findInternal(QWindow *w) const
{
if (!w) {
return nullptr;
@ -2341,12 +2341,12 @@ QRect Workspace::clientArea(clientAreaOption opt, const Output *output, const Vi
}
}
QRect Workspace::clientArea(clientAreaOption opt, const Toplevel *window) const
QRect Workspace::clientArea(clientAreaOption opt, const AbstractClient *window) const
{
return clientArea(opt, window, window->output());
}
QRect Workspace::clientArea(clientAreaOption opt, const Toplevel *window, const Output *output) const
QRect Workspace::clientArea(clientAreaOption opt, const AbstractClient *window, const Output *output) const
{
const VirtualDesktop *desktop;
if (window->isOnCurrentDesktop()) {
@ -2358,7 +2358,7 @@ QRect Workspace::clientArea(clientAreaOption opt, const Toplevel *window, const
return clientArea(opt, output, desktop);
}
QRect Workspace::clientArea(clientAreaOption opt, const Toplevel *window, const QPoint &pos) const
QRect Workspace::clientArea(clientAreaOption opt, const AbstractClient *window, const QPoint &pos) const
{
return clientArea(opt, window, kwinApp()->platform()->outputAt(pos));
}

View file

@ -49,7 +49,6 @@ class Group;
class InternalClient;
class KillWindow;
class ShortcutDialog;
class Toplevel;
class Unmanaged;
class UserActionsMenu;
class VirtualDesktop;
@ -125,25 +124,25 @@ public:
*/
Unmanaged *findUnmanaged(xcb_window_t w) const;
void forEachUnmanaged(std::function<void(Unmanaged *)> func);
Toplevel *findToplevel(std::function<bool(const Toplevel *)> func) const;
void forEachToplevel(std::function<void(Toplevel *)> func);
AbstractClient *findToplevel(std::function<bool(const AbstractClient *)> func) const;
void forEachToplevel(std::function<void(AbstractClient *)> func);
Toplevel *findToplevel(const QUuid &internalId) const;
AbstractClient *findToplevel(const QUuid &internalId) const;
/**
* @brief Finds a Toplevel for the internal window @p w.
* @brief Finds a AbstractClient for the internal window @p w.
*
* Internal window means a window created by KWin itself. On X11 this is an Unmanaged
* and mapped by the window id, on Wayland a XdgShellClient mapped on the internal window id.
*
* @returns Toplevel
* @returns AbstractClient
*/
Toplevel *findInternal(QWindow *w) const;
AbstractClient *findInternal(QWindow *w) const;
QRect clientArea(clientAreaOption, const Output *output, const VirtualDesktop *desktop) const;
QRect clientArea(clientAreaOption, const Toplevel *window) const;
QRect clientArea(clientAreaOption, const Toplevel *window, const Output *output) const;
QRect clientArea(clientAreaOption, const Toplevel *window, const QPoint &pos) const;
QRect clientArea(clientAreaOption, const AbstractClient *window) const;
QRect clientArea(clientAreaOption, const AbstractClient *window, const Output *output) const;
QRect clientArea(clientAreaOption, const AbstractClient *window, const QPoint &pos) const;
/**
* Returns the geometry of this Workspace, i.e. the bounding rectangle of all outputs.
@ -283,9 +282,9 @@ public:
* Returns the list of clients sorted in stacking order, with topmost client
* at the last position
*/
const QList<Toplevel *> &stackingOrder() const;
QList<Toplevel *> xStackingOrder() const;
QList<Toplevel *> unconstrainedStackingOrder() const;
const QList<AbstractClient *> &stackingOrder() const;
QList<AbstractClient *> xStackingOrder() const;
QList<AbstractClient *> unconstrainedStackingOrder() const;
QList<X11Client *> ensureStackingOrder(const QList<X11Client *> &clients) const;
QList<AbstractClient *> ensureStackingOrder(const QList<AbstractClient *> &clients) const;
@ -350,7 +349,7 @@ public:
void removeUnmanaged(Unmanaged *); // Only called from Unmanaged::release()
void removeDeleted(Deleted *);
void addDeleted(Deleted *, Toplevel *);
void addDeleted(Deleted *, AbstractClient *);
bool checkStartupNotification(xcb_window_t w, KStartupInfoId &id, KStartupInfoData &data);
@ -572,7 +571,7 @@ private:
bool switchWindow(AbstractClient *c, Direction direction, QPoint curPos, VirtualDesktop *desktop);
void propagateClients(bool propagate_new_clients); // Called only from updateStackingOrder
QList<Toplevel *> constrainedStackingOrder();
QList<AbstractClient *> constrainedStackingOrder();
void raiseClientWithinApplication(AbstractClient *c);
void lowerClientWithinApplication(AbstractClient *c);
bool allowFullClientRaising(const AbstractClient *c, xcb_timestamp_t timestamp);
@ -580,9 +579,9 @@ private:
void updateToolWindows(bool also_hide);
void fixPositionAfterCrash(xcb_window_t w, const xcb_get_geometry_reply_t *geom);
void saveOldScreenSizes();
void addToStack(Toplevel *toplevel);
void replaceInStack(Toplevel *original, Deleted *deleted);
void removeFromStack(Toplevel *toplevel);
void addToStack(AbstractClient *toplevel);
void replaceInStack(AbstractClient *original, Deleted *deleted);
void removeFromStack(AbstractClient *toplevel);
/// This is the right way to create a new client
X11Client *createClient(xcb_window_t w, bool is_mapped);
@ -604,8 +603,8 @@ private:
struct Constraint
{
Toplevel *below;
Toplevel *above;
AbstractClient *below;
AbstractClient *above;
// All constraints above our "below" window
QList<Constraint *> parents;
// All constraints below our "above" window
@ -638,11 +637,11 @@ private:
QList<Deleted *> deleted;
QList<InternalClient *> m_internalClients;
QList<Toplevel *> unconstrained_stacking_order; // Topmost last
QList<Toplevel *> stacking_order; // Topmost last
QList<AbstractClient *> unconstrained_stacking_order; // Topmost last
QList<AbstractClient *> stacking_order; // Topmost last
QVector<xcb_window_t> manual_overlays; // Topmost last
bool force_restacking;
QList<Toplevel *> x_stacking; // From XQueryTree()
QList<AbstractClient *> x_stacking; // From XQueryTree()
std::unique_ptr<Xcb::Tree> m_xStackingQueryTree;
bool m_xStackingDirty = false;
QList<AbstractClient *> should_get_focus; // Last is most recent
@ -771,7 +770,7 @@ inline void Workspace::removeGroup(Group *group)
groups.removeAll(group);
}
inline const QList<Toplevel *> &Workspace::stackingOrder() const
inline const QList<AbstractClient *> &Workspace::stackingOrder() const
{
// TODO: Q_ASSERT( block_stacking_updates == 0 );
return stacking_order;

View file

@ -1417,7 +1417,7 @@ void X11Client::showClient()
bool X11Client::setupCompositing()
{
if (!Toplevel::setupCompositing()) {
if (!AbstractClient::setupCompositing()) {
return false;
}
// If compositing is back on, stop rendering decoration in the frame window.
@ -1428,7 +1428,7 @@ bool X11Client::setupCompositing()
void X11Client::finishCompositing(ReleaseReason releaseReason)
{
Toplevel::finishCompositing(releaseReason);
AbstractClient::finishCompositing(releaseReason);
updateVisibility();
// If compositing is off, render the decoration in the X11 frame window.
maybeCreateX11DecorationRenderer();
@ -1554,7 +1554,7 @@ void X11Client::doSetShade(ShadeMode previousShadeMode)
setActive(true);
}
if (shadeMode() == ShadeHover) {
QList<Toplevel *> order = workspace()->stackingOrder();
QList<AbstractClient *> order = workspace()->stackingOrder();
// invalidate, since "this" could be the topmost toplevel and shade_below dangeling
shade_below = nullptr;
// this is likely related to the index parameter?!
@ -1988,7 +1988,7 @@ void X11Client::updateActivities(bool includeTransients)
/**
* Returns the list of activities the client window is on.
* if it's on all activities, the list will be empty.
* Don't use this, use isOnActivity() and friends (from class Toplevel)
* Don't use this, use isOnActivity() and friends (from class AbstractClient)
*/
QStringList X11Client::activities() const
{

View file

@ -19,7 +19,7 @@ namespace KWin
XwaylandClient::XwaylandClient()
{
// The wayland surface is associated with the Xwayland window asynchronously.
connect(this, &Toplevel::surfaceChanged, this, &XwaylandClient::associate);
connect(this, &AbstractClient::surfaceChanged, this, &XwaylandClient::associate);
}
void XwaylandClient::associate()

View file

@ -70,7 +70,7 @@ bool DataBridge::nativeEventFilter(const QByteArray &eventType, void *message, q
return false;
}
DragEventReply DataBridge::dragMoveFilter(Toplevel *target, const QPoint &pos)
DragEventReply DataBridge::dragMoveFilter(AbstractClient *target, const QPoint &pos)
{
return m_dnd->dragMoveFilter(target, pos);
}

View file

@ -23,7 +23,7 @@ class SurfaceInterface;
namespace KWin
{
class Toplevel;
class AbstractClient;
namespace Xwl
{
@ -47,7 +47,7 @@ public:
~DataBridge() override;
DragEventReply dragMoveFilter(Toplevel *target, const QPoint &pos);
DragEventReply dragMoveFilter(AbstractClient *target, const QPoint &pos);
Dnd *dnd() const
{

View file

@ -133,7 +133,7 @@ bool Dnd::handleClientMessage(xcb_client_message_event_t *event)
return false;
}
DragEventReply Dnd::dragMoveFilter(Toplevel *target, const QPoint &pos)
DragEventReply Dnd::dragMoveFilter(AbstractClient *target, const QPoint &pos)
{
Q_ASSERT(m_currentDrag);
return m_currentDrag->moveFilter(target, pos);

View file

@ -21,7 +21,7 @@ class SurfaceInterface;
namespace KWin
{
class Toplevel;
class AbstractClient;
namespace Xwl
{
@ -48,7 +48,7 @@ public:
void x11OffersChanged(const QStringList &added, const QStringList &removed) override;
bool handleClientMessage(xcb_client_message_event_t *event) override;
DragEventReply dragMoveFilter(Toplevel *target, const QPoint &pos);
DragEventReply dragMoveFilter(AbstractClient *target, const QPoint &pos);
using DnDAction = KWaylandServer::DataDeviceManagerInterface::DnDAction;
using DnDActions = KWaylandServer::DataDeviceManagerInterface::DnDActions;

View file

@ -16,7 +16,7 @@
namespace KWin
{
class Toplevel;
class AbstractClient;
namespace Xwl
{
@ -36,7 +36,7 @@ public:
static void sendClientMessage(xcb_window_t target, xcb_atom_t type, xcb_client_message_data_t *data);
virtual bool handleClientMessage(xcb_client_message_event_t *event) = 0;
virtual DragEventReply moveFilter(Toplevel *target, const QPoint &pos) = 0;
virtual DragEventReply moveFilter(AbstractClient *target, const QPoint &pos) = 0;
Q_SIGNALS:
void finish(Drag *self);

View file

@ -36,7 +36,7 @@ namespace KWin
namespace Xwl
{
DragEventReply WlToXDrag::moveFilter(Toplevel *target, const QPoint &pos)
DragEventReply WlToXDrag::moveFilter(AbstractClient *target, const QPoint &pos)
{
Q_UNUSED(target)
Q_UNUSED(pos)

View file

@ -26,7 +26,6 @@ class SurfaceInterface;
namespace KWin
{
class Toplevel;
class AbstractClient;
namespace Xwl
@ -41,7 +40,7 @@ class WlToXDrag : public Drag
using Drag::Drag;
public:
DragEventReply moveFilter(Toplevel *target, const QPoint &pos) override;
DragEventReply moveFilter(AbstractClient *target, const QPoint &pos) override;
bool handleClientMessage(xcb_client_message_event_t *event) override;
private:

View file

@ -119,7 +119,7 @@ XToWlDrag::~XToWlDrag()
{
}
DragEventReply XToWlDrag::moveFilter(Toplevel *target, const QPoint &pos)
DragEventReply XToWlDrag::moveFilter(AbstractClient *target, const QPoint &pos)
{
Q_UNUSED(pos);

View file

@ -20,7 +20,6 @@
namespace KWin
{
class Toplevel;
class AbstractClient;
namespace Xwl
@ -39,7 +38,7 @@ public:
explicit XToWlDrag(X11Source *source);
~XToWlDrag() override;
DragEventReply moveFilter(Toplevel *target, const QPoint &pos) override;
DragEventReply moveFilter(AbstractClient *target, const QPoint &pos) override;
bool handleClientMessage(xcb_client_message_event_t *event) override;
void setDragAndDropAction(KWaylandServer::DataDeviceManagerInterface::DnDAction action);

View file

@ -302,7 +302,7 @@ void Xwayland::destroyX11Connection()
Q_EMIT m_app->x11ConnectionChanged();
}
DragEventReply Xwayland::dragMoveFilter(Toplevel *target, const QPoint &pos)
DragEventReply Xwayland::dragMoveFilter(AbstractClient *target, const QPoint &pos)
{
DataBridge *bridge = DataBridge::self();
if (!bridge) {

View file

@ -68,7 +68,7 @@ private:
bool createX11Connection();
void destroyX11Connection();
DragEventReply dragMoveFilter(Toplevel *target, const QPoint &pos) override;
DragEventReply dragMoveFilter(AbstractClient *target, const QPoint &pos) override;
KWaylandServer::AbstractDropHandler *xwlDropHandler() override;
QSocketNotifier *m_socketNotifier = nullptr;

View file

@ -23,7 +23,7 @@ class AbstractDropHandler;
namespace KWin
{
class Toplevel;
class AbstractClient;
namespace Xwl
{
@ -44,7 +44,7 @@ class KWIN_EXPORT XwaylandInterface : public QObject
public:
static XwaylandInterface *self();
virtual Xwl::DragEventReply dragMoveFilter(Toplevel *target, const QPoint &pos) = 0;
virtual Xwl::DragEventReply dragMoveFilter(AbstractClient *target, const QPoint &pos) = 0;
virtual KWaylandServer::AbstractDropHandler *xwlDropHandler() = 0;
protected: