news download themes documentation links










Remember.hh

00001 // Remember.hh for Fluxbox Window Manager
00002 // Copyright (c) 2002 Xavier Brouckaert
00003 // Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
00004 //                and Simon Bowden    (rathnor at users.sourceforge.net)
00005 //
00006 // Permission is hereby granted, free of charge, to any person obtaining a
00007 // copy of this software and associated documentation files (the "Software"),
00008 // to deal in the Software without restriction, including without limitation
00009 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
00010 // and/or sell copies of the Software, and to permit persons to whom the
00011 // Software is furnished to do so, subject to the following conditions:
00012 //
00013 // The above copyright notice and this permission notice shall be included in
00014 // all copies or substantial portions of the Software.
00015 //
00016 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00017 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00018 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00019 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00020 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00021 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00022 // DEALINGS IN THE SOFTWARE.
00023 
00024 // $Id: Remember.hh,v 1.13 2003/12/11 15:23:14 fluxgen Exp $
00025 
00026 /* Based on the original "Remember patch" by Xavier Brouckaert */
00027 
00028 #ifndef REMEMBER_HH
00029 #define REMEMBER_HH
00030 
00031 #include "AtomHandler.hh"
00032 
00033 #include <fstream>
00034 #include <map>
00035 #include <list>
00036 #include <string>
00037 #include <utility>
00038 
00039 class FluxboxWindow;
00040 class BScreen;
00041 class WinClient;
00042 class ClientPattern;
00043 
00044 class Application {
00045 public:
00046     Application(bool grouped);
00047     inline void forgetWorkspace() { workspace_remember = false; }
00048     inline void forgetDimensions() { dimensions_remember = false; }
00049     inline void forgetPosition() { position_remember = false; }
00050     inline void forgetShadedstate() { shadedstate_remember = false; }
00051     inline void forgetTabstate() { tabstate_remember = false; }
00052     inline void forgetDecostate() { decostate_remember = false; }
00053     inline void forgetStuckstate() { stuckstate_remember = false; }
00054     inline void forgetJumpworkspace() { jumpworkspace_remember = false; }
00055     inline void forgetLayer() { layer_remember = false; }
00056     inline void forgetSaveOnClose() { save_on_close_remember = false; }
00057     
00058     inline void rememberWorkspace(int ws) 
00059         { workspace = ws; workspace_remember = true; }
00060     inline void rememberDimensions(int width, int height) 
00061         { w = width; h = height; dimensions_remember = true; }
00062     inline void rememberPosition(int posx, int posy, unsigned char rfc= 0 )
00063         { x = posx; y = posy; refc = rfc; position_remember = true; }
00064     inline void rememberShadedstate(bool state)
00065         { shadedstate = state; shadedstate_remember = true; }
00066     inline void rememberTabstate(bool state)
00067         { tabstate = state; tabstate_remember = true; }
00068     inline void rememberDecostate(unsigned int state)
00069         { decostate = state; decostate_remember = true; }
00070     inline void rememberStuckstate(bool state)
00071         { stuckstate = state; stuckstate_remember = true; }
00072     inline void rememberJumpworkspace(bool state)
00073         { jumpworkspace = state; jumpworkspace_remember = true; }
00074     inline void rememberLayer(int layernum) 
00075         { layer = layernum; layer_remember = true; }
00076     inline void rememberSaveOnClose(bool state)
00077         { save_on_close = state; save_on_close_remember = true; }
00078 
00079 
00080     bool workspace_remember;
00081     unsigned int workspace;
00082 
00083     bool dimensions_remember;
00084     int w,h; // width, height
00085 
00086     bool position_remember;
00087     int x,y;
00088     unsigned char refc;    // referenceCorner-> 0 - upperleft
00089                            //                   1 - upperight
00090                            //                   2 - lowerleft
00091                            //                   3 - lowerright
00092 
00093     bool shadedstate_remember;
00094     bool shadedstate;
00095 
00096     bool tabstate_remember;
00097     bool tabstate;
00098 
00099     bool decostate_remember;
00100     unsigned int decostate;
00101 
00102     bool stuckstate_remember;
00103     bool stuckstate;
00104 
00105     bool jumpworkspace_remember;
00106     bool jumpworkspace;
00107 
00108     bool layer_remember;
00109     int layer;
00110 
00111     bool save_on_close_remember;
00112     bool save_on_close;
00113 
00114     bool is_grouped;
00115     FluxboxWindow *group;
00116 
00117 };
00118 
00126 class Remember : public AtomHandler {
00127 public:
00131     enum Attribute {
00132         REM_WORKSPACE=0,
00133         REM_DIMENSIONS,
00134         REM_POSITION,
00135         REM_STUCKSTATE,
00136         REM_DECOSTATE,
00137         REM_SHADEDSTATE,
00138         //REM_TABSTATE, ... external tabs disabled atm
00139         REM_LAYER,
00140         REM_JUMPWORKSPACE,
00141         REM_SAVEONCLOSE,
00142         REM_LASTATTRIB // not actually used
00143     };
00144 
00145     enum {
00146       POS_UPPERLEFT= 0,
00147       POS_UPPERRIGHT,
00148       POS_LOWERLEFT,
00149       POS_LOWERRIGHT,
00150       POS_CENTER,
00151       POS_WINCENTER
00152     };
00153 
00154 
00155 
00156     // a "pattern"  to the relevant app
00157     // each app exists ONLY for that pattern.
00158     // And we need to keep a list of pairs as we want to keep the
00159     // applications in the same order as they will be in the apps file
00160     typedef std::list< std::pair<ClientPattern *, Application *> > Patterns;
00161 
00162     // We keep track of which app is assigned to a winclient
00163     // particularly useful to update counters etc on windowclose
00164     typedef std::map<WinClient *, Application *> Clients;
00165     
00166     // we have to remember any startups we did so that they are saved again
00167     typedef std::list<std::string> Startups;
00168 
00169     Remember();
00170     ~Remember();
00171 
00172     Application* find(WinClient &winclient);
00173     Application* add(WinClient &winclient);
00174 
00175     void load();
00176     void save();
00177 
00178     bool isRemembered(WinClient &win, Attribute attrib);
00179     void rememberAttrib(WinClient &win, Attribute attrib);
00180     void forgetAttrib(WinClient &win, Attribute attrib);
00181 
00182     // Functions relating to AtomHandler
00183     
00184     // Functions we actually use
00185     void setupFrame(FluxboxWindow &win);
00186     void setupClient(WinClient &winclient);
00187     void updateFrameClose(FluxboxWindow &win);
00188     void updateClientClose(WinClient &winclient);
00189 
00190     // Functions we ignore (zero from AtomHandler)
00191     // Leaving here in case they might be useful later
00192 
00193     void initForScreen(BScreen &screen) {}
00194 
00195     void updateClientList(BScreen &screen) {}
00196     void updateWorkspaceNames(BScreen &screen) {}
00197     void updateCurrentWorkspace(BScreen &screen) {}
00198     void updateWorkspaceCount(BScreen &screen) {}
00199 
00200     void updateWorkspace(FluxboxWindow &win) {}
00201     void updateState(FluxboxWindow &win) {}
00202     void updateHints(FluxboxWindow &win) {}
00203     void updateLayer(FluxboxWindow &win) {}
00204 
00205     bool checkClientMessage(const XClientMessageEvent &ce, 
00206         BScreen * screen, WinClient * const winclient) { return false; }
00207     // ignore this
00208     bool propertyNotify(WinClient &winclient, Atom the_property) { return false; }
00209 private:
00210 
00211     // returns number of lines read
00212     // optionally can give a line to read before the first (lookahead line)
00213     int parseApp(std::ifstream &file, Application &app, std::string *first_line = 0);
00214     Patterns m_pats;
00215     Clients m_clients;
00216 
00217     Startups m_startups;
00218 
00219 };
00220 
00221 #endif // REMEMBER_HH

Fluxbox CVS-Jan-2003




      



Got comments about the page? Send them to webmaster.
If you have general Fluxbox related questions ask them on our irc channel or mailing lists.

Show Source








Designed by aLEczapKA