summaryrefslogtreecommitdiff
path: root/resizeinfo.h
blob: 9e35b47a4203d1b4519c17da134c04e89d4d6ee0 (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
/**
 *
 * Compiz metacity like info during resize
 *
 * resizeinfo.c
 *
 * Copyright (c) 2007 Robert Carr <racarr@opencompositing.org>
 *
 * Compiz resize atom usage and general cleanups by
 * Copyright (c) 2007 Danny Baumann <maniac@opencompositing.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.
 *
 **/

#include <core/core.h>
#include <core/privatehandler.h>

#include <composite/composite.h>
#include <opengl/opengl.h>

#include <cairo-xlib-xrender.h>
#include <math.h>
#include <pango/pango.h>
#include <pango/pangocairo.h>

#include "resizeinfo_options.h"

#define RESIZE_POPUP_WIDTH 85
#define RESIZE_POPUP_HEIGHT 50

#define PI 3.1415926

/* Cairo helper class */

class InfoLayer
{
    public:

	InfoLayer ();
	~InfoLayer ();

	bool valid;

	Screen		  *s;
	XRenderPictFormat *format;
	Pixmap            pixmap;
	cairo_surface_t   *surface;
	GLTexture::List   texture;
	cairo_t           *cr;

	void draw (int x,
	 	   int y);

	void renderBackground ();
	void renderText ();
};

class InfoScreen :
    public PrivateHandler <InfoScreen, CompScreen>,
    public ScreenInterface,
    public CompositeScreenInterface,
    public GLScreenInterface,
    public ResizeinfoOptions
{
    public:

	InfoScreen (CompScreen *);

	GLScreen 	*gScreen;
	CompositeScreen *cScreen;

	Atom resizeInfoAtom;

	CompWindow *pWindow;

	bool drawing;
	int  fadeTime;

	InfoLayer backgroundLayer;
	InfoLayer textLayer;

	XRectangle resizeGeometry;

	void
	damagePaintRegion ();

	void
	preparePaint (int);

	bool
	glPaintOutput (const GLScreenPaintAttrib &,
		       const GLMatrix &,
		       const CompRegion &,
		       CompOutput *,
		       unsigned int);

	void
	donePaint ();

	void
	handleEvent (XEvent *event);
};

class InfoWindow :
    public PrivateHandler <InfoWindow, CompWindow>,
    public WindowInterface
{
    public:

	InfoWindow (CompWindow *);

	CompWindow *window;

	void
	grabNotify (int,
	      	    int,
	      	    unsigned int,
	      	    unsigned int);

	void
	ungrabNotify ();
};

#define INFO_SCREEN(s)							       \
    InfoScreen *is = InfoScreen::get (s);

#define INFO_WINDOW(w)							       \
    InfoWindow *iw = InfoWindow::get (w);

class InfoPluginVTable :
    public CompPlugin::VTableForScreenAndWindow <InfoScreen, InfoWindow>
{
    public:

	bool init ();

	PLUGIN_OPTION_HELPER (InfoScreen);
};