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)
28 #include "grab_defs.hh" // grab* definitions
29 #include "Basewindow.hh"
30 #include "resource.hh"
31 #include "wminterface.hh"
32 #include "stackmenu.hh"
35 #include <X11/keysym.h>
37 #define MaxInstructions 100
38 #define RCFILE ".bbkeysrc"
41 unsigned long modMask
;
49 KEY_ACTION_MAP KeyMap
[MaxInstructions
];
50 } KEY_GRAB_INSTRUCTION
;
55 // Pixmap focusedDesktop;
56 // Pixmap focusedWindow;
63 Pixmap pix_pressedBtn
;
87 class ToolWindow
: public Basewindow
, public TimeoutHandler
{
89 ToolWindow(int argc
,char **argv
,struct CMDOPTIONS
*);
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;*/ }
158 // functions for dealing with the bbkeys window
159 void MakeWindow(bool);
161 virtual void process_event(XEvent
*);
162 virtual void CheckConfig(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
; }
170 XGCValues gcv
; // font stuff
173 Window win_frame
; // windows for the tool
177 Window win_configBtn
;
178 GEOM frame
; // size/pos data for the windows and label
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
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
;
216 friend class Stackmenu
;
220 #endif /* __BBKEYS_HH */