Give Depth to Your KDE Windows

Give Depth to Your KDE Windows

Create a 3D effect with drop shadows for all open KDE Windows.

You can give your application windows and other on-screen elements (such as menus and dialog boxes) a really nice 3D effect if you add drop shadows to them. The active window seems to pop right out at you, and you don't even need geeky cardboard and plastic glasses for this trick to work.

Although it is also possible to create drop shadows if you use the xcompmgr utility with Xorg-X11 6.8.0 or higher instead of XFree86, xcompmgr is still a work in progress. The xcompmgr program crashes a lot, and sometimes it takes down the window manager with it.

The only real disadvantage to this hack is that it is most useful on fast machines, especially if you have an accelerated X driver for your video card. But apart from speed and convenience, these patches have the distinct advantage of saving you time restarting after a window manager crash caused by xcompmgr.

These instructions assume you are using KDE 3.3.1; you can combine these instructions with the KDE improvements in [Hack #41] .

As I write this, KDE 3.3.2, a bug-fix release for KDE, is being launched. The patches described here do not apply cleanly to KDE 3.3.2, although if you are an experienced programmer, you might be able to fix the areas where the patches fail.

Figure shows what the drop shadows look like, as well as proof that this hack and the previous sidebar and icon hacks work well together. Notice also from Figure that you can configure this hack to give inactive windows a smaller drop shadow to make them look like they've receded into the background.

KDE windows with drop shadows

I assume you already compiled and installed KDE 3.3.1. If you still have the source code on your hard drive, this will make things easier. If not, get the source code for the following portions of KDE, and unpack it where you will compile it. For the purposes of this example, I am assuming you will work in the /usr/local/src directory. You need to have the source code installed for the following packages, which are listed in the order in which you will compile and install them:

  • kdelibs 3.3.1

  • kdebase 3.3.1

For more detailed instructions on how to build and install all of KDE 3.3.1, see and/or [Hack #44] .

Download the hack ( The file you want should be named kwin_shadow-patch.tar.bz2. Log in as root, and then enter the following commands to put the patches in the /patches-2 directory:

# tar jxvf kwin_shadow-patch.tar.bz2
# cd kwin_shadow/kde-3.3.1
# cp kdebase.kwin-kwin_shadow-3.3.1.patch /patches-2
# cp kdelibs.kdefx-kwin_shadow-3.3.1.patch /patches-2

Now you are ready to apply these patches to the KDE source code.

If you are working with source code that has already been patched to include the KDE improvements described in this hack, you will see some messages that the patches were applied at various offsets (2 lines, 52 lines, etc.). These messages are harmless.

Here are the commands for applying the drop-shadow patches, then configuring and installing kdelibs and kdebase:

# cd /usr/local/src/kdelibs-3.3.1/kdefx
# cat /patches-2/kdelibs.kdefx-kwin_shadow-3.3.1.patch | patch -p1
# ./configure <your configure preferences>

# make
# make install
# cd /usr/local/src/kdebase-3.3.1/kwin
# cat /patches-2/kdebase.kwin-kwin_shadow-3.3.1.patch | patch -p1
# ./configure <your configure preferences>

# make
# make install

These commands assume the names of the directories for your kdelibs and kdebase source are:

  • /usr/local/src/kdelibs-3.3.1

  • /usr/local/src/kdebase-3.3.1

The names of the directories in this example, such as kdelibs-3.3.2, might not match yours, depending on where you get your source code. Just substitute your directory names for the ones in the examples.

Take note of <your configure preferences> following every ./configure command. This is where you can specify the destination directory prefix, along with other configuration parameters you find necessary. As for the prefix, some people like to install KDE under the /opt/kde directory, others like /usr, and so on. It's up to you, but you should stick with whatever prefix you used when you installed KDE 3.3.1 before making this modification. If you installed it with the prefix /usr, the command would look like this:

# ./conFigureprefix=/usr  <other preferences>

Make sure to run ./configure --help before you actually run ./configure as part of the build process. This command tells you about options that might be important to your installation of KDE 3.3.1.

If all went smoothly, you should be able to start up KDE, but you won't see any drop shadows yet. To set up the drop shadows, open the KDE Control Center and click Appearance & ThemesWindow Decorations. Then click the Shadows tab, which should look something like the picture in Figure. From here, you can choose to draw drop shadows on active or inactive windows, determine how big a drop shadow you want on each, set the opacity (how much you can see through the shadow), and more. Experiment until you get the effect you like best.

The Shadows configuration tab

This hack has a long list of credits. Karol Szwed started the process, and David Sansome wrote some decoration code, some of which was converted for use in this patch. Thomas Libking added a lot of work to make the drop shadows for different applications interact. Bernardo Hung pulled it all together, and then Heiko Przybyl ([email protected]) ported the latest version of the code for use with KDE 3.3.0 and KDE 3.3.1.

     Python   SQL   Java   php   Perl 
     game development   web development   internet   *nix   graphics   hardware 
     telecommunications   C++ 
     Flash   Active Directory   Windows