add 'bootstrap' script
[bbkeys.git] / src / KeyClient.h
blob53681e450c6fe073055887e6fbcae9121fb43b72
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 <Resource.hh>
46 #include <Timer.hh>
49 class ScreenHandler;
50 class keytree;
52 class KeyClient : public bt::Application, public bt::TimeoutHandler
55 public:
56 KeyClient (int argc, char **argv,
57 Config & config, std::string display);
58 ~KeyClient () ;
59 keytree * getKeybindings () {return _keybindings;}
60 inline Netclient * getNetclient() { return _netclient; }
61 inline Config * getConfig() { return &_config; }
62 inline KeyGrabber * getKeyGrabber() { return _keyGrabber; }
63 inline bt::Application & getMainApplication()
64 { return dynamic_cast<bt::Application&> (* this); }
65 void cycleScreen(int current, bool forward) const;
67 void getLockModifiers(int &numlockMask, int &scrolllockMask) const {
68 numlockMask = numLockMask();
69 scrolllockMask = scrollLockMask();
72 WindowList& clientsList() { return _clients; }
73 WindowList::iterator& activeWindow() { return _active; }
74 virtual void timeout(bt::Timer *timer);
76 private:
77 int _argc;
78 char **_argv;
79 keytree *_keybindings;
80 std::string _configFileName;
81 Config & _config;
82 KeywordMap _keywordMap;
83 bt::EWMH * _ewmh;
84 Netclient * _netclient;
85 Display * _display;
86 KeyGrabber * _keyGrabber;
87 bool _debug;
89 typedef std::vector<ScreenHandler*> ScreenList;
90 ScreenList screenList;
92 void handleConfigFile();
94 void initKeywords(KeywordMap &);
95 void reconfigure();
96 void initialize();
97 void setKeybindings(FileTokenizer &);
99 bool process_signal(int sig);
100 void process_event(XEvent *e);
102 WindowList _clients;
103 WindowList::iterator _active;
105 bt::Timer *config_check_timer;
106 long _autoConfigCheckTimeout;
107 bool _autoConfig;
108 void checkConfigFile();
109 time_t _last_time_config_changed;
112 #endif