Drop more legacy Workspace.clientArea() overloads
With this change, the Workspace would provide clientArea() overloads that take only AbstractOutput and VirtualDesktop. integer ids are obsolete as they are unstable.
This commit is contained in:
parent
3ebe480976
commit
601ef328df
6 changed files with 55 additions and 45 deletions
|
@ -478,14 +478,14 @@ void TransientPlacementTest::testXdgPopupWithPanel()
|
|||
plasmaSurface->setPanelBehavior(PlasmaShellSurface::PanelBehavior::AlwaysVisible);
|
||||
|
||||
// now render and map the window
|
||||
QVERIFY(workspace()->clientArea(PlacementArea, 0, 1) == workspace()->clientArea(FullScreenArea, 0, 1));
|
||||
auto dock = Test::renderAndWaitForShown(surface.data(), QSize(1280, 50), Qt::blue);
|
||||
QVERIFY(dock);
|
||||
QCOMPARE(dock->windowType(), NET::Dock);
|
||||
QVERIFY(dock->isDock());
|
||||
QCOMPARE(dock->frameGeometry(), QRect(0, screens()->geometry(0).height() - 50, 1280, 50));
|
||||
QCOMPARE(dock->hasStrut(), true);
|
||||
QVERIFY(workspace()->clientArea(PlacementArea, 0, 1) != workspace()->clientArea(FullScreenArea, 0, 1));
|
||||
QCOMPARE(workspace()->clientArea(PlacementArea, dock), QRect(0, 0, 1280, 1024 - 50));
|
||||
QCOMPARE(workspace()->clientArea(FullScreenArea, dock), QRect(0, 0, 1280, 1024));
|
||||
|
||||
// create parent
|
||||
QScopedPointer<KWayland::Client::Surface> parentSurface(Test::createSurface());
|
||||
|
|
|
@ -1264,17 +1264,19 @@ EffectScreen *EffectsHandlerImpl::activeScreen() const
|
|||
return EffectScreenImpl::get(workspace()->activeOutput());
|
||||
}
|
||||
|
||||
QRect EffectsHandlerImpl::clientArea(clientAreaOption opt, const EffectScreen *screen, int desktop) const
|
||||
static VirtualDesktop *resolveVirtualDesktop(int desktopId)
|
||||
{
|
||||
const VirtualDesktop *virtualDesktop;
|
||||
if (desktop == 0 || desktop == -1) {
|
||||
virtualDesktop = VirtualDesktopManager::self()->currentDesktop();
|
||||
if (desktopId == 0 || desktopId == -1) {
|
||||
return VirtualDesktopManager::self()->currentDesktop();
|
||||
} else {
|
||||
virtualDesktop = VirtualDesktopManager::self()->desktopForX11Id(desktop);
|
||||
return VirtualDesktopManager::self()->desktopForX11Id(desktopId);
|
||||
}
|
||||
}
|
||||
|
||||
QRect EffectsHandlerImpl::clientArea(clientAreaOption opt, const EffectScreen *screen, int desktop) const
|
||||
{
|
||||
const EffectScreenImpl *screenImpl = static_cast<const EffectScreenImpl *>(screen);
|
||||
return Workspace::self()->clientArea(opt, screenImpl->platformOutput(), virtualDesktop);
|
||||
return Workspace::self()->clientArea(opt, screenImpl->platformOutput(), resolveVirtualDesktop(desktop));
|
||||
}
|
||||
|
||||
QRect EffectsHandlerImpl::clientArea(clientAreaOption opt, const EffectWindow *c) const
|
||||
|
@ -1285,7 +1287,9 @@ QRect EffectsHandlerImpl::clientArea(clientAreaOption opt, const EffectWindow *c
|
|||
|
||||
QRect EffectsHandlerImpl::clientArea(clientAreaOption opt, const QPoint &p, int desktop) const
|
||||
{
|
||||
return Workspace::self()->clientArea(opt, p, desktop);
|
||||
const AbstractOutput *output = kwinApp()->platform()->outputAt(p);
|
||||
const VirtualDesktop *virtualDesktop = resolveVirtualDesktop(desktop);
|
||||
return Workspace::self()->clientArea(opt, output, virtualDesktop);
|
||||
}
|
||||
|
||||
QRect EffectsHandlerImpl::virtualScreenGeometry() const
|
||||
|
|
|
@ -114,7 +114,7 @@ void KWin::InputPanelV1Client::reposition()
|
|||
}
|
||||
if (textClient) {
|
||||
cursorRectangle.translate(textClient->bufferGeometry().topLeft());
|
||||
const QRect screen = Workspace::self()->clientArea(PlacementArea, cursorRectangle.bottomLeft(), 0);
|
||||
const QRect screen = Workspace::self()->clientArea(PlacementArea, this, cursorRectangle.bottomLeft());
|
||||
|
||||
// Reuse the similar logic like xdg popup
|
||||
QRect popupRect(popupOffset(cursorRectangle, Qt::BottomEdge | Qt::LeftEdge, Qt::RightEdge | Qt::BottomEdge, surface()->size()), surface()->size());
|
||||
|
|
|
@ -254,9 +254,20 @@ int WorkspaceWrapper::displayHeight() const
|
|||
return displaySize().height();
|
||||
}
|
||||
|
||||
static VirtualDesktop *resolveVirtualDesktop(int desktopId)
|
||||
{
|
||||
if (desktopId == 0 || desktopId == -1) {
|
||||
return VirtualDesktopManager::self()->currentDesktop();
|
||||
} else {
|
||||
return VirtualDesktopManager::self()->desktopForX11Id(desktopId);
|
||||
}
|
||||
}
|
||||
|
||||
QRect WorkspaceWrapper::clientArea(ClientAreaOption option, const QPoint &p, int desktop) const
|
||||
{
|
||||
return Workspace::self()->clientArea(static_cast<clientAreaOption>(option), p, desktop);
|
||||
const AbstractOutput *output = kwinApp()->platform()->outputAt(p);
|
||||
const VirtualDesktop *virtualDesktop = resolveVirtualDesktop(desktop);
|
||||
return Workspace::self()->clientArea(static_cast<clientAreaOption>(option), output, virtualDesktop);
|
||||
}
|
||||
|
||||
QRect WorkspaceWrapper::clientArea(ClientAreaOption option, const KWin::AbstractClient *c) const
|
||||
|
@ -271,7 +282,24 @@ QRect WorkspaceWrapper::clientArea(ClientAreaOption option, KWin::AbstractClient
|
|||
|
||||
QRect WorkspaceWrapper::clientArea(ClientAreaOption option, int screen, int desktop) const
|
||||
{
|
||||
return Workspace::self()->clientArea(static_cast<clientAreaOption>(option), screen, desktop);
|
||||
VirtualDesktop *virtualDesktop;
|
||||
AbstractOutput *output;
|
||||
|
||||
if (desktop == NETWinInfo::OnAllDesktops || desktop == 0) {
|
||||
virtualDesktop = VirtualDesktopManager::self()->currentDesktop();
|
||||
} else {
|
||||
virtualDesktop = VirtualDesktopManager::self()->desktopForX11Id(desktop);
|
||||
Q_ASSERT(virtualDesktop);
|
||||
}
|
||||
|
||||
if (screen == -1) {
|
||||
output = workspace()->activeOutput();
|
||||
} else {
|
||||
output = kwinApp()->platform()->findOutput(screen);
|
||||
Q_ASSERT(output);
|
||||
}
|
||||
|
||||
return workspace()->clientArea(static_cast<clientAreaOption>(option), output, virtualDesktop);
|
||||
}
|
||||
|
||||
QString WorkspaceWrapper::desktopName(int desktop) const
|
||||
|
|
|
@ -2327,33 +2327,6 @@ QRect Workspace::clientArea(clientAreaOption opt, const AbstractOutput *output,
|
|||
}
|
||||
}
|
||||
|
||||
QRect Workspace::clientArea(clientAreaOption opt, int screen, int desktop) const
|
||||
{
|
||||
VirtualDesktop *virtualDesktop;
|
||||
AbstractOutput *output;
|
||||
|
||||
if (desktop == NETWinInfo::OnAllDesktops || desktop == 0) {
|
||||
virtualDesktop = VirtualDesktopManager::self()->currentDesktop();
|
||||
} else {
|
||||
virtualDesktop = VirtualDesktopManager::self()->desktopForX11Id(desktop);
|
||||
Q_ASSERT(virtualDesktop);
|
||||
}
|
||||
|
||||
if (screen == -1) {
|
||||
output = activeOutput();
|
||||
} else {
|
||||
output = kwinApp()->platform()->findOutput(screen);
|
||||
Q_ASSERT(output);
|
||||
}
|
||||
|
||||
return clientArea(opt, output, virtualDesktop);
|
||||
}
|
||||
|
||||
QRect Workspace::clientArea(clientAreaOption opt, const QPoint &p, int desktop) const
|
||||
{
|
||||
return clientArea(opt, screens()->number(p), desktop);
|
||||
}
|
||||
|
||||
QRect Workspace::clientArea(clientAreaOption opt, const Toplevel *window) const
|
||||
{
|
||||
return clientArea(opt, window, window->frameGeometry().center());
|
||||
|
@ -2361,12 +2334,19 @@ QRect Workspace::clientArea(clientAreaOption opt, const Toplevel *window) const
|
|||
|
||||
QRect Workspace::clientArea(clientAreaOption opt, const Toplevel *window, const AbstractOutput *output) const
|
||||
{
|
||||
return clientArea(opt, window, output->geometry().center());
|
||||
const VirtualDesktop *desktop;
|
||||
if (window->isOnCurrentDesktop()) {
|
||||
desktop = VirtualDesktopManager::self()->currentDesktop();
|
||||
} else {
|
||||
desktop = window->desktops().constLast();
|
||||
}
|
||||
|
||||
return clientArea(opt, output, desktop);
|
||||
}
|
||||
|
||||
QRect Workspace::clientArea(clientAreaOption opt, const Toplevel *window, const QPoint &pos) const
|
||||
{
|
||||
return clientArea(opt, screens()->number(pos), window->desktop());
|
||||
return clientArea(opt, window, kwinApp()->platform()->outputAt(pos));
|
||||
}
|
||||
|
||||
QRect Workspace::geometry() const
|
||||
|
|
|
@ -141,11 +141,9 @@ public:
|
|||
Toplevel *findInternal(QWindow *w) const;
|
||||
|
||||
QRect clientArea(clientAreaOption, const AbstractOutput *output, const VirtualDesktop *desktop) const;
|
||||
QRect clientArea(clientAreaOption, const QPoint &p, int desktop) const;
|
||||
QRect clientArea(clientAreaOption, const Toplevel *window) const;
|
||||
QRect clientArea(clientAreaOption, const Toplevel *window, const AbstractOutput *output) const;
|
||||
QRect clientArea(clientAreaOption, const Toplevel *window, const QPoint &pos) const;
|
||||
QRect clientArea(clientAreaOption, int screen, int desktop) const;
|
||||
|
||||
/**
|
||||
* Returns the geometry of this Workspace, i.e. the bounding rectangle of all outputs.
|
||||
|
|
Loading…
Reference in a new issue