- changing MaxInstructions to 100 for cthulhain (crazy nut) =:)
[bbkeys.git] / src / bbkeys.hh
blob33720f62b9f8362ab864c326dbf8663840b61429
1 // bbkeys.hh for bbkeys - Ye Olde Keystroke Grabber for Blackbox
2 //
3 // Copyright (c) 1998-1999 by John Kennis, jkennis@chello.nl
4 // Copyright (c) 1999-2001 by Jason Kasper (vanRijn) vR@movingparts.net
5 // Copyright (c) 2001 by Ben Jansens <xor@orodu.net>
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 2 of the License, or
10 // (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 // (See the included file COPYING / GPL-2.0)
23 // $Id$
25 #ifndef __BBKEYS_HH
26 #define __BBKEYS_HH
28 #include "grab_defs.hh" // grab* definitions
29 #include "Basewindow.hh"
30 #include "resource.hh"
31 #include "wminterface.hh"
32 #include "stackmenu.hh"
34 #include <X11/Xlib.h>
35 #include <X11/keysym.h>
37 #define MaxInstructions 100
38 #define RCFILE ".bbkeysrc"
40 typedef struct {
41 unsigned long modMask;
42 KeyCode keycode;
43 int action;
44 char *execCommand;
45 } KEY_ACTION_MAP;
47 typedef struct {
48 int instructCount;
49 KEY_ACTION_MAP KeyMap[MaxInstructions];
50 } KEY_GRAB_INSTRUCTION;
52 struct PIXMAP {
53 Pixmap frame;
54 Pixmap window;
55 // Pixmap focusedDesktop;
56 // Pixmap focusedWindow;
57 // Pixmap desktop;
59 Pixmap pix_title;
60 Pixmap pix_back;
61 Pixmap pix_closeBtn;
62 Pixmap pix_configBtn;
63 Pixmap pix_pressedBtn;
66 struct GEOM {
67 int height;
68 int width;
69 int x;
70 int y;
73 struct WindowList {
74 Window win;
75 bool iconic;
76 bool shaded;
77 bool sticky;
78 int desktop;
81 struct DesktopList {
82 int number;
85 class Stackmenu;
87 class ToolWindow : public Basewindow, public TimeoutHandler {
88 public:
89 ToolWindow(int argc,char **argv,struct CMDOPTIONS *);
90 ~ToolWindow(void);
92 void reconfigure(void);
93 void execCommand(char *);
95 // functions for translation of grab information
96 char *index_to_name(int);
97 int translateAction(char *);
98 int translateModifier(char *);
100 // functions for handling/grabbing keys
101 void loadKeygrabs(void);
102 void setKeygrabs(void);
103 void activateKeygrabs(void);
104 void getOffendingModifiers(void);
105 void wHackedGrabKey(int,unsigned int,Window,Bool,int,int);
106 void x_reset_modifier_mapping(Display *);
107 void InitializeModifiers(void);
109 // functions for maintaining the desktop list
110 void addDesktop(void);
111 void removeDesktop(int);
112 void focusDesktop(int);
113 void setDesktopCount(int); // this should only be called during the
114 // initialization stage
116 // functions for maintaining the window list
117 void addWindow(Window,int);
118 void removeWindow(Window);
119 void focusWindow(Window);
120 void moveWinToDesktop(Window,int);
121 void windowAttributeChange(Window); // called when attributes for a window
122 // have changed, such as sticky
123 void cycleWindowFocus(bool);
125 // functions for modifying windows
126 void raiseWindow(Window);
127 void lowerWindow(Window);
129 // functions for the Linear window cycling style
130 void add_linear(WindowList *);
131 void cycle_linear(bool);
133 // functions for the Stack window cycling style
134 void add_stack(WindowList *);
135 void cycle_stack(bool);
136 void focus_stack(Window);
137 void saveMenuSearch(Window,Basemenu *);
138 void removeMenuSearch(Window);
140 // functions which return information
141 inline int getCurrentDesktopNr(void) {
142 return current_desktop?current_desktop->number:-1;
144 inline Window getFocusWindow() { return focus_window; }
145 inline int getDesktopCount(void) { return desktop_count; }
146 inline Resource *getResource() { return resource; }
147 inline GC getMenuTitleGC(void) {return NULL;/*menuTitleGC;*/}
148 inline GC getMenuHiBGGC(void) {return menuHiBGGC;}
149 inline GC getMenuHiGC(void) {return menuHiGC; }
150 inline GC getMenuFrameGC(void) {return menuFrameGC;}
151 inline bool getDoingCycling(void) { return doingCycling; }
152 inline bool getShowAllWorkspaces(void) { return showAllWorkspaces; }
153 unsigned int KeycodeToModmask(unsigned int code);
155 // void setNETInit(void) { /*wm_init = True;*/ }
157 protected:
158 // functions for dealing with the bbkeys window
159 void MakeWindow(bool);
160 void Redraw(void);
161 virtual void process_event(XEvent *);
162 virtual void CheckConfig(void);
163 void timeout(void);
164 void addSticky(WindowList *);
165 void removeSticky(const Window,const int);
166 inline void setCycling(bool f) { doingCycling = f; }
167 inline void setShowAllWorkspaces(bool f) { showAllWorkspaces = f; }
169 private:
170 XGCValues gcv; // font stuff
171 GC frameGC;
173 Window win_frame; // windows for the tool
174 Window win_title;
175 Window win_back;
176 Window win_closeBtn;
177 Window win_configBtn;
178 GEOM frame; // size/pos data for the windows and label
179 GEOM label;
180 GEOM geom_title;
181 GEOM geom_back;
182 GEOM geom_closeBtn;
183 GEOM geom_configBtn;
184 PIXMAP pixmap; // pixmaps for all of the windows
185 BTimer *timer; // window background drawing timer
186 // bool raised; // window is raised above all others
188 KEY_GRAB_INSTRUCTION grabSet; // key grab/handling vars
189 int actionList[NUM_GRABS];
190 unsigned int ValidModMask;
191 unsigned int _NumLockMask;
192 unsigned int _ScrollLockMask;
194 char *bbkeys_rcfile; // resource file
195 time_t bbkeys_rcTime; // time used for autoloading resource file
196 Resource *resource; // resource data
198 int desktop_count; // the number of desktops
199 DesktopList *current_desktop; // the currently active desktop
200 LinkedList<WindowList> *windowList; // list of all windows
201 LinkedList<DesktopList> *desktopList; // list of all desktop windows
202 Window focus_window; // window which has the focus
204 WMInterface *wminterface; // interface for communicating with the
205 // window manager
207 Stackmenu *stackMenu; // variables for the stack cycling style menu
208 bool doingCycling; // are we in the middle of a stacked cycle?
209 bool showAllWorkspaces;
210 Window menuWin;
211 GC menuGC;
212 GC menuHiBGGC;
213 GC menuHiGC;
214 GC menuFrameGC;
216 friend class Stackmenu;
217 void p();
220 #endif /* __BBKEYS_HH */