PieDock  1.6.3
TransparentWindow.h
1 /*
2  * O ,-
3  * o . - ' ,-
4  * . ` . ,
5  * ( )) . (
6  * `-;_ . - `.`.
7  * `._'
8  *
9  * Copyright (c) 2007-2010 Markus Fisch <mf@markusfisch.de>
10  *
11  * Licensed under the MIT license:
12  * http://www.opensource.org/licenses/mit-license.php
13  */
14 #ifndef _PieDock_TransparentWindow_
15 #define _PieDock_TransparentWindow_
16 
17 #include "Application.h"
18 #include "XSurface.h"
19 
20 #include <X11/Xlib.h>
21 
22 #ifdef HAVE_XRENDER
23 #include <X11/extensions/Xrender.h>
24 #endif
25 
26 namespace PieDock
27 {
34  {
35  public:
37  virtual ~TransparentWindow();
38  inline const Window &getWindow() const { return window; }
39  virtual void appear() {}
40  virtual void draw() {}
41  virtual bool processEvent( XEvent & ) { return false; }
42 
43  protected:
44  inline Application *getApp() const { return app; }
45  inline const int &getWidth() const { return width; }
46  inline const int &getHeight() const { return height; }
47  inline XSurface *getCanvas() const { return canvas; }
48  inline const GC &getGc() const { return gc; }
49 #ifdef HAVE_XRENDER
50  inline const Pixmap &getAlphaPixmap() const { return alphaPixmap; }
51  inline virtual void composite() const
52  {
53  XRenderComposite(
54  app->getDisplay(),
55  PictOpOver,
56  windowPicture,
57  None,
58  alphaPicture,
59  0,
60  0,
61  0,
62  0,
63  0,
64  0,
65  width,
66  height );
67  }
68 #endif
69  virtual void show();
70  virtual void hide() const;
71  virtual void clear();
72  virtual void update() const;
73 
74  private:
75  Application *app;
76  Window window;
77  int width;
78  int height;
79  XSurface *canvas;
80  unsigned char *buffer;
81  GC gc;
82 #ifdef HAVE_XRENDER
83  Pixmap alphaPixmap;
84  Picture windowPicture;
85  Picture alphaPicture;
86 #endif
87  };
88 }
89 
90 #endif