fixing parse error in execcommand
[bbkeys.git] / src / bbkeys.hh
blobdc450068b9f65cc4dbab2bfadbab26f4fa60f297
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 extern "C" {
29 #include <X11/Xlib.h>
30 #include <X11/keysym.h>
33 #include "grab_defs.hh" // grab* definitions
34 #include "Basewindow.hh"
35 #include "Timer.hh"
37 class Stackmenu;
38 class Resource;
39 class WMInterface;
40 class Basemenu;
42 #define MaxInstructions 100
43 #define RCFILE ".bbkeysrc"
45 typedef struct {
46 unsigned long modMask;
47 KeyCode keycode;
48 int action;
49 char *execCommand;
50 } KEY_ACTION_MAP;
52 typedef struct {
53 int instructCount;
54 KEY_ACTION_MAP KeyMap[MaxInstructions];
55 } KEY_GRAB_INSTRUCTION;
57 struct PIXMAP {
58 Pixmap frame;
59 Pixmap window;
60 // Pixmap focusedDesktop;
61 // Pixmap focusedWindow;
62 // Pixmap desktop;
64 Pixmap pix_title;
65 Pixmap pix_back;
66 Pixmap pix_closeBtn;
67 Pixmap pix_configBtn;
68 Pixmap pix_pressedBtn;
71 struct GEOM {
72 int height;
73 int width;
74 int x;
75 int y;
78 struct WindowList {
79 Window win;
80 bool iconic;
81 bool shaded;
82 bool sticky;
83 int desktop;
86 struct DesktopList {
87 int number;
90 class Stackmenu;
92 class ToolWindow : public Basewindow, public TimeoutHandler {
93 public:
94 ToolWindow(int argc,char **argv,struct CMDOPTIONS *);
95 ~ToolWindow(void);
97 void reconfigure(void);
98 void execCommand(char *const);
100 // functions for translation of grab information
101 const char *index_to_name(int);
102 int translateAction(char *);
103 int translateModifier(char *);
105 // functions for handling/grabbing keys
106 void loadKeygrabs(void);
107 void setKeygrabs(void);
108 void activateKeygrabs(void);
109 void getOffendingModifiers(void);
110 void wHackedGrabKey(int,unsigned int,Window,Bool,int,int);
111 void x_reset_modifier_mapping(Display *);
112 void InitializeModifiers(void);
114 // functions for maintaining the desktop list
115 void addDesktop(void);
116 void removeDesktop(int);
117 void focusDesktop(int);
118 void setDesktopCount(int); // this should only be called during the
119 // initialization stage
121 // functions for maintaining the window list
122 void addWindow(Window,int);
123 void removeWindow(Window);
124 void clearWindows(void);
125 void focusWindow(Window);
126 void moveWinToDesktop(Window,int);
127 void windowAttributeChange(Window); // called when attributes for a window
128 // have changed, such as sticky
129 void cycleWindowFocus(bool);
131 // functions for modifying windows
132 void raiseWindow(Window);
133 void lowerWindow(Window);
135 // functions for the Linear window cycling style
136 void add_linear(WindowList *);
137 void cycle_linear(bool);
139 // functions for the Stack window cycling style
140 void add_stack(WindowList *);
141 void cycle_stack(bool);
142 void focus_stack(Window);
143 void saveMenuSearch(Window,Basemenu *);
144 void removeMenuSearch(Window);
146 // functions which return information
147 inline int getCurrentDesktopNr(void) {
148 return current_desktop?current_desktop->number:-1;
150 inline Window getFocusWindow() { return focus_window; }
151 inline int getDesktopCount(void) { return desktop_count; }
152 inline Resource *getResource() { return resource; }
153 inline GC getMenuTitleGC(void) {return NULL;/*menuTitleGC;*/}
154 inline GC getMenuHiBGGC(void) {return menuHiBGGC;}
155 inline GC getMenuHiGC(void) {return menuHiGC; }
156 inline GC getMenuFrameGC(void) {return menuFrameGC;}
157 inline bool getDoingCycling(void) { return doingCycling; }
158 inline bool getShowAllWorkspaces(void) { return showAllWorkspaces; }
159 unsigned int KeycodeToModmask(unsigned int code);
161 // void setNETInit(void) { /*wm_init = True;*/ }
163 protected:
164 // functions for dealing with the bbkeys window
165 void MakeWindow(bool);
166 void Redraw(void);
167 virtual void process_event(XEvent *);
168 virtual void CheckConfig(void);
169 void timeout(void);
170 void addSticky(WindowList *);
171 void removeSticky(const Window,const int);
172 inline void setCycling(bool f) { doingCycling = f; }
173 inline void setShowAllWorkspaces(bool f) { showAllWorkspaces = f; }
174 void findFramePosition(Window window, int &x, int &y);
176 private:
177 XGCValues gcv; // font stuff
178 GC frameGC;
180 Window win_frame; // windows for the tool
181 Window win_title;
182 Window win_back;
183 Window win_closeBtn;
184 Window win_configBtn;
185 GEOM frame; // size/pos data for the windows and label
186 GEOM label;
187 GEOM geom_title;
188 GEOM geom_back;
189 GEOM geom_closeBtn;
190 GEOM geom_configBtn;
191 PIXMAP pixmap; // pixmaps for all of the windows
192 BTimer *timer; // window background drawing timer
193 // bool raised; // window is raised above all others
195 KEY_GRAB_INSTRUCTION grabSet; // key grab/handling vars
196 int actionList[NUM_GRABS];
197 unsigned int ValidModMask;
198 unsigned int _NumLockMask;
199 unsigned int _ScrollLockMask;
201 char *bbkeys_rcfile; // resource file
202 time_t bbkeys_rcTime; // time used for autoloading resource file
203 Resource *resource; // resource data
205 int desktop_count; // the number of desktops
206 DesktopList *current_desktop; // the currently active desktop
207 LinkedList<WindowList> *windowList; // list of all windows
208 LinkedList<DesktopList> *desktopList; // list of all desktop windows
209 Window focus_window; // window which has the focus
211 WMInterface *wminterface; // interface for communicating with the
212 // window manager
214 Stackmenu *stackMenu; // variables for the stack cycling style menu
215 bool doingCycling; // are we in the middle of a stacked cycle?
216 bool showAllWorkspaces;
217 Window menuWin;
218 GC menuGC;
219 GC menuHiBGGC;
220 GC menuHiGC;
221 GC menuFrameGC;
223 friend class Stackmenu;
224 void p();
227 #endif /* __BBKEYS_HH */