Move cascadeDesktop and unclutterDesktop to Placement

It is more Placement related and does not really fit into geometry given
that it only calls methods on Placement. It probably only was inside
Workspace due to being part of the DBus interface. The DBus methods are
used by external components so it needs to stay.

The DBus Wrapper is now calling the methods on the singleton Placement
directly, so no need in Workspace anymore.
This commit is contained in:
Martin Gräßlin 2012-11-22 11:07:33 +01:00
parent 607e175b4b
commit 835648bc20
5 changed files with 53 additions and 40 deletions

View file

@ -72,11 +72,20 @@ void DBusInterface::name() \
Workspace::self()->name();\
}
WRAP(cascadeDesktop)
WRAP(killWindow)
WRAP(nextDesktop)
WRAP(previousDesktop)
WRAP(reconfigure)
#undef WRAP
#define WRAP(name) \
void DBusInterface::name() \
{\
Placement::self()->name();\
}
WRAP(cascadeDesktop)
WRAP(unclutterDesktop)
#undef WRAP

View file

@ -763,43 +763,6 @@ void Workspace::setClientIsMoving(Client *c)
--block_focus;
}
/*!
Cascades all clients on the current desktop
*/
void Workspace::cascadeDesktop()
{
// TODO XINERAMA this probably is not right for xinerama
Q_ASSERT(block_stacking_updates == 0);
initPositioning->reinitCascading(currentDesktop());
QRect area = clientArea(PlacementArea, QPoint(0, 0), currentDesktop());
foreach (Toplevel *toplevel, stackingOrder()) {
Client *client = qobject_cast<Client*>(toplevel);
if (!client ||
(!client->isOnDesktop(currentDesktop())) ||
(client->isMinimized()) ||
(client->isOnAllDesktops()) ||
(!client->isMovable()))
continue;
initPositioning->placeCascaded(client, area);
}
}
/*!
Unclutters the current desktop by smart-placing all clients
again.
*/
void Workspace::unclutterDesktop()
{
for (int i = clients.size() - 1; i >= 0; i--) {
if ((!clients.at(i)->isOnDesktop(currentDesktop())) ||
(clients.at(i)->isMinimized()) ||
(clients.at(i)->isOnAllDesktops()) ||
(!clients.at(i)->isMovable()))
continue;
initPositioning->placeSmart(clients.at(i), QRect());
}
}
// When kwin crashes, windows will not be gravitated back to their original position
// and will remain offset by the size of the decoration. So when restarting, fix this
// (the property with the size of the frame remains on the window after the crash).

View file

@ -543,6 +543,40 @@ void Placement::placeMaximizing(Client* c, QRect& area, Policy nextPlacement)
}
}
void Placement::cascadeDesktop()
{
// TODO XINERAMA this probably is not right for xinerama
Workspace *ws = Workspace::self();
const int desktop = ws->currentDesktop();
reinitCascading(desktop);
// TODO: make area const once placeFoo methods are fixed to take a const QRect&
QRect area = ws->clientArea(PlacementArea, QPoint(0, 0), desktop);
foreach (Toplevel *toplevel, ws->stackingOrder()) {
Client *client = qobject_cast<Client*>(toplevel);
if (!client ||
(!client->isOnCurrentDesktop()) ||
(client->isMinimized()) ||
(client->isOnAllDesktops()) ||
(!client->isMovable()))
continue;
placeCascaded(client, area);
}
}
void Placement::unclutterDesktop()
{
const ClientList &clients = Workspace::self()->clientList();
for (int i = clients.size() - 1; i >= 0; i--) {
Client *client = clients.at(i);
if ((!client->isOnCurrentDesktop()) ||
(client->isMinimized()) ||
(client->isOnAllDesktops()) ||
(!client->isMovable()))
continue;
placeSmart(client, QRect());
}
}
QRect Placement::checkArea(const Client* c, const QRect& area)
{
if (area.isNull())

View file

@ -71,6 +71,15 @@ public:
void reinitCascading(int desktop);
/**
* Cascades all clients on the current desktop
**/
void cascadeDesktop();
/**
* Unclutters the current desktop by smart-placing all clients again.
**/
void unclutterDesktop();
static Policy policyFromString(const QString& policy, bool no_special);
static const char* policyToString(Policy policy);

View file

@ -448,8 +448,6 @@ public:
bool decorationSupportsBlurBehind() const;
// D-Bus interface
void cascadeDesktop();
void unclutterDesktop();
void doNotManage(const QString&);
/**
* @deprecated