initial import
[bbkeys.git] / bbkeys.hh
blobea4850067b16a5ff142b965c04242c5f3c188197
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@x-o-r.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 #ifndef __BBKEYS_HH
24 #define __BBKEYS_HH
26 #include "grab_defs.hh" // grab* definitions
27 #include "Basewindow.hh"
28 #include "resource.hh"
29 #include "wminterface.hh"
31 #include <X11/Xlib.h>
32 #include <X11/keysym.h>
34 #define MaxInstructions 50
36 typedef struct {
37 unsigned long modMask;
38 KeyCode keycode;
39 int action;
40 char *execCommand;
41 } KEY_ACTION_MAP;
43 typedef struct {
44 int instructCount;
45 KEY_ACTION_MAP KeyMap[MaxInstructions];
46 } KEY_GRAB_INSTRUCTION;
48 struct PIXMAP {
49 Pixmap frame;
50 Pixmap window;
51 // Pixmap focusedDesktop;
52 // Pixmap focusedWindow;
53 // Pixmap desktop;
55 Pixmap pix_title;
56 Pixmap pix_back;
57 Pixmap pix_closeBtn;
58 Pixmap pix_configBtn;
59 Pixmap pix_pressedBtn;
62 struct GEOM {
63 int height;
64 int width;
65 int x;
66 int y;
69 struct WindowList {
70 Window win;
71 bool iconic;
72 bool shaded;
73 bool sticky;
74 int desktop;
77 struct DesktopList {
78 int number;
82 class ToolWindow : public Basewindow, public TimeoutHandler {
83 public:
84 ToolWindow(int argc,char **argv,struct CMDOPTIONS *);
85 ~ToolWindow(void);
87 void reconfigure(void);
88 void execCommand(char *);
90 // functions for translation of grab information
91 char *index_to_name(int);
92 int translateAction(char *);
93 int translateModifier(char *);
95 // functions for handling/grabbing keys
96 void loadKeygrabs(void);
97 void setKeygrabs(void);
98 void activateKeygrabs(void);
99 void getOffendingModifiers(void);
100 void wHackedGrabKey(int,unsigned int,Window,Bool,int,int);
101 void x_reset_modifier_mapping(Display *);
102 void InitializeModifiers(void);
104 // functions for maintaining the desktop list
105 void addDesktop(void);
106 void removeDesktop(int);
107 void focusDesktop(int);
108 void setDesktopCount(int); // this should only be called during the
109 // initialization stage
111 // functions for maintaining the window list
112 void addWindow(Window,int);
113 void removeWindow(Window);
114 void focusWindow(Window);
115 void moveWinToDesktop(Window,int);
116 void windowAttributeChange(Window); // called when attributes for a window
117 // have changed, such as sticky
118 void cycleWindowFocus(bool);
120 // functions for modifying windows
121 void raiseWindow(Window);
122 void lowerWindow(Window);
124 // functions which return information
125 inline int getCurrentDesktopNr(void) {
126 return current_desktop?current_desktop->number:-1;
128 inline int getDesktopCount(void) { return desktop_count; }
130 // void setNETInit(void) { /*wm_init = True;*/ }
132 protected:
133 // functions for dealing with the bbkeys window
134 void MakeWindow(bool);
135 void Redraw(void);
136 virtual void process_event(XEvent *);
137 virtual void CheckConfig(void);
138 void timeout(void);
140 private:
141 XGCValues gcv; // font stuff
142 GC frameGC;
144 Window win_frame; // windows for the tool
145 Window win_title;
146 Window win_back;
147 Window win_closeBtn;
148 Window win_configBtn;
149 GEOM frame; // size/pos data for the windows and label
150 GEOM label;
151 GEOM geom_title;
152 GEOM geom_back;
153 GEOM geom_closeBtn;
154 GEOM geom_configBtn;
155 PIXMAP pixmap; // pixmaps for all of the windows
156 BTimer *timer; // window background drawing timer
157 // bool raised; // window is raised above all others
159 KEY_GRAB_INSTRUCTION grabSet; // key grab/handling vars
160 unsigned int ValidModMask;
161 unsigned int _NumLockMask;
162 unsigned int _ScrollLockMask;
164 char *bbkeys_rcfile; // resource file
165 time_t bbkeys_rcTime; // time used for autoloading resource file
166 Resource *resource; // resource data
168 int desktop_count; // the number of desktops
169 DesktopList *current_desktop; // the currently active desktop
170 LinkedList<WindowList> *windowList; // list of all windows
171 LinkedList<DesktopList> *desktopList; // list of all desktop windows
172 Window focus_window; // window which has the focus
174 WMInterface *wminterface; // interface for communicating with the
175 // window manager
177 // bool wm_init;
178 // int day,month,year;
179 // fd_set rfds;
182 #endif /* __BBKEYS_HH */