PieDock 1.6.0

src/TransparentWindow.h

00001 /*
00002  *   O         ,-
00003  *  ° o    . -´  '     ,-
00004  *   °  .´        ` . ´,´
00005  *     ( °   ))     . (
00006  *      `-;_    . -´ `.`.
00007  *          `._'       ´
00008  *
00009  * Copyright (c) 2007-2010 Markus Fisch <mf@markusfisch.de>
00010  *
00011  * Licensed under the MIT license:
00012  * http://www.opensource.org/licenses/mit-license.php
00013  */
00014 #ifndef _PieDock_TransparentWindow_
00015 #define _PieDock_TransparentWindow_
00016 
00017 #include "Application.h"
00018 #include "XSurface.h"
00019 
00020 #include <X11/Xlib.h>
00021 
00022 #ifdef HAVE_XRENDER
00023 #include <X11/extensions/Xrender.h>
00024 #endif
00025 
00026 namespace PieDock
00027 {
00033     class TransparentWindow
00034     {
00035         public:
00036             TransparentWindow( Application & );
00037             virtual ~TransparentWindow();
00038             inline const Window &getWindow() const { return window; }
00039             virtual void appear() {}
00040             virtual void draw() {}
00041             virtual bool processEvent( XEvent & ) { return false; }
00042 
00043         protected:
00044             inline Application *getApp() const { return app; }
00045             inline const int &getWidth() const { return width; }
00046             inline const int &getHeight() const { return height; }
00047             inline XSurface *getCanvas() const { return canvas; }
00048             inline const GC &getGc() const { return gc; }
00049 #ifdef HAVE_XRENDER
00050             inline const Pixmap &getAlphaPixmap() const { return alphaPixmap; }
00051             inline virtual void composite() const
00052             {
00053                 XRenderComposite(
00054                     app->getDisplay(),
00055                     PictOpOver,
00056                     windowPicture,
00057                     None,
00058                     alphaPicture,
00059                     0,
00060                     0,
00061                     0,
00062                     0,
00063                     0,
00064                     0,
00065                     width,
00066                     height );
00067             }
00068 #endif
00069             virtual void show();
00070             virtual void hide() const;
00071             virtual void clear();
00072             virtual void update() const;
00073 
00074         private:
00075             Application *app;
00076             Window window;
00077             int width;
00078             int height;
00079             XSurface *canvas;
00080             unsigned char *buffer;
00081             GC gc;
00082 #ifdef HAVE_XRENDER
00083             Pixmap alphaPixmap;
00084             Picture windowPicture;
00085             Picture alphaPicture;
00086 #endif
00087     };
00088 }
00089 
00090 #endif