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 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
; }
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;
75 friend class WindowlistMenu
;
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
;
92 Netclient
* _netclient
;
96 KeyGrabber
* _keyGrabber
;
97 keytree
* _keybindings
;
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 ;
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;