~lbrulet-8/compiz-plugins-main/fix-876591

« back to all changes in this revision

Viewing changes to staticswitcher/src/staticswitcher.h

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2011-02-24 17:34:18 UTC
  • Revision ID: james.westby@ubuntu.com-20110224173418-b81hfllshqpciq6n
Tags: upstream-0.9.4
ImportĀ upstreamĀ versionĀ 0.9.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *
 
3
 * Compiz application switcher plugin
 
4
 *
 
5
 * staticswitcher.h
 
6
 *
 
7
 * Copyright : (C) 2008 by Danny Baumann
 
8
 * E-mail    : maniac@compiz-fusion.org
 
9
 *
 
10
 * Based on switcher.c:
 
11
 * Copyright : (C) 2007 David Reveman
 
12
 * E-mail    : davidr@novell.com
 
13
 *
 
14
 * This program is free software; you can redistribute it and/or
 
15
 * modify it under the terms of the GNU General Public License
 
16
 * as published by the Free Software Foundation; either version 2
 
17
 * of the License, or (at your option) any later version.
 
18
 *
 
19
 * This program is distributed in the hope that it will be useful,
 
20
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
22
 * GNU General Public License for more details.
 
23
 *
 
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
#include <X11/Xatom.h>
 
33
 
 
34
#include <compiztoolbox/compiztoolbox.h>
 
35
 
 
36
#include <core/pluginclasshandler.h>
 
37
 
 
38
#include "staticswitcher_options.h"
 
39
 
 
40
class StaticSwitchScreen :
 
41
    public BaseSwitchScreen,
 
42
    public ScreenInterface,
 
43
    public CompositeScreenInterface,
 
44
    public GLScreenInterface,
 
45
    public PluginClassHandler<StaticSwitchScreen,CompScreen>,
 
46
    public StaticswitcherOptions
 
47
{
 
48
    public:
 
49
        StaticSwitchScreen (CompScreen *screen);
 
50
        ~StaticSwitchScreen ();
 
51
 
 
52
        void preparePaint (int);
 
53
        void donePaint ();
 
54
 
 
55
        bool glPaintOutput (const GLScreenPaintAttrib &,
 
56
                            const GLMatrix &, const CompRegion &,
 
57
                            CompOutput *, unsigned int);
 
58
 
 
59
        void updatePopupWindow ();
 
60
        void updateWindowList ();
 
61
        void createWindowList ();
 
62
        bool getPaintRectangle (CompWindow *w,
 
63
                                CompRect   &rect,
 
64
                                int        *opacity);
 
65
        void doWindowDamage (CompWindow *w);
 
66
        void handleSelectionChange (bool toNext, int nextIdx);
 
67
        void createPopup ();
 
68
        bool showPopup ();
 
69
        Cursor getCursor (bool mouseSelectOn);
 
70
        void initiate (SwitchWindowSelection selection,
 
71
                       bool                  shouldShowPopup);
 
72
        void windowRemove (CompWindow *w);
 
73
        int getRowXOffset (int y);
 
74
        void getWindowPosition (unsigned int index,
 
75
                                int          *x,
 
76
                                int          *y);
 
77
        CompWindow *findWindowAt (int x,
 
78
                                  int y);
 
79
        void handleEvent (XEvent *event);
 
80
        bool adjustVelocity ();
 
81
        void paintRect (CompRect &box,
 
82
                        int offset,
 
83
                        unsigned short *color,
 
84
                        int opacity);
 
85
        void paintSelectionRect (int          x,
 
86
                                 int          y,
 
87
                                 float        dx,
 
88
                                 float        dy,
 
89
                                 unsigned int opacity);
 
90
        void getMinimizedAndMatch (bool &minimizedOption,
 
91
                                   CompMatch *&match);
 
92
        bool getMipmap ();
 
93
 
 
94
        Window    lastActiveWindow;
 
95
 
 
96
        CompTimer popupDelayTimer;
 
97
 
 
98
        Window clientLeader;
 
99
 
 
100
        int previewWidth;
 
101
        int previewHeight;
 
102
        int previewBorder;
 
103
        int xCount;
 
104
 
 
105
        bool switching;
 
106
 
 
107
        GLfloat mVelocity;
 
108
 
 
109
        float pos;
 
110
        float move;
 
111
 
 
112
        bool mouseSelect;
 
113
};
 
114
 
 
115
class StaticSwitchWindow :
 
116
    public BaseSwitchWindow,
 
117
    public CompositeWindowInterface,
 
118
    public GLWindowInterface,
 
119
    public PluginClassHandler<StaticSwitchWindow,CompWindow>
 
120
{
 
121
    public:
 
122
        StaticSwitchWindow (CompWindow *window);
 
123
 
 
124
        bool isSwitchWin (bool removing = false);
 
125
        bool damageRect (bool initial, const CompRect &rect);
 
126
 
 
127
        bool glPaint (const GLWindowPaintAttrib &, const GLMatrix &,
 
128
                      const CompRegion &, unsigned int);
 
129
 
 
130
        void paintThumb (const GLWindowPaintAttrib &, const GLMatrix &,
 
131
                         unsigned int, int, int);
 
132
        void updateIconTexturedWindow (GLWindowPaintAttrib  &sAttrib,
 
133
                                       int                  &wx,
 
134
                                       int                  &wy,
 
135
                                       int                  x,
 
136
                                       int                  y,
 
137
                                       GLTexture            *icon);
 
138
        void updateIconNontexturedWindow (GLWindowPaintAttrib  &sAttrib,
 
139
                                          int                  &wx,
 
140
                                          int                  &wy,
 
141
                                          float                &width,
 
142
                                          float                &height,
 
143
                                          int                  x,
 
144
                                          int                  y,
 
145
                                          GLTexture            *icon);
 
146
        void updateIconPos (int   &wx,
 
147
                            int   &wy,
 
148
                            int   x,
 
149
                            int   y,
 
150
                            float width,
 
151
                            float height);
 
152
 
 
153
        IconMode getIconMode ();
 
154
 
 
155
        StaticSwitchScreen    *sScreen;
 
156
};
 
157
 
 
158
#define MAX_ICON_SIZE 256
 
159
 
 
160
#define PREVIEWSIZE 150
 
161
#define BORDER 10
 
162
 
 
163
#define SWITCH_SCREEN(s) \
 
164
    StaticSwitchScreen *ss = StaticSwitchScreen::get (s)
 
165
 
 
166
#define SWITCH_WINDOW(w) \
 
167
    StaticSwitchWindow *sw = StaticSwitchWindow::get (w)
 
168
 
 
169
class StaticSwitchPluginVTable :
 
170
    public CompPlugin::VTableForScreenAndWindow<StaticSwitchScreen, StaticSwitchWindow>
 
171
{
 
172
    public:
 
173
 
 
174
        bool init ();
 
175
};
 
176