bringing window list menu in, slowly
[bbkeys.git] / src / ScreenHandler.h
blob060e9b3191ebe1a6137e6d4584f2c7b8d16f111a
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 <Netwm.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 Window getRootWindow() const { return _screenInfo.rootWindow(); }
61 inline KeyClient & getKeyClient() const { return * _keyClient; }
62 inline bool isManaged() const { return _managed; }
63 inline const bt::ScreenInfo & getScreenInfo() { return _screenInfo; }
64 inline int screenNumber() const { return _screenNumber; }
66 void initialize();
67 void grabKey(const KeyCode keyCode, const int modifierMask) const;
68 void ungrabKey(const KeyCode keyCode, const int modifierMask) const;
70 const XWindow *lastActiveWindow() const;
72 private:
73 friend class WindowlistMenu;
74 bool _managed;
75 bool _debug;
76 bool _grabbed; // used for keygrab toggle function
77 bool _cycling; // used for window cycling
78 bool _raise_while_cycling;
79 bool _show_cycle_menu;
80 bool _honor_modifiers;
81 std::string _menu_text_justify;
82 unsigned int _workspace_columns;
83 unsigned int _workspace_rows;
85 unsigned int _screenNumber;
86 KeyClient * _keyClient;
87 bt::Netwm * _netwm;
88 Netclient * _netclient;
89 Config * _config;
90 Display * _display;
91 Window _root;
92 KeyGrabber * _keyGrabber;
93 keytree * _keybindings;
94 int _numlockMask;
95 int _scrolllockMask;
96 std::string _wm_name;
97 WindowlistMenu * _windowmenu;
100 unsigned int _num_desktops;
101 unsigned int _active_desktop;
103 const bt::ScreenInfo & _screenInfo;
105 bool careAboutWindow(Window window) const ;
106 XWindow * findWindow(Window window) const ;
107 void p(void);
109 void keyPressEvent (const XKeyEvent * const e) ;
110 void keyReleaseEvent (const XKeyEvent * const e) ;
111 void propertyNotifyEvent(const XPropertyEvent * const e);
112 void updateNumDesktops();
113 void updateActiveDesktop();
114 void updateActiveWindow();
115 void updateClientList();
116 void updateClientListStacking();
118 WindowList & _clients;
119 WindowList::iterator & _active;
120 WindowList::iterator _last_active;
122 bool nothingIsPressed(void) const;
123 bool findSupportingWM();
125 void cycleWindow(unsigned int state, const bool forward, const int increment,
126 const bool allscreens = false,
127 const bool alldesktops = false,
128 const bool sameclass = false,
129 const std::string &classname = "");
130 WindowList getCycleWindowList(unsigned int state, const bool forward, const int increment,
131 const bool allscreens = false,
132 const bool alldesktops = false,
133 const bool sameclass = false,
134 const std::string &classname = "");
135 void cycleWorkspace(const bool forward, const int increment,
136 const bool loop = true) const;
137 void changeWorkspace(const int num) const;
138 void changeWorkspaceVert(const int num) const;
139 void changeWorkspaceHorz(const int num) const;
141 void execCommand(const std::string &cmd) const;
144 #endif