~ubuntu-branches/ubuntu/trusty/fluxbox/trusty-proposed

« back to all changes in this revision

Viewing changes to src/Remember.hh

  • Committer: Bazaar Package Importer
  • Author(s): Dmitry E. Oboukhov
  • Date: 2008-07-01 10:38:14 UTC
  • mfrom: (2.1.12 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080701103814-khx2b6il152x9p93
Tags: 1.0.0+deb1-8
* x-dev has been removed from build-depends (out-of-date package).
* Standards-Version bumped to 3.8.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Remember.hh for Fluxbox Window Manager
2
 
// Copyright (c) 2003 - 2005 Henrik Kinnunen (fluxgen at fluxbox dot org)
3
 
//                     and Simon Bowden    (rathnor at users.sourceforge.net)
4
 
// Copyright (c) 2002 Xavier Brouckaert
5
 
//
6
 
// Permission is hereby granted, free of charge, to any person obtaining a
7
 
// copy of this software and associated documentation files (the "Software"),
8
 
// to deal in the Software without restriction, including without limitation
9
 
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
10
 
// and/or sell copies of the Software, and to permit persons to whom the
11
 
// Software is furnished to do so, subject to the following conditions:
12
 
//
13
 
// The above copyright notice and this permission notice shall be included in
14
 
// all copies or substantial portions of the Software.
15
 
//
16
 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19
 
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
 
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
 
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22
 
// DEALINGS IN THE SOFTWARE.
23
 
 
24
 
// $Id: Remember.hh 4064 2005-06-23 03:10:26Z fluxgen $
25
 
 
26
 
/* Based on the original "Remember patch" by Xavier Brouckaert */
27
 
 
28
 
#ifndef REMEMBER_HH
29
 
#define REMEMBER_HH
30
 
 
31
 
#include "AtomHandler.hh"
32
 
 
33
 
#include <fstream>
34
 
#include <map>
35
 
#include <list>
36
 
#include <string>
37
 
#include <utility>
38
 
 
39
 
class FluxboxWindow;
40
 
class BScreen;
41
 
class WinClient;
42
 
class ClientPattern;
43
 
 
44
 
class Application {
45
 
public:
46
 
    Application(bool grouped);
47
 
    inline void forgetWorkspace() { workspace_remember = false; }
48
 
    inline void forgetHead() { head_remember = false; }
49
 
    inline void forgetDimensions() { dimensions_remember = false; }
50
 
    inline void forgetPosition() { position_remember = false; }
51
 
    inline void forgetShadedstate() { shadedstate_remember = false; }
52
 
    inline void forgetTabstate() { tabstate_remember = false; }
53
 
    inline void forgetDecostate() { decostate_remember = false; }
54
 
    inline void forgetFocusHiddenstate() { focushiddenstate_remember= false; }
55
 
    inline void forgetIconHiddenstate() { iconhiddenstate_remember= false; }
56
 
    inline void forgetStuckstate() { stuckstate_remember = false; }
57
 
    inline void forgetJumpworkspace() { jumpworkspace_remember = false; }
58
 
    inline void forgetLayer() { layer_remember = false; }
59
 
    inline void forgetSaveOnClose() { save_on_close_remember = false; }
60
 
 
61
 
    inline void rememberWorkspace(int ws)
62
 
        { workspace = ws; workspace_remember = true; }
63
 
    inline void rememberHead(int h)
64
 
        { head = h; head_remember = true; }
65
 
    inline void rememberDimensions(int width, int height)
66
 
        { w = width; h = height; dimensions_remember = true; }
67
 
    inline void rememberFocusHiddenstate(bool state)
68
 
        { focushiddenstate= state; focushiddenstate_remember= true; }
69
 
    inline void rememberIconHiddenstate(bool state)
70
 
        { iconhiddenstate= state; iconhiddenstate_remember= true; }
71
 
    inline void rememberPosition(int posx, int posy, unsigned char rfc= 0 )
72
 
        { x = posx; y = posy; refc = rfc; position_remember = true; }
73
 
    inline void rememberShadedstate(bool state)
74
 
        { shadedstate = state; shadedstate_remember = true; }
75
 
    inline void rememberTabstate(bool state)
76
 
        { tabstate = state; tabstate_remember = true; }
77
 
    inline void rememberDecostate(unsigned int state)
78
 
        { decostate = state; decostate_remember = true; }
79
 
    inline void rememberStuckstate(bool state)
80
 
        { stuckstate = state; stuckstate_remember = true; }
81
 
    inline void rememberJumpworkspace(bool state)
82
 
        { jumpworkspace = state; jumpworkspace_remember = true; }
83
 
    inline void rememberLayer(int layernum) 
84
 
        { layer = layernum; layer_remember = true; }
85
 
    inline void rememberSaveOnClose(bool state)
86
 
        { save_on_close = state; save_on_close_remember = true; }
87
 
 
88
 
 
89
 
    bool workspace_remember;
90
 
    unsigned int workspace;
91
 
 
92
 
    bool head_remember;
93
 
    int head;
94
 
 
95
 
    bool dimensions_remember;
96
 
    int w,h; // width, height
97
 
 
98
 
    bool position_remember;
99
 
    int x,y;
100
 
    unsigned char refc;    // referenceCorner-> 0 - upperleft
101
 
                           //                   1 - upperight
102
 
                           //                   2 - lowerleft
103
 
                           //                   3 - lowerright
104
 
 
105
 
    bool shadedstate_remember;
106
 
    bool shadedstate;
107
 
 
108
 
    bool tabstate_remember;
109
 
    bool tabstate;
110
 
 
111
 
    bool decostate_remember;
112
 
    unsigned int decostate;
113
 
 
114
 
    bool stuckstate_remember;
115
 
    bool stuckstate;
116
 
 
117
 
    bool focushiddenstate_remember;
118
 
    bool focushiddenstate;
119
 
 
120
 
    bool iconhiddenstate_remember;
121
 
    bool iconhiddenstate;
122
 
 
123
 
    bool jumpworkspace_remember;
124
 
    bool jumpworkspace;
125
 
 
126
 
    bool layer_remember;
127
 
    int layer;
128
 
 
129
 
    bool save_on_close_remember;
130
 
    bool save_on_close;
131
 
 
132
 
    bool is_grouped;
133
 
    FluxboxWindow *group;
134
 
 
135
 
};
136
 
 
137
 
/**
138
 
 * Class Remember is an atomhandler to avoid interfering with
139
 
 * the main code as much as possible, since we hope that one day
140
 
 * things like this (and maybe toolbar/slit) can become some sort
141
 
 * of modular plugin. Doing this should help give an idea of what
142
 
 * sort of interface abilities we'll need...
143
 
 */
144
 
class Remember : public AtomHandler {
145
 
public:
146
 
    /**
147
 
     * holds which attributes to remember
148
 
     */
149
 
    enum Attribute {
150
 
        REM_DECOSTATE= 0,
151
 
        REM_DIMENSIONS,
152
 
        REM_FOCUSHIDDENSTATE,
153
 
        REM_ICONHIDDENSTATE,
154
 
        REM_JUMPWORKSPACE,
155
 
        REM_LAYER,
156
 
        REM_POSITION,
157
 
        REM_SAVEONCLOSE,
158
 
        REM_SHADEDSTATE,
159
 
        REM_STUCKSTATE,
160
 
        //REM_TABSTATE, ... external tabs disabled atm
161
 
        REM_WORKSPACE,
162
 
        REM_HEAD,
163
 
        REM_LASTATTRIB // not actually used
164
 
    };
165
 
 
166
 
    enum {
167
 
      POS_UPPERLEFT= 0,
168
 
      POS_UPPERRIGHT,
169
 
      POS_LOWERLEFT,
170
 
      POS_LOWERRIGHT,
171
 
      POS_CENTER,
172
 
      POS_WINCENTER
173
 
    };
174
 
 
175
 
 
176
 
 
177
 
    // a "pattern"  to the relevant app
178
 
    // each app exists ONLY for that pattern.
179
 
    // And we need to keep a list of pairs as we want to keep the
180
 
    // applications in the same order as they will be in the apps file
181
 
    typedef std::list< std::pair<ClientPattern *, Application *> > Patterns;
182
 
 
183
 
    // We keep track of which app is assigned to a winclient
184
 
    // particularly useful to update counters etc on windowclose
185
 
    typedef std::map<WinClient *, Application *> Clients;
186
 
 
187
 
    // we have to remember any startups we did so that they are saved again
188
 
    typedef std::list<std::string> Startups;
189
 
 
190
 
    Remember();
191
 
    ~Remember();
192
 
 
193
 
    Application* find(WinClient &winclient);
194
 
    Application* add(WinClient &winclient);
195
 
 
196
 
    void load();
197
 
    void save();
198
 
 
199
 
    bool isRemembered(WinClient &win, Attribute attrib);
200
 
    void rememberAttrib(WinClient &win, Attribute attrib);
201
 
    void forgetAttrib(WinClient &win, Attribute attrib);
202
 
 
203
 
    // Functions relating to AtomHandler
204
 
 
205
 
    // Functions we actually use
206
 
    void setupFrame(FluxboxWindow &win);
207
 
    void setupClient(WinClient &winclient);
208
 
    void updateFrameClose(FluxboxWindow &win);
209
 
    void updateClientClose(WinClient &winclient);
210
 
 
211
 
    void initForScreen(BScreen &screen);
212
 
 
213
 
    // Functions we ignore (zero from AtomHandler)
214
 
    // Leaving here in case they might be useful later
215
 
 
216
 
 
217
 
 
218
 
    void updateFocusedWindow(BScreen &, Window) { }
219
 
    void updateClientList(BScreen &screen) {}
220
 
    void updateWorkspaceNames(BScreen &screen) {}
221
 
    void updateCurrentWorkspace(BScreen &screen) {}
222
 
    void updateWorkspaceCount(BScreen &screen) {}
223
 
    void updateWorkarea(BScreen &) { }
224
 
 
225
 
    void updateWorkspace(FluxboxWindow &win) {}
226
 
    void updateState(FluxboxWindow &win) {}
227
 
    void updateHints(FluxboxWindow &win) {}
228
 
    void updateLayer(FluxboxWindow &win) {}
229
 
 
230
 
    bool checkClientMessage(const XClientMessageEvent &ce, 
231
 
        BScreen * screen, WinClient * const winclient) { return false; }
232
 
    // ignore this
233
 
    bool propertyNotify(WinClient &winclient, Atom the_property) { return false; }
234
 
 
235
 
    static Remember &instance() { return *s_instance; }
236
 
private:
237
 
 
238
 
    // returns number of lines read
239
 
    // optionally can give a line to read before the first (lookahead line)
240
 
    int parseApp(std::ifstream &file, Application &app, std::string *first_line = 0);
241
 
    Patterns m_pats;
242
 
    Clients m_clients;
243
 
 
244
 
    Startups m_startups;
245
 
    static Remember *s_instance;
246
 
};
247
 
 
248
 
#endif // REMEMBER_HH