~compiz-team/compiz-plugins-main/oneiric

« back to all changes in this revision

Viewing changes to opacify/src/opacify.h

  • Committer: Sam Spilsbury
  • Date: 2011-09-29 11:34:08 UTC
  • Revision ID: sam.spilsbury@canonical.com-20110929113408-vnew477gska3l802
Sync in changes from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * Compiz Opacify 
 
3
 *
 
4
 * opacify.h
 
5
 *
 
6
 * Copyright (c) 2006 Kristian Lyngstøl <kristian@beryl-project.org>
 
7
 * Ported to Compiz and BCOP usage by Danny Baumann <maniac@beryl-project.org>
 
8
 * Ported to Compiz 0.9 by Sam Spilsbury <smspillaz@gmail.com>
 
9
 *
 
10
 * This program is free software; you can redistribute it and/or
 
11
 * modify it under the terms of the GNU General Public License
 
12
 * as published by the Free Software Foundation; either version 2
 
13
 * of the License, or (at your option) any later version.
 
14
 *
 
15
 * This program is distributed in the hope that it will be useful,
 
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
 * GNU General Public License for more details.
 
19
 *
 
20
 *
 
21
 * Opacify increases opacity on targeted windows and reduces it on
 
22
 * blocking windows, making whatever window you are targeting easily
 
23
 * visible. 
 
24
 *
 
25
 */
 
26
 
 
27
#include <core/core.h>
 
28
#include <core/serialization.h>
 
29
#include <composite/composite.h>
 
30
#include <opengl/opengl.h>
 
31
 
 
32
#include "opacify_options.h"
 
33
 
 
34
/* Size of the Window array storing passive windows. */
 
35
#define MAX_WINDOWS 64
 
36
 
 
37
class OpacifyScreen :
 
38
    public PluginClassHandler <OpacifyScreen, CompScreen>,
 
39
    public PluginStateWriter <OpacifyScreen>,
 
40
    public OpacifyOptions,
 
41
    public ScreenInterface
 
42
{
 
43
    public:
 
44
        OpacifyScreen (CompScreen *);
 
45
        ~OpacifyScreen ();
 
46
 
 
47
        CompositeScreen *cScreen;
 
48
        GLScreen        *gScreen;
 
49
 
 
50
        bool isToggle;
 
51
 
 
52
        CompTimer timeoutHandle;
 
53
 
 
54
        CompWindow *newActive;
 
55
 
 
56
        Window active;
 
57
        std::vector<Window> passive;
 
58
        CompRegion intersect;
 
59
        unsigned short int passiveNum;
 
60
        
 
61
        template <class Archive>
 
62
        void serialize (Archive &ar, const unsigned int version)
 
63
        {
 
64
            ar & isToggle;
 
65
        };
 
66
        
 
67
        void postLoad ();
 
68
 
 
69
        bool justMoved;
 
70
 
 
71
        void
 
72
        handleEvent (XEvent *);
 
73
 
 
74
        void
 
75
        resetOpacity (Window  id);
 
76
 
 
77
        void
 
78
        clearPassive ();
 
79
 
 
80
        int
 
81
        passiveWindows (CompRegion     fRegion);
 
82
 
 
83
        bool
 
84
        handleTimeout ();
 
85
 
 
86
        bool
 
87
        checkDelay ();
 
88
 
 
89
        bool
 
90
        toggle (CompAction         *action,
 
91
                CompAction::State  state,
 
92
                CompOption::Vector options);
 
93
 
 
94
        void
 
95
        optionChanged (CompOption              *option,
 
96
                       OpacifyOptions::Options num);
 
97
                       
 
98
        bool
 
99
        checkStateTimeout ();
 
100
};
 
101
 
 
102
class OpacifyWindow :
 
103
    public PluginClassHandler <OpacifyWindow, CompWindow>,
 
104
    public GLWindowInterface
 
105
{
 
106
    public:
 
107
 
 
108
        OpacifyWindow (CompWindow *);
 
109
 
 
110
        CompWindow      *window;
 
111
        CompositeWindow *cWindow;
 
112
        GLWindow        *gWindow;
 
113
 
 
114
        bool opacified;
 
115
        int opacity;
 
116
 
 
117
        bool
 
118
        glPaint (const GLWindowPaintAttrib &,
 
119
                 const GLMatrix &,
 
120
                 const CompRegion &,
 
121
                 unsigned int);
 
122
 
 
123
        void
 
124
        setOpacity (int fOpacity);
 
125
 
 
126
        void
 
127
        dim ();
 
128
 
 
129
        void
 
130
        handleEnter ();
 
131
 
 
132
 
 
133
 
 
134
};
 
135
 
 
136
#define OPACIFY_SCREEN(s)                                                      \
 
137
    OpacifyScreen *os = OpacifyScreen::get (s);
 
138
 
 
139
#define OPACIFY_WINDOW(w)                                                      \
 
140
    OpacifyWindow *ow = OpacifyWindow::get (w);
 
141
 
 
142
class OpacifyPluginVTable :
 
143
    public CompPlugin::VTableForScreenAndWindow <OpacifyScreen, OpacifyWindow>
 
144
{
 
145
    public:
 
146
 
 
147
        bool init ();
 
148
};