]> Dogcows Code - chaz/openbox/blob - src/python.hh
redo otk::Property. make it static.
[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_StickyButton,
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 EventAction {
57 EventEnterWindow,
58 EventLeaveWindow,
59 EventPlaceWindow,
60 EventNewWindow,
61 EventCloseWindow,
62 EventStartup,
63 EventShutdown,
64 EventFocus,
65 EventBell,
66 NUM_EVENTS
67 };
68
69 class MouseData {
70 public:
71 int screen;
72 Client *client;
73 Time time;
74 unsigned int state;
75 unsigned int button;
76 MouseContext context;
77 MouseAction action;
78 int xroot;
79 int yroot;
80 int pressx;
81 int pressy;
82 int press_clientx;
83 int press_clienty;
84 int press_clientwidth;
85 int press_clientheight;
86
87 MouseData(int screen, Client *client, Time time, unsigned int state,
88 unsigned int button, MouseContext context, MouseAction action,
89 int xroot, int yroot, const otk::Point &initpos,
90 const otk::Rect &initarea) {
91 this->screen = screen;
92 this->client = client;
93 this->time = time;
94 this->state = state;
95 this->button = button;
96 this->context= context;
97 this->action = action;
98 this->xroot = xroot;
99 this->yroot = yroot;
100 this->pressx = initpos.x();
101 this->pressy = initpos.y();
102 this->press_clientx = initarea.x();
103 this->press_clienty = initarea.y();
104 this->press_clientwidth = initarea.width();
105 this->press_clientheight = initarea.height();
106 }
107 MouseData(int screen, Client *client, Time time, unsigned int state,
108 unsigned int button, MouseContext context, MouseAction action) {
109 this->screen = screen;
110 this->client = client;
111 this->time = time;
112 this->state = state;
113 this->button = button;
114 this->context= context;
115 this->action = action;
116 this->xroot = xroot;
117 this->yroot = yroot;
118 this->pressx = 0;
119 this->pressy = 0;
120 this->press_clientx = 0;
121 this->press_clienty = 0;
122 this->press_clientwidth = 0;
123 this->press_clientheight = 0;
124 }
125 };
126
127 class EventData {
128 public:
129 int screen;
130 Client *client;
131 unsigned int state;
132 EventAction action;
133
134 EventData(int screen, Client *client, EventAction action,
135 unsigned int state) {
136 this->screen = screen;
137 this->client = client;
138 this->action = action;
139 this->state = state;
140 }
141 };
142
143 class KeyData {
144 public:
145 int screen;
146 Client *client;
147 Time time;
148 unsigned int state;
149 std::string key;
150
151 KeyData(int screen, Client *client, Time time, unsigned int state,
152 unsigned int key) {
153 this->screen = screen;
154 this->client = client;
155 this->time = time;
156 this->state = state;
157 this->key = XKeysymToString(XKeycodeToKeysym(**otk::display,
158 key, 0));
159 }
160 };
161
162 #ifndef SWIG
163
164 void python_init(char *argv0);
165 void python_destroy();
166 bool python_exec(const std::string &path);
167
168 bool python_get_long(const char *name, long *value);
169 bool python_get_string(const char *name, otk::ustring *value);
170 bool python_get_stringlist(const char *name, std::vector<otk::ustring> *value);
171
172 /***********************************************
173 * These are found in openbox.i, not python.cc *
174 ***********************************************/
175 void python_callback(PyObject *func, MouseData *data);
176 void python_callback(PyObject *func, EventData *data);
177 void python_callback(PyObject *func, KeyData *data);
178
179 #endif // SWIG
180
181 PyObject *mbind(const std::string &button, ob::MouseContext context,
182 ob::MouseAction action, PyObject *func);
183
184 PyObject *kbind(PyObject *keylist, ob::KeyContext context, PyObject *func);
185
186 PyObject *ebind(ob::EventAction action, PyObject *func);
187
188 void set_reset_key(const std::string &key);
189
190 PyObject *send_client_msg(Window target, Atom type, Window about,
191 long data, long data1 = 0, long data2 = 0,
192 long data3 = 0, long data4 = 0);
193 }
194
195
196 #endif // __python_hh
This page took 0.046251 seconds and 5 git commands to generate.