]> Dogcows Code - chaz/openbox/blob - src/python.hh
948e9a72af9b3bede62c58a802e7e645ab9819ae
[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
12 extern "C" {
13 #include <X11/Xlib.h>
14 #include <Python.h>
15 }
16
17 #include <string>
18 #include <vector>
19
20 namespace ob {
21
22 enum MouseContext {
23 MC_Frame,
24 MC_Titlebar,
25 MC_Handle,
26 MC_Window,
27 MC_MaximizeButton,
28 MC_CloseButton,
29 MC_IconifyButton,
30 MC_StickyButton,
31 MC_Grip,
32 MC_Root,
33 MC_MenuItem,
34 NUM_MOUSE_CONTEXT
35 };
36
37 enum MouseAction {
38 MousePress,
39 MouseClick,
40 MouseDoubleClick,
41 MouseMotion,
42 NUM_MOUSE_ACTION
43 };
44
45 enum KeyContext {
46 KC_Menu,
47 KC_All,
48 NUM_KEY_CONTEXT
49 };
50
51 enum EventAction {
52 EventEnterWindow,
53 EventLeaveWindow,
54 EventNewWindow,
55 EventCloseWindow,
56 NUM_EVENTS
57 };
58
59 #ifndef SWIG
60
61 // *** MotionData can be (and is) cast ButtonData!! (in actions.cc) *** //
62 typedef struct {
63 PyObject_HEAD;
64 int screen;
65 Window window;
66 Time time;
67 unsigned int state;
68 unsigned int button;
69 MouseContext context;
70 MouseAction action;
71 int xroot;
72 int yroot;
73 int pressx;
74 int pressy;
75 int press_clientx;
76 int press_clienty;
77 int press_clientwidth;
78 int press_clientheight;
79 } MotionData;
80
81 // *** MotionData can be (and is) cast ButtonData!! (in actions.cc) *** //
82 typedef struct {
83 PyObject_HEAD;
84 int screen;
85 Window window;
86 Time time;
87 unsigned int state;
88 unsigned int button;
89 MouseContext context;
90 MouseAction action;
91 } ButtonData;
92
93 typedef struct {
94 PyObject_HEAD;
95 int screen;
96 Window window;
97 unsigned int state;
98 EventAction action;
99 } EventData;
100
101 typedef struct {
102 PyObject_HEAD;
103 int screen;
104 Window window;
105 Time time;
106 unsigned int state;
107 unsigned int key;
108 } KeyData;
109
110 void python_init(char *argv0);
111 void python_destroy();
112 bool python_exec(const std::string &path);
113
114 MotionData *new_motion_data(int screen, Window window, Time time,
115 unsigned int state, unsigned int button,
116 MouseContext context, MouseAction action,
117 int xroot, int yroot, const otk::Point &initpos,
118 const otk::Rect &initarea);
119 ButtonData *new_button_data(int screen, Window window, Time time,
120 unsigned int state, unsigned int button,
121 MouseContext context, MouseAction action);
122 EventData *new_event_data(int screen, Window window, EventAction action,
123 unsigned int state);
124 KeyData *new_key_data(int screen, Window window, Time time, unsigned int state,
125 unsigned int key);
126
127 void python_callback(PyObject *func, PyObject *data);
128
129 bool python_get_long(const char *name, long *value);
130 bool python_get_string(const char *name, std::string *value);
131 bool python_get_stringlist(const char *name, std::vector<std::string> *value);
132 #endif
133
134 PyObject *mbind(const std::string &button, ob::MouseContext context,
135 ob::MouseAction action, PyObject *func);
136
137 PyObject *kbind(PyObject *keylist, ob::KeyContext context, PyObject *func);
138
139 PyObject *ebind(ob::EventAction action, PyObject *func);
140
141 void set_reset_key(const std::string &key);
142
143 }
144
145 #endif // __python_hh
This page took 0.042663 seconds and 4 git commands to generate.