~mc-return/compiz/compiz.merge-src-screen.cpp-improvements

« back to all changes in this revision

Viewing changes to plugins/switcher.h

  • Committer: Dennis kasprzyk
  • Author(s): Dennis Kasprzyk
  • Date: 2009-03-15 05:09:18 UTC
  • Revision ID: git-v1:163f6b6f3c3b7764987cbdf8e03cc355edeaa499
New generalized build system.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright © 2005 Novell, Inc.
3
 
 *
4
 
 * Permission to use, copy, modify, distribute, and sell this software
5
 
 * and its documentation for any purpose is hereby granted without
6
 
 * fee, provided that the above copyright notice appear in all copies
7
 
 * and that both that copyright notice and this permission notice
8
 
 * appear in supporting documentation, and that the name of
9
 
 * Novell, Inc. not be used in advertising or publicity pertaining to
10
 
 * distribution of the software without specific, written prior permission.
11
 
 * Novell, Inc. makes no representations about the suitability of this
12
 
 * software for any purpose. It is provided "as is" without express or
13
 
 * implied warranty.
14
 
 *
15
 
 * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16
 
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17
 
 * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18
 
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19
 
 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20
 
 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21
 
 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22
 
 *
23
 
 * Author: David Reveman <davidr@novell.com>
24
 
 */
25
 
 
26
 
#include <stdio.h>
27
 
#include <stdlib.h>
28
 
#include <string.h>
29
 
#include <math.h>
30
 
#include <sys/types.h>
31
 
#include <unistd.h>
32
 
 
33
 
#include <decoration.h>
34
 
#include <core/core.h>
35
 
#include <core/privatehandler.h>
36
 
#include <core/atoms.h>
37
 
 
38
 
#include <composite/composite.h>
39
 
#include <opengl/opengl.h>
40
 
 
41
 
#include <X11/Xatom.h>
42
 
#include <X11/extensions/Xrender.h>
43
 
 
44
 
#define ZOOMED_WINDOW_MASK (1 << 0)
45
 
#define NORMAL_WINDOW_MASK (1 << 1)
46
 
 
47
 
#define SWITCH_OPTION_NEXT_BUTTON          0
48
 
#define SWITCH_OPTION_NEXT_KEY             1
49
 
#define SWITCH_OPTION_PREV_BUTTON          2
50
 
#define SWITCH_OPTION_PREV_KEY             3
51
 
#define SWITCH_OPTION_NEXT_ALL_BUTTON      4
52
 
#define SWITCH_OPTION_NEXT_ALL_KEY         5
53
 
#define SWITCH_OPTION_PREV_ALL_BUTTON      6
54
 
#define SWITCH_OPTION_PREV_ALL_KEY         7
55
 
#define SWITCH_OPTION_NEXT_NO_POPUP_BUTTON 8
56
 
#define SWITCH_OPTION_NEXT_NO_POPUP_KEY    9
57
 
#define SWITCH_OPTION_PREV_NO_POPUP_BUTTON 10
58
 
#define SWITCH_OPTION_PREV_NO_POPUP_KEY    11
59
 
#define SWITCH_OPTION_NEXT_PANEL_BUTTON    12
60
 
#define SWITCH_OPTION_NEXT_PANEL_KEY       13
61
 
#define SWITCH_OPTION_PREV_PANEL_BUTTON    14
62
 
#define SWITCH_OPTION_PREV_PANEL_KEY       15
63
 
#define SWITCH_OPTION_SPEED                16
64
 
#define SWITCH_OPTION_TIMESTEP             17
65
 
#define SWITCH_OPTION_WINDOW_MATCH         18
66
 
#define SWITCH_OPTION_MIPMAP               19
67
 
#define SWITCH_OPTION_SATURATION           20
68
 
#define SWITCH_OPTION_BRIGHTNESS           21
69
 
#define SWITCH_OPTION_OPACITY              22
70
 
#define SWITCH_OPTION_BRINGTOFRONT         23
71
 
#define SWITCH_OPTION_ZOOM                 24
72
 
#define SWITCH_OPTION_ICON                 25
73
 
#define SWITCH_OPTION_MINIMIZED            26
74
 
#define SWITCH_OPTION_AUTO_ROTATE          27
75
 
#define SWITCH_OPTION_NUM                  28
76
 
 
77
 
enum SwitchWindowSelection{
78
 
    CurrentViewport = 0,
79
 
    AllViewports,
80
 
    Panels
81
 
};
82
 
 
83
 
class SwitchScreen :
84
 
    public ScreenInterface,
85
 
    public CompositeScreenInterface,
86
 
    public GLScreenInterface,
87
 
    public PrivateHandler<SwitchScreen,CompScreen>
88
 
