Replace direct method calls with signal and slot mechanism
The direct method calls for createTile(), removeTile() and resizeing the tiling layouts from class Workspace are replaced by connecting to the appropriate signal. The methods are slots now and a new slot for resizeing the tiling layouts was introduced.
This commit is contained in:
parent
3634525613
commit
bc4fea10f3
3 changed files with 21 additions and 10 deletions
|
@ -63,11 +63,18 @@ void Tiling::setTilingEnabled(bool tiling)
|
|||
options->tilingRaisePolicy = config.readEntry("TilingRaisePolicy", 0);
|
||||
|
||||
if (tilingEnabled_) {
|
||||
connect(m_workspace, SIGNAL(clientAdded(KWin::Client*)), this, SLOT(createTile(KWin::Client*)));
|
||||
connect(m_workspace, SIGNAL(clientAdded(KWin::Client*)), this, SLOT(slotResizeTilingLayouts()));
|
||||
connect(m_workspace, SIGNAL(numberDesktopsChanged(int)), this, SLOT(slotResizeTilingLayouts()));
|
||||
connect(m_workspace, SIGNAL(clientRemoved(KWin::Client*)), this, SLOT(removeTile(KWin::Client*)));
|
||||
tilingLayouts.resize(Workspace::self()->numberOfDesktops() + 1);
|
||||
foreach (Client * c, Workspace::self()->stackingOrder()) {
|
||||
createTile(c);
|
||||
}
|
||||
} else {
|
||||
disconnect(m_workspace, SIGNAL(clientAdded(KWin::Client*)));
|
||||
disconnect(m_workspace, SIGNAL(numberDesktopsChanged(int)));
|
||||
disconnect(m_workspace, SIGNAL(clientRemoved(KWin::Client*)));
|
||||
qDeleteAll(tilingLayouts);
|
||||
tilingLayouts.clear();
|
||||
}
|
||||
|
@ -112,6 +119,9 @@ void Tiling::createTile(Client* c)
|
|||
|
||||
void Tiling::removeTile(Client *c)
|
||||
{
|
||||
if (!tilingLayouts.value(c->desktop())) {
|
||||
return;
|
||||
}
|
||||
if (tilingLayouts[ c->desktop()])
|
||||
tilingLayouts[ c->desktop()]->removeTile(c);
|
||||
}
|
||||
|
@ -462,9 +472,14 @@ void Tiling::dumpTiles() const
|
|||
}
|
||||
}
|
||||
|
||||
QVector< TilingLayout* >& Tiling::getTilingLayouts()
|
||||
const QVector< TilingLayout* >& Tiling::getTilingLayouts() const
|
||||
{
|
||||
return tilingLayouts;
|
||||
}
|
||||
|
||||
void Tiling::slotResizeTilingLayouts()
|
||||
{
|
||||
tilingLayouts.resize(m_workspace->numberOfDesktops() + 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -41,12 +41,10 @@ public:
|
|||
bool tilingEnabled() const;
|
||||
void setTilingEnabled(bool tiling);
|
||||
bool tileable(Client *c);
|
||||
void createTile(Client *c);
|
||||
void removeTile(Client *c);
|
||||
// updates geometry of tiles on all desktops,
|
||||
// this rearranges the tiles.
|
||||
void updateAllTiles();
|
||||
QVector< TilingLayout* >& getTilingLayouts();
|
||||
const QVector< TilingLayout* >& getTilingLayouts() const;
|
||||
|
||||
// The notification functions are called from
|
||||
// various points in existing code so that
|
||||
|
@ -64,6 +62,8 @@ public:
|
|||
KDecorationDefines::Position supportedTilingResizeMode(Client *c, KDecorationDefines::Position currentMode);
|
||||
|
||||
public Q_SLOTS:
|
||||
void createTile(KWin::Client *c);
|
||||
void removeTile(KWin::Client *c);
|
||||
// user actions, usually bound to shortcuts
|
||||
// and also provided through the D-BUS interface.
|
||||
void slotToggleTiling();
|
||||
|
@ -102,6 +102,8 @@ private:
|
|||
// virtual desktops so that we can quickly index them
|
||||
// without having to remember to subtract one.
|
||||
QVector<TilingLayout *> tilingLayouts;
|
||||
private Q_SLOTS:
|
||||
void slotResizeTilingLayouts();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -566,7 +566,6 @@ Client* Workspace::createClient(Window w, bool is_mapped)
|
|||
}
|
||||
addClient(c, Allowed);
|
||||
|
||||
m_tiling->getTilingLayouts().resize(numberOfDesktops() + 1);
|
||||
m_tiling->createTile(c);
|
||||
|
||||
return c;
|
||||
|
@ -672,9 +671,6 @@ void Workspace::removeClient(Client* c, allowed_t)
|
|||
#endif
|
||||
|
||||
Q_ASSERT(clients.contains(c) || desktops.contains(c));
|
||||
if (m_tiling->tilingEnabled() && m_tiling->getTilingLayouts().value(c->desktop())) {
|
||||
m_tiling->removeTile(c);
|
||||
}
|
||||
// TODO: if marked client is removed, notify the marked list
|
||||
clients.removeAll(c);
|
||||
desktops.removeAll(c);
|
||||
|
@ -1581,8 +1577,6 @@ void Workspace::setNumberOfDesktops(int n)
|
|||
for (int i = 0; i < int(desktop_focus_chain.size()); i++)
|
||||
desktop_focus_chain[i] = i + 1;
|
||||
|
||||
m_tiling->getTilingLayouts().resize(numberOfDesktops() + 1);
|
||||
|
||||
saveDesktopSettings();
|
||||
emit numberDesktopsChanged(old_number_of_desktops);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue