1 // bbkeys.hh for bbkeys - Ye Olde Keystroke Grabber for Blackbox
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>
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)
30 #include <X11/keysym.h>
33 #include "grab_defs.hh" // grab* definitions
34 #include "Basewindow.hh"
42 #define MaxInstructions 100
43 #define RCFILE ".bbkeysrc"
46 unsigned long modMask
;
54 KEY_ACTION_MAP KeyMap
[MaxInstructions
];
55 } KEY_GRAB_INSTRUCTION
;
60 // Pixmap focusedDesktop;
61 // Pixmap focusedWindow;
68 Pixmap pix_pressedBtn
;
92 class ToolWindow
: public Basewindow
, public TimeoutHandler
{
94 ToolWindow(int argc
,char **argv
,struct CMDOPTIONS
*);
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;*/ }
164 // functions for dealing with the bbkeys window
165 void MakeWindow(bool);
167 virtual void process_event(XEvent
*);
168 virtual void CheckConfig(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
);
177 XGCValues gcv
; // font stuff
180 Window win_frame
; // windows for the tool
184 Window win_configBtn
;
185 GEOM frame
; // size/pos data for the windows and label
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
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
;
223 friend class Stackmenu
;
227 #endif /* __BBKEYS_HH */