{
89
 
    public:
90
 
        
91
 
        SwitchScreen (CompScreen *screen);
92
 
        ~SwitchScreen ();
93
 
 
94
 
        CompOption::Vector & getOptions ();
95
 
        bool setOption (const char *name, CompOption::Value &value);    
96
 
 
97
 
        void handleEvent (XEvent *);
98
 
 
99
 
        void preparePaint (int);
100
 
        void donePaint ();
101
 
 
102
 
        bool glPaintOutput (const GLScreenPaintAttrib &,
103
 
                            const GLMatrix &, const CompRegion &,
104
 
                            CompOutput *, unsigned int);
105
 
 
106
 
        void setSelectedWindowHint ();
107
 
        void activateEvent (bool activating);
108
 
        void updateWindowList (int count);
109
 
        void createWindowList (int count);
110
 
        void switchToWindow (bool toNext);
111
 
        int countWindows ();
112
 
        void initiate (SwitchWindowSelection selection,
113
 
                       bool                  showPopup);
114
 
        void windowRemove (Window id);
115
 
        void updateForegroundColor ();
116
 
 
117
 
        bool adjustVelocity ();
118
 
 
119
 
        CompositeScreen *cScreen;
120
 
        GLScreen        *gScreen;
121
 
        
122
 
        CompOption::Vector opt;
123
 
 
124
 
        Atom selectWinAtom;
125
 
        Atom selectFgColorAtom;
126
 
 
127
 
        Window popupWindow;
128
 
 
129
 
        Window   selectedWindow;
130
 
        Window   zoomedWindow;
131
 
        unsigned int lastActiveNum;
132
 
 
133
 
        float zoom;
134
 
 
135
 
        CompScreen::GrabHandle grabIndex;
136
 
 
137
 
        Bool switching;
138
 
        Bool zooming;
139
 
        int  zoomMask;
140
 
 
141
 
        bool moreAdjust;
142
 
 
143
 
        GLfloat mVelocity;
144
 
        GLfloat tVelocity;
145
 
        GLfloat sVelocity;
146
 
 
147
 
        CompWindowList windows;
148
 
 
149
 
        int pos;
150
 
        int move;
151
 
 
152
 
        float translate;
153
 
        float sTranslate;
154
 
 
155
 
        SwitchWindowSelection selection;
156
 
 
157
 
        unsigned int fgColor[4];
158
 
 
159
 
        bool ignoreSwitcher;
160
 
};
161
 
 
162
 
class SwitchWindow :
163
 
    public CompositeWindowInterface,
164
 
    public GLWindowInterface,
165
 
    public PrivateHandler<SwitchWindow,CompWindow>
166
 
{
167
 
    public:
168
 
        SwitchWindow (CompWindow *window) :
169
 
            PrivateHandler<SwitchWindow,CompWindow> (window),
170
 
            window (window),
171
 
            gWindow (GLWindow::get (window)),
172
 
            cWindow (CompositeWindow::get (window)),
173
 
            sScreen (SwitchScreen::get (screen)),
174
 
            gScreen (GLScreen::get (screen))
175
 
        {
176
 
            GLWindowInterface::setHandler (gWindow, false);
177
 
            CompositeWindowInterface::setHandler (cWindow, false);
178
 
 
179
 
            if (sScreen->popupWindow && sScreen->popupWindow == window->id ())
180
 
                gWindow->glPaintSetEnabled (this, true);
181
 
        }
182
 
 
183
 
        bool glPaint (const GLWindowPaintAttrib &, const GLMatrix &,
184
 
                      const CompRegion &, unsigned int);
185
 
 
186
 
        bool damageRect (bool, const CompRect &);
187
 
 
188
 
        bool isSwitchWin ();
189
 
 
190
 
        void paintThumb (const GLWindowPaintAttrib &, const GLMatrix &,
191
 
                         unsigned int, int, int, int, int);
192
 
 
193
 
        CompWindow      *window;
194
 
        GLWindow        *gWindow;
195
 
        CompositeWindow *cWindow;
196
 
        SwitchScreen    *sScreen;
197
 
        GLScreen        *gScreen;
198
 
};
199
 
 
200
 
#define MwmHintsDecorations (1L << 1)
201
 
 
202
 
typedef struct {
203
 
    unsigned long flags;
204
 
    unsigned long functions;
205
 
    unsigned long decorations;
206
 
} MwmHints;
207
 
 
208
 
#define WIDTH  212
209
 
#define HEIGHT 192
210
 
#define SPACE  10
211
 
 
212
 
#define SWITCH_ZOOM 0.1f
213
 
 
214
 
#define BOX_WIDTH 3
215
 
 
216
 
#define ICON_SIZE 64
217
 
 
218
 
#define WINDOW_WIDTH(count) (WIDTH * (count) + (SPACE << 1))
219
 
#define WINDOW_HEIGHT (HEIGHT + (SPACE << 1))
220
 
 
221
 
#define SWITCH_SCREEN(s) \
222
 
    SwitchScreen *ss = SwitchScreen::get (s)
223
 
 
224
 
#define SWITCH_WINDOW(w) \
225
 
    SwitchWindow *sw = SwitchWindow::get (w)
226
 
 
227
 
class SwitchPluginVTable :
228
 
    public CompPlugin::VTableForScreenAndWindow<SwitchScreen, SwitchWindow>
229
 
{
230
 
    public:
231
 
 
232
 
        bool init ();
233
 
 
234
 
        PLUGIN_OPTION_HELPER (SwitchScreen);
235
 
 
236
 
};
237
 
 
238