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>
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.
25 #ifndef SCREENHANDLER_HH
26 #define SCREENHANDLER_HH
36 #include "KeyClient.h"
37 #include "WindowlistMenu.h"
38 #include "KeyGrabber.h"
41 #include "Netclient.h"
44 // the blackbox library
46 #include <EventHandler.hh>
53 class ScreenHandler
: public bt::EventHandler
57 ScreenHandler (KeyClient
* _k
, unsigned int number
);
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
; }
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;
73 friend class WindowlistMenu
;
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
;
88 Netclient
* _netclient
;
92 KeyGrabber
* _keyGrabber
;
93 keytree
* _keybindings
;
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 ;
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;