summaryrefslogtreecommitdiff
path: root/kde/window-decorator-kde4/decorator.h
blob: 0ab3522e56fac0cb01f51e46533431145ec57f8c (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
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
183
184
185
186
187
188
189
190
/*
 * Copyright © 2008 Dennis Kasprzyk <onestone@opencompositing.org>
 * Copyright © 2006 Novell, Inc.
 * Copyright © 2006 Volker Krause <vkrause@kde.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 *
 * Author: David Reveman <davidr@novell.com>
 */

#ifndef _DECORATOR_H
#define _DECORATOR_H

#include <kapplication.h>

#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/cursorfont.h>

#include <QTimer>

#include <fixx11h.h>
#include <KDE/KConfig>
#include <netwm.h>

#include <decoration.h>

#include "window.h"
#include "switcher.h"
#include "kdecoration_plugins.h"
#include "utils.h"

#define ROOT_OFF_X 8192
#define ROOT_OFF_Y 8192

#define C(name) { 0, XC_ ## name }

struct _cursor {
    Cursor       cursor;
    unsigned int shape;
};

extern struct _cursor cursors[3][3];

extern double decorationOpacity;
extern bool   decorationOpacityShade;
extern double activeDecorationOpacity;
extern bool   activeDecorationOpacityShade;

#define BLUR_TYPE_NONE     0
#define BLUR_TYPE_TITLEBAR 1
#define BLUR_TYPE_ALL      2

extern int blurType;

class KConfig;
class KWindowSystem;

namespace KWD
{
    class Options;

class PluginManager:public KDecorationPlugins {
    public:
	PluginManager (KSharedConfigPtr config);
	virtual bool provides (Requirement)
	{
	    return false;
	}
    };


class Decorator:public KApplication {
    Q_OBJECT public:
#ifdef QT_45
	Decorator ();
#else
        Decorator (Display* display, Qt::HANDLE visual, Qt::HANDLE colormap);
#endif
	~Decorator (void);

	static NETRootInfo *rootInfo (void)
	{
	    return mRootInfo;
	}
	static PluginManager *pluginManager (void)
	{
	    return mPlugins;
	}
	static KWD::Options *options (void)
	{
	    return mOptions;
	}
	static WId activeId (void)
	{
	    return mActiveId;
	}
	static decor_shadow_options_t *shadowOptions (void)
	{
	    return &mShadowOptions;
	}
	static decor_shadow_t *defaultWindowShadow (decor_context_t *context,
						    decor_extents_t *border)
	{
	    if (!mDefaultShadow)
		return NULL;

	    if (memcmp (border, &mDefaultBorder, sizeof (decor_extents_t)) != 0)
		return NULL;

	    *context = mDefaultContext;
	    return mDefaultShadow;
	}
	static void sendClientMessage (WId  eventWid,
				       WId  wid,
				       Atom atom,
				       Atom value,
				       long data1 = 0,
				       long data2 = 0,
				       long data3 = 0);
	static void updateDefaultShadow (KWD::Window *w);

	bool enableDecorations (Time timestamp, int  damageEvent);
	bool x11EventFilter (XEvent *xevent);
	void changeShadowOptions (decor_shadow_options_t *opt);

    public slots:
	void reconfigure (void);
	
    private:
	WId fetchFrame (WId window);
	void updateShadow (void);
	void updateAllShadowOptions (void);

    private slots:
	void handleWindowAdded (WId id);
	void handleWindowRemoved (WId id);
	void handleActiveWindowChanged (WId id);
	void handleWindowChanged (WId		      id,
				  const unsigned long *properties);
	void processDamage (void);
	void shadowRadiusChanged (double value);
	void shadowOpacityChanged (double value);
	void shadowXOffsetChanged (int value);
	void shadowYOffsetChanged (int value);
	void shadowColorChanged (QString value);

	void plasmaThemeChanged ();

    private:
	static PluginManager *mPlugins;
	static KWD::Options *mOptions;
	static decor_extents_t mDefaultBorder;
	static decor_context_t mDefaultContext;
	static decor_shadow_t *mDefaultShadow;
	static decor_shadow_t *mNoBorderShadow;
	static decor_shadow_options_t mShadowOptions;
	static NETRootInfo *mRootInfo;
	static WId mActiveId;

	KWD::Window *mDecorNormal;
	KWD::Window *mDecorActive;
	QMap <WId, KWD::Window *>mClients;
	QMap <WId, KWD::Window *>mFrames;
	QMap <WId, KWD::Window *>mWindows;
	KConfig *mConfig;
	Time mDmSnTimestamp;
	int mDamageEvent;
	QTimer mIdleTimer;

	WId mCompositeWindow;

	Switcher *mSwitcher;
    };
}

#endif