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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
/* vi: ts=8 sts=4 sw=4
* kate: space-indent on; tab-width 8; indent-width 4; indent-mode cstyle;
*
* This file is part of the KDE project, module kdesktop.
* Copyright (C) 1999 Geert Jansen <g.t.jansen@stud.tue.nl>
*
* You can Freely distribute this program under the GNU Library General
* Public License. See the file "COPYING.LIB" for the exact licensing terms.
*/
#ifndef BGRender_h_Included
#define BGRender_h_Included
#include <tqobject.h>
#include <tqptrvector.h>
#include <tqimage.h>
#include <tqpixmap.h>
#include "bgsettings.h"
class TQSize;
class TQRect;
class TQString;
class TQTimer;
class KConfig;
class TDEProcess;
class KTempFile;
class KShellProcess;
class KStandardDirs;
/**
* This class renders a desktop background to a TQImage. The operation is
* asynchronous: connect to the signal imageDone() to find out when the
* rendering is finished. It also has support for preview images, like
* the monitor in kcmdisplay.
*/
class KBackgroundRenderer:
public TQObject,
public KBackgroundSettings
{
Q_OBJECT
public:
KBackgroundRenderer(int desk, int screen, bool drawBackgroundPerScreen, KConfig *config=0);
~KBackgroundRenderer();
void load(int desk, int screen, bool drawBackgroundPerScreen, bool reparseConfig=true);
void setPreview(const TQSize &size);
void setSize(const TQSize &size);
TQPixmap pixmap();
TQImage image();
bool isActive() { return m_State & Rendering; }
void cleanup();
void saveCacheFile();
void enableTiling( bool enable ) { m_TilingEnabled = enable; }
public slots:
void start(bool enableBusyCursor = false);
void stop();
void desktopResized();
signals:
void imageDone(int desk, int screen);
void programFailure(int desk, int exitstatus); //Guaranteed either programFailure or
void programSuccess(int desk); //programSuccess is emitted after imageDone
private slots:
void slotBackgroundDone(TDEProcess *);
void render();
void done();
private:
enum { Error, Wait, WaitUpdate, Done };
enum { Rendering = 1, InitCheck = 2,
BackgroundStarted = 4, BackgroundDone = 8,
WallpaperStarted = 0x10, WallpaperDone = 0x20,
AllDone = 0x40 };
TQString buildCommand();
void createTempFile();
void tile(TQImage& dst, TQRect rect, const TQImage& src);
void blend(TQImage& dst, TQRect dr, const TQImage& src, TQPoint soffs = TQPoint(0, 0), int blendFactor=100);
void wallpaperBlend();
void fastWallpaperBlend();
void fullWallpaperBlend();
int doBackground(bool quit=false);
int doWallpaper(bool quit=false);
void setBusyCursor(bool isBusy);
TQString cacheFileName();
bool useCacheFile() const;
bool canTile() const;
bool m_isBusyCursor;
bool m_enableBusyCursor;
bool m_bPreview;
int m_State;
bool m_Cached;
bool m_TilingEnabled;
KTempFile* m_Tempfile;
TQSize m_Size, m_rSize;
TQRect m_WallpaperRect;
TQImage m_Image, m_Background, m_Wallpaper;
TQPixmap m_Pixmap;
TQTimer *m_pTimer;
KStandardDirs *m_pDirs;
KShellProcess *m_pProc;
};
/**
* In xinerama mode, each screen is rendered seperately by KBackgroundRenderer.
* This class controls a set of renderers for a desktop, and coallates the
* images. Usage is similar to KBackgroundRenderer: connect to the imageDone
* signal.
*/
class KVirtualBGRenderer : public QObject
{
Q_OBJECT
public:
KVirtualBGRenderer(int desk, KConfig *config=0l);
~KVirtualBGRenderer();
KBackgroundRenderer * renderer(unsigned screen);
unsigned numRenderers() const { return m_numRenderers; }
TQPixmap pixmap();
void setPreview(const TQSize & size);
bool needProgramUpdate();
void programUpdate();
bool needWallpaperChange();
void changeWallpaper();
int hash();
bool isActive();
void setEnabled( bool enable );
void desktopResized();
void load(int desk, bool reparseConfig=true);
void start();
void stop();
void cleanup();
void saveCacheFile();
void enableTiling( bool enable );
signals:
void imageDone(int desk);
private slots:
void screenDone(int desk, int screen);
private:
TQSize renderSize(int screen); // the size the renderer should be
void initRenderers();
KConfig *m_pConfig;
float m_scaleX;
float m_scaleY;
int m_desk;
unsigned m_numRenderers;
bool m_bDrawBackgroundPerScreen;
bool m_bCommonScreen;
bool m_bDeleteConfig;
TQSize m_size;
TQMemArray<bool> m_bFinished;
TQPtrVector<KBackgroundRenderer> m_renderer;
TQPixmap *m_pPixmap;
};
#endif // BGRender_h_Included
|