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.
icc-effect-5.14.5
Arthur Arlt 2011-07-20 13:25:00 +02:00
parent 0c5da9f96f
commit 1326316049
7 changed files with 100 additions and 24 deletions

View File

@ -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

View File

@ -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

View File

@ -50,7 +50,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <kephal/screens.h>
#include <KDE/KGlobalSettings>
#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);
}

6
sm.cpp
View File

@ -34,7 +34,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QSocketNotifier>
#include <QSessionManager>
#include <kdebug.h>
#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);
}

View File

@ -30,9 +30,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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<KAction*>(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
}
}
}

View File

@ -44,7 +44,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QtDBus/QtDBus>
#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 <http://www.gnu.org/licenses/>.
#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

View File

@ -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