summaryrefslogtreecommitdiffstats
path: root/src/komposetaskvisualizer.h
blob: 93235158b45fd13e791672cc488bb2c1cbad2210 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//
// C++ Interface: %{MODULE}
//
// Description:
//
//
// Author: %{AUTHOR} <%{EMAIL}>, (C) %{YEAR}
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef KOMPOSETASKVISUALIZER_H
#define KOMPOSETASKVISUALIZER_H

#include <tqobject.h>

#include "komposetask.h"

#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <Imlib2.h>

#ifdef COMPOSITE
#include <X11/Xatom.h>
#include <X11/extensions/Xcomposite.h>
#include <X11/extensions/Xdamage.h>
#include <X11/extensions/Xrender.h>
#endif

enum ImageEffect { IEFFECT_NONE, IEFFECT_TITLE, IEFFECT_MINIMIZED, IEFFECT_MINIMIZED_AND_TITLE, IEFFECT_HIGHLIGHT };

class TQPixmap;
class TQSize;

/**
@author Hans Oischinger
*/
class KomposeTaskVisualizer : public TQObject
{
  Q_OBJECT
public:
  KomposeTaskVisualizer(KomposeTask *parent, const char *name = 0);
  ~KomposeTaskVisualizer();

  void renderOnPixmap( TQPixmap* pix, int effect );

protected:
  void applyEffect();

protected slots:
  void initXComposite();
  void captureScreenshot_GrabWindow();
  void updateXCompositeNamedPixmap();
  void renderScaledScreenshot( TQSize size );

  void setScaledScreenshotDirty() { scaledScreenshotDirty = true; }
  void clearCached();
  void enablePasvScreenshots();

public slots:
  void slotTaskActivated();
  void slotUpdateScreenshot();

private:
  KomposeTask *task;
  TQPixmap screenshot;
  TQPixmap scaledScreenshot;
  bool scaledScreenshotDirty;
  bool screenshotSuspended;   // suspend pasv screenshots for this task
  bool screenshotBlocked;   // dis/enable pasv screenshots for this task

  Imlib_Color_Modifier cmHighlight, cmMinimized;
  int lasteffect; // the effect that has been applied to scaledScreenshot

#ifdef COMPOSITE
  Pixmap windowBackingPix;
  bool validBackingPix;
  Display *dpy;
  XRenderPictFormat *format;
  XRenderPictureAttributes pa;
  bool hasAlpha;
  Damage damage;
  bool compositeInit;  // true if composite&damage has been initialised
#endif
};

#endif