]> Dogcows Code - chaz/openbox/blob - src/python.hh
allow python to grab the keyboard. have release events go to the grabs callback....
[chaz/openbox] / src / python.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 #ifndef __python_hh
3 #define __python_hh
4
5 /*! @file python.hh
6 @brief wee
7 */
8
9 #include "otk/point.hh"
10 #include "otk/rect.hh"
11 #include "otk/property.hh"
12 #include "otk/display.hh"
13 #include "otk/ustring.hh"
14
15 extern "C" {
16 #include <X11/Xlib.h>
17 #include <Python.h>
18 }
19
20 #include <string>
21 #include <vector>
22
23 namespace ob {
24
25 class Client;
26
27 enum MouseContext {
28 MC_Frame,
29 MC_Titlebar,
30 MC_Handle,
31 MC_Window,
32 MC_MaximizeButton,
33 MC_CloseButton,
34 MC_IconifyButton,
35 MC_AllDesktopsButton,
36 MC_Grip,
37 MC_Root,
38 MC_MenuItem,
39 NUM_MOUSE_CONTEXT
40 };
41
42 enum MouseAction {
43 MousePress,
44 MouseClick,
45 MouseDoubleClick,
46 MouseMotion,
47 NUM_MOUSE_ACTION
48 };
49
50 enum KeyContext {
51 KC_Menu,
52 KC_All,
53 NUM_KEY_CONTEXT
54 };
55
56 enum KeyAction {
57 EventKeyPress,
58 EventKeyRelease,
59 NUM_KEY_ACTION
60 };
61
62 enum EventAction {
63 EventEnterWindow,
64 EventLeaveWindow,
65 EventPlaceWindow,
66 EventNewWindow,
67 EventCloseWindow,
68 EventStartup,
69 EventShutdown,
70 EventFocus,
71 EventBell,
72 EventUrgentWindow,
73 NUM_EVENTS
74 };
75
76 class MouseData {
77 public:
78 int screen;
79 Client *client;
80 Time time;
81 unsigned int state;
82 unsigned int button;
83 MouseContext context;
84 MouseAction action;
85 int xroot;
86 int yroot;
87 int pressx;
88 int pressy;
89 int press_clientx;
90 int press_clienty;
91 int press_clientwidth;
92 int press_clientheight;
93
94 MouseData(int screen, Client *client, Time time, unsigned int state,
95 unsigned int button, MouseContext context, MouseAction action,
96 int xroot, int yroot, const otk::Point &initpos,
97 const otk::Rect &initarea) {
98 this->screen = screen;
99 this->client = client;
100 this->time = time;
101 this->state = state;
102 this->button = button;
103 this->context= context;
104 this->action = action;
105 this->xroot = xroot;
106 this->yroot = yroot;
107 this->pressx = initpos.x();
108 this->pressy = initpos.y();
109 this->press_clientx = initarea.x();
110 this->press_clienty = initarea.y();
111 this->press_clientwidth = initarea.width();
112 this->press_clientheight = initarea.height();
113 }
114 MouseData(int screen, Client *client, Time time, unsigned int state,
115 unsigned int button, MouseContext context, MouseAction action) {
116 this->screen = screen;
117 this->client = client;
118 this->time = time;
119 this->state = state;
120 this->button = button;
121 this->context= context;
122 this->action = action;
123 this->xroot = xroot;
124 this->yroot = yroot;
125 this->pressx = 0;
126 this->pressy = 0;
127 this->press_clientx = 0;
128 this->press_clienty = 0;
129 this->press_clientwidth = 0;
130 this->press_clientheight = 0;
131 }
132 };
133
134 class EventData {
135 public:
136 int screen;
137 Client *client;
138 unsigned int state;
139 EventAction action;
140
141 EventData(int screen, Client *client, EventAction action,
142 unsigned int state) {
143 this->screen = screen;
144 this->client = client;
145 this->action = action;
146 this->state = state;
147 }
148 };
149
150 class KeyData {
151 public:
152 int screen;
153 Client *client;
154 Time time;
155 unsigned int state;
156 char *key;
157 KeyAction action;
158
159 KeyData(int screen, Client *client, Time time, unsigned int state,
160 unsigned int key, KeyAction action) {
161 this->screen = screen;
162 this->client = client;
163 this->time = time;
164 this->state = state;
165 this->key = XKeysymToString(XKeycodeToKeysym(**otk::display,
166 key, 0));
167 this->action = action;
168 }
169 };
170
171 #ifndef SWIG
172
173 void python_init(char *argv0);
174 void python_destroy();
175 bool python_exec(const std::string &path);
176
177 bool python_get_long(const char *name, long *value);
178 bool python_get_string(const char *name, otk::ustring *value);
179 bool python_get_stringlist(const char *name, std::vector<otk::ustring> *value);
180
181 /***********************************************
182 * These are found in openbox.i, not python.cc *
183 ***********************************************/
184 void python_callback(PyObject *func, MouseData *data);
185 void python_callback(PyObject *func, EventData *data);
186 void python_callback(PyObject *func, KeyData *data);
187
188 #endif // SWIG
189
190 PyObject *mbind(const std::string &button, ob::MouseContext context,
191 ob::MouseAction action, PyObject *func);
192
193 PyObject *kbind(PyObject *keylist, ob::KeyContext context, PyObject *func);
194
195 PyObject *kgrab(PyObject *func);
196 PyObject *kungrab();
197
198 PyObject *ebind(ob::EventAction action, PyObject *func);
199
200 void set_reset_key(const std::string &key);
201
202 PyObject *send_client_msg(Window target, Atom type, Window about,
203 long data, long data1 = 0, long data2 = 0,
204 long data3 = 0, long data4 = 0);
205 }
206
207
208 #endif // __python_hh
This page took 0.041712 seconds and 5 git commands to generate.