Hack 42. 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] .
Figure 5-7 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 5-7 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.
Figure 5-7. 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:
Download the hack (http://www.kde-look.org/content/show.php?content=15781). 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.
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:
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:
# ./configure --prefix=/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 5-8. 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.
Figure 5-8. 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@example.com) ported the latest version of the code for use with KDE 3.3.0 and KDE 3.3.1.