summaryrefslogtreecommitdiffstats
path: root/kdesktop/bgmanager.h
blob: 99d30a7bdccc4b69c9aff6c5119e733df81057b0 (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
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
/*
 *
 * This file is part of the KDE project, module kdesktop.
 * Copyright (C) 1999,2000 Geert Jansen <jansen@kde.org>
 *
 * You can Freely distribute this program under the GNU General Public
 * License. See the file "COPYING" for the exact licensing terms.
 */

#ifndef __BGMANAGER_H__
#define __BGMANAGER_H__

#include <tqstring.h>
#include <tqptrvector.h>

#include <tqdatetime.h>
#include <KBackgroundIface.h>

#if defined(Q_WS_X11) && defined(HAVE_XRENDER) && TQT_VERSION >= 0x030300
#define COMPOSITE
#endif

class TDEConfig;
class TQTimer;
class TQPixmap;
class TDEPopupMenu;
class KWinModule;
class KPixmap;
class KVirtualBGRenderer;
class KPixmapServer;

/**
 * Internal struct for KBackgroundManager.
 */
struct KBackgroundCacheEntry
{
    int hash;
    int atime;
    int exp_from;
    KPixmap *pixmap;
};


/**
 * Background manager for KDE. This class is to be used in kdesktop. Usage is
 * very simple: instantiate this class once and the desktop background will
 * be painted automatically from now on.
 *
 * The background manager also has a DCOP interface to remotely control its
 * operation. See KBackgroundIface.h for details.
 */

class KBackgroundManager
    : public TQObject,
      public KBackgroundIface
{
    TQ_OBJECT
    

public:
    KBackgroundManager(TQWidget *desktop, KWinModule* twinModule);
    ~KBackgroundManager();

    void configure();
    void setCommon(int);
    bool isCommon() { return m_bCommon; };
    void setExport(int);
    bool isExport() { return m_bExport; };
    void setCache(int, int);
    void setWallpaper(int desk, TQString wallpaper, int mode);
    void setWallpaper(TQString wallpaper, int mode);
    void setWallpaper(TQString wallpaper);
    void changeWallpaper();
    TQString currentWallpaper(int desk);
    void setColor(const TQColor & c, bool isColorA = true);
    void setBackgroundEnabled(const bool enable);
    TQStringList wallpaperList(int desk);
    TQStringList wallpaperFiles(int desk);

signals:
    void initDone();

private slots:
    void slotTimeout();
    void slotImageDone(int desk);
    void slotChangeDesktop(int);
    void slotChangeViewport(int, const TQPoint&);
    void slotChangeNumberOfDesktops(int);
    void repaintBackground();
    void desktopResized();
    void clearRoot();
    void saveImages();
    void slotCrossFadeTimeout();
    void slotCmBackgroundChanged(bool);

private:
    void applyCommon(bool common);
    void applyExport(bool _export);
    void applyCache(bool limit, int size);

    int realDesktop();
    int effectiveDesktop();
    int validateDesk(int desk);
    int m_numberOfViewports;

    void renderBackground(int desk);
    void exportBackground(int pixmap, int desk);
    int pixmapSize(TQPixmap *pm);
    int cacheSize();
    void removeCache(int desk);
    bool freeCache(int size);
    void addCache(KPixmap *pm, int hash, int desk);
    void setPixmap(KPixmap *pm, int hash, int desk);

    bool m_bExport, m_bCommon;
    bool m_bLimitCache, m_bInit;
    bool m_bBgInitDone;
    bool m_bEnabled;

    int m_CacheLimit;
    int m_Serial, m_Hash, m_Current;

    TDEConfig *m_pConfig;
    TQWidget *m_pDesktop;
    TQTimer *m_pTimer;

    KPixmap *m_tPixmap;
	
    TQPtrVector<KVirtualBGRenderer> m_Renderer;
    TQPtrVector<KBackgroundCacheEntry> m_Cache;

    KWinModule *m_pKwinmodule;
    KPixmapServer *m_pPixmapServer;
    
    unsigned long m_xrootpmap;

    /*CrossFade vars*/
    TQTimer * m_crossTimer;
    double mAlpha;
    TQPixmap  mNextScreen;
    TQPixmap  * mOldScreen;
    int fadeDesk;
    TQTime mBenchmark;
    bool crossInit;
    bool resizingDesktop; // is True if desktop is resizing
};

#endif // __BGMANAGER_H__