adding auto-config-checker timer, woot
[bbkeys.git] / src / KeyClient.h
blob59b555228c5d0285b75663de6b8cdca6b88ae983
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 // -- KeyClient.h --
3 // Copyright (c) 2001 - 2003 Jason 'vanRijn' Kasper <vR at movingparts dot net>
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a
6 // copy of this software and associated documentation files (the "Software"),
7 // to deal in the Software without restriction, including without limitation
8 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 // and/or sell copies of the Software, and to permit persons to whom the
10 // Software is furnished to do so, subject to the following conditions:
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 // DEALINGS IN THE SOFTWARE.
23 // E_O_H_VR
25 #ifndef KEYCLIENT_HH
26 #define KEYCLIENT_HH
28 #include "FileTokenizer.h"
29 #include "ConfigOptions.h"
30 #include "actions.hh"
31 #include "keytree.hh"
32 #include "window.hh"
33 #include "Config.h"
34 #include "ScreenHandler.h"
35 #include "KeyGrabber.h"
36 #include "Netclient.h"
37 #include "main.h"
39 #include <string>
40 #include <stdio.h>
42 // the blackbox library
43 #include <Application.hh>
44 #include <Util.hh>
45 #include <i18n.hh>
46 #include <Resource.hh>
47 #include <Timer.hh>
50 class ScreenHandler;
51 class keytree;
53 class KeyClient : public bt::Application, public bt::TimeoutHandler
56 public:
57 KeyClient (int argc, char **argv,
58 Config & config, std::string display);
59 ~KeyClient () ;
60 keytree * getKeybindings () {return _keybindings;}
61 inline Netclient * getNetclient() { return _netclient; }
62 inline Config * getConfig() { return &_config; }
63 inline KeyGrabber * getKeyGrabber() { return _keyGrabber; }
64 inline bt::Application & getMainApplication()
65 { return dynamic_cast<bt::Application&> (* this); }
66 void cycleScreen(int current, bool forward) const;
68 void getLockModifiers(int &numlockMask, int &scrolllockMask) const {
69 numlockMask = numLockMask();
70 scrolllockMask = scrollLockMask();
73 WindowList& clientsList() { return _clients; }
74 WindowList::iterator& activeWindow() { return _active; }
75 virtual void timeout(bt::Timer *timer);
77 private:
78 int _argc;
79 char **_argv;
80 keytree *_keybindings;
81 std::string _configFileName;
82 Config & _config;
83 KeywordMap _keywordMap;
84 bt::Netwm * _netwm;
85 Netclient * _netclient;
86 Display * _display;
87 KeyGrabber * _keyGrabber;
88 bool _debug;
90 typedef std::vector<ScreenHandler*> ScreenList;
91 ScreenList screenList;
93 void handleConfigFile();
95 void initKeywords(KeywordMap &);
96 void reconfigure();
97 void initialize();
98 void setKeybindings(FileTokenizer &);
100 bool process_signal(int sig);
101 void process_event(XEvent *e);
103 WindowList _clients;
104 WindowList::iterator _active;
106 bt::Timer *config_check_timer;
107 long _autoConfigCheckTimeout;
108 bool _autoConfig;
109 void checkConfigFile();
110 time_t _last_time_config_changed;
113 #endif