~didrocks/unity/fixes-natty-finale

« back to all changes in this revision

Viewing changes to utouch/unity-mt-grab-handles/src/unity-mt-grab-handles.h

  • Committer: Sam Spilsbury
  • Date: 2011-02-28 17:38:48 UTC
  • mto: This revision was merged to the branch mainline in revision 903.
  • Revision ID: sam.spilsbury@canonical.com-20110228173848-stetnb02rtowg7ur
Add mt grab handles

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2011 Canonical Ltd
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License version 3 as
 
6
 * published by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
 
17
 */
 
18
 
 
19
 
 
20
#include <core/core.h>
 
21
#include <composite/composite.h>
 
22
#include <opengl/opengl.h>
 
23
 
 
24
#include <core/atoms.h>
 
25
 
 
26
#include "unitymtgrabhandles_options.h"
 
27
 
 
28
namespace Unity
 
29
{
 
30
    namespace MT
 
31
    {
 
32
        typedef std::pair <GLTexture::List, CompSize> TextureSize;
 
33
        typedef std::pair <GLTexture::List *, CompRect *> TextureLayout;
 
34
 
 
35
 
 
36
        class GrabHandle :
 
37
            public CompRect
 
38
        {
 
39
            public:
 
40
 
 
41
                GrabHandle (TextureSize *texture, Window owner, unsigned int id);
 
42
                ~GrabHandle ();
 
43
 
 
44
                void handleButtonPress (XButtonEvent *ev);
 
45
                void reposition (CompPoint *p, bool);
 
46
 
 
47
                void show ();
 
48
                void hide ();
 
49
 
 
50
                TextureLayout layout ();
 
51
 
 
52
            private:
 
53
 
 
54
                Window          mIpw;
 
55
                Window          mOwner;
 
56
                TextureSize     *mTexture;
 
57
                unsigned int    mId;
 
58
        };
 
59
 
 
60
        class GrabHandleGroup :
 
61
            public std::vector <Unity::MT::GrabHandle>
 
62
        {
 
63
            public:
 
64
 
 
65
                GrabHandleGroup (Window owner);
 
66
                ~GrabHandleGroup ();
 
67
 
 
68
                void relayout (const CompRect &, bool);
 
69
                void restack ();
 
70
 
 
71
                bool visible ();
 
72
                bool animate (unsigned int);
 
73
                bool needsAnimate ();
 
74
 
 
75
                int opacity ();
 
76
 
 
77
                void hide ();
 
78
                void show ();
 
79
 
 
80
                std::vector <TextureLayout> layout ();
 
81
 
 
82
            private:
 
83
 
 
84
                typedef enum _state {
 
85
                    FADE_IN = 1,
 
86
                    FADE_OUT,
 
87
                    NONE
 
88
                } State;
 
89
 
 
90
                State  mState;
 
91
                int    mOpacity;
 
92
 
 
93
                bool mMoreAnimate;
 
94
        };
 
95
    };
 
96
};
 
97
 
 
98
class UnityMTGrabHandlesScreen :
 
99
    public PluginClassHandler <UnityMTGrabHandlesScreen, CompScreen>,
 
100
    public ScreenInterface,
 
101
    public CompositeScreenInterface,
 
102
    public GLScreenInterface,
 
103
    public UnitymtgrabhandlesOptions
 
104
{
 
105
    public:
 
106
 
 
107
        UnityMTGrabHandlesScreen (CompScreen *);
 
108
        ~UnityMTGrabHandlesScreen ();
 
109
 
 
110
        CompositeScreen *cScreen;
 
111
        GLScreen        *gScreen;
 
112
 
 
113
    public:
 
114
 
 
115
        void handleEvent (XEvent *);
 
116
 
 
117
        bool showHandles (CompAction         *action,
 
118
                          CompAction::State  state,
 
119
                          CompOption::Vector &options);
 
120
 
 
121
        void addHandles (Unity::MT::GrabHandleGroup *handles);
 
122
        void removeHandles (Unity::MT::GrabHandleGroup *handles);
 
123
 
 
124
        void addHandleWindow (Unity::MT::GrabHandle *, Window);
 
125
        void removeHandleWindow (Window);
 
126
 
 
127
        void preparePaint (int);
 
128
        void donePaint ();
 
129
 
 
130
        std::vector <Unity::MT::TextureSize>  & textures () { return mHandleTextures; }
 
131
 
 
132
    private:
 
133
 
 
134
        std::list <Unity::MT::GrabHandleGroup *> mGrabHandles;
 
135
        std::vector <Unity::MT::TextureSize> mHandleTextures;
 
136
 
 
137
        std::map <Window, Unity::MT::GrabHandle *> mInputHandles;
 
138
        CompWindowVector                                   mLastClientListStacking;
 
139
        Atom                                    mCompResizeWindowAtom;
 
140
 
 
141
        bool                                    mMoreAnimate;
 
142
};
 
143
 
 
144
#define UMTGH_SCREEN(screen)                                                  \
 
145
    UnityMTGrabHandlesScreen *us = UnityMTGrabHandlesScreen::get (screen)
 
146
 
 
147
class UnityMTGrabHandlesWindow :
 
148
    public PluginClassHandler <UnityMTGrabHandlesWindow, CompWindow>,
 
149
    public WindowInterface,
 
150
    public CompositeWindowInterface,
 
151
    public GLWindowInterface
 
152
{
 
153
    public:
 
154
 
 
155
        UnityMTGrabHandlesWindow (CompWindow *);
 
156
        ~UnityMTGrabHandlesWindow ();
 
157
 
 
158
        CompWindow      *window;
 
159
        CompositeWindow *cWindow;
 
160
        GLWindow        *gWindow;
 
161
 
 
162
    public:
 
163
 
 
164
        void grabNotify (int, int, unsigned int, unsigned int);
 
165
        void ungrabNotify ();
 
166
 
 
167
        void relayout (const CompRect &, bool);
 
168
 
 
169
        void getOutputExtents (CompWindowExtents &output);
 
170
 
 
171
        void moveNotify (int dx, int dy, bool immediate);
 
172
 
 
173
        bool glDraw (const GLMatrix &,
 
174
                     GLFragment::Attrib &,
 
175
                     const CompRegion &,
 
176
                     unsigned int);
 
177
 
 
178
        void    hideHandles ();
 
179
        void    showHandles ();
 
180
        void    restackHandles ();
 
181
 
 
182
    private:
 
183
 
 
184
        Unity::MT::GrabHandleGroup *mHandles;
 
185
};
 
186
 
 
187
#define UMTGH_WINDOW(window)                                                  \
 
188
    UnityMTGrabHandlesWindow *uw = UnityMTGrabHandlesWindow::get (window)
 
189
 
 
190
class UnityMTGrabHandlesPluginVTable :
 
191
    public CompPlugin::VTableForScreenAndWindow <UnityMTGrabHandlesScreen,
 
192
                                                 UnityMTGrabHandlesWindow>
 
193
{
 
194
    public:
 
195
 
 
196
        bool init ();
 
197
};