add 'bootstrap' script
[bbkeys.git] / src / ScreenHandler.h
blobd09d30bc953069ff3c2db0cd1eb9a5dacb4d54fe
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 // -- ScreenHandler.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 SCREENHANDLER_HH
26 #define SCREENHANDLER_HH
28 extern "C" {
29 #include <X11/Xlib.h>
32 #include <list>
33 #include <iostream>
34 #include <string>
36 #include "KeyClient.h"
37 #include "WindowlistMenu.h"
38 #include "KeyGrabber.h"
39 #include "Config.h"
40 #include "keytree.hh"
41 #include "Netclient.h"
42 #include "window.hh"
44 // the blackbox library
45 #include <Display.hh>
46 #include <EventHandler.hh>
47 #include <EWMH.hh>
49 class KeyClient;
50 class WindowlistMenu;
51 class keytree;
53 class ScreenHandler : public bt::EventHandler
56 public:
57 ScreenHandler (KeyClient * _k, unsigned int number);
58 ~ScreenHandler () ;
59 inline unsigned int getScreenNumber() const { return _screenNumber; }
60 inline unsigned int getDesktopNumber() const { return _active_desktop; }
61 void focusWindow(const XWindow * win);
62 bt::ustring getDesktopName(unsigned int desktopNbr) const;
63 inline Window getRootWindow() const { return _screenInfo.rootWindow(); }
64 inline KeyClient & getKeyClient() const { return * _keyClient; }
65 inline bool isManaged() const { return _managed; }
66 inline const bt::ScreenInfo & getScreenInfo() { return _screenInfo; }
68 void initialize();
69 bool grabKey(const KeyCode keyCode, const int modifierMask) const;
70 bool ungrabKey(const KeyCode keyCode, const int modifierMask) const;
72 const XWindow *lastActiveWindow() const;
74 private:
75 friend class WindowlistMenu;
76 bool _managed;
77 bool _debug;
78 bool _grabbed; // used for keygrab toggle function
79 bool _cycling; // used for window cycling
80 bool _raise_while_cycling;
81 bool _show_cycle_menu;
82 bool _honor_modifiers;
83 bool _follow_window_on_send;
84 bool _include_iconified_windows_in_cycle;
85 std::string _menu_text_justify;
86 unsigned int _workspace_columns;
87 unsigned int _workspace_rows;
89 unsigned int _screenNumber;
90 KeyClient * _keyClient;
91 bt::EWMH * _ewmh;
92 Netclient * _netclient;
93 Config * _config;
94 Display * _display;
95 Window _root;
96 KeyGrabber * _keyGrabber;
97 keytree * _keybindings;
98 int _numlockMask;
99 int _scrolllockMask;
100 std::string _wm_name;
101 WindowlistMenu * _windowmenu;
104 unsigned int _num_desktops;
105 unsigned int _active_desktop;
106 std::vector<bt::ustring> _desktop_names;
109 const bt::ScreenInfo & _screenInfo;
111 bool careAboutWindow(Window window) const ;
112 XWindow * findWindow(Window window) const ;
113 void p(void);
115 void keyPressEvent (const XKeyEvent * const e) ;
116 void keyReleaseEvent (const XKeyEvent * const e) ;
117 void propertyNotifyEvent(const XPropertyEvent * const e);
118 void updateNumDesktops();
119 void updateDesktopNames();
120 void updateActiveDesktop();
121 void updateActiveWindow();
122 void updateClientList();
123 void updateClientListStacking();
125 WindowList & _clients;
126 WindowList::iterator & _active;
127 WindowList::iterator _last_active;
129 bool nothingIsPressed(void) const;
130 bool findSupportingWM();
132 void cycleWindow(unsigned int state, const bool forward, const int increment,
133 const bool allscreens = false,
134 const bool alldesktops = false,
135 const bool sameclass = false,
136 const std::string &classname = "");
137 WindowList getCycleWindowList(unsigned int state, const bool forward, const int increment,
138 const bool allscreens = false,
139 const bool alldesktops = false,
140 const bool sameclass = false,
141 const std::string &classname = "");
142 void cycleWorkspace(const bool forward, const int increment,
143 const bool loop = true) const;
144 void changeWorkspace(const int num) const;
145 void changeWorkspaceVert(const int num) const;
146 void changeWorkspaceHorz(const int num) const;
148 void execCommand(const std::string &cmd) const;
151 #endif