There are several options to build KWin from sources. The easiest one is probably to use kdesrc-build and just build the module kde-workspace. But it's also possible to build KWin standalone without the other parts of kde-workspace. This article aims to describe how to build current master.
Obtaining Source Code
KWin is part of the kde-workspace module and is located in the sub-folder kwin of this module. To obtain the KWin source code you have therefore to clone the git repository:
git clone git://anongit.kde.org/kde-workspace
In case you cannot use the git protocol please have a look to the repository website for other options.
The dependencies to build KWin should best be resolved using your distribution. On Debian based systems just use:
sudo apt-get build-dep kde-workspace
Given that the KDE 4 libraries are currently frozen it should be possible to build KWin with kdelibs version 4.8 or later.
First create a directory where you want to build kwin, which we assume to be in $BUILD. Furthermore create a directory where to install to, which we will call $KWIN_INSTALL_DIR. We assume the cloned kde-workspace repository is located in $KDE_WORKSPACE
Now run cmake from the build directory and specify the build options you want to have. KWin specific build options are documented on techbase.
cd $BUILD cmake "$KDE_WORKSPACE" -DCMAKE_INSTALL_PREFIX=$KWIN_INSTALL_DIR \ -DCMAKE_BUILD_TYPE=debugfull \ -DKWIN_BUILD_OXYGEN=OFF \ -DKDE4_BUILD_TESTS=TRUE
Build and install
After cmake has run sucessfully you can just make and make install from the kwin directory in your build tree:
cd $BUILD cd kwin make make install
The default window decoration Oxygen is known to provide problems from time to time when running KWin from master. The reason is that the decoration shares an internal library with the kstyle. This can resolve in ABI problems and if KWin is started with an Oxygen linked against an old version it won't start.
To circumvent this problem a build option is available to disable building Oxygen. In the cmake snippet above this build option is set to disable building Oxygen to make building KWin as easy as possible. If you want to build Oxygen (e.g. to work on the window decoration) just remove the line with KWIN_BUILD_OXYGEN.
Now after successfully building KWin all that is left is adjusting your local environment, so that it finds your KWin version. For an overview on available variables to adjust have a look at Build/Environment.
export KDEDIR=$KWIN_INSTALL_DIR export KDEDIRS=$KDEDIR:$KDEDIRS # remove the added $KDEDIRS if you don't want to find your distribution KDE version # Add the KDE plugins to the Qt plugins path export QT_PLUGIN_PATH=$KDEDIR/lib/kde4/plugins # Export the standard paths to include KDE export PATH=$KDEDIR/bin:$PATH export LD_LIBRARY_PATH=$KDEDIR/lib:$LD_LIBRARY_PATH export PKG_CONFIG_PATH=$KDEDIR/lib/pkgconfig:$PKG_CONFIG_PATH
In case you don't want KWin to pick up your standard configuration file, also adjust $KDEHOME, please see referenced documentation above.
To start KWin from this environment just run:
kwin --replace &
In case you run from a tty, don't forget to export the $DISPLAY variable. You can also start KWin on an embedded X-Server (Xephyr) or in a separate X session by adjusting the $DISPLAY variable.