From 6db74c8d6687e65f967634c147e2002e6c74c17e Mon Sep 17 00:00:00 2001 From: Arthur Arlt Date: Mon, 18 Jul 2011 15:43:00 +0200 Subject: [PATCH 01/10] Original Tiling.cpp moved to directory tiling/ --- CMakeLists.txt | 3 ++- tiling.cpp => tiling/tiling.cpp | 0 2 files changed, 2 insertions(+), 1 deletion(-) rename tiling.cpp => tiling/tiling.cpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ef13e59cd..8dbe9f1e0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -145,7 +145,6 @@ set(kwin_KDEINIT_SRCS desktoplayout.cpp paintredirector.cpp tile.cpp - tiling.cpp tilinglayout.cpp tilinglayoutfactory.cpp @@ -160,6 +159,8 @@ set(kwin_KDEINIT_SRCS # floating tilinglayouts/floating/floating.cpp + + tiling/tiling.cpp ) if(KWIN_BUILD_SCRIPTING) diff --git a/tiling.cpp b/tiling/tiling.cpp similarity index 100% rename from tiling.cpp rename to tiling/tiling.cpp From 363452561334ed19233f49ab2f5d04e8cb9ed894 Mon Sep 17 00:00:00 2001 From: Arthur Arlt Date: Wed, 13 Jul 2011 18:48:56 +0200 Subject: [PATCH 02/10] Refactoring Tiling This initial commit introduces a new class Tiling. It is provided by the files tiling/tiling.h and tiling/tiling.cpp. It covers all the Tiling functionality which was provided by Workspace. In this initial commit, all the functions were just moved and adjusted. A new member variable m_tiling is introduced to Workspace, which makes the new class Tiling accessible from Workspace. The Tiling pointer is created in the constructor and deleted in the deconstructor. Also a getter method tiling() is provided. All calls from other classes are updated to use the methods in class Tiling now. --- activation.cpp | 5 +- client.cpp | 7 ++- geometry.cpp | 21 +++---- sm.cpp | 9 +-- tile.cpp | 3 +- tiling/tiling.cpp | 139 +++++++++++++++++++++++++--------------------- tiling/tiling.h | 108 +++++++++++++++++++++++++++++++++++ tilinglayout.cpp | 3 +- useractions.cpp | 19 ++++--- workspace.cpp | 73 +++++++++++++++++++----- workspace.h | 88 ++--------------------------- 11 files changed, 283 insertions(+), 192 deletions(-) create mode 100644 tiling/tiling.h diff --git a/activation.cpp b/activation.cpp index 1f67f96a42..c07a2b63cd 100644 --- a/activation.cpp +++ b/activation.cpp @@ -42,6 +42,7 @@ along with this program. If not, see . #include "group.h" #include "rules.h" #include +#include "tiling/tiling.h" namespace KWin { @@ -263,8 +264,8 @@ void Workspace::setActiveClient(Client* c, allowed_t) active_client->sl_activated(); } - if (tilingEnabled()) - notifyTilingWindowActivated(active_client); + if (m_tiling->tilingEnabled()) + m_tiling->notifyTilingWindowActivated(active_client); --set_active_client_recursion; } diff --git a/client.cpp b/client.cpp index c4fdd95d87..fe5016c3db 100644 --- a/client.cpp +++ b/client.cpp @@ -47,6 +47,7 @@ along with this program. If not, see . #include "notifications.h" #include "rules.h" #include "shadow.h" +#include "tiling/tiling.h" #include "deleted.h" #include "paintredirector.h" #ifdef KWIN_BUILD_TABBOX @@ -951,7 +952,7 @@ void Client::minimize(bool avoid_animation) emit clientMinimized(this, !avoid_animation); // when tiling, request a rearrangement - workspace()->notifyTilingWindowMinimizeToggled(this); + workspace()->tiling()->notifyTilingWindowMinimizeToggled(this); // Update states of all other windows in this group if (clientGroup()) @@ -978,11 +979,11 @@ void Client::unminimize(bool avoid_animation) updateAllowedActions(); workspace()->updateMinimizedOfTransients(this); updateWindowRules(); - workspace()->updateAllTiles(); + workspace()->tiling()->updateAllTiles(); emit clientUnminimized(this, !avoid_animation); // when tiling, request a rearrangement - workspace()->notifyTilingWindowMinimizeToggled(this); + workspace()->tiling()->notifyTilingWindowMinimizeToggled(this); // Update states of all other windows in this group if (clientGroup()) diff --git a/geometry.cpp b/geometry.cpp index a357162b15..43e66eadc3 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -50,6 +50,7 @@ along with this program. If not, see . #include #include #include "outline.h" +#include "tiling/tiling.h" namespace KWin { @@ -2032,7 +2033,7 @@ void Client::move(int x, int y, ForceGeometry_t force) workspace()->checkActiveScreen(this); workspace()->updateStackingOrder(); workspace()->checkUnredirect(); - workspace()->notifyTilingWindowMove(this, moveResizeGeom, initialMoveResizeGeom); + workspace()->tiling()->notifyTilingWindowMove(this, moveResizeGeom, initialMoveResizeGeom); // client itself is not damaged const QRect deco_rect = decorationRect().translated(geom.x(), geom.y()); addWorkspaceRepaint(deco_rect_before_block); @@ -2590,11 +2591,11 @@ void Client::finishMoveResize(bool cancel) leaveMoveResize(); - if (workspace()->tilingEnabled()) { + if (workspace()->tiling()->tilingEnabled()) { if (wasResize) - workspace()->notifyTilingWindowResizeDone(this, moveResizeGeom, initialMoveResizeGeom, cancel); + workspace()->tiling()->notifyTilingWindowResizeDone(this, moveResizeGeom, initialMoveResizeGeom, cancel); else if (wasMove) - workspace()->notifyTilingWindowMoveDone(this, moveResizeGeom, initialMoveResizeGeom, cancel); + workspace()->tiling()->notifyTilingWindowMoveDone(this, moveResizeGeom, initialMoveResizeGeom, cancel); } else { if (cancel) setGeometry(initialMoveResizeGeom); @@ -2763,8 +2764,8 @@ void Client::handleMoveResize(int x, int y, int x_root, int y_root) bool update = false; if (isResize()) { // query layout for supported resize mode - if (workspace()->tilingEnabled()) { - mode = workspace()->supportedTilingResizeMode(this, mode); + if (workspace()->tiling()->tilingEnabled()) { + mode = workspace()->tiling()->supportedTilingResizeMode(this, mode); } // first resize (without checking constrains), then snap, then check bounds, then check constrains QRect orig = initialMoveResizeGeom; @@ -2801,7 +2802,7 @@ void Client::handleMoveResize(int x, int y, int x_root, int y_root) case PositionCenter: // exception for tiling // Center means no resizing allowed - if (workspace()->tilingEnabled()) { + if (workspace()->tiling()->tilingEnabled()) { finishMoveResize(false); buttonDown = false; return; @@ -2810,7 +2811,7 @@ void Client::handleMoveResize(int x, int y, int x_root, int y_root) abort(); break; } - workspace()->notifyTilingWindowResize(this, moveResizeGeom, initialMoveResizeGeom); + workspace()->tiling()->notifyTilingWindowResize(this, moveResizeGeom, initialMoveResizeGeom); // adjust new size to snap to other windows/borders moveResizeGeom = workspace()->adjustClientSize(this, moveResizeGeom, mode); @@ -2968,7 +2969,7 @@ void Client::handleMoveResize(int x, int y, int x_root, int y_root) performMoveResize(); if (isMove()) { - workspace()->notifyTilingWindowMove(this, moveResizeGeom, initialMoveResizeGeom); + workspace()->tiling()->notifyTilingWindowMove(this, moveResizeGeom, initialMoveResizeGeom); #ifdef KWIN_BUILD_SCREENEDGES workspace()->screenEdge()->check(globalPos, xTime()); #endif @@ -2986,7 +2987,7 @@ void Client::performMoveResize() sendSyncRequest(); } #endif - if (!workspace()->tilingEnabled()) + if (!workspace()->tiling()->tilingEnabled()) setGeometry(moveResizeGeom); positionGeometryTip(); emit clientStepUserMovedResized(this, moveResizeGeom); diff --git a/sm.cpp b/sm.cpp index db44ce008d..d2111d1a7c 100644 --- a/sm.cpp +++ b/sm.cpp @@ -34,6 +34,7 @@ along with this program. If not, see . #include #include #include +#include "tiling/tiling.h" namespace KWin { @@ -84,10 +85,10 @@ void Workspace::storeSession(KConfig* config, SMSavePhase phase) int active_client = -1; if (phase == SMSavePhase2 || phase == SMSavePhase2Full) { - cg.writeEntry("tiling", tilingEnabled()); - if (tilingEnabled()) { + cg.writeEntry("tiling", m_tiling->tilingEnabled()); + if (m_tiling->tilingEnabled()) { kDebug(1212) << "Tiling was ON"; - setTilingEnabled(false); + m_tiling->setTilingEnabled(false); } } @@ -273,7 +274,7 @@ void Workspace::loadSessionInfo() session.clear(); KConfigGroup cg(kapp->sessionConfig(), "Session"); - setTilingEnabled(cg.readEntry("tiling", false)); + m_tiling->setTilingEnabled(cg.readEntry("tiling", false)); addSessionInfo(cg); } diff --git a/tile.cpp b/tile.cpp index a188129581..ee1f848a09 100644 --- a/tile.cpp +++ b/tile.cpp @@ -26,6 +26,7 @@ along with this program. If not, see . #include "client.h" #include "workspace.h" +#include "tiling/tiling.h" namespace KWin { @@ -95,7 +96,7 @@ void Tile::floatTile() restorePreviousGeometry(); commit(); - client()->workspace()->notifyTilingWindowActivated(client()); + client()->workspace()->tiling()->notifyTilingWindowActivated(client()); // TODO: notify layout manager } diff --git a/tiling/tiling.cpp b/tiling/tiling.cpp index 85b22274db..9ab3a5fa1e 100644 --- a/tiling/tiling.cpp +++ b/tiling/tiling.cpp @@ -3,6 +3,7 @@ This file is part of the KDE project. Copyright (C) 2009 Nikhil Marathe +Copyright (C) 2011 Arthur Arlt This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,30 +19,36 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . *********************************************************************/ -// all the tiling related code that is extensions to existing KWin classes -// Includes Workspace for now +#include -#include "client.h" -#include "workspace.h" -#include "tile.h" -#include "tilinglayout.h" -#include "tilinglayoutfactory.h" - -#include #include +#include #include #include +#include "tile.h" +#include "tilinglayout.h" +#include "tilinglayoutfactory.h" +#include "workspace.h" -namespace KWin +namespace KWin { +Tiling::Tiling(KWin::Workspace* w) + : QObject(w) + , m_workspace(w) + , tilingEnabled_(false) { +} -bool Workspace::tilingEnabled() const +Tiling::~Tiling() +{ +} + +bool Tiling::tilingEnabled() const { return tilingEnabled_; } -void Workspace::setTilingEnabled(bool tiling) +void Tiling::setTilingEnabled(bool tiling) { if (tilingEnabled() == tiling) return; @@ -56,8 +63,8 @@ void Workspace::setTilingEnabled(bool tiling) options->tilingRaisePolicy = config.readEntry("TilingRaisePolicy", 0); if (tilingEnabled_) { - tilingLayouts.resize(numberOfDesktops() + 1); - foreach (Client * c, stackingOrder()) { + tilingLayouts.resize(Workspace::self()->numberOfDesktops() + 1); + foreach (Client * c, Workspace::self()->stackingOrder()) { createTile(c); } } else { @@ -66,7 +73,7 @@ void Workspace::setTilingEnabled(bool tiling) } } -void Workspace::slotToggleTiling() +void Tiling::slotToggleTiling() { if (tilingEnabled()) { setTilingEnabled(false); @@ -79,7 +86,7 @@ void Workspace::slotToggleTiling() } } -void Workspace::createTile(Client *c) +void Tiling::createTile(Client* c) { if (c == NULL) return; @@ -90,28 +97,27 @@ void Workspace::createTile(Client *c) if (!tilingEnabled() || !tileable(c)) return; - Tile *t = new Tile(c, clientArea(PlacementArea, c)); + Tile *t = new Tile(c, Workspace::self()->clientArea(PlacementArea, c)); if (!tileable(c)) { kDebug(1212) << c->caption() << "is not tileable"; t->floatTile(); } if (!tilingLayouts.value(c->desktop())) { - tilingLayouts[c->desktop()] = TilingLayoutFactory::createLayout(TilingLayoutFactory::DefaultLayout, this); + tilingLayouts[c->desktop()] = TilingLayoutFactory::createLayout(TilingLayoutFactory::DefaultLayout, m_workspace); } tilingLayouts[c->desktop()]->addTile(t); tilingLayouts[c->desktop()]->commit(); } -void Workspace::removeTile(Client *c) +void Tiling::removeTile(Client *c) { if (tilingLayouts[ c->desktop()]) tilingLayouts[ c->desktop()]->removeTile(c); } -bool Workspace::tileable(Client *c) +bool Tiling::tileable(Client* c) { - kDebug(1212) << c->caption(); KWindowInfo info = KWindowSystem::windowInfo(c->window(), -1U, NET::WM2WindowClass); kDebug(1212) << "WINDOW CLASS IS " << info.windowClassClass(); @@ -134,21 +140,21 @@ bool Workspace::tileable(Client *c) return true; } -void Workspace::belowCursor() +void Tiling::belowCursor() { // TODO } -Tile* Workspace::getNiceTile() const +Tile* Tiling::getNiceTile() const { if (!tilingEnabled()) return NULL; - if (!tilingLayouts.value(activeClient()->desktop())) return NULL; + if (!tilingLayouts.value(m_workspace->activeClient()->desktop())) return NULL; - return tilingLayouts[ activeClient()->desktop()]->findTile(activeClient()); + return tilingLayouts[ m_workspace->activeClient()->desktop()]->findTile(m_workspace->activeClient()); // TODO } -void Workspace::updateAllTiles() +void Tiling::updateAllTiles() { foreach (TilingLayout * t, tilingLayouts) { if (!t) continue; @@ -159,14 +165,14 @@ void Workspace::updateAllTiles() /* * Resize the neighbouring clients to close any gaps */ -void Workspace::notifyTilingWindowResize(Client *c, const QRect &moveResizeGeom, const QRect &orig) +void Tiling::notifyTilingWindowResize(Client *c, const QRect &moveResizeGeom, const QRect &orig) { if (tilingLayouts.value(c->desktop()) == NULL) return; tilingLayouts[ c->desktop()]->clientResized(c, moveResizeGeom, orig); } -void Workspace::notifyTilingWindowMove(Client *c, const QRect &moveResizeGeom, const QRect &orig) +void Tiling::notifyTilingWindowMove(Client *c, const QRect &moveResizeGeom, const QRect &orig) { if (tilingLayouts.value(c->desktop()) == NULL) { return; @@ -175,7 +181,7 @@ void Workspace::notifyTilingWindowMove(Client *c, const QRect &moveResizeGeom, c updateAllTiles(); } -void Workspace::notifyTilingWindowResizeDone(Client *c, const QRect &moveResizeGeom, const QRect &orig, bool canceled) +void Tiling::notifyTilingWindowResizeDone(Client *c, const QRect &moveResizeGeom, const QRect &orig, bool canceled) { if (canceled) notifyTilingWindowResize(c, orig, moveResizeGeom); @@ -183,7 +189,7 @@ void Workspace::notifyTilingWindowResizeDone(Client *c, const QRect &moveResizeG notifyTilingWindowResize(c, moveResizeGeom, orig); } -void Workspace::notifyTilingWindowMoveDone(Client *c, const QRect &moveResizeGeom, const QRect &orig, bool canceled) +void Tiling::notifyTilingWindowMoveDone(Client *c, const QRect &moveResizeGeom, const QRect &orig, bool canceled) { if (canceled) notifyTilingWindowMove(c, orig, moveResizeGeom); @@ -191,9 +197,9 @@ void Workspace::notifyTilingWindowMoveDone(Client *c, const QRect &moveResizeGeo notifyTilingWindowMove(c, moveResizeGeom, orig); } -void Workspace::notifyTilingWindowDesktopChanged(Client *c, int old_desktop) +void Tiling::notifyTilingWindowDesktopChanged(Client *c, int old_desktop) { - if (c->desktop() < 1 || c->desktop() > numberOfDesktops()) + if (c->desktop() < 1 || c->desktop() > m_workspace->numberOfDesktops()) return; if (tilingLayouts.value(old_desktop)) { @@ -201,7 +207,7 @@ void Workspace::notifyTilingWindowDesktopChanged(Client *c, int old_desktop) // TODO: copied from createTile(), move this into separate method? if (!tilingLayouts.value(c->desktop())) { - tilingLayouts[c->desktop()] = TilingLayoutFactory::createLayout(TilingLayoutFactory::DefaultLayout, this); + tilingLayouts[c->desktop()] = TilingLayoutFactory::createLayout(TilingLayoutFactory::DefaultLayout, m_workspace); } if (t) @@ -215,7 +221,7 @@ void Workspace::notifyTilingWindowDesktopChanged(Client *c, int old_desktop) /* * Implements the 3 raising modes in Window Behaviour -> Advanced */ -void Workspace::notifyTilingWindowActivated(Client *c) +void Tiling::notifyTilingWindowActivated(Client *c) { if (c == NULL) return; @@ -226,7 +232,7 @@ void Workspace::notifyTilingWindowActivated(Client *c) if (tilingLayouts.value(c->desktop())) { QList tiles = tilingLayouts[ c->desktop()]->tiles(); - StackingUpdatesBlocker blocker(this); + StackingUpdatesBlocker blocker(m_workspace); Tile *tile_to_raise = tilingLayouts[ c->desktop()]->findTile(c); @@ -243,24 +249,24 @@ void Workspace::notifyTilingWindowActivated(Client *c) foreach (Tile * t, tiles) { if (t->floating() == raise_floating && t != tile_to_raise) - raiseClient(t->client()); + m_workspace->raiseClient(t->client()); } // raise the current tile last so that it ends up on top // but only if it supposed to be raised, required to support tilingRaisePolicy kDebug(1212) << "Raise floating? " << raise_floating << "to raise is floating?" << tile_to_raise->floating(); if (tile_to_raise->floating() == raise_floating) - raiseClient(tile_to_raise->client()); + m_workspace->raiseClient(tile_to_raise->client()); } } -void Workspace::notifyTilingWindowMinimizeToggled(Client *c) +void Tiling::notifyTilingWindowMinimizeToggled(Client *c) { if (tilingLayouts.value(c->desktop())) { tilingLayouts[ c->desktop()]->clientMinimizeToggled(c); } } -void Workspace::notifyTilingWindowMaximized(Client *c, Options::WindowOperation op) +void Tiling::notifyTilingWindowMaximized(Client *c, Options::WindowOperation op) { if (tilingLayouts.value(c->desktop())) { Tile *t = tilingLayouts[ c->desktop()]->findTile(c); @@ -291,7 +297,7 @@ void Workspace::notifyTilingWindowMaximized(Client *c, Options::WindowOperation } } -Tile* Workspace::findAdjacentTile(Tile *ref, int d) +Tile* Tiling::findAdjacentTile(Tile *ref, int d) { QRect reference = ref->geometry(); QPoint origin = reference.center(); @@ -346,17 +352,17 @@ Tile* Workspace::findAdjacentTile(Tile *ref, int d) return closest; } -void Workspace::focusTile(int d) +void Tiling::focusTile(int d) { Tile *t = getNiceTile(); if (t) { Tile *adj = findAdjacentTile(t, d); if (adj) - activateClient(adj->client()); + m_workspace->activateClient(adj->client()); } } -void Workspace::moveTile(int d) +void Tiling::moveTile(int d) { Tile *t = getNiceTile(); if (t) { @@ -366,75 +372,75 @@ void Workspace::moveTile(int d) } } -void Workspace::slotFocusTileLeft() +void Tiling::slotFocusTileLeft() { focusTile(Tile::Left); } -void Workspace::slotFocusTileRight() +void Tiling::slotFocusTileRight() { focusTile(Tile::Right); } -void Workspace::slotFocusTileTop() +void Tiling::slotFocusTileTop() { focusTile(Tile::Top); } -void Workspace::slotFocusTileBottom() +void Tiling::slotFocusTileBottom() { focusTile(Tile::Bottom); } -void Workspace::slotMoveTileLeft() +void Tiling::slotMoveTileLeft() { moveTile(Tile::Left); } -void Workspace::slotMoveTileRight() +void Tiling::slotMoveTileRight() { moveTile(Tile::Right); } -void Workspace::slotMoveTileTop() +void Tiling::slotMoveTileTop() { moveTile(Tile::Top); } -void Workspace::slotMoveTileBottom() +void Tiling::slotMoveTileBottom() { moveTile(Tile::Bottom); } -void Workspace::slotToggleFloating() +void Tiling::slotToggleFloating() { - Client *c = activeClient(); + Client *c = m_workspace->activeClient(); if (tilingLayouts.value(c->desktop())) { tilingLayouts[ c->desktop()]->toggleFloatTile(c); } } -void Workspace::slotNextTileLayout() +void Tiling::slotNextTileLayout() { - if (tilingLayouts.value(currentDesktop())) { + if (tilingLayouts.value(m_workspace->currentDesktop())) { - tilingLayouts.replace(currentDesktop(), TilingLayoutFactory::nextLayout(tilingLayouts[currentDesktop()])); + tilingLayouts.replace(m_workspace->currentDesktop(), TilingLayoutFactory::nextLayout(tilingLayouts[m_workspace->currentDesktop()])); - tilingLayouts[currentDesktop()]->commit(); + tilingLayouts[m_workspace->currentDesktop()]->commit(); } } -void Workspace::slotPreviousTileLayout() +void Tiling::slotPreviousTileLayout() { - if (tilingLayouts.value(currentDesktop())) { + if (tilingLayouts.value(m_workspace->currentDesktop())) { - tilingLayouts.replace(currentDesktop(), TilingLayoutFactory::previousLayout(tilingLayouts[currentDesktop()])); + tilingLayouts.replace(m_workspace->currentDesktop(), TilingLayoutFactory::previousLayout(tilingLayouts[m_workspace->currentDesktop()])); - tilingLayouts[currentDesktop()]->commit(); + tilingLayouts[m_workspace->currentDesktop()]->commit(); } } -KDecorationDefines::Position Workspace::supportedTilingResizeMode(Client *c, KDecorationDefines::Position currentMode) +KDecorationDefines::Position Tiling::supportedTilingResizeMode(Client *c, KDecorationDefines::Position currentMode) { if (tilingLayouts.value(c->desktop())) { return tilingLayouts[c->desktop()]->resizeMode(c, currentMode); @@ -442,7 +448,7 @@ KDecorationDefines::Position Workspace::supportedTilingResizeMode(Client *c, KDe return currentMode; } -void Workspace::dumpTiles() const +void Tiling::dumpTiles() const { foreach (TilingLayout * t, tilingLayouts) { if (!t) { @@ -455,5 +461,10 @@ void Workspace::dumpTiles() const } } } -} // namespace +QVector< TilingLayout* >& Tiling::getTilingLayouts() +{ + return tilingLayouts; +} + +} diff --git a/tiling/tiling.h b/tiling/tiling.h new file mode 100644 index 0000000000..fcd8f4382a --- /dev/null +++ b/tiling/tiling.h @@ -0,0 +1,108 @@ +/******************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + +Copyright (C) 2009 Nikhil Marathe +Copyright (C) 2011 Arthur Arlt + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*********************************************************************/ + +#ifndef KWIN_TILING_H +#define KWIN_TILING_H + +#include + +#include "client.h" + +#include + +namespace KWin { + +class Tile; +class TilingLayout; + +class Tiling : public QObject { + Q_OBJECT +public: + Tiling(Workspace *w); + ~Tiling(); + 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(); + + // The notification functions are called from + // various points in existing code so that + // tiling can take any action if required. + // They are defined in tiling.cpp + void notifyTilingWindowResize(Client *c, const QRect &moveResizeGeom, const QRect &orig); + void notifyTilingWindowMove(Client *c, const QRect &moveResizeGeom, const QRect &orig); + void notifyTilingWindowResizeDone(Client *c, const QRect &moveResizeGeom, const QRect &orig, bool canceled); + void notifyTilingWindowMoveDone(Client *c, const QRect &moveResizeGeom, const QRect &orig, bool canceled); + void notifyTilingWindowDesktopChanged(Client *c, int old_desktop); + void notifyTilingWindowActivated(Client *c); + void notifyTilingWindowMinimizeToggled(Client *c); + void notifyTilingWindowMaximized(Client *c, KDecorationDefines::WindowOperation op); + + KDecorationDefines::Position supportedTilingResizeMode(Client *c, KDecorationDefines::Position currentMode); + +public Q_SLOTS: + // user actions, usually bound to shortcuts + // and also provided through the D-BUS interface. + void slotToggleTiling(); + void slotToggleFloating(); + void slotNextTileLayout(); + void slotPreviousTileLayout(); + + // Changes the focused client + void slotFocusTileLeft(); + void slotFocusTileRight(); + void slotFocusTileTop(); + void slotFocusTileBottom(); + // swaps active and adjacent client. + void slotMoveTileLeft(); + void slotMoveTileRight(); + void slotMoveTileTop(); + void slotMoveTileBottom(); + void belowCursor(); + + // NOTE: debug method + void dumpTiles() const; +private: + // try to get a decent tile, either the one with + // focus or the one below the mouse. + Tile* getNiceTile() const; + // int, and not Tile::Direction because + // we are using a forward declaration for Tile + Tile* findAdjacentTile(Tile *ref, int d); + void focusTile(int d); + void moveTile(int d); + + Workspace* m_workspace; + bool tilingEnabled_; + // Each tilingLayout is for one virtual desktop. + // The length is always one more than the number of + // virtual desktops so that we can quickly index them + // without having to remember to subtract one. + QVector tilingLayouts; +}; +} + +#endif // KWIN_TILING_H \ No newline at end of file diff --git a/tilinglayout.cpp b/tilinglayout.cpp index 6e1152b15c..c7ab849fa0 100644 --- a/tilinglayout.cpp +++ b/tilinglayout.cpp @@ -25,6 +25,7 @@ along with this program. If not, see . #include "client.h" #include "tile.h" #include "workspace.h" +#include "tiling/tiling.h" namespace KWin { @@ -194,7 +195,7 @@ void TilingLayout::reconfigureTiling() foreach (Client * c, workspace()->stackingOrder()) { if (c->rules()->checkTilingOption(0) == 1) - workspace()->createTile(c); + workspace()->tiling()->createTile(c); } } diff --git a/useractions.cpp b/useractions.cpp index 387e4992b7..66b5efd876 100644 --- a/useractions.cpp +++ b/useractions.cpp @@ -32,6 +32,7 @@ along with this program. If not, see . #include "effects.h" #include "tile.h" #include "tilinglayout.h" +#include "tiling/tiling.h" #include "kactivityinfo.h" @@ -198,7 +199,7 @@ QMenu* Workspace::clientPopup() // then hide it mTilingStateOpAction->setVisible(false); // actions for window tiling - if (tilingEnabled()) { + if (m_tiling->tilingEnabled()) { kaction = qobject_cast(keys->action("Toggle Floating")); mTilingStateOpAction->setCheckable(true); mTilingStateOpAction->setData(Options::ToggleClientTiledStateOp); @@ -289,15 +290,15 @@ void Workspace::clientPopupAboutToShow() mMinimizeOpAction->setEnabled(active_popup_client->isMinimizable()); mCloseOpAction->setEnabled(active_popup_client->isCloseable()); - if (tilingEnabled()) { + if (m_tiling->tilingEnabled()) { int desktop = active_popup_client->desktop(); - if (tilingLayouts.value(desktop)) { - Tile *t = tilingLayouts[desktop]->findTile(active_popup_client); + if (m_tiling->getTilingLayouts().value(desktop)) { + Tile *t = m_tiling->getTilingLayouts()[desktop]->findTile(active_popup_client); if (t) mTilingStateOpAction->setChecked(t->floating()); } } - mTilingStateOpAction->setVisible(tilingEnabled()); + mTilingStateOpAction->setVisible(m_tiling->tilingEnabled()); delete switch_to_tab_popup; switch_to_tab_popup = 0; @@ -661,12 +662,12 @@ void Workspace::performWindowOperation(Client* c, Options::WindowOperation op) return; // Allows us to float a window when it is maximized, if it is tiled. - if (tilingEnabled() + if (m_tiling->tilingEnabled() && (op == Options::MaximizeOp || op == Options::HMaximizeOp || op == Options::VMaximizeOp || op == Options::RestoreOp)) { - notifyTilingWindowMaximized(c, op); + m_tiling->notifyTilingWindowMaximized(c, op); } if (op == Options::MoveOp || op == Options::UnrestrictedMoveOp) @@ -780,8 +781,8 @@ void Workspace::performWindowOperation(Client* c, Options::WindowOperation op) c->clientGroup()->closeAll(); case Options::ToggleClientTiledStateOp: { int desktop = c->desktop(); - if (tilingLayouts.value(desktop)) { - tilingLayouts[desktop]->toggleFloatTile(c); + if (m_tiling->getTilingLayouts().value(desktop)) { + m_tiling->getTilingLayouts()[desktop]->toggleFloatTile(c); } } } diff --git a/workspace.cpp b/workspace.cpp index b9556681b2..f742288224 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -63,6 +63,7 @@ along with this program. If not, see . #include "effects.h" #include "overlaywindow.h" #include "tilinglayout.h" +#include "tiling/tiling.h" #ifdef KWIN_BUILD_SCRIPTING #include "scripting/scripting.h" @@ -107,7 +108,6 @@ Workspace::Workspace(bool restore) , desktopGridSize_(1, 2) // Default to two rows , desktopGrid_(new int[2]) , currentDesktop_(0) - , tilingEnabled_(false) // Unsorted , active_popup(NULL) , active_popup_client(NULL) @@ -235,11 +235,14 @@ Workspace::Workspace(bool restore) ); client_keys = new KActionCollection(this); - initShortcuts(); + #ifdef KWIN_BUILD_DESKTOPCHANGEOSD desktop_change_osd = new DesktopChangeOSD(this); #endif m_outline = new Outline(); + m_tiling = new Tiling(this); + + initShortcuts(); init(); @@ -488,7 +491,7 @@ void Workspace::init() activateClient(new_active_client); // Enable/disable tiling - setTilingEnabled(options->tilingOn); + m_tiling->setTilingEnabled(options->tilingOn); // SELI TODO: This won't work with unreasonable focus policies, // and maybe in rare cases also if the selected client doesn't @@ -525,6 +528,7 @@ Workspace::~Workspace() delete desktop_change_osd; #endif delete m_outline; + delete m_tiling; discardPopup(); XDeleteProperty(display(), rootWindow(), atoms->kwin_running); @@ -562,9 +566,9 @@ Client* Workspace::createClient(Window w, bool is_mapped) } addClient(c, Allowed); - tilingLayouts.resize(numberOfDesktops() + 1); + m_tiling->getTilingLayouts().resize(numberOfDesktops() + 1); + m_tiling->createTile(c); - createTile(c); return c; } @@ -668,8 +672,8 @@ void Workspace::removeClient(Client* c, allowed_t) #endif Q_ASSERT(clients.contains(c) || desktops.contains(c)); - if (tilingEnabled() && tilingLayouts.value(c->desktop())) { - removeTile(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); @@ -1027,13 +1031,13 @@ void Workspace::slotReconfigure() } } - setTilingEnabled(options->tilingOn); - foreach (TilingLayout * layout, tilingLayouts) { + m_tiling->setTilingEnabled(options->tilingOn); + foreach (TilingLayout * layout, m_tiling->getTilingLayouts()) { if (layout) layout->reconfigureTiling(); } // just so that we reset windows in the right manner, 'activate' the current active window - notifyTilingWindowActivated(activeClient()); + m_tiling->notifyTilingWindowActivated(activeClient()); if (hasDecorationPlugin()) { rootInfo->setSupported(NET::WM2FrameOverlap, mgr->factory()->supports(AbilityExtendIntoClientArea)); } else { @@ -1296,8 +1300,8 @@ bool Workspace::setCurrentDesktop(int new_desktop) if (movingClient && !movingClient->isOnDesktop(new_desktop)) { int old_desktop = movingClient->desktop(); movingClient->setDesktop(new_desktop); - if (tilingEnabled()) { - notifyTilingWindowDesktopChanged(movingClient, old_desktop); + if (m_tiling->tilingEnabled()) { + m_tiling->notifyTilingWindowDesktopChanged(movingClient, old_desktop); } } @@ -1577,7 +1581,7 @@ void Workspace::setNumberOfDesktops(int n) for (int i = 0; i < int(desktop_focus_chain.size()); i++) desktop_focus_chain[i] = i + 1; - tilingLayouts.resize(numberOfDesktops() + 1); + m_tiling->getTilingLayouts().resize(numberOfDesktops() + 1); saveDesktopSettings(); emit numberDesktopsChanged(old_number_of_desktops); @@ -1611,7 +1615,7 @@ void Workspace::sendClientToDesktop(Client* c, int desk, bool dont_activate) } else raiseClient(c); - notifyTilingWindowDesktopChanged(c, old_desktop); + m_tiling->notifyTilingWindowDesktopChanged(c, old_desktop); ClientList transients_stacking_order = ensureStackingOrder(c->transients()); for (ClientList::ConstIterator it = transients_stacking_order.constBegin(); @@ -2151,6 +2155,47 @@ TabBox::TabBox* Workspace::tabBox() const } #endif +Tiling* Workspace::tiling() +{ + return m_tiling; +} + +/* + * Called from D-BUS + */ +void Workspace::toggleTiling() +{ + if (m_tiling) { + m_tiling->slotToggleTiling(); + } +} + +/* + * Called from D-BUS + */ +void Workspace::nextTileLayout() +{ + if (m_tiling) { + m_tiling->slotNextTileLayout(); + } +} + +/* + * Called from D-BUS + */ +void Workspace::previousTileLayout() +{ + if (m_tiling) { + m_tiling->slotPreviousTileLayout(); + } +} + +void Workspace::dumpTiles() const { + if (m_tiling) { + m_tiling->dumpTiles(); + } +} + } // namespace #include "workspace.moc" diff --git a/workspace.h b/workspace.h index 79c1e2d691..871f74cc61 100644 --- a/workspace.h +++ b/workspace.h @@ -74,6 +74,7 @@ class TabBox; class Client; class Tile; +class Tiling; class TilingLayout; class ClientGroup; #ifdef KWIN_BUILD_DESKTOPCHANGEOSD @@ -197,31 +198,7 @@ public: return unmanaged; } - //------------------------------------------------- - // Tiling -public: - bool tilingEnabled() const; - void setTilingEnabled(bool tiling); - bool tileable(Client *c); - void createTile(Client *c); - // updates geometry of tiles on all desktops, - // this rearranges the tiles. - void updateAllTiles(); - - // The notification functions are called from - // various points in existing code so that - // tiling can take any action if required. - // They are defined in tiling.cpp - void notifyTilingWindowResize(Client *c, const QRect &moveResizeGeom, const QRect &orig); - void notifyTilingWindowMove(Client *c, const QRect &moveResizeGeom, const QRect &orig); - void notifyTilingWindowResizeDone(Client *c, const QRect &moveResizeGeom, const QRect &orig, bool canceled); - void notifyTilingWindowMoveDone(Client *c, const QRect &moveResizeGeom, const QRect &orig, bool canceled); - void notifyTilingWindowDesktopChanged(Client *c, int old_desktop); - void notifyTilingWindowActivated(Client *c); - void notifyTilingWindowMinimizeToggled(Client *c); - void notifyTilingWindowMaximized(Client *c, WindowOperation op); - - Position supportedTilingResizeMode(Client *c, Position currentMode); + Tiling* tiling(); Outline* outline(); #ifdef KWIN_BUILD_SCREENEDGES @@ -329,14 +306,10 @@ private: KActivityController activityController_; - bool tilingEnabled_; - // Each tilingLayout is for one virtual desktop. - // The length is always one more than the number of - // virtual desktops so that we can quickly index them - // without having to remember to subtract one. - QVector tilingLayouts; + Tiling* m_tiling; Outline* m_outline; + #ifdef KWIN_BUILD_SCREENEDGES ScreenEdge m_screenEdge; #endif @@ -640,25 +613,6 @@ public slots: void suspendCompositing(); void suspendCompositing(bool suspend); - // user actions, usually bound to shortcuts - // and also provided through the D-BUS interface. - void slotToggleTiling(); - void slotToggleFloating(); - void slotNextTileLayout(); - void slotPreviousTileLayout(); - - // Changes the focused client - void slotFocusTileLeft(); - void slotFocusTileRight(); - void slotFocusTileTop(); - void slotFocusTileBottom(); - // swaps active and adjacent client. - void slotMoveTileLeft(); - void slotMoveTileRight(); - void slotMoveTileTop(); - void slotMoveTileBottom(); - void belowCursor(); - // NOTE: debug method void dumpTiles() const; @@ -805,16 +759,6 @@ private: static NET::WindowType txtToWindowType(const char* txt); static bool sessionInfoWindowTypeMatch(Client* c, SessionInfo* info); - // try to get a decent tile, either the one with - // focus or the one below the mouse. - Tile* getNiceTile() const; - void removeTile(Client *c); - // int, and not Tile::Direction because - // we are using a forward declaration for Tile - Tile* findAdjacentTile(Tile *ref, int d); - void focusTile(int d); - void moveTile(int d); - Client* active_client; Client* last_active_client; Client* most_recently_raised; // Used ONLY by raiseOrLowerClient() @@ -1263,30 +1207,6 @@ inline void Workspace::removeClientGroup(ClientGroup* group) clientGroups.removeAll(group); } -/* - * Called from D-BUS - */ -inline void Workspace::toggleTiling() -{ - slotToggleTiling(); -} - -/* - * Called from D-BUS - */ -inline void Workspace::nextTileLayout() -{ - slotNextTileLayout(); -} - -/* - * Called from D-BUS - */ -inline void Workspace::previousTileLayout() -{ - slotPreviousTileLayout(); -} - } // namespace #endif From bc4fea10f3b023319cf3ff48c44aace0502b23fa Mon Sep 17 00:00:00 2001 From: Arthur Arlt Date: Fri, 15 Jul 2011 21:52:19 +0200 Subject: [PATCH 03/10] 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. --- tiling/tiling.cpp | 17 ++++++++++++++++- tiling/tiling.h | 8 +++++--- workspace.cpp | 6 ------ 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/tiling/tiling.cpp b/tiling/tiling.cpp index 9ab3a5fa1e..5812567cc4 100644 --- a/tiling/tiling.cpp +++ b/tiling/tiling.cpp @@ -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); +} + } diff --git a/tiling/tiling.h b/tiling/tiling.h index fcd8f4382a..555b0a4e91 100644 --- a/tiling/tiling.h +++ b/tiling/tiling.h @@ -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 tilingLayouts; +private Q_SLOTS: + void slotResizeTilingLayouts(); }; } diff --git a/workspace.cpp b/workspace.cpp index f742288224..8be3a10f48 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -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); } From f29d151220c8097fba1b0ef892e68bd0b62fe42a Mon Sep 17 00:00:00 2001 From: Arthur Arlt Date: Mon, 18 Jul 2011 11:09:12 +0200 Subject: [PATCH 04/10] Use configChanged() signal in TilingLayouts Since there is a signal triggered if configurations are changed, the reconfiguration method in TilingLayouts was made a slot and is connected to the appropriate signal in Workspace. --- tilinglayout.cpp | 4 +++- tilinglayout.h | 7 +++++-- workspace.cpp | 6 +----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/tilinglayout.cpp b/tilinglayout.cpp index c7ab849fa0..da50b7629e 100644 --- a/tilinglayout.cpp +++ b/tilinglayout.cpp @@ -31,8 +31,10 @@ namespace KWin { TilingLayout::TilingLayout(Workspace *w) - : m_workspace(w) + : QObject() + , m_workspace(w) { + connect(m_workspace, SIGNAL(configChanged()), this, SLOT(reconfigureTiling())); } TilingLayout::~TilingLayout() diff --git a/tilinglayout.h b/tilinglayout.h index 687d28c776..677db1aa00 100644 --- a/tilinglayout.h +++ b/tilinglayout.h @@ -33,8 +33,9 @@ class Workspace; class Client; class Tile; -class TilingLayout +class TilingLayout : public QObject { + Q_OBJECT public: TilingLayout(Workspace *w); virtual ~TilingLayout(); @@ -59,7 +60,6 @@ public: void removeTile(Client *c); void toggleFloatTile(Client *c); void swapTiles(Tile *a, Tile *b); - void reconfigureTiling(); /** * All tiling layouts do not allow the user to manually @@ -92,6 +92,9 @@ protected: virtual void postAddTile(Tile *t); virtual void preRemoveTile(Tile *t); +protected Q_SLOTS: + void reconfigureTiling(); + private: int findTilePos(Client *c) const; virtual void arrange(QRect wgeom) = 0; diff --git a/workspace.cpp b/workspace.cpp index 8be3a10f48..733bc109c6 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -505,6 +505,7 @@ Workspace::~Workspace() { finishCompositing(); blockStackingUpdates(true); + delete m_tiling; // TODO: grabXServer(); @@ -528,7 +529,6 @@ Workspace::~Workspace() delete desktop_change_osd; #endif delete m_outline; - delete m_tiling; discardPopup(); XDeleteProperty(display(), rootWindow(), atoms->kwin_running); @@ -1028,10 +1028,6 @@ void Workspace::slotReconfigure() } m_tiling->setTilingEnabled(options->tilingOn); - foreach (TilingLayout * layout, m_tiling->getTilingLayouts()) { - if (layout) - layout->reconfigureTiling(); - } // just so that we reset windows in the right manner, 'activate' the current active window m_tiling->notifyTilingWindowActivated(activeClient()); if (hasDecorationPlugin()) { From b1e3c7ba38072586c71bb4eb8de4fc03250637b0 Mon Sep 17 00:00:00 2001 From: Arthur Arlt Date: Mon, 18 Jul 2011 16:38:55 +0200 Subject: [PATCH 05/10] Move initialization of shortcuts to separate method in new Tiling class --- kwinbindings.cpp | 16 ---------------- tiling/tiling.cpp | 30 ++++++++++++++++++++++++++++++ tiling/tiling.h | 1 + useractions.cpp | 3 +++ 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/kwinbindings.cpp b/kwinbindings.cpp index 0d818570e6..0bea892be5 100644 --- a/kwinbindings.cpp +++ b/kwinbindings.cpp @@ -188,22 +188,6 @@ DEF(I18N_NOOP("Kill Window"), Qt::CTRL + Qt::ALT + Qt::Key_ DEF(I18N_NOOP("Block Global Shortcuts"), 0, slotDisableGlobalShortcuts()); DEF(I18N_NOOP("Suspend Compositing"), Qt::SHIFT + Qt::ALT + Qt::Key_F12, slotToggleCompositing()); -a = actionCollection->addAction("Group:Tiling"); -a->setText(i18n("Tiling")); -DEF(I18N_NOOP("Enable/Disable Tiling"), Qt::SHIFT + Qt::ALT + Qt::Key_F11, slotToggleTiling()); -DEF(I18N_NOOP("Toggle Floating"), Qt::META + Qt::Key_F, slotToggleFloating()); - -DEF(I18N_NOOP("Switch Focus Left") , Qt::META + Qt::Key_H, slotFocusTileLeft()); -DEF(I18N_NOOP("Switch Focus Right") , Qt::META + Qt::Key_L, slotFocusTileRight()); -DEF(I18N_NOOP("Switch Focus Up") , Qt::META + Qt::Key_K, slotFocusTileTop()); -DEF(I18N_NOOP("Switch Focus Down") , Qt::META + Qt::Key_J, slotFocusTileBottom()); -DEF(I18N_NOOP("Move Window Left") , Qt::SHIFT + Qt::META + Qt::Key_H, slotMoveTileLeft()); -DEF(I18N_NOOP("Move Window Right") , Qt::SHIFT + Qt::META + Qt::Key_L, slotMoveTileRight()); -DEF(I18N_NOOP("Move Window Up") , Qt::SHIFT + Qt::META + Qt::Key_K, slotMoveTileTop()); -DEF(I18N_NOOP("Move Window Down") , Qt::SHIFT + Qt::META + Qt::Key_J, slotMoveTileBottom()); -DEF(I18N_NOOP("Next Layout"), Qt::META + Qt::Key_PageDown, slotNextTileLayout()); -DEF(I18N_NOOP("Previous Layout"), Qt::META + Qt::Key_PageUp, slotPreviousTileLayout()); - #undef DEF #undef DEF2 diff --git a/tiling/tiling.cpp b/tiling/tiling.cpp index 5812567cc4..4e8714429e 100644 --- a/tiling/tiling.cpp +++ b/tiling/tiling.cpp @@ -26,6 +26,9 @@ along with this program. If not, see . #include #include +#include +#include + #include "tile.h" #include "tilinglayout.h" #include "tilinglayoutfactory.h" @@ -43,6 +46,32 @@ Tiling::~Tiling() { } +void Tiling::initShortcuts(KActionCollection* keys){ + KAction *a = NULL; + #define KEY( name, key, fnSlot ) \ + a = keys->addAction( name ); \ + a->setText( i18n( name ) ); \ + qobject_cast( a )->setGlobalShortcut(KShortcut(key)); \ + connect(a, SIGNAL(triggered(bool)), SLOT(fnSlot)); + + a = keys->addAction("Group:Tiling"); + a->setText(i18n("Tiling")); + KEY(I18N_NOOP("Enable/Disable Tiling"), Qt::SHIFT + Qt::ALT + Qt::Key_F11, slotToggleTiling()); + KEY(I18N_NOOP("Toggle Floating"), Qt::META + Qt::Key_F, slotToggleFloating()); + + KEY(I18N_NOOP("Switch Focus Left") , Qt::META + Qt::Key_H, slotFocusTileLeft()); + KEY(I18N_NOOP("Switch Focus Right") , Qt::META + Qt::Key_L, slotFocusTileRight()); + KEY(I18N_NOOP("Switch Focus Up") , Qt::META + Qt::Key_K, slotFocusTileTop()); + KEY(I18N_NOOP("Switch Focus Down") , Qt::META + Qt::Key_J, slotFocusTileBottom()); + KEY(I18N_NOOP("Move Window Left") , Qt::SHIFT + Qt::META + Qt::Key_H, slotMoveTileLeft()); + KEY(I18N_NOOP("Move Window Right") , Qt::SHIFT + Qt::META + Qt::Key_L, slotMoveTileRight()); + KEY(I18N_NOOP("Move Window Up") , Qt::SHIFT + Qt::META + Qt::Key_K, slotMoveTileTop()); + KEY(I18N_NOOP("Move Window Down") , Qt::SHIFT + Qt::META + Qt::Key_J, slotMoveTileBottom()); + KEY(I18N_NOOP("Next Layout"), Qt::META + Qt::Key_PageDown, slotNextTileLayout()); + KEY(I18N_NOOP("Previous Layout"), Qt::META + Qt::Key_PageUp, slotPreviousTileLayout()); + +} + bool Tiling::tilingEnabled() const { return tilingEnabled_; @@ -112,6 +141,7 @@ void Tiling::createTile(Client* c) if (!tilingLayouts.value(c->desktop())) { tilingLayouts[c->desktop()] = TilingLayoutFactory::createLayout(TilingLayoutFactory::DefaultLayout, m_workspace); + tilingLayouts[c->desktop()]->setParent(this); } tilingLayouts[c->desktop()]->addTile(t); tilingLayouts[c->desktop()]->commit(); diff --git a/tiling/tiling.h b/tiling/tiling.h index 555b0a4e91..a3cee78dc4 100644 --- a/tiling/tiling.h +++ b/tiling/tiling.h @@ -45,6 +45,7 @@ public: // this rearranges the tiles. void updateAllTiles(); const QVector< TilingLayout* >& getTilingLayouts() const; + void initShortcuts(KActionCollection* keys); // The notification functions are called from // various points in existing code so that diff --git a/useractions.cpp b/useractions.cpp index 66b5efd876..a22d24f21a 100644 --- a/useractions.cpp +++ b/useractions.cpp @@ -565,6 +565,9 @@ void Workspace::initShortcuts() tab_box->initShortcuts(actionCollection); } #endif + if (m_tiling) { + m_tiling->initShortcuts(actionCollection); + } discardPopup(); // so that it's recreated next time } From 85c5439b5d0d482dc0f5f389249a4ecaed635c0d Mon Sep 17 00:00:00 2001 From: Arthur Arlt Date: Tue, 19 Jul 2011 12:21:35 +0200 Subject: [PATCH 06/10] Remove tiling dependency from Client The direct method calls from class Client were removed and replaced by connecting to the appropriate signals emitted by class Client. The affected methods in class Tiling are notifyTilingWindowMinimizeToggle() and updateAllTiles() which are now private Q_SLOTS. Including tiling.h in class Client is no longer needed and was removed. --- client.cpp | 8 -------- tiling/tiling.cpp | 6 +++++- tiling/tiling.h | 8 ++++---- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/client.cpp b/client.cpp index fe5016c3db..46c8effed8 100644 --- a/client.cpp +++ b/client.cpp @@ -47,7 +47,6 @@ along with this program. If not, see . #include "notifications.h" #include "rules.h" #include "shadow.h" -#include "tiling/tiling.h" #include "deleted.h" #include "paintredirector.h" #ifdef KWIN_BUILD_TABBOX @@ -951,9 +950,6 @@ void Client::minimize(bool avoid_animation) // TODO: merge signal with s_minimized emit clientMinimized(this, !avoid_animation); - // when tiling, request a rearrangement - workspace()->tiling()->notifyTilingWindowMinimizeToggled(this); - // Update states of all other windows in this group if (clientGroup()) clientGroup()->updateStates(this); @@ -979,12 +975,8 @@ void Client::unminimize(bool avoid_animation) updateAllowedActions(); workspace()->updateMinimizedOfTransients(this); updateWindowRules(); - workspace()->tiling()->updateAllTiles(); emit clientUnminimized(this, !avoid_animation); - // when tiling, request a rearrangement - workspace()->tiling()->notifyTilingWindowMinimizeToggled(this); - // Update states of all other windows in this group if (clientGroup()) clientGroup()->updateStates(this); diff --git a/tiling/tiling.cpp b/tiling/tiling.cpp index 4e8714429e..904ecea520 100644 --- a/tiling/tiling.cpp +++ b/tiling/tiling.cpp @@ -145,6 +145,10 @@ void Tiling::createTile(Client* c) } tilingLayouts[c->desktop()]->addTile(t); tilingLayouts[c->desktop()]->commit(); + // if tiling is activated, connect to Client's signals and react with rearrangement when (un)minimizing + connect(c, SIGNAL(clientMinimized(KWin::Client*,bool)), this, SLOT(notifyTilingWindowMinimizeToggled(KWin::Client*))); + connect(c, SIGNAL(clientUnminimized(KWin::Client*,bool)), this, SLOT(notifyTilingWindowMinimizeToggled(KWin::Client*))); + connect(c, SIGNAL(s_unminimized()), this, SLOT(updateAllTiles())); } void Tiling::removeTile(Client *c) @@ -299,7 +303,7 @@ void Tiling::notifyTilingWindowActivated(Client *c) } } -void Tiling::notifyTilingWindowMinimizeToggled(Client *c) +void Tiling::notifyTilingWindowMinimizeToggled(KWin::Client* c) { if (tilingLayouts.value(c->desktop())) { tilingLayouts[ c->desktop()]->clientMinimizeToggled(c); diff --git a/tiling/tiling.h b/tiling/tiling.h index a3cee78dc4..52543c8120 100644 --- a/tiling/tiling.h +++ b/tiling/tiling.h @@ -41,9 +41,6 @@ public: bool tilingEnabled() const; void setTilingEnabled(bool tiling); bool tileable(Client *c); - // updates geometry of tiles on all desktops, - // this rearranges the tiles. - void updateAllTiles(); const QVector< TilingLayout* >& getTilingLayouts() const; void initShortcuts(KActionCollection* keys); @@ -57,7 +54,6 @@ public: void notifyTilingWindowMoveDone(Client *c, const QRect &moveResizeGeom, const QRect &orig, bool canceled); void notifyTilingWindowDesktopChanged(Client *c, int old_desktop); void notifyTilingWindowActivated(Client *c); - void notifyTilingWindowMinimizeToggled(Client *c); void notifyTilingWindowMaximized(Client *c, KDecorationDefines::WindowOperation op); KDecorationDefines::Position supportedTilingResizeMode(Client *c, KDecorationDefines::Position currentMode); @@ -105,6 +101,10 @@ private: QVector tilingLayouts; private Q_SLOTS: void slotResizeTilingLayouts(); + void notifyTilingWindowMinimizeToggled(KWin::Client *c); + // updates geometry of tiles on all desktops, + // this rearranges the tiles. + void updateAllTiles(); }; } From 0c5da9f96ffd4d7d3a1fde463bc887ce726a49a0 Mon Sep 17 00:00:00 2001 From: Arthur Arlt Date: Tue, 19 Jul 2011 12:38:49 +0200 Subject: [PATCH 07/10] Remove tiling dependency from activation.cpp Instead of directly calling notifyTilingWindowActivated() the signal clientActivated() is used and connected. Including tiling.h is no longer needed in activation.cpp. --- activation.cpp | 4 ---- tiling/tiling.cpp | 3 ++- tiling/tiling.h | 3 ++- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/activation.cpp b/activation.cpp index c07a2b63cd..911e9e65c8 100644 --- a/activation.cpp +++ b/activation.cpp @@ -42,7 +42,6 @@ along with this program. If not, see . #include "group.h" #include "rules.h" #include -#include "tiling/tiling.h" namespace KWin { @@ -263,9 +262,6 @@ void Workspace::setActiveClient(Client* c, allowed_t) if (active_client) { active_client->sl_activated(); } - - if (m_tiling->tilingEnabled()) - m_tiling->notifyTilingWindowActivated(active_client); --set_active_client_recursion; } diff --git a/tiling/tiling.cpp b/tiling/tiling.cpp index 904ecea520..39660d9fd4 100644 --- a/tiling/tiling.cpp +++ b/tiling/tiling.cpp @@ -96,6 +96,7 @@ void Tiling::setTilingEnabled(bool tiling) 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*))); + connect(m_workspace, SIGNAL(clientActivated(KWin::Client*)), this, SLOT(notifyTilingWindowActivated(KWin::Client*))); tilingLayouts.resize(Workspace::self()->numberOfDesktops() + 1); foreach (Client * c, Workspace::self()->stackingOrder()) { createTile(c); @@ -265,7 +266,7 @@ void Tiling::notifyTilingWindowDesktopChanged(Client *c, int old_desktop) /* * Implements the 3 raising modes in Window Behaviour -> Advanced */ -void Tiling::notifyTilingWindowActivated(Client *c) +void Tiling::notifyTilingWindowActivated(KWin::Client *c) { if (c == NULL) return; diff --git a/tiling/tiling.h b/tiling/tiling.h index 52543c8120..a59bac84d4 100644 --- a/tiling/tiling.h +++ b/tiling/tiling.h @@ -53,7 +53,6 @@ public: void notifyTilingWindowResizeDone(Client *c, const QRect &moveResizeGeom, const QRect &orig, bool canceled); void notifyTilingWindowMoveDone(Client *c, const QRect &moveResizeGeom, const QRect &orig, bool canceled); void notifyTilingWindowDesktopChanged(Client *c, int old_desktop); - void notifyTilingWindowActivated(Client *c); void notifyTilingWindowMaximized(Client *c, KDecorationDefines::WindowOperation op); KDecorationDefines::Position supportedTilingResizeMode(Client *c, KDecorationDefines::Position currentMode); @@ -82,6 +81,8 @@ public Q_SLOTS: // NOTE: debug method void dumpTiles() const; + + void notifyTilingWindowActivated(KWin::Client *c); private: // try to get a decent tile, either the one with // focus or the one below the mouse. From 1326316049541c5984b2d29906255f4b2d88a048 Mon Sep 17 00:00:00 2001 From: Arthur Arlt Date: Wed, 20 Jul 2011 13:25:00 +0200 Subject: [PATCH 08/10] Introduce Build Option for Tiling A build option is introduced to file CMakeLists.txt. Classes Tiling, Tile and TilingLayouts are only built if the option is set to ON. #ifdef's are added to the classes where functions of the excluded classes are called. --- CMakeLists.txt | 42 +++++++++++++++++++++++++----------------- config-kwin.h.cmake | 1 + geometry.cpp | 23 +++++++++++++++++++++++ sm.cpp | 6 ++++++ useractions.cpp | 15 ++++++++++++--- workspace.cpp | 29 +++++++++++++++++++++++++++-- workspace.h | 8 ++++++-- 7 files changed, 100 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8dbe9f1e0f..4f3738bf50 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,7 @@ OPTION(KWIN_BUILD_DECORATIONS "Enable building of KWin decorations." ON) OPTION(KWIN_BUILD_KCMS "Enable building of KWin configuration modules." ON) OPTION(KWIN_MOBILE_EFFECTS "Only build effects relevant for mobile devices" OFF) OPTION(KWIN_BUILD_TABBOX "Enable building of KWin Tabbox functionality" ON) +OPTION(KWIN_BUILD_TILING "Enable building of KWin Tiling functionality" ON) OPTION(KWIN_BUILD_DESKTOPCHANGEOSD "Enable building of KWin DesktopChangeOSD funtionality" ON) OPTION(KWIN_BUILD_SCREENEDGES "Enable building of KWin with screen edge support" ON) OPTION(KWIN_BUILD_SCRIPTING "Enable building of KWin with scripting support" ON) @@ -18,6 +19,7 @@ if(KWIN_PLASMA_ACTIVE) set(KWIN_BUILD_DECORATIONS OFF) set(KWIN_BUILD_KCMS OFF) set(KWIN_BUILD_TABBOX OFF) + set(KWIN_BUILD_TILING OFF) set(KWIN_BUILD_DESKTOPCHANGEOSD OFF) set(KWIN_BUILD_SCREENEDGES OFF) set(KWIN_BUILD_SCRIPTING OFF) @@ -144,23 +146,6 @@ set(kwin_KDEINIT_SRCS compositingprefs.cpp desktoplayout.cpp paintredirector.cpp - tile.cpp - tilinglayout.cpp - tilinglayoutfactory.cpp - - # tiling layouts - # spiral - #tilinglayouts/spiral/spiralfactory.cpp - tilinglayouts/spiral/spiral.cpp - - # columns - #tilinglayouts/columns/columnsfactory.cpp - tilinglayouts/columns/columns.cpp - - # floating - tilinglayouts/floating/floating.cpp - - tiling/tiling.cpp ) if(KWIN_BUILD_SCRIPTING) @@ -194,6 +179,29 @@ if(KWIN_BUILD_TABBOX) ) endif(KWIN_BUILD_TABBOX) +if(KWIN_BUILD_TILING) + set( + kwin_KDEINIT_SRCS ${kwin_KDEINIT_SRCS} + tile.cpp + tilinglayout.cpp + tilinglayoutfactory.cpp + + # tiling layouts + # spiral + #tilinglayouts/spiral/spiralfactory.cpp + tilinglayouts/spiral/spiral.cpp + + # columns + #tilinglayouts/columns/columnsfactory.cpp + tilinglayouts/columns/columns.cpp + + # floating + tilinglayouts/floating/floating.cpp + + tiling/tiling.cpp + ) +endif(KWIN_BUILD_TILING) + if(KWIN_BUILD_DESKTOPCHANGEOSD) set(kwin_KDEINIT_SRCS ${kwin_KDEINIT_SRCS} desktopchangeosd.cpp diff --git a/config-kwin.h.cmake b/config-kwin.h.cmake index 8c8c9d9011..b5bd9b6f08 100644 --- a/config-kwin.h.cmake +++ b/config-kwin.h.cmake @@ -2,6 +2,7 @@ #cmakedefine HAVE_CAPTURY 1 #cmakedefine KWIN_BUILD_DECORATIONS 1 #cmakedefine KWIN_BUILD_TABBOX 1 +#cmakedefine KWIN_BUILD_TILING 1 #cmakedefine KWIN_BUILD_DESKTOPCHANGEOSD 1 #cmakedefine KWIN_BUILD_SCREENEDGES 1 #cmakedefine KWIN_BUILD_SCRIPTING 1 diff --git a/geometry.cpp b/geometry.cpp index 43e66eadc3..0059ff9b8b 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -50,7 +50,9 @@ along with this program. If not, see . #include #include #include "outline.h" +#ifdef KWIN_BUILD_TILING #include "tiling/tiling.h" +#endif namespace KWin { @@ -2033,7 +2035,9 @@ void Client::move(int x, int y, ForceGeometry_t force) workspace()->checkActiveScreen(this); workspace()->updateStackingOrder(); workspace()->checkUnredirect(); +#ifdef KWIN_BUILD_TILING workspace()->tiling()->notifyTilingWindowMove(this, moveResizeGeom, initialMoveResizeGeom); +#endif // client itself is not damaged const QRect deco_rect = decorationRect().translated(geom.x(), geom.y()); addWorkspaceRepaint(deco_rect_before_block); @@ -2591,6 +2595,7 @@ void Client::finishMoveResize(bool cancel) leaveMoveResize(); +#ifdef KWIN_BUILD_TILING if (workspace()->tiling()->tilingEnabled()) { if (wasResize) workspace()->tiling()->notifyTilingWindowResizeDone(this, moveResizeGeom, initialMoveResizeGeom, cancel); @@ -2602,6 +2607,14 @@ void Client::finishMoveResize(bool cancel) else setGeometry(moveResizeGeom); } +#else + if (cancel) + setGeometry(initialMoveResizeGeom); + else + setGeometry(moveResizeGeom); + Q_UNUSED(wasResize); + Q_UNUSED(wasMove); +#endif if (cancel) setGeometry(initialMoveResizeGeom); @@ -2763,10 +2776,12 @@ void Client::handleMoveResize(int x, int y, int x_root, int y_root) bool update = false; if (isResize()) { +#ifdef KWIN_BUILD_TILING // query layout for supported resize mode if (workspace()->tiling()->tilingEnabled()) { mode = workspace()->tiling()->supportedTilingResizeMode(this, mode); } +#endif // first resize (without checking constrains), then snap, then check bounds, then check constrains QRect orig = initialMoveResizeGeom; Sizemode sizemode = SizemodeAny; @@ -2800,6 +2815,7 @@ void Client::handleMoveResize(int x, int y, int x_root, int y_root) sizemode = SizemodeFixedW; break; case PositionCenter: +#ifdef KWIN_BUILD_TILING // exception for tiling // Center means no resizing allowed if (workspace()->tiling()->tilingEnabled()) { @@ -2807,11 +2823,14 @@ void Client::handleMoveResize(int x, int y, int x_root, int y_root) buttonDown = false; return; } +#endif default: abort(); break; } +#ifdef KWIN_BUILD_TILING workspace()->tiling()->notifyTilingWindowResize(this, moveResizeGeom, initialMoveResizeGeom); +#endif // adjust new size to snap to other windows/borders moveResizeGeom = workspace()->adjustClientSize(this, moveResizeGeom, mode); @@ -2969,7 +2988,9 @@ void Client::handleMoveResize(int x, int y, int x_root, int y_root) performMoveResize(); if (isMove()) { +#ifdef KWIN_BUILD_TILING workspace()->tiling()->notifyTilingWindowMove(this, moveResizeGeom, initialMoveResizeGeom); +#endif #ifdef KWIN_BUILD_SCREENEDGES workspace()->screenEdge()->check(globalPos, xTime()); #endif @@ -2987,8 +3008,10 @@ void Client::performMoveResize() sendSyncRequest(); } #endif +#ifdef KWIN_BUILD_TILING if (!workspace()->tiling()->tilingEnabled()) setGeometry(moveResizeGeom); +#endif positionGeometryTip(); emit clientStepUserMovedResized(this, moveResizeGeom); } diff --git a/sm.cpp b/sm.cpp index d2111d1a7c..2bbd85ce7f 100644 --- a/sm.cpp +++ b/sm.cpp @@ -34,7 +34,9 @@ along with this program. If not, see . #include #include #include +#ifdef KWIN_BUILD_TILING #include "tiling/tiling.h" +#endif namespace KWin { @@ -85,11 +87,13 @@ void Workspace::storeSession(KConfig* config, SMSavePhase phase) int active_client = -1; if (phase == SMSavePhase2 || phase == SMSavePhase2Full) { +#ifdef KWIN_BUILD_TILING cg.writeEntry("tiling", m_tiling->tilingEnabled()); if (m_tiling->tilingEnabled()) { kDebug(1212) << "Tiling was ON"; m_tiling->setTilingEnabled(false); } +#endif } for (ClientList::Iterator it = clients.begin(); it != clients.end(); ++it) { @@ -274,7 +278,9 @@ void Workspace::loadSessionInfo() session.clear(); KConfigGroup cg(kapp->sessionConfig(), "Session"); +#ifdef KWIN_BUILD_TILING m_tiling->setTilingEnabled(cg.readEntry("tiling", false)); +#endif addSessionInfo(cg); } diff --git a/useractions.cpp b/useractions.cpp index a22d24f21a..7d6c1b6886 100644 --- a/useractions.cpp +++ b/useractions.cpp @@ -30,9 +30,11 @@ along with this program. If not, see . #include "client.h" #include "workspace.h" #include "effects.h" +#ifdef KWIN_BUILD_TILING #include "tile.h" #include "tilinglayout.h" #include "tiling/tiling.h" +#endif #include "kactivityinfo.h" @@ -198,6 +200,7 @@ QMenu* Workspace::clientPopup() mTilingStateOpAction = popup->addAction(i18nc("When in tiling mode, toggle's the window's floating/tiled state", "&Float Window")); // then hide it mTilingStateOpAction->setVisible(false); +#ifdef KWIN_BUILD_TILING // actions for window tiling if (m_tiling->tilingEnabled()) { kaction = qobject_cast(keys->action("Toggle Floating")); @@ -206,6 +209,7 @@ QMenu* Workspace::clientPopup() if (kaction != 0) mTilingStateOpAction->setShortcut(kaction->globalShortcut().primary()); } +#endif popup->addSeparator(); @@ -290,6 +294,7 @@ void Workspace::clientPopupAboutToShow() mMinimizeOpAction->setEnabled(active_popup_client->isMinimizable()); mCloseOpAction->setEnabled(active_popup_client->isCloseable()); +#ifdef KWIN_BUILD_TILING if (m_tiling->tilingEnabled()) { int desktop = active_popup_client->desktop(); if (m_tiling->getTilingLayouts().value(desktop)) { @@ -299,7 +304,7 @@ void Workspace::clientPopupAboutToShow() } } mTilingStateOpAction->setVisible(m_tiling->tilingEnabled()); - +#endif delete switch_to_tab_popup; switch_to_tab_popup = 0; delete add_tabs_popup; @@ -565,9 +570,11 @@ void Workspace::initShortcuts() tab_box->initShortcuts(actionCollection); } #endif +#ifdef KWIN_BUILD_TILING if (m_tiling) { m_tiling->initShortcuts(actionCollection); } +#endif discardPopup(); // so that it's recreated next time } @@ -663,7 +670,7 @@ void Workspace::performWindowOperation(Client* c, Options::WindowOperation op) { if (!c) return; - +#ifdef KWIN_BUILD_TILING // Allows us to float a window when it is maximized, if it is tiled. if (m_tiling->tilingEnabled() && (op == Options::MaximizeOp @@ -672,7 +679,7 @@ void Workspace::performWindowOperation(Client* c, Options::WindowOperation op) || op == Options::RestoreOp)) { m_tiling->notifyTilingWindowMaximized(c, op); } - +#endif if (op == Options::MoveOp || op == Options::UnrestrictedMoveOp) QCursor::setPos(c->geometry().center()); if (op == Options::ResizeOp || op == Options::UnrestrictedResizeOp) @@ -783,10 +790,12 @@ void Workspace::performWindowOperation(Client* c, Options::WindowOperation op) case Options::CloseClientGroupOp: c->clientGroup()->closeAll(); case Options::ToggleClientTiledStateOp: { +#ifdef KWIN_BUILD_TILING int desktop = c->desktop(); if (m_tiling->getTilingLayouts().value(desktop)) { m_tiling->getTilingLayouts()[desktop]->toggleFloatTile(c); } +#endif } } } diff --git a/workspace.cpp b/workspace.cpp index 733bc109c6..0ab3280ef2 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -44,7 +44,6 @@ along with this program. If not, see . #include #include "client.h" -#include "tile.h" #ifdef KWIN_BUILD_TABBOX #include "tabbox.h" #endif @@ -62,9 +61,11 @@ along with this program. If not, see . #include "deleted.h" #include "effects.h" #include "overlaywindow.h" +#ifdef KWIN_BUILD_TILING +#include "tile.h" #include "tilinglayout.h" #include "tiling/tiling.h" - +#endif #ifdef KWIN_BUILD_SCRIPTING #include "scripting/scripting.h" #endif @@ -240,7 +241,9 @@ Workspace::Workspace(bool restore) desktop_change_osd = new DesktopChangeOSD(this); #endif m_outline = new Outline(); +#ifdef KWIN_BUILD_TILING m_tiling = new Tiling(this); +#endif initShortcuts(); @@ -490,8 +493,10 @@ void Workspace::init() if (new_active_client != NULL) activateClient(new_active_client); +#ifdef KWIN_BUILD_TILING // Enable/disable tiling m_tiling->setTilingEnabled(options->tilingOn); +#endif // SELI TODO: This won't work with unreasonable focus policies, // and maybe in rare cases also if the selected client doesn't @@ -505,7 +510,9 @@ Workspace::~Workspace() { finishCompositing(); blockStackingUpdates(true); +#ifdef KWIN_BUILD_TILING delete m_tiling; +#endif // TODO: grabXServer(); @@ -1027,9 +1034,11 @@ void Workspace::slotReconfigure() } } +#ifdef KWIN_BUILD_TILING m_tiling->setTilingEnabled(options->tilingOn); // just so that we reset windows in the right manner, 'activate' the current active window m_tiling->notifyTilingWindowActivated(activeClient()); +#endif if (hasDecorationPlugin()) { rootInfo->setSupported(NET::WM2FrameOverlap, mgr->factory()->supports(AbilityExtendIntoClientArea)); } else { @@ -1292,9 +1301,13 @@ bool Workspace::setCurrentDesktop(int new_desktop) if (movingClient && !movingClient->isOnDesktop(new_desktop)) { int old_desktop = movingClient->desktop(); movingClient->setDesktop(new_desktop); +#ifdef KWIN_BUILD_TILING if (m_tiling->tilingEnabled()) { m_tiling->notifyTilingWindowDesktopChanged(movingClient, old_desktop); } +#else + Q_UNUSED(old_desktop) +#endif } for (int i = stacking_order.size() - 1; i >= 0 ; --i) @@ -1605,7 +1618,9 @@ void Workspace::sendClientToDesktop(Client* c, int desk, bool dont_activate) } else raiseClient(c); +#ifdef KWIN_BUILD_TILING m_tiling->notifyTilingWindowDesktopChanged(c, old_desktop); +#endif ClientList transients_stacking_order = ensureStackingOrder(c->transients()); for (ClientList::ConstIterator it = transients_stacking_order.constBegin(); @@ -2145,19 +2160,23 @@ TabBox::TabBox* Workspace::tabBox() const } #endif +#ifdef KWIN_BUILD_TILING Tiling* Workspace::tiling() { return m_tiling; } +#endif /* * Called from D-BUS */ void Workspace::toggleTiling() { +#ifdef KWIN_BUILD_TILING if (m_tiling) { m_tiling->slotToggleTiling(); } +#endif } /* @@ -2165,9 +2184,11 @@ void Workspace::toggleTiling() */ void Workspace::nextTileLayout() { +#ifdef KWIN_BUILD_TILING if (m_tiling) { m_tiling->slotNextTileLayout(); } +#endif } /* @@ -2175,15 +2196,19 @@ void Workspace::nextTileLayout() */ void Workspace::previousTileLayout() { +#ifdef KWIN_BUILD_TILING if (m_tiling) { m_tiling->slotPreviousTileLayout(); } +#endif } void Workspace::dumpTiles() const { +#ifdef KWIN_BUILD_TILING if (m_tiling) { m_tiling->dumpTiles(); } +#endif } } // namespace diff --git a/workspace.h b/workspace.h index 871f74cc61..492d1ca33b 100644 --- a/workspace.h +++ b/workspace.h @@ -73,9 +73,11 @@ class TabBox; #endif class Client; +#ifdef KWIN_BUILD_TILING class Tile; class Tiling; class TilingLayout; +#endif class ClientGroup; #ifdef KWIN_BUILD_DESKTOPCHANGEOSD class DesktopChangeOSD; @@ -198,7 +200,9 @@ public: return unmanaged; } +#ifdef KWIN_BUILD_TILING Tiling* tiling(); +#endif Outline* outline(); #ifdef KWIN_BUILD_SCREENEDGES @@ -306,10 +310,10 @@ private: KActivityController activityController_; +#ifdef KWIN_BUILD_TILING Tiling* m_tiling; - +#endif Outline* m_outline; - #ifdef KWIN_BUILD_SCREENEDGES ScreenEdge m_screenEdge; #endif From 8c3a0e218a2f79891700056810ddcd8be1d2e5f5 Mon Sep 17 00:00:00 2001 From: Arthur Arlt Date: Thu, 28 Jul 2011 13:36:25 +0200 Subject: [PATCH 09/10] Move tile.cpp, tile.h, tilinglayout.cpp and tiling.h to directory tiling/ The three files are moved to the directory tiling/ and the includes were adjusted as well as the CMakeLists.txt file. --- CMakeLists.txt | 9 +++------ tile.cpp => tiling/tile.cpp | 0 tile.h => tiling/tile.h | 0 tiling/tiling.cpp | 4 ++-- tilinglayout.cpp => tiling/tilinglayout.cpp | 4 ++-- tilinglayout.h => tiling/tilinglayout.h | 0 tilinglayoutfactory.cpp | 2 +- tilinglayouts/columns/columns.cpp | 2 +- tilinglayouts/columns/columns.h | 2 +- tilinglayouts/floating/floating.cpp | 2 +- tilinglayouts/floating/floating.h | 4 ++-- tilinglayouts/spiral/spiral.cpp | 2 +- tilinglayouts/spiral/spiral.h | 2 +- useractions.cpp | 4 ++-- workspace.cpp | 4 ++-- 15 files changed, 19 insertions(+), 22 deletions(-) rename tile.cpp => tiling/tile.cpp (100%) rename tile.h => tiling/tile.h (100%) rename tilinglayout.cpp => tiling/tilinglayout.cpp (98%) rename tilinglayout.h => tiling/tilinglayout.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f3738bf50..7efb982392 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -182,23 +182,20 @@ endif(KWIN_BUILD_TABBOX) if(KWIN_BUILD_TILING) set( kwin_KDEINIT_SRCS ${kwin_KDEINIT_SRCS} - tile.cpp - tilinglayout.cpp + tiling/tile.cpp + tiling/tiling.cpp + tiling/tilinglayout.cpp tilinglayoutfactory.cpp # tiling layouts # spiral - #tilinglayouts/spiral/spiralfactory.cpp tilinglayouts/spiral/spiral.cpp # columns - #tilinglayouts/columns/columnsfactory.cpp tilinglayouts/columns/columns.cpp # floating tilinglayouts/floating/floating.cpp - - tiling/tiling.cpp ) endif(KWIN_BUILD_TILING) diff --git a/tile.cpp b/tiling/tile.cpp similarity index 100% rename from tile.cpp rename to tiling/tile.cpp diff --git a/tile.h b/tiling/tile.h similarity index 100% rename from tile.h rename to tiling/tile.h diff --git a/tiling/tiling.cpp b/tiling/tiling.cpp index 39660d9fd4..5fbde974ed 100644 --- a/tiling/tiling.cpp +++ b/tiling/tiling.cpp @@ -29,8 +29,8 @@ along with this program. If not, see . #include #include -#include "tile.h" -#include "tilinglayout.h" +#include "tiling/tile.h" +#include "tiling/tilinglayout.h" #include "tilinglayoutfactory.h" #include "workspace.h" diff --git a/tilinglayout.cpp b/tiling/tilinglayout.cpp similarity index 98% rename from tilinglayout.cpp rename to tiling/tilinglayout.cpp index da50b7629e..0e1d642ad5 100644 --- a/tilinglayout.cpp +++ b/tiling/tilinglayout.cpp @@ -18,12 +18,12 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . *********************************************************************/ -#include "tilinglayout.h" +#include "tiling/tilinglayout.h" #include #include "client.h" -#include "tile.h" +#include "tiling/tile.h" #include "workspace.h" #include "tiling/tiling.h" diff --git a/tilinglayout.h b/tiling/tilinglayout.h similarity index 100% rename from tilinglayout.h rename to tiling/tilinglayout.h diff --git a/tilinglayoutfactory.cpp b/tilinglayoutfactory.cpp index 887b0b3ff0..78734e9f90 100644 --- a/tilinglayoutfactory.cpp +++ b/tilinglayoutfactory.cpp @@ -26,7 +26,7 @@ along with this program. If not, see . #include #include "notifications.h" -#include "tile.h" +#include "tiling/tile.h" #include "client.h" #include "tilinglayouts/spiral/spiral.h" diff --git a/tilinglayouts/columns/columns.cpp b/tilinglayouts/columns/columns.cpp index 0fd33d1a76..d0e1e1b5ec 100644 --- a/tilinglayouts/columns/columns.cpp +++ b/tilinglayouts/columns/columns.cpp @@ -21,7 +21,7 @@ along with this program. If not, see . #include "columns.h" #include "client.h" -#include "tile.h" +#include "tiling/tile.h" #include diff --git a/tilinglayouts/columns/columns.h b/tilinglayouts/columns/columns.h index bcd6f89d77..b8bb1f5469 100644 --- a/tilinglayouts/columns/columns.h +++ b/tilinglayouts/columns/columns.h @@ -23,7 +23,7 @@ along with this program. If not, see . #include -#include "tilinglayout.h" +#include "tiling/tilinglayout.h" namespace KWin { diff --git a/tilinglayouts/floating/floating.cpp b/tilinglayouts/floating/floating.cpp index a0c33e601e..e6623b649c 100644 --- a/tilinglayouts/floating/floating.cpp +++ b/tilinglayouts/floating/floating.cpp @@ -20,7 +20,7 @@ along with this program. If not, see . #include "floating.h" -#include "tile.h" +#include "tiling/tile.h" #include "client.h" namespace KWin diff --git a/tilinglayouts/floating/floating.h b/tilinglayouts/floating/floating.h index c3b40fa3b2..1c007cbfab 100644 --- a/tilinglayouts/floating/floating.h +++ b/tilinglayouts/floating/floating.h @@ -24,8 +24,8 @@ along with this program. If not, see . #include #include -#include "tilinglayout.h" -#include "tile.h" +#include "tiling/tilinglayout.h" +#include "tiling/tile.h" namespace KWin { diff --git a/tilinglayouts/spiral/spiral.cpp b/tilinglayouts/spiral/spiral.cpp index 979e001e52..b70be995e6 100644 --- a/tilinglayouts/spiral/spiral.cpp +++ b/tilinglayouts/spiral/spiral.cpp @@ -21,7 +21,7 @@ along with this program. If not, see . #include "spiral.h" #include "client.h" -#include "tile.h" +#include "tiling/tile.h" namespace KWin { diff --git a/tilinglayouts/spiral/spiral.h b/tilinglayouts/spiral/spiral.h index f5749f88ef..4621fb06fa 100644 --- a/tilinglayouts/spiral/spiral.h +++ b/tilinglayouts/spiral/spiral.h @@ -23,7 +23,7 @@ along with this program. If not, see . #include -#include "tilinglayout.h" +#include "tiling/tilinglayout.h" namespace KWin { diff --git a/useractions.cpp b/useractions.cpp index 7d6c1b6886..70206e1df0 100644 --- a/useractions.cpp +++ b/useractions.cpp @@ -31,8 +31,8 @@ along with this program. If not, see . #include "workspace.h" #include "effects.h" #ifdef KWIN_BUILD_TILING -#include "tile.h" -#include "tilinglayout.h" +#include "tiling/tile.h" +#include "tiling/tilinglayout.h" #include "tiling/tiling.h" #endif diff --git a/workspace.cpp b/workspace.cpp index 0ab3280ef2..4525c01919 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -62,8 +62,8 @@ along with this program. If not, see . #include "effects.h" #include "overlaywindow.h" #ifdef KWIN_BUILD_TILING -#include "tile.h" -#include "tilinglayout.h" +#include "tiling/tile.h" +#include "tiling/tilinglayout.h" #include "tiling/tiling.h" #endif #ifdef KWIN_BUILD_SCRIPTING From e79cf500870ad75bad258648bfbf2f4740491036 Mon Sep 17 00:00:00 2001 From: Arthur Arlt Date: Thu, 28 Jul 2011 13:48:57 +0200 Subject: [PATCH 10/10] Rename some functions and variables in class Tiling Some functions and variables were given more proper names and are now following the naming scheme. 'Redundant' naming information was also removed. REVIEW: 102020 --- geometry.cpp | 8 +-- sm.cpp | 8 +-- tiling/tiling.cpp | 132 +++++++++++++++++++++++----------------------- tiling/tiling.h | 10 ++-- useractions.cpp | 16 +++--- workspace.cpp | 6 +-- 6 files changed, 90 insertions(+), 90 deletions(-) diff --git a/geometry.cpp b/geometry.cpp index 0059ff9b8b..af6ce8c50c 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -2596,7 +2596,7 @@ void Client::finishMoveResize(bool cancel) leaveMoveResize(); #ifdef KWIN_BUILD_TILING - if (workspace()->tiling()->tilingEnabled()) { + if (workspace()->tiling()->isEnabled()) { if (wasResize) workspace()->tiling()->notifyTilingWindowResizeDone(this, moveResizeGeom, initialMoveResizeGeom, cancel); else if (wasMove) @@ -2778,7 +2778,7 @@ void Client::handleMoveResize(int x, int y, int x_root, int y_root) if (isResize()) { #ifdef KWIN_BUILD_TILING // query layout for supported resize mode - if (workspace()->tiling()->tilingEnabled()) { + if (workspace()->tiling()->isEnabled()) { mode = workspace()->tiling()->supportedTilingResizeMode(this, mode); } #endif @@ -2818,7 +2818,7 @@ void Client::handleMoveResize(int x, int y, int x_root, int y_root) #ifdef KWIN_BUILD_TILING // exception for tiling // Center means no resizing allowed - if (workspace()->tiling()->tilingEnabled()) { + if (workspace()->tiling()->isEnabled()) { finishMoveResize(false); buttonDown = false; return; @@ -3009,7 +3009,7 @@ void Client::performMoveResize() } #endif #ifdef KWIN_BUILD_TILING - if (!workspace()->tiling()->tilingEnabled()) + if (!workspace()->tiling()->isEnabled()) setGeometry(moveResizeGeom); #endif positionGeometryTip(); diff --git a/sm.cpp b/sm.cpp index 2bbd85ce7f..113018cdf3 100644 --- a/sm.cpp +++ b/sm.cpp @@ -88,10 +88,10 @@ void Workspace::storeSession(KConfig* config, SMSavePhase phase) if (phase == SMSavePhase2 || phase == SMSavePhase2Full) { #ifdef KWIN_BUILD_TILING - cg.writeEntry("tiling", m_tiling->tilingEnabled()); - if (m_tiling->tilingEnabled()) { + cg.writeEntry("tiling", m_tiling->isEnabled()); + if (m_tiling->isEnabled()) { kDebug(1212) << "Tiling was ON"; - m_tiling->setTilingEnabled(false); + m_tiling->setEnabled(false); } #endif } @@ -279,7 +279,7 @@ void Workspace::loadSessionInfo() KConfigGroup cg(kapp->sessionConfig(), "Session"); #ifdef KWIN_BUILD_TILING - m_tiling->setTilingEnabled(cg.readEntry("tiling", false)); + m_tiling->setEnabled(cg.readEntry("tiling", false)); #endif addSessionInfo(cg); diff --git a/tiling/tiling.cpp b/tiling/tiling.cpp index 5fbde974ed..0b8fb95e66 100644 --- a/tiling/tiling.cpp +++ b/tiling/tiling.cpp @@ -38,7 +38,7 @@ namespace KWin { Tiling::Tiling(KWin::Workspace* w) : QObject(w) , m_workspace(w) - , tilingEnabled_(false) + , m_enabled(false) { } @@ -72,32 +72,32 @@ void Tiling::initShortcuts(KActionCollection* keys){ } -bool Tiling::tilingEnabled() const +bool Tiling::isEnabled() const { - return tilingEnabled_; + return m_enabled; } -void Tiling::setTilingEnabled(bool tiling) +void Tiling::setEnabled(bool tiling) { - if (tilingEnabled() == tiling) return; + if (isEnabled() == tiling) return; - tilingEnabled_ = tiling; + m_enabled = tiling; KSharedConfig::Ptr _config = KGlobal::config(); KConfigGroup config(_config, "Windows"); - config.writeEntry("TilingOn", tilingEnabled_); + config.writeEntry("TilingOn", m_enabled); config.sync(); - options->tilingOn = tilingEnabled_; + options->tilingOn = m_enabled; options->tilingLayout = static_cast(config.readEntry("TilingDefaultLayout", 0)); options->tilingRaisePolicy = config.readEntry("TilingRaisePolicy", 0); - if (tilingEnabled_) { + if (m_enabled) { 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*))); connect(m_workspace, SIGNAL(clientActivated(KWin::Client*)), this, SLOT(notifyTilingWindowActivated(KWin::Client*))); - tilingLayouts.resize(Workspace::self()->numberOfDesktops() + 1); + m_tilingLayouts.resize(Workspace::self()->numberOfDesktops() + 1); foreach (Client * c, Workspace::self()->stackingOrder()) { createTile(c); } @@ -105,19 +105,19 @@ void Tiling::setTilingEnabled(bool tiling) disconnect(m_workspace, SIGNAL(clientAdded(KWin::Client*))); disconnect(m_workspace, SIGNAL(numberDesktopsChanged(int))); disconnect(m_workspace, SIGNAL(clientRemoved(KWin::Client*))); - qDeleteAll(tilingLayouts); - tilingLayouts.clear(); + qDeleteAll(m_tilingLayouts); + m_tilingLayouts.clear(); } } void Tiling::slotToggleTiling() { - if (tilingEnabled()) { - setTilingEnabled(false); + if (isEnabled()) { + setEnabled(false); QString message = i18n("Tiling Disabled"); KNotification::event("tilingdisabled", message, QPixmap(), NULL, KNotification::CloseOnTimeout, KComponentData("kwin")); } else { - setTilingEnabled(true); + setEnabled(true); QString message = i18n("Tiling Enabled"); KNotification::event("tilingenabled", message, QPixmap(), NULL, KNotification::CloseOnTimeout, KComponentData("kwin")); } @@ -128,10 +128,10 @@ void Tiling::createTile(Client* c) if (c == NULL) return; - if (c->desktop() < 0 || c->desktop() >= tilingLayouts.size()) return; + if (c->desktop() < 0 || c->desktop() >= m_tilingLayouts.size()) return; kDebug(1212) << "Now tiling " << c->caption(); - if (!tilingEnabled() || !tileable(c)) + if (!isEnabled() || !tileable(c)) return; Tile *t = new Tile(c, Workspace::self()->clientArea(PlacementArea, c)); @@ -140,12 +140,12 @@ void Tiling::createTile(Client* c) t->floatTile(); } - if (!tilingLayouts.value(c->desktop())) { - tilingLayouts[c->desktop()] = TilingLayoutFactory::createLayout(TilingLayoutFactory::DefaultLayout, m_workspace); - tilingLayouts[c->desktop()]->setParent(this); + if (!m_tilingLayouts.value(c->desktop())) { + m_tilingLayouts[c->desktop()] = TilingLayoutFactory::createLayout(TilingLayoutFactory::DefaultLayout, m_workspace); + m_tilingLayouts[c->desktop()]->setParent(this); } - tilingLayouts[c->desktop()]->addTile(t); - tilingLayouts[c->desktop()]->commit(); + m_tilingLayouts[c->desktop()]->addTile(t); + m_tilingLayouts[c->desktop()]->commit(); // if tiling is activated, connect to Client's signals and react with rearrangement when (un)minimizing connect(c, SIGNAL(clientMinimized(KWin::Client*,bool)), this, SLOT(notifyTilingWindowMinimizeToggled(KWin::Client*))); connect(c, SIGNAL(clientUnminimized(KWin::Client*,bool)), this, SLOT(notifyTilingWindowMinimizeToggled(KWin::Client*))); @@ -154,11 +154,11 @@ void Tiling::createTile(Client* c) void Tiling::removeTile(Client *c) { - if (!tilingLayouts.value(c->desktop())) { + if (!m_tilingLayouts.value(c->desktop())) { return; } - if (tilingLayouts[ c->desktop()]) - tilingLayouts[ c->desktop()]->removeTile(c); + if (m_tilingLayouts[ c->desktop()]) + m_tilingLayouts[ c->desktop()]->removeTile(c); } bool Tiling::tileable(Client* c) @@ -192,16 +192,16 @@ void Tiling::belowCursor() Tile* Tiling::getNiceTile() const { - if (!tilingEnabled()) return NULL; - if (!tilingLayouts.value(m_workspace->activeClient()->desktop())) return NULL; + if (!isEnabled()) return NULL; + if (!m_tilingLayouts.value(m_workspace->activeClient()->desktop())) return NULL; - return tilingLayouts[ m_workspace->activeClient()->desktop()]->findTile(m_workspace->activeClient()); + return m_tilingLayouts[ m_workspace->activeClient()->desktop()]->findTile(m_workspace->activeClient()); // TODO } void Tiling::updateAllTiles() { - foreach (TilingLayout * t, tilingLayouts) { + foreach (TilingLayout * t, m_tilingLayouts) { if (!t) continue; t->commit(); } @@ -212,17 +212,17 @@ void Tiling::updateAllTiles() */ void Tiling::notifyTilingWindowResize(Client *c, const QRect &moveResizeGeom, const QRect &orig) { - if (tilingLayouts.value(c->desktop()) == NULL) + if (m_tilingLayouts.value(c->desktop()) == NULL) return; - tilingLayouts[ c->desktop()]->clientResized(c, moveResizeGeom, orig); + m_tilingLayouts[ c->desktop()]->clientResized(c, moveResizeGeom, orig); } void Tiling::notifyTilingWindowMove(Client *c, const QRect &moveResizeGeom, const QRect &orig) { - if (tilingLayouts.value(c->desktop()) == NULL) { + if (m_tilingLayouts.value(c->desktop()) == NULL) { return; } - tilingLayouts[ c->desktop()]->clientMoved(c, moveResizeGeom, orig); + m_tilingLayouts[ c->desktop()]->clientMoved(c, moveResizeGeom, orig); updateAllTiles(); } @@ -247,19 +247,19 @@ void Tiling::notifyTilingWindowDesktopChanged(Client *c, int old_desktop) if (c->desktop() < 1 || c->desktop() > m_workspace->numberOfDesktops()) return; - if (tilingLayouts.value(old_desktop)) { - Tile *t = tilingLayouts[ old_desktop ]->findTile(c); + if (m_tilingLayouts.value(old_desktop)) { + Tile *t = m_tilingLayouts[ old_desktop ]->findTile(c); // TODO: copied from createTile(), move this into separate method? - if (!tilingLayouts.value(c->desktop())) { - tilingLayouts[c->desktop()] = TilingLayoutFactory::createLayout(TilingLayoutFactory::DefaultLayout, m_workspace); + if (!m_tilingLayouts.value(c->desktop())) { + m_tilingLayouts[c->desktop()] = TilingLayoutFactory::createLayout(TilingLayoutFactory::DefaultLayout, m_workspace); } if (t) - tilingLayouts[ c->desktop()]->addTile(t); + m_tilingLayouts[ c->desktop()]->addTile(t); - tilingLayouts[ old_desktop ]->removeTile(c); - tilingLayouts[ old_desktop ]->commit(); + m_tilingLayouts[ old_desktop ]->removeTile(c); + m_tilingLayouts[ old_desktop ]->commit(); } } @@ -274,12 +274,12 @@ void Tiling::notifyTilingWindowActivated(KWin::Client *c) if (options->tilingRaisePolicy == 1) // individual raise/lowers return; - if (tilingLayouts.value(c->desktop())) { - QList tiles = tilingLayouts[ c->desktop()]->tiles(); + if (m_tilingLayouts.value(c->desktop())) { + QList tiles = m_tilingLayouts[ c->desktop()]->tiles(); StackingUpdatesBlocker blocker(m_workspace); - Tile *tile_to_raise = tilingLayouts[ c->desktop()]->findTile(c); + Tile *tile_to_raise = m_tilingLayouts[ c->desktop()]->findTile(c); if (!tile_to_raise) { return; @@ -306,18 +306,18 @@ void Tiling::notifyTilingWindowActivated(KWin::Client *c) void Tiling::notifyTilingWindowMinimizeToggled(KWin::Client* c) { - if (tilingLayouts.value(c->desktop())) { - tilingLayouts[ c->desktop()]->clientMinimizeToggled(c); + if (m_tilingLayouts.value(c->desktop())) { + m_tilingLayouts[ c->desktop()]->clientMinimizeToggled(c); } } void Tiling::notifyTilingWindowMaximized(Client *c, Options::WindowOperation op) { - if (tilingLayouts.value(c->desktop())) { - Tile *t = tilingLayouts[ c->desktop()]->findTile(c); + if (m_tilingLayouts.value(c->desktop())) { + Tile *t = m_tilingLayouts[ c->desktop()]->findTile(c); if (!t) { createTile(c); - t = tilingLayouts[ c->desktop()]->findTile(c); + t = m_tilingLayouts[ c->desktop()]->findTile(c); // if still no tile, it couldn't be tiled // so ignore it @@ -336,7 +336,7 @@ void Tiling::notifyTilingWindowMaximized(Client *c, Options::WindowOperation op) && (op == Options::MaximizeOp || op == Options::HMaximizeOp || op == Options::VMaximizeOp)) { - tilingLayouts[ c->desktop()]->toggleFloatTile(c); + m_tilingLayouts[ c->desktop()]->toggleFloatTile(c); } } @@ -350,7 +350,7 @@ Tile* Tiling::findAdjacentTile(Tile *ref, int d) Tile *closest = NULL; int minDist = -1; - QList tiles = tilingLayouts[ ref->client()->desktop()]->tiles(); + QList tiles = m_tilingLayouts[ ref->client()->desktop()]->tiles(); foreach (Tile * t, tiles) { if (t->client() == ref->client() || t->ignoreGeometry()) @@ -413,7 +413,7 @@ void Tiling::moveTile(int d) if (t) { Tile* adj = findAdjacentTile(t, d); - tilingLayouts[ t->client()->desktop()]->swapTiles(t, adj); + m_tilingLayouts[ t->client()->desktop()]->swapTiles(t, adj); } } @@ -460,61 +460,61 @@ void Tiling::slotMoveTileBottom() void Tiling::slotToggleFloating() { Client *c = m_workspace->activeClient(); - if (tilingLayouts.value(c->desktop())) { - tilingLayouts[ c->desktop()]->toggleFloatTile(c); + if (m_tilingLayouts.value(c->desktop())) { + m_tilingLayouts[ c->desktop()]->toggleFloatTile(c); } } void Tiling::slotNextTileLayout() { - if (tilingLayouts.value(m_workspace->currentDesktop())) { + if (m_tilingLayouts.value(m_workspace->currentDesktop())) { - tilingLayouts.replace(m_workspace->currentDesktop(), TilingLayoutFactory::nextLayout(tilingLayouts[m_workspace->currentDesktop()])); + m_tilingLayouts.replace(m_workspace->currentDesktop(), TilingLayoutFactory::nextLayout(m_tilingLayouts[m_workspace->currentDesktop()])); - tilingLayouts[m_workspace->currentDesktop()]->commit(); + m_tilingLayouts[m_workspace->currentDesktop()]->commit(); } } void Tiling::slotPreviousTileLayout() { - if (tilingLayouts.value(m_workspace->currentDesktop())) { + if (m_tilingLayouts.value(m_workspace->currentDesktop())) { - tilingLayouts.replace(m_workspace->currentDesktop(), TilingLayoutFactory::previousLayout(tilingLayouts[m_workspace->currentDesktop()])); + m_tilingLayouts.replace(m_workspace->currentDesktop(), TilingLayoutFactory::previousLayout(m_tilingLayouts[m_workspace->currentDesktop()])); - tilingLayouts[m_workspace->currentDesktop()]->commit(); + m_tilingLayouts[m_workspace->currentDesktop()]->commit(); } } KDecorationDefines::Position Tiling::supportedTilingResizeMode(Client *c, KDecorationDefines::Position currentMode) { - if (tilingLayouts.value(c->desktop())) { - return tilingLayouts[c->desktop()]->resizeMode(c, currentMode); + if (m_tilingLayouts.value(c->desktop())) { + return m_tilingLayouts[c->desktop()]->resizeMode(c, currentMode); } return currentMode; } void Tiling::dumpTiles() const { - foreach (TilingLayout * t, tilingLayouts) { + foreach (TilingLayout * t, m_tilingLayouts) { if (!t) { kDebug(1212) << "EMPTY DESKTOP"; continue; } - kDebug(1212) << "Desktop" << tilingLayouts.indexOf(t); + kDebug(1212) << "Desktop" << m_tilingLayouts.indexOf(t); foreach (Tile * tile, t->tiles()) { tile->dumpTile("--"); } } } -const QVector< TilingLayout* >& Tiling::getTilingLayouts() const +const QVector< TilingLayout* >& Tiling::tilingLayouts() const { - return tilingLayouts; + return m_tilingLayouts; } void Tiling::slotResizeTilingLayouts() { - tilingLayouts.resize(m_workspace->numberOfDesktops() + 1); + m_tilingLayouts.resize(m_workspace->numberOfDesktops() + 1); } } diff --git a/tiling/tiling.h b/tiling/tiling.h index a59bac84d4..694bd9cde6 100644 --- a/tiling/tiling.h +++ b/tiling/tiling.h @@ -38,10 +38,10 @@ class Tiling : public QObject { public: Tiling(Workspace *w); ~Tiling(); - bool tilingEnabled() const; - void setTilingEnabled(bool tiling); + bool isEnabled() const; + void setEnabled(bool tiling); bool tileable(Client *c); - const QVector< TilingLayout* >& getTilingLayouts() const; + const QVector< TilingLayout* >& tilingLayouts() const; void initShortcuts(KActionCollection* keys); // The notification functions are called from @@ -94,12 +94,12 @@ private: void moveTile(int d); Workspace* m_workspace; - bool tilingEnabled_; + bool m_enabled; // Each tilingLayout is for one virtual desktop. // The length is always one more than the number of // virtual desktops so that we can quickly index them // without having to remember to subtract one. - QVector tilingLayouts; + QVector m_tilingLayouts; private Q_SLOTS: void slotResizeTilingLayouts(); void notifyTilingWindowMinimizeToggled(KWin::Client *c); diff --git a/useractions.cpp b/useractions.cpp index 70206e1df0..b6ee9a63e1 100644 --- a/useractions.cpp +++ b/useractions.cpp @@ -202,7 +202,7 @@ QMenu* Workspace::clientPopup() mTilingStateOpAction->setVisible(false); #ifdef KWIN_BUILD_TILING // actions for window tiling - if (m_tiling->tilingEnabled()) { + if (m_tiling->isEnabled()) { kaction = qobject_cast(keys->action("Toggle Floating")); mTilingStateOpAction->setCheckable(true); mTilingStateOpAction->setData(Options::ToggleClientTiledStateOp); @@ -295,15 +295,15 @@ void Workspace::clientPopupAboutToShow() mCloseOpAction->setEnabled(active_popup_client->isCloseable()); #ifdef KWIN_BUILD_TILING - if (m_tiling->tilingEnabled()) { + if (m_tiling->isEnabled()) { int desktop = active_popup_client->desktop(); - if (m_tiling->getTilingLayouts().value(desktop)) { - Tile *t = m_tiling->getTilingLayouts()[desktop]->findTile(active_popup_client); + if (m_tiling->tilingLayouts().value(desktop)) { + Tile *t = m_tiling->tilingLayouts()[desktop]->findTile(active_popup_client); if (t) mTilingStateOpAction->setChecked(t->floating()); } } - mTilingStateOpAction->setVisible(m_tiling->tilingEnabled()); + mTilingStateOpAction->setVisible(m_tiling->isEnabled()); #endif delete switch_to_tab_popup; switch_to_tab_popup = 0; @@ -672,7 +672,7 @@ void Workspace::performWindowOperation(Client* c, Options::WindowOperation op) return; #ifdef KWIN_BUILD_TILING // Allows us to float a window when it is maximized, if it is tiled. - if (m_tiling->tilingEnabled() + if (m_tiling->isEnabled() && (op == Options::MaximizeOp || op == Options::HMaximizeOp || op == Options::VMaximizeOp @@ -792,8 +792,8 @@ void Workspace::performWindowOperation(Client* c, Options::WindowOperation op) case Options::ToggleClientTiledStateOp: { #ifdef KWIN_BUILD_TILING int desktop = c->desktop(); - if (m_tiling->getTilingLayouts().value(desktop)) { - m_tiling->getTilingLayouts()[desktop]->toggleFloatTile(c); + if (m_tiling->tilingLayouts().value(desktop)) { + m_tiling->tilingLayouts()[desktop]->toggleFloatTile(c); } #endif } diff --git a/workspace.cpp b/workspace.cpp index 4525c01919..74a854e5ef 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -495,7 +495,7 @@ void Workspace::init() #ifdef KWIN_BUILD_TILING // Enable/disable tiling - m_tiling->setTilingEnabled(options->tilingOn); + m_tiling->setEnabled(options->tilingOn); #endif // SELI TODO: This won't work with unreasonable focus policies, @@ -1035,7 +1035,7 @@ void Workspace::slotReconfigure() } #ifdef KWIN_BUILD_TILING - m_tiling->setTilingEnabled(options->tilingOn); + m_tiling->setEnabled(options->tilingOn); // just so that we reset windows in the right manner, 'activate' the current active window m_tiling->notifyTilingWindowActivated(activeClient()); #endif @@ -1302,7 +1302,7 @@ bool Workspace::setCurrentDesktop(int new_desktop) int old_desktop = movingClient->desktop(); movingClient->setDesktop(new_desktop); #ifdef KWIN_BUILD_TILING - if (m_tiling->tilingEnabled()) { + if (m_tiling->isEnabled()) { m_tiling->notifyTilingWindowDesktopChanged(movingClient, old_desktop); } #else