1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
3 // Copyright (c) 2001 - 2003 Jason 'vanRijn' Kasper <vR at movingparts dot net>
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.
28 #include "FileTokenizer.h"
29 #include "ConfigOptions.h"
34 #include "ScreenHandler.h"
35 #include "KeyGrabber.h"
36 #include "Netclient.h"
42 // the blackbox library
43 #include <Application.hh>
45 #include <Resource.hh>
52 class KeyClient
: public bt::Application
, public bt::TimeoutHandler
56 KeyClient (int argc
, char **argv
,
57 Config
& config
, std::string display
);
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
);
79 keytree
*_keybindings
;
80 std::string _configFileName
;
82 KeywordMap _keywordMap
;
84 Netclient
* _netclient
;
86 KeyGrabber
* _keyGrabber
;
89 typedef std::vector
<ScreenHandler
*> ScreenList
;
90 ScreenList screenList
;
92 void handleConfigFile();
94 void initKeywords(KeywordMap
&);
97 void setKeybindings(FileTokenizer
&);
99 bool process_signal(int sig
);
100 void process_event(XEvent
*e
);
103 WindowList::iterator _active
;
105 bt::Timer
*config_check_timer
;
106 long _autoConfigCheckTimeout
;
108 void checkConfigFile();
109 time_t _last_time_config_changed
;