]> Dogcows Code - chaz/openbox/blob - src/python.hh
add startup and shutdown callback events for each screen
[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 EventStartup,
57 EventShutdown,
58 NUM_EVENTS
59 };
60
61 #ifndef SWIG
62
63 // *** MotionData can be (and is) cast ButtonData!! (in actions.cc) *** //
64 typedef struct {
65 PyObject_HEAD;
66 int screen;
67 Window window;
68 Time time;
69 unsigned int state;
70 unsigned int button;
71 MouseContext context;
72 MouseAction action;
73 int xroot;
74 int yroot;
75 int pressx;
76 int pressy;
77 int press_clientx;
78 int press_clienty;
79 int press_clientwidth;
80 int press_clientheight;
81 } MotionData;
82
83 // *** MotionData can be (and is) cast ButtonData!! (in actions.cc) *** //
84 typedef struct {
85 PyObject_HEAD;
86 int screen;
87 Window window;
88 Time time;
89 unsigned int state;
90 unsigned int button;
91 MouseContext context;
92 MouseAction action;
93 } ButtonData;
94
95 typedef struct {
96 PyObject_HEAD;
97 int screen;
98 Window window;
99 unsigned int state;
100 EventAction action;
101 } EventData;
102
103 typedef struct {
104 PyObject_HEAD;
105 int screen;
106 Window window;
107 Time time;
108 unsigned int state;
109 unsigned int key;
110 } KeyData;
111
112 void python_init(char *argv0);
113 void python_destroy();
114 bool python_exec(const std::string &path);
115
116 MotionData *new_motion_data(int screen, Window window, Time time,
117 unsigned int state, unsigned int button,
118 MouseContext context, MouseAction action,
119 int xroot, int yroot, const otk::Point &initpos,
120 const otk::Rect &initarea);
121 ButtonData *new_button_data(int screen, Window window, Time time,
122 unsigned int state, unsigned int button,
123 MouseContext context, MouseAction action);
124 EventData *new_event_data(int screen, Window window, EventAction action,
125 unsigned int state);
126 KeyData *new_key_data(int screen, Window window, Time time, unsigned int state,
127 unsigned int key);
128
129 void python_callback(PyObject *func, PyObject *data);
130
131 bool python_get_long(const char *name, long *value);
132 bool python_get_string(const char *name, std::string *value);
133 bool python_get_stringlist(const char *name, std::vector<std::string> *value);
134 #endif
135
136 PyObject *mbind(const std::string &button, ob::MouseContext context,
137 ob::MouseAction action, PyObject *func);
138
139 PyObject *kbind(PyObject *keylist, ob::KeyContext context, PyObject *func);
140
141 PyObject *ebind(ob::EventAction action, PyObject *func);
142
143 void set_reset_key(const std::string &key);
144
145 }
146
147 #endif // __python_hh
This page took 0.043153 seconds and 5 git commands to generate.