~unity-team/compiz/plugins-main-trunk.fix_wrong_window_move_expo

« back to all changes in this revision

Viewing changes to thumbnail/src/thumbnail.h

  • Committer: David Barth
  • Date: 2011-03-29 16:36:40 UTC
  • Revision ID: david.barth@canonical.com-20110329163640-fpen5qsoo0lbjode
initial import from compiz-plugins-main_0.9.4git20110322.orig.tar.gz

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *
 
3
 * Compiz thumbnail plugin
 
4
 *
 
5
 * thumbnail.cpp
 
6
 *
 
7
 * Copyright : (C) 2007 by Dennis Kasprzyk
 
8
 * E-mail    : onestone@beryl-project.org
 
9
 *
 
10
 * Ported to Compiz 0.9
 
11
 * Copyright : (C) 2009 by Sam Spilsbury
 
12
 * E-mail    : smspillaz@gmail.com
 
13
 *
 
14
 * Based on thumbnail.c:
 
15
 * Copyright : (C) 2007 Stjepan Glavina
 
16
 * E-mail    : stjepang@gmail.com
 
17
 *
 
18
 * This program is free software; you can redistribute it and/or
 
19
 * modify it under the terms of the GNU General Public License
 
20
 * as published by the Free Software Foundation; either version 2
 
21
 * of the License, or (at your option) any later version.
 
22
 *
 
23
 * This program is distributed in the hope that it will be useful,
 
24
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
25
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
26
 * GNU General Public License for more details.
 
27
 *
 
28
 */
 
29
 
 
30
 
 
31
/* TODO:
 
32
        * - Make Thumbnail it's own class with methods
 
33
        * - Make a Thumbnail container class - this is where the window /
 
34
            glow texture is drawn
 
35
        * - Set KDE Thumbnail property
 
36
        * - Set Compiz Thumbnail property (for plugins like peek)
 
37
 */
 
38
 
 
39
#include <cmath>
 
40
 
 
41
#include <core/core.h>
 
42
#include <core/atoms.h>
 
43
#include <composite/composite.h>
 
44
#include <opengl/opengl.h>
 
45
#include <text/text.h>
 
46
#include <mousepoll/mousepoll.h>
 
47
 
 
48
#include "thumbnail_options.h"
 
49
 
 
50
#define THUMB_SCREEN(s)                                               \
 
51
    ThumbScreen *ts = ThumbScreen::get (s)
 
52
 
 
53
#define THUMB_WINDOW(w)                                               \
 
54
    ThumbWindow *tw = ThumbWindow::get (w)
 
55
 
 
56
#define WIN_X(w) ((w)->x () - (w)->border ().left)
 
57
#define WIN_Y(w) ((w)->y () - (w)->border ().top)
 
58
#define WIN_W(w) ((w)->width () + (w)->border ().left + (w)->border ().right)
 
59
#define WIN_H(w) ((w)->height () + (w)->border ().top + (w)->border ().bottom)
 
60
 
 
61
#define TEXT_DISTANCE 10
 
62
 
 
63
bool textPluginLoaded;
 
64
 
 
65
typedef struct _Thumbnail
 
66
{
 
67
    int   x;
 
68
    int   y;
 
69
    int   width;
 
70
    int   height;
 
71
    float scale;
 
72
    float opacity;
 
73
    int   offset;
 
74
 
 
75
    CompWindow *win;
 
76
    CompWindow *dock;
 
77
 
 
78
    CompText   *text;
 
79
    bool       textValid;
 
80
} Thumbnail;
 
81
 
 
82
class ThumbScreen:
 
83
        public PluginClassHandler <ThumbScreen, CompScreen>,
 
84
        public ScreenInterface,
 
85
        public GLScreenInterface,
 
86
        public CompositeScreenInterface,
 
87
        public ThumbnailOptions
 
88
{
 
89
    public:
 
90
 
 
91
        ThumbScreen (CompScreen *sceen);
 
92
        ~ThumbScreen ();
 
93
 
 
94
        void handleEvent (XEvent *);
 
95
 
 
96
        void preparePaint (int);
 
97
 
 
98
        bool
 
99
        glPaintOutput (const GLScreenPaintAttrib &,
 
100
                       const GLMatrix &,
 
101
                       const CompRegion &,
 
102
                       CompOutput *,
 
103
                       unsigned int);
 
104
 
 
105
        void
 
106
        donePaint ();
 
107
 
 
108
        void
 
109
        glPaintTransformedOutput (const GLScreenPaintAttrib &,
 
110
                                  const GLMatrix &,
 
111
                                  const CompRegion &,
 
112
                                  CompOutput *,
 
113
                                  unsigned int);
 
114
 
 
115
        void
 
116
        freeThumbText (Thumbnail  *t);
 
117
 
 
118
        void
 
119
        renderThumbText (Thumbnail  *t,
 
120
                         bool       freeThumb);
 
121
 
 
122
        void
 
123
        damageThumbRegion (Thumbnail  *t);
 
124
 
 
125
        void
 
126
        thumbUpdateThumbnail ();
 
127
 
 
128
        bool
 
129
        thumbShowThumbnail ();
 
130
 
 
131
        bool
 
132
        checkPosition (CompWindow *w);
 
133
 
 
134
        void
 
135
        positionUpdate (const CompPoint &pos);
 
136
 
 
137
        void
 
138
        paintTexture (int wx,
 
139
                      int wy,
 
140
                      int width,
 
141
                      int height,
 
142
                      int off);
 
143
 
 
144
        void
 
145
        thumbPaintThumb (Thumbnail           *t,
 
146
                         const GLMatrix *transform);
 
147
 
 
148
 
 
149
        GLScreen   *gScreen;
 
150
        CompositeScreen *cScreen;
 
151
 
 
152
        CompWindow *dock;
 
153
        CompWindow *pointedWin;
 
154
 
 
155
        bool      showingThumb;
 
156
        Thumbnail thumb;
 
157
        Thumbnail oldThumb;
 
158
        bool      painted;
 
159
 
 
160
        CompTimer displayTimeout;
 
161
 
 
162
        GLTexture::List glowTexture;
 
163
        GLTexture::List windowTexture;
 
164
 
 
165
        int x;
 
166
        int y;
 
167
 
 
168
        MousePoller poller;
 
169
};
 
170
 
 
171
class ThumbWindow :
 
172
        public PluginClassHandler <ThumbWindow, CompWindow>,
 
173
        public WindowInterface,
 
174
        public CompositeWindowInterface,
 
175
        public GLWindowInterface
 
176
{
 
177
    public:
 
178
 
 
179
        ThumbWindow (CompWindow *window);
 
180
        ~ThumbWindow ();
 
181
 
 
182
        CompWindow *window;
 
183
        CompositeWindow *cWindow;
 
184
        GLWindow *gWindow;
 
185
 
 
186
        bool
 
187
        glPaint (const GLWindowPaintAttrib &attrib,
 
188
                const GLMatrix          &transform,
 
189
                CompRegion              &region,
 
190
                unsigned int            mask);
 
191
 
 
192
        void
 
193
        resizeNotify (int dx,
 
194
                      int dy,
 
195
                      int dwidth,
 
196
                      int dheight);
 
197
 
 
198
        bool
 
199
        damageRect (bool initial,
 
200
                    const CompRect &rect);
 
201
};
 
202
 
 
203
class ThumbPluginVTable :
 
204
    public CompPlugin::VTableForScreenAndWindow <ThumbScreen, ThumbWindow>
 
205
{
 
206
    public:
 
207
        bool init ();
 
208
};