namespace ob {
const unsigned int OBActions::DOUBLECLICKDELAY = 300;
+const int OBActions::BUTTONS;
OBActions::OBActions()
: _button(0)
{
- // XXX: load a configuration out of somewhere
-
+ for (int i=0; i<BUTTONS; ++i)
+ _posqueue[i] = new ButtonPressAction();
}
OBActions::~OBActions()
{
+ for (int i=0; i<BUTTONS; ++i)
+ delete _posqueue[i];
+}
+
+
+void OBActions::insertPress(const XButtonEvent &e)
+{
+ ButtonPressAction *a = _posqueue[BUTTONS - 1];
+ for (int i=BUTTONS-1; i>0;)
+ _posqueue[i] = _posqueue[--i];
+ _posqueue[0] = a;
+ a->button = e.button;
+ a->pos.setPoint(e.x_root, e.y_root);
+
+ OBClient *c = Openbox::instance->findClient(e.window);
+ if (c) a->clientarea = c->area();
}
+void OBActions::removePress(const XButtonEvent &e)
+{
+ ButtonPressAction *a = 0;
+ for (int i=0; i<BUTTONS; ++i) {
+ if (_posqueue[i]->button == e.button)
+ a = _posqueue[i];
+ if (a) // found one and removed it
+ _posqueue[i] = _posqueue[i+1];
+ }
+ if (a) { // found one
+ _posqueue[BUTTONS-1] = a;
+ a->button = 0;
+ }
+}
void OBActions::buttonPressHandler(const XButtonEvent &e)
{
OtkEventHandler::buttonPressHandler(e);
+ insertPress(e);
// run the PRESS python hook
OBWidget *w = dynamic_cast<OBWidget*>
(Openbox::instance->findHandler(e.window));
- doCallback(Action_ButtonPress, e.window,
+/* doCallback(Action_ButtonPress, e.window,
(OBWidget::WidgetType)(w ? w->type():-1),
- e.state, e.button, e.x_root, e.y_root, e.time);
+ e.state, e.button, e.x_root, e.y_root, e.time);*/
+ if (w) {
+ Openbox::instance->bindings()->fire(MousePress, w->type(), e.window,
+ e.state, e.button,
+ e.x_root, e.y_root, e.time);
+ } else
+ assert(false); // why isnt there a type?
if (_button) return; // won't count toward CLICK events
void OBActions::buttonReleaseHandler(const XButtonEvent &e)
{
OtkEventHandler::buttonReleaseHandler(e);
+ removePress(e);
OBWidget *w = dynamic_cast<OBWidget*>
(Openbox::instance->findHandler(e.window));
return;
// run the CLICK python hook
- doCallback(Action_Click, e.window,
+/* doCallback(Action_Click, e.window,
(OBWidget::WidgetType)(w ? w->type():-1),
- e.state, e.button, e.x_root, e.y_root, e.time);
+ e.state, e.button, e.x_root, e.y_root, e.time);*/
+ if (w) {
+ Openbox::instance->bindings()->fire(MouseClick, w->type(), e.window,
+ e.state, e.button,
+ e.x_root, e.y_root, e.time);
+ } else
+ assert(false); // why isnt there a type?
if (e.time - _release.time < DOUBLECLICKDELAY &&
_release.win == e.window && _release.button == e.button) {
// run the DOUBLECLICK python hook
- doCallback(Action_DoubleClick, e.window,
+/* doCallback(Action_DoubleClick, e.window,
(OBWidget::WidgetType)(w ? w->type():-1),
- e.state, e.button, e.x_root, e.y_root, e.time);
+ e.state, e.button, e.x_root, e.y_root, e.time);*/
+ if (w) {
+ Openbox::instance->bindings()->fire(MouseDoubleClick, w->type(),
+ e.window, e.state, e.button,
+ e.x_root, e.y_root, e.time);
+ } else
+ assert(false); // why isnt there a type?
// reset so you cant triple click for 2 doubleclicks
_release.win = 0;
}
}
-
+ _dx = x_root - _posqueue[0]->pos.x(); _posqueue[0]->pos.setX(x_root);
+ _dy = y_root - _posqueue[0]->pos.y(); _posqueue[0]->pos.setY(y_root);
+
OBWidget *w = dynamic_cast<OBWidget*>
(Openbox::instance->findHandler(e.window));
// XXX: i can envision all sorts of crazy shit with this.. gestures, etc
// maybe that should all be done via python tho.. (or radial menus!)
// run the simple MOTION python hook for now...
- doCallback(Action_MouseMotion, e.window,
+/* doCallback(Action_MouseMotion, e.window,
(OBWidget::WidgetType)(w ? w->type():-1),
- e.state, (unsigned)-1, x_root, y_root, e.time);
+ e.state, (unsigned)-1, x_root, y_root, e.time);*/
+ if (w) {
+ Openbox::instance->bindings()->fire(MouseMotion, w->type(), e.window,
+ e.state, _posqueue[0]->button,
+ _dx, _dy, e.time);
+ } else
+ assert(false); // why isnt there a type?
}
void OBActions::mapRequestHandler(const XMapRequestEvent &e)
_callbacks.equal_range(action);
CallbackMap::iterator it;
- for (it = it_pair.first; it != it_pair.second; ++it)
- python_callback(it->second, action, window, type, state,
- button, xroot, yroot, time);
+// for (it = it_pair.first; it != it_pair.second; ++it)
+// python_callback(it->second, action, window, type, state,
+// button, xroot, yroot, time);
+ // XXX do a callback
}
bool OBActions::registerCallback(ActionType action, PyObject *func,
bool atfront)
{
- if (action < 0 || action >= OBActions::NUM_ACTIONS ||
- action == OBActions::Action_KeyPress) {
+ if (action < 0 || action >= OBActions::NUM_ACTIONS) {
return false;
}
if (!func)
bool OBActions::unregisterCallback(ActionType action, PyObject *func)
{
- if (action < 0 || action >= OBActions::NUM_ACTIONS ||
- action == OBActions::Action_KeyPress) {
+ if (action < 0 || action >= OBActions::NUM_ACTIONS) {
return false;
}
if (!func)
bool OBActions::unregisterAllCallbacks(ActionType action)
{
- if (action < 0 || action >= OBActions::NUM_ACTIONS ||
- action == OBActions::Action_KeyPress) {
+ if (action < 0 || action >= OBActions::NUM_ACTIONS) {
return false;
}
public:
// update the same enum in openbox.i when making changes to this
enum ActionType {
- Action_ButtonPress,
- Action_Click,
- Action_DoubleClick,
Action_EnterWindow,
Action_LeaveWindow,
- Action_KeyPress,
- Action_MouseMotion,
Action_NewWindow,
Action_CloseWindow,
NUM_ACTIONS
Time time;
ButtonReleaseAction() { win = 0; button = 0; time = 0; }
};
+
+ struct ButtonPressAction {
+ unsigned int button;
+ otk::Point pos;
+ otk::Rect clientarea;
+ ButtonPressAction() { button = 0; }
+ };
private:
// milliseconds XXX: config option
static const unsigned int DOUBLECLICKDELAY;
+ static const int BUTTONS = 5;
//! The mouse button currently being watched from a press for a CLICK
unsigned int _button;
//! The last button release processed for CLICKs
ButtonReleaseAction _release;
+ //! The point where the mouse was when each mouse button was pressed
+ /*!
+ Used for motion events as the starting position.
+ */
+ ButtonPressAction *_posqueue[BUTTONS];
+ //! The delta x/y of the last motion sequence
+ int _dx, _dy;
+
+ void insertPress(const XButtonEvent &e);
+ void removePress(const XButtonEvent &e);
+
typedef std::multimap<ActionType, PyObject*> CallbackMap;
typedef std::pair<ActionType, PyObject*> CallbackMapPair;
CallbackMap _callbacks;
}
}
-static void destroytree(BindingTree *tree)
+static void destroytree(KeyBindingTree *tree)
{
while (tree) {
- BindingTree *c = tree->first_child;
+ KeyBindingTree *c = tree->first_child;
delete tree;
tree = c;
}
}
-BindingTree *OBBindings::buildtree(const StringVect &keylist,
+KeyBindingTree *OBBindings::buildtree(const StringVect &keylist,
PyObject *callback) const
{
if (keylist.empty()) return 0; // nothing in the list.. return 0
- BindingTree *ret = 0, *p;
+ KeyBindingTree *ret = 0, *p;
StringVect::const_reverse_iterator it, end = keylist.rend();
for (it = keylist.rbegin(); it != end; ++it) {
p = ret;
- ret = new BindingTree(callback);
+ ret = new KeyBindingTree(callback);
if (!p) ret->chain = false; // only the first built node
ret->first_child = p;
if (!translate(*it, ret->binding)) {
OBBindings::OBBindings()
- : _curpos(&_tree),
+ : _curpos(&_keytree),
_resetkey(0,0),
_timer(Openbox::instance->timerManager(),
(otk::OBTimeoutHandler)reset, this)
}
-void OBBindings::assimilate(BindingTree *node)
+void OBBindings::assimilate(KeyBindingTree *node)
{
- BindingTree *a, *b, *tmp, *last;
+ KeyBindingTree *a, *b, *tmp, *last;
- if (!_tree.first_child) {
+ if (!_keytree.first_child) {
// there are no nodes at this level yet
- _tree.first_child = node;
+ _keytree.first_child = node;
} else {
- a = _tree.first_child;
+ a = _keytree.first_child;
last = a;
b = node;
while (a) {
}
-PyObject *OBBindings::find(BindingTree *search, bool *conflict) const {
+PyObject *OBBindings::find(KeyBindingTree *search, bool *conflict) const {
*conflict = false;
- BindingTree *a, *b;
- a = _tree.first_child;
+ KeyBindingTree *a, *b;
+ a = _keytree.first_child;
b = search;
while (a && b) {
if (a->binding != b->binding) {
bool OBBindings::add(const StringVect &keylist, PyObject *callback)
{
- BindingTree *tree;
+ KeyBindingTree *tree;
bool conflict;
if (!(tree = buildtree(keylist, callback)))
{
assert(false); // XXX: function not implemented yet
- BindingTree *tree;
+ KeyBindingTree *tree;
bool conflict;
if (!(tree = buildtree(keylist, 0)))
if (func) {
grabKeys(false);
- _curpos = &_tree;
+ _curpos = &_keytree;
// XXX do shit here ...
Py_DECREF(func);
}
-static void remove_branch(BindingTree *first)
+static void remove_branch(KeyBindingTree *first)
{
- BindingTree *p = first;
+ KeyBindingTree *p = first;
while (p) {
if (p->first_child)
remove_branch(p->first_child);
- BindingTree *s = p->next_sibling;
+ KeyBindingTree *s = p->next_sibling;
Py_XDECREF(p->callback);
delete p;
p = s;
void OBBindings::removeAll()
{
- if (_tree.first_child) {
- remove_branch(_tree.first_child);
- _tree.first_child = 0;
+ if (_keytree.first_child) {
+ remove_branch(_keytree.first_child);
+ _keytree.first_child = 0;
}
}
for (int i = 0; i < Openbox::instance->screenCount(); ++i) {
Window root = otk::OBDisplay::screenInfo(i)->rootWindow();
- BindingTree *p = _curpos->first_child;
+ KeyBindingTree *p = _curpos->first_child;
while (p) {
if (grab) {
otk::OBDisplay::grabKey(p->binding.key, p->binding.modifiers,
if (key == _resetkey.key && modifiers == _resetkey.modifiers) {
reset(this);
} else {
- BindingTree *p = _curpos->first_child;
+ KeyBindingTree *p = _curpos->first_child;
while (p) {
if (p->binding.key == key && p->binding.modifiers == modifiers) {
if (p->chain) {
{
self->_timer.stop();
self->grabKeys(false);
- self->_curpos = &self->_tree;
+ self->_curpos = &self->_keytree;
self->grabKeys(true);
}
+
+bool OBBindings::addButton(const std::string &but, MouseContext context,
+ MouseAction action, PyObject *callback)
+{
+ assert(context >= 0 && context < NUM_MOUSE_CONTEXT);
+
+ Binding b(0,0);
+ if (!translate(but, b, false))
+ return false;
+
+ ButtonBindingList::iterator it, end = _buttons[context].end();
+
+ // look for a duplicate binding
+ for (it = _buttons[context].begin(); it != end; ++it)
+ if ((*it)->binding.key == b.key &&
+ (*it)->binding.modifiers == b.modifiers) {
+ ButtonBinding::CallbackList::iterator c_it,
+ c_end = (*it)->callback[action].end();
+ for (c_it = (*it)->callback[action].begin(); c_it != c_end; ++c_it)
+ if (*c_it == callback)
+ return true; // already bound
+ break;
+ }
+
+ ButtonBinding *bind;
+
+ // the binding didnt exist yet, add it
+ if (it == end) {
+ bind = new ButtonBinding();
+ bind->binding.key = b.key;
+ bind->binding.modifiers = b.modifiers;
+ _buttons[context].push_back(bind);
+ printf("adding %d.%d to %d\n", b.key, b.modifiers, context);
+ // XXX GRAB the new button everywhere!
+ } else
+ bind = *it;
+ bind->callback[action].push_back(callback);
+ Py_INCREF(callback);
+ return true;
+}
+
+void OBBindings::grabButtons(bool grab, OBClient *client)
+{
+ for (int i = 0; i < NUM_MOUSE_CONTEXT; ++i) {
+ Window win[3] = {0, 0, 0}; // at most 2 windows
+ switch (i) {
+ case MC_Frame:
+ win[0] = client->frame->window();
+ break;
+ case MC_Titlebar:
+ win[0] = client->frame->titlebar();
+ win[1] = client->frame->label();
+ break;
+ case MC_Window:
+ win[0] = client->frame->plate();
+ break;
+ case MC_MaximizeButton:
+// win[0] = client->frame->button_max();
+ break;
+ case MC_CloseButton:
+// win[0] = client->frame->button_close();
+ break;
+ case MC_IconifyButton:
+// win[0] = client->frame->button_iconify();
+ break;
+ case MC_StickyButton:
+// win[0] = client->frame->button_stick();
+ break;
+ case MC_Grip:
+// win[0] = client->frame->grip_left();
+// win[1] = client->frame->grip_right();
+ break;
+ case MC_Root:
+// win[0] = otk::OBDisplay::screenInfo(client->screen())->rootWindow();
+ break;
+ case MC_MenuItem:
+ break;
+ default:
+ assert(false); // invalid mouse context
+ }
+ ButtonBindingList::iterator it, end = _buttons[i].end();
+ for (it = _buttons[i].begin(); it != end; ++it)
+ for (Window *w = win; *w; ++w) {
+ if (grab) {
+ otk::OBDisplay::grabButton((*it)->binding.key,
+ (*it)->binding.modifiers, *w, false,
+ ButtonPressMask | ButtonMotionMask |
+ ButtonReleaseMask, GrabModeAsync,
+ GrabModeAsync, None, None, false);
+ }
+ else
+ otk::OBDisplay::ungrabButton((*it)->binding.key,
+ (*it)->binding.modifiers, *w);
+ }
+ }
+}
+
+void OBBindings::fire(MouseAction action, OBWidget::WidgetType type,
+ Window win, unsigned int modifiers, unsigned int button,
+ int xroot, int yroot, Time time)
+{
+ assert(action >= 0 && action < NUM_MOUSE_ACTION);
+
+ MouseContext context;
+ switch (type) {
+ case OBWidget::Type_Frame:
+ context = MC_Frame; break;
+ case OBWidget::Type_Titlebar:
+ context = MC_Titlebar; break;
+ case OBWidget::Type_Handle:
+ context = MC_Frame; break;
+ case OBWidget::Type_Plate:
+ context = MC_Window; break;
+ case OBWidget::Type_Label:
+ context = MC_Titlebar; break;
+ case OBWidget::Type_MaximizeButton:
+ context = MC_MaximizeButton; break;
+ case OBWidget::Type_CloseButton:
+ context = MC_CloseButton; break;
+ case OBWidget::Type_IconifyButton:
+ context = MC_IconifyButton; break;
+ case OBWidget::Type_StickyButton:
+ context = MC_StickyButton; break;
+ case OBWidget::Type_LeftGrip:
+ context = MC_Grip; break;
+ case OBWidget::Type_RightGrip:
+ context = MC_Grip; break;
+ case OBWidget::Type_Client:
+ context = MC_Window; break;
+ case OBWidget::Type_Root:
+ context = MC_Root; break;
+ default:
+ assert(false); // unhandled type
+ }
+
+ modifiers &= (ControlMask | ShiftMask | Mod1Mask | Mod2Mask | Mod3Mask |
+ Mod4Mask | Mod5Mask);
+
+ printf("but.mods %d.%d\n", button, modifiers);
+
+ ButtonBindingList::iterator it, end = _buttons[context].end();
+ for (it = _buttons[context].begin(); it != end; ++it)
+ if ((*it)->binding.key == button &&
+ (*it)->binding.modifiers == modifiers) {
+ ButtonBinding::CallbackList::iterator c_it,
+ c_end = (*it)->callback[action].end();
+ for (c_it = (*it)->callback[action].begin(); c_it != c_end; ++c_it)
+ python_callback(*c_it, action, win, context, modifiers,
+ button, xroot, yroot, time);
+ }
+}
+
}
*/
#include "actions.hh"
+#include "python.hh"
#include "otk/timer.hh"
extern "C" {
Binding(unsigned int mod, unsigned int k) { modifiers = mod; key = k; }
} Binding;
-typedef struct BindingTree {
+typedef struct KeyBindingTree {
Binding binding;
PyObject *callback; // the callback given for the binding in add()
bool chain; // true if this is a chain to another key (not an action)
- struct BindingTree *next_sibling; // the next binding in the tree at the same
+ struct KeyBindingTree *next_sibling; // the next binding in the tree at the same
// level
- struct BindingTree *first_child; // the first child of this binding (next
+ struct KeyBindingTree *first_child; // the first child of this binding (next
// binding in a chained sequence).
- BindingTree(PyObject *callback) : binding(0, 0) {
+ KeyBindingTree(PyObject *callback) : binding(0, 0) {
this->callback = callback; chain = true; next_sibling = first_child = 0;
}
- BindingTree() : binding(0, 0) {
+ KeyBindingTree() : binding(0, 0) {
this->callback = 0; chain = true; next_sibling = first_child = 0;
}
-} BindingTree;
+} KeyBindingTree;
+
+typedef struct ButtonBinding {
+ Binding binding;
+ typedef std::list<PyObject*> CallbackList;
+ CallbackList callback[NUM_MOUSE_ACTION];
+ ButtonBinding() : binding(0, 0) {
+ }
+};
class OBBindings {
public:
typedef std::vector<std::string> StringVect;
private:
- BindingTree _tree; // root node of the tree (this doesn't have siblings!)
- BindingTree *_curpos; // position in the keytree
+ // root node of the tree (this doesn't have siblings!)
+ KeyBindingTree _keytree;
+ KeyBindingTree *_curpos; // position in the keytree
Binding _resetkey; // the key which resets the key chain status
otk::OBTimer _timer;
- PyObject *find(BindingTree *search, bool *conflict) const;
- BindingTree *buildtree(const StringVect &keylist, PyObject *callback) const;
- void assimilate(BindingTree *node);
+ PyObject *find(KeyBindingTree *search, bool *conflict) const;
+ KeyBindingTree *buildtree(const StringVect &keylist,
+ PyObject *callback) const;
+ void assimilate(KeyBindingTree *node);
static void reset(OBBindings *self); // the timer's timeout function
+ typedef std::list <ButtonBinding*> ButtonBindingList;
+ ButtonBindingList _buttons[NUM_MOUSE_CONTEXT];
+
public:
//! Initializes an OBBindings object
OBBindings();
void setResetKey(const std::string &key);
void grabKeys(bool grab);
+
+ bool addButton(const std::string &but, MouseContext context,
+ MouseAction action, PyObject *callback);
+
+ void grabButtons(bool grab, OBClient *client);
+
+ void fire(MouseAction action, OBWidget::WidgetType type, Window win,
+ unsigned int modifiers, unsigned int button,
+ int xroot, int yroot, Time time);
};
}
void OBFrame::grabButtons(bool grab)
{
- _plate.grabButtons(grab);
+/* _plate.grabButtons(grab);
// grab any requested buttons on the entire frame
std::vector<std::string> grabs;
otk::OBDisplay::ungrabButton(b.key, b.modifiers, _window);
}
}
- }
+ }*/
}
{
_state = State_Exiting; // time to kill everything
- delete _bindings;
- delete _actions;
-
std::for_each(_screens.begin(), _screens.end(), otk::PointerAssassin());
+ delete _bindings;
+ delete _actions;
delete _property;
python_destroy();
ob::Openbox *Openbox_instance() { return ob::Openbox::instance; }
%};
-// stuff for scripting callbacks!
-%inline %{
- enum ActionType {
- Action_ButtonPress,
- Action_Click,
- Action_DoubleClick,
- Action_EnterWindow,
- Action_LeaveWindow,
- Action_KeyPress,
- Action_MouseMotion,
- Action_NewWindow,
- Action_CloseWindow
- };
- enum WidgetType {
- Type_Frame,
- Type_Titlebar,
- Type_Handle,
- Type_Plate,
- Type_Label,
- Type_MaximizeButton,
- Type_CloseButton,
- Type_IconifyButton,
- Type_StickyButton,
- Type_LeftGrip,
- Type_RightGrip,
- Type_Window,
- Type_Root
- };
-%}
%rename(register) python_register;
-%inline %{
-/*PyObject * python_register(int action, PyObject *func, bool infront = false)
-{
- if (!PyCallable_Check(func)) {
- PyErr_SetString(PyExc_TypeError, "Invalid callback function.");
- return NULL;
- }
-
- if (!ob::Openbox::instance->actions()->registerCallback(
- (ob::OBActions::ActionType)action, func, infront)) {
- PyErr_SetString(PyExc_RuntimeError, "Unable to register action callback.");
- return NULL;
- }
- Py_INCREF(Py_None); return Py_None;
-}
-
-PyObject * unregister(int action, PyObject *func)
-{
- if (!PyCallable_Check(func)) {
- PyErr_SetString(PyExc_TypeError, "Invalid callback function.");
- return NULL;
- }
-
- if (!ob::Openbox::instance->actions()->unregisterCallback(
- (ob::OBActions::ActionType)action, func)) {
- PyErr_SetString(PyExc_RuntimeError, "Unable to unregister action callback.");
- return NULL;
- }
- Py_INCREF(Py_None); return Py_None;
-}
-
-PyObject * unregister_all(int action)
-{
- if (!ob::Openbox::instance->actions()->unregisterAllCallbacks(
- (ob::OBActions::ActionType)action)) {
- PyErr_SetString(PyExc_RuntimeError,
- "Unable to unregister action callbacks.");
- return NULL;
- }
- Py_INCREF(Py_None); return Py_None;
-}
-*/
-PyObject * mbind(const std::string &button, MouseContext context,
- PyObject *func)
-{
- if (!PyCallable_Check(func)) {
- PyErr_SetString(PyExc_TypeError, "Invalid callback function.");
- return NULL;
- }
-
- if (!ob::Openbox::instance->bindings()->add(vectkeylist, func)) {
- PyErr_SetString(PyExc_RuntimeError,"Unable to add binding.");
- return NULL;
- }
- Py_INCREF(Py_None); return Py_None;
-}
-
-PyObject * kbind(PyObject *keylist, KeyContext context, PyObject *func)
-{
- if (!PyCallable_Check(func)) {
- PyErr_SetString(PyExc_TypeError, "Invalid callback function.");
- return NULL;
- }
- if (!PyList_Check(keylist)) {
- PyErr_SetString(PyExc_TypeError, "Invalid keylist. Not a list.");
- return NULL;
- }
-
- ob::OBBindings::StringVect vectkeylist;
- for (int i = 0, end = PyList_Size(keylist); i < end; ++i) {
- PyObject *str = PyList_GetItem(keylist, i);
- if (!PyString_Check(str)) {
- PyErr_SetString(PyExc_TypeError,
- "Invalid keylist. It must contain only strings.");
- return NULL;
- }
- vectkeylist.push_back(PyString_AsString(str));
- }
-
- if (!ob::Openbox::instance->bindings()->add(vectkeylist, func)) {
- PyErr_SetString(PyExc_RuntimeError,"Unable to add binding.");
- return NULL;
- }
- Py_INCREF(Py_None); return Py_None;
-}
-
-PyObject * kunbind(PyObject *keylist)
-{
- if (!PyList_Check(keylist)) {
- PyErr_SetString(PyExc_TypeError, "Invalid keylist. Not a list.");
- return NULL;
- }
-
- ob::OBBindings::StringVect vectkeylist;
- for (int i = 0, end = PyList_Size(keylist); i < end; ++i) {
- PyObject *str = PyList_GetItem(keylist, i);
- if (!PyString_Check(str)) {
- PyErr_SetString(PyExc_TypeError,
- "Invalid keylist. It must contain only strings.");
- return NULL;
- }
- vectkeylist.push_back(PyString_AsString(str));
- }
-
- ob::Openbox::instance->bindings()->remove(vectkeylist);
- Py_INCREF(Py_None); return Py_None;
-}
-
-void kunbind_all()
-{
- ob::Openbox::instance->bindings()->removeAll();
-}
-
-void set_reset_key(const std::string &key)
-{
- ob::Openbox::instance->bindings()->setResetKey(key);
-}
-%}
%ignore ob::OBScreen::clients;
%{
#define SWIGTYPE_p_ob__Cursors swig_types[2]
#define SWIGTYPE_p_ob__OBScreen swig_types[3]
#define SWIGTYPE_p_otk__Style swig_types[4]
-#define SWIGTYPE_p_KeyContext swig_types[5]
-#define SWIGTYPE_p_ob__OBFrame swig_types[6]
-#define SWIGTYPE_p_XReparentEvent swig_types[7]
-#define SWIGTYPE_p_ob__OBClient swig_types[8]
-#define SWIGTYPE_p_ob__Openbox swig_types[9]
-#define SWIGTYPE_p_otk__Strut swig_types[10]
-#define SWIGTYPE_p_XShapeEvent swig_types[11]
-#define SWIGTYPE_p_XConfigureRequestEvent swig_types[12]
-#define SWIGTYPE_p_otk__OtkEventHandler swig_types[13]
+#define SWIGTYPE_p_ob__OBFrame swig_types[5]
+#define SWIGTYPE_p_XReparentEvent swig_types[6]
+#define SWIGTYPE_p_ob__OBClient swig_types[7]
+#define SWIGTYPE_p_ob__Openbox swig_types[8]
+#define SWIGTYPE_p_otk__Strut swig_types[9]
+#define SWIGTYPE_p_XShapeEvent swig_types[10]
+#define SWIGTYPE_p_XConfigureRequestEvent swig_types[11]
+#define SWIGTYPE_p_otk__OtkEventHandler swig_types[12]
+#define SWIGTYPE_p_otk__Rect swig_types[13]
#define SWIGTYPE_p_ob__OBWidget swig_types[14]
-#define SWIGTYPE_p_otk__Rect swig_types[15]
-#define SWIGTYPE_p_XFocusChangeEvent swig_types[16]
-#define SWIGTYPE_p_XClientMessageEvent swig_types[17]
-#define SWIGTYPE_p_otk__OBProperty swig_types[18]
-#define SWIGTYPE_p_otk__OtkEventDispatcher swig_types[19]
-#define SWIGTYPE_p_XPropertyEvent swig_types[20]
-#define SWIGTYPE_p_XDestroyWindowEvent swig_types[21]
+#define SWIGTYPE_p_XFocusChangeEvent swig_types[15]
+#define SWIGTYPE_p_XClientMessageEvent swig_types[16]
+#define SWIGTYPE_p_otk__OBProperty swig_types[17]
+#define SWIGTYPE_p_otk__OtkEventDispatcher swig_types[18]
+#define SWIGTYPE_p_XPropertyEvent swig_types[19]
+#define SWIGTYPE_p_XDestroyWindowEvent swig_types[20]
+#define SWIGTYPE_p_otk__BImageControl swig_types[21]
#define SWIGTYPE_p_PyObject swig_types[22]
-#define SWIGTYPE_p_otk__BImageControl swig_types[23]
-#define SWIGTYPE_p_ob__OBBindings swig_types[24]
-#define SWIGTYPE_p_ob__MwmHints swig_types[25]
-#define SWIGTYPE_p_XUnmapEvent swig_types[26]
-static swig_type_info *swig_types[28];
+#define SWIGTYPE_p_ob__OBBindings swig_types[23]
+#define SWIGTYPE_p_ob__MwmHints swig_types[24]
+#define SWIGTYPE_p_XUnmapEvent swig_types[25]
+static swig_type_info *swig_types[27];
/* -------- TYPES TABLE (END) -------- */
ob::Openbox *Openbox_instance() { return ob::Openbox::instance; }
- enum ActionType {
- Action_ButtonPress,
- Action_Click,
- Action_DoubleClick,
- Action_EnterWindow,
- Action_LeaveWindow,
- Action_KeyPress,
- Action_MouseMotion,
- Action_NewWindow,
- Action_CloseWindow
- };
- enum WidgetType {
- Type_Frame,
- Type_Titlebar,
- Type_Handle,
- Type_Plate,
- Type_Label,
- Type_MaximizeButton,
- Type_CloseButton,
- Type_IconifyButton,
- Type_StickyButton,
- Type_LeftGrip,
- Type_RightGrip,
- Type_Window,
- Type_Root
- };
-
-
-/*PyObject * python_register(int action, PyObject *func, bool infront = false)
-{
- if (!PyCallable_Check(func)) {
- PyErr_SetString(PyExc_TypeError, "Invalid callback function.");
- return NULL;
- }
-
- if (!ob::Openbox::instance->actions()->registerCallback(
- (ob::OBActions::ActionType)action, func, infront)) {
- PyErr_SetString(PyExc_RuntimeError, "Unable to register action callback.");
- return NULL;
- }
- Py_INCREF(Py_None); return Py_None;
-}
-
-PyObject * unregister(int action, PyObject *func)
-{
- if (!PyCallable_Check(func)) {
- PyErr_SetString(PyExc_TypeError, "Invalid callback function.");
- return NULL;
- }
-
- if (!ob::Openbox::instance->actions()->unregisterCallback(
- (ob::OBActions::ActionType)action, func)) {
- PyErr_SetString(PyExc_RuntimeError, "Unable to unregister action callback.");
- return NULL;
- }
- Py_INCREF(Py_None); return Py_None;
-}
-
-PyObject * unregister_all(int action)
-{
- if (!ob::Openbox::instance->actions()->unregisterAllCallbacks(
- (ob::OBActions::ActionType)action)) {
- PyErr_SetString(PyExc_RuntimeError,
- "Unable to unregister action callbacks.");
- return NULL;
- }
- Py_INCREF(Py_None); return Py_None;
-}
-*/
-PyObject * mbind(const std::string &button, KeyContext context, PyObject *func)
-{
- if (!PyCallable_Check(func)) {
- PyErr_SetString(PyExc_TypeError, "Invalid callback function.");
- return NULL;
- }
-
- if (!ob::Openbox::instance->bindings()->add(vectkeylist, func)) {
- PyErr_SetString(PyExc_RuntimeError,"Unable to add binding.");
- return NULL;
- }
- Py_INCREF(Py_None); return Py_None;
-}
-
-PyObject * kbind(PyObject *keylist, KeyContext context, PyObject *func)
-{
- if (!PyCallable_Check(func)) {
- PyErr_SetString(PyExc_TypeError, "Invalid callback function.");
- return NULL;
- }
- if (!PyList_Check(keylist)) {
- PyErr_SetString(PyExc_TypeError, "Invalid keylist. Not a list.");
- return NULL;
- }
-
- ob::OBBindings::StringVect vectkeylist;
- for (int i = 0, end = PyList_Size(keylist); i < end; ++i) {
- PyObject *str = PyList_GetItem(keylist, i);
- if (!PyString_Check(str)) {
- PyErr_SetString(PyExc_TypeError,
- "Invalid keylist. It must contain only strings.");
- return NULL;
- }
- vectkeylist.push_back(PyString_AsString(str));
- }
-
- if (!ob::Openbox::instance->bindings()->add(vectkeylist, func)) {
- PyErr_SetString(PyExc_RuntimeError,"Unable to add binding.");
- return NULL;
- }
- Py_INCREF(Py_None); return Py_None;
-}
-
-PyObject * kunbind(PyObject *keylist)
-{
- if (!PyList_Check(keylist)) {
- PyErr_SetString(PyExc_TypeError, "Invalid keylist. Not a list.");
- return NULL;
- }
-
- ob::OBBindings::StringVect vectkeylist;
- for (int i = 0, end = PyList_Size(keylist); i < end; ++i) {
- PyObject *str = PyList_GetItem(keylist, i);
- if (!PyString_Check(str)) {
- PyErr_SetString(PyExc_TypeError,
- "Invalid keylist. It must contain only strings.");
- return NULL;
- }
- vectkeylist.push_back(PyString_AsString(str));
- }
-
- ob::Openbox::instance->bindings()->remove(vectkeylist);
- Py_INCREF(Py_None); return Py_None;
-}
-
-void kunbind_all()
-{
- ob::Openbox::instance->bindings()->removeAll();
-}
-
-void set_reset_key(const std::string &key)
-{
- ob::Openbox::instance->bindings()->setResetKey(key);
-}
-
-
#include <iterator>
ob::OBClient *ob_OBScreen_client(ob::OBScreen *self,int i){
}
-static PyObject *_wrap_mbind(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- std::string *arg1 = 0 ;
- KeyContext arg2 ;
- PyObject *arg3 = (PyObject *) 0 ;
- PyObject *result;
- std::string temp1 ;
- KeyContext *argp2 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- PyObject * obj2 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"OOO:mbind",&obj0,&obj1,&obj2)) goto fail;
- {
- if (PyString_Check(obj0)) {
- temp1 = std::string(PyString_AsString(obj0));
- arg1 = &temp1;
- }else {
- SWIG_exception(SWIG_TypeError, "string expected");
- }
- }
- if ((SWIG_ConvertPtr(obj1,(void **) &argp2, SWIGTYPE_p_KeyContext,SWIG_POINTER_EXCEPTION) == -1)) SWIG_fail;
- arg2 = *argp2;
- arg3 = obj2;
- result = (PyObject *)mbind((std::string const &)*arg1,arg2,arg3);
-
- resultobj = result;
- return resultobj;
- fail:
- return NULL;
-}
-
-
-static PyObject *_wrap_kbind(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- PyObject *arg1 = (PyObject *) 0 ;
- KeyContext arg2 ;
- PyObject *arg3 = (PyObject *) 0 ;
- PyObject *result;
- KeyContext *argp2 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- PyObject * obj2 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"OOO:kbind",&obj0,&obj1,&obj2)) goto fail;
- arg1 = obj0;
- if ((SWIG_ConvertPtr(obj1,(void **) &argp2, SWIGTYPE_p_KeyContext,SWIG_POINTER_EXCEPTION) == -1)) SWIG_fail;
- arg2 = *argp2;
- arg3 = obj2;
- result = (PyObject *)kbind(arg1,arg2,arg3);
-
- resultobj = result;
- return resultobj;
- fail:
- return NULL;
-}
-
-
-static PyObject *_wrap_kunbind(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- PyObject *arg1 = (PyObject *) 0 ;
- PyObject *result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:kunbind",&obj0)) goto fail;
- arg1 = obj0;
- result = (PyObject *)kunbind(arg1);
-
- resultobj = result;
- return resultobj;
- fail:
- return NULL;
-}
-
-
-static PyObject *_wrap_kunbind_all(PyObject *self, PyObject *args) {
- PyObject *resultobj;
-
- if(!PyArg_ParseTuple(args,(char *)":kunbind_all")) goto fail;
- kunbind_all();
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
-}
-
-
-static PyObject *_wrap_set_reset_key(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- std::string *arg1 = 0 ;
- std::string temp1 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:set_reset_key",&obj0)) goto fail;
- {
- if (PyString_Check(obj0)) {
- temp1 = std::string(PyString_AsString(obj0));
- arg1 = &temp1;
- }else {
- SWIG_exception(SWIG_TypeError, "string expected");
- }
- }
- set_reset_key((std::string const &)*arg1);
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
-}
-
-
static PyObject *_wrap_Cursors_session_set(PyObject *self, PyObject *args) {
PyObject *resultobj;
ob::Cursors *arg1 = (ob::Cursors *) 0 ;
Py_INCREF(obj);
return Py_BuildValue((char *)"");
}
+static PyObject *_wrap_mbind(PyObject *self, PyObject *args) {
+ PyObject *resultobj;
+ std::string *arg1 = 0 ;
+ int arg2 ;
+ int arg3 ;
+ PyObject *arg4 = (PyObject *) 0 ;
+ PyObject *result;
+ std::string temp1 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj3 = 0 ;
+
+ if(!PyArg_ParseTuple(args,(char *)"OiiO:mbind",&obj0,&arg2,&arg3,&obj3)) goto fail;
+ {
+ if (PyString_Check(obj0)) {
+ temp1 = std::string(PyString_AsString(obj0));
+ arg1 = &temp1;
+ }else {
+ SWIG_exception(SWIG_TypeError, "string expected");
+ }
+ }
+ arg4 = obj3;
+ result = (PyObject *)ob::mbind((std::string const &)*arg1,(ob::MouseContext )arg2,(ob::MouseAction )arg3,arg4);
+
+ resultobj = result;
+ return resultobj;
+ fail:
+ return NULL;
+}
+
+
+static PyObject *_wrap_kbind(PyObject *self, PyObject *args) {
+ PyObject *resultobj;
+ PyObject *arg1 = (PyObject *) 0 ;
+ int arg2 ;
+ PyObject *arg3 = (PyObject *) 0 ;
+ PyObject *result;
+ PyObject * obj0 = 0 ;
+ PyObject * obj2 = 0 ;
+
+ if(!PyArg_ParseTuple(args,(char *)"OiO:kbind",&obj0,&arg2,&obj2)) goto fail;
+ arg1 = obj0;
+ arg3 = obj2;
+ result = (PyObject *)ob::kbind(arg1,(ob::KeyContext )arg2,arg3);
+
+ resultobj = result;
+ return resultobj;
+ fail:
+ return NULL;
+}
+
+
+static PyObject *_wrap_kunbind(PyObject *self, PyObject *args) {
+ PyObject *resultobj;
+ PyObject *arg1 = (PyObject *) 0 ;
+ PyObject *result;
+ PyObject * obj0 = 0 ;
+
+ if(!PyArg_ParseTuple(args,(char *)"O:kunbind",&obj0)) goto fail;
+ arg1 = obj0;
+ result = (PyObject *)ob::kunbind(arg1);
+
+ resultobj = result;
+ return resultobj;
+ fail:
+ return NULL;
+}
+
+
+static PyObject *_wrap_kunbind_all(PyObject *self, PyObject *args) {
+ PyObject *resultobj;
+
+ if(!PyArg_ParseTuple(args,(char *)":kunbind_all")) goto fail;
+ ob::kunbind_all();
+
+ Py_INCREF(Py_None); resultobj = Py_None;
+ return resultobj;
+ fail:
+ return NULL;
+}
+
+
+static PyObject *_wrap_set_reset_key(PyObject *self, PyObject *args) {
+ PyObject *resultobj;
+ std::string *arg1 = 0 ;
+ std::string temp1 ;
+ PyObject * obj0 = 0 ;
+
+ if(!PyArg_ParseTuple(args,(char *)"O:set_reset_key",&obj0)) goto fail;
+ {
+ if (PyString_Check(obj0)) {
+ temp1 = std::string(PyString_AsString(obj0));
+ arg1 = &temp1;
+ }else {
+ SWIG_exception(SWIG_TypeError, "string expected");
+ }
+ }
+ ob::set_reset_key((std::string const &)*arg1);
+
+ Py_INCREF(Py_None); resultobj = Py_None;
+ return resultobj;
+ fail:
+ return NULL;
+}
+
+
static PyMethodDef SwigMethods[] = {
{ (char *)"Openbox_instance", _wrap_Openbox_instance, METH_VARARGS },
- { (char *)"mbind", _wrap_mbind, METH_VARARGS },
- { (char *)"kbind", _wrap_kbind, METH_VARARGS },
- { (char *)"kunbind", _wrap_kunbind, METH_VARARGS },
- { (char *)"kunbind_all", _wrap_kunbind_all, METH_VARARGS },
- { (char *)"set_reset_key", _wrap_set_reset_key, METH_VARARGS },
{ (char *)"Cursors_session_set", _wrap_Cursors_session_set, METH_VARARGS },
{ (char *)"Cursors_session_get", _wrap_Cursors_session_get, METH_VARARGS },
{ (char *)"Cursors_move_set", _wrap_Cursors_move_set, METH_VARARGS },
{ (char *)"OBClient_destroyHandler", _wrap_OBClient_destroyHandler, METH_VARARGS },
{ (char *)"OBClient_reparentHandler", _wrap_OBClient_reparentHandler, METH_VARARGS },
{ (char *)"OBClient_swigregister", OBClient_swigregister, METH_VARARGS },
+ { (char *)"mbind", _wrap_mbind, METH_VARARGS },
+ { (char *)"kbind", _wrap_kbind, METH_VARARGS },
+ { (char *)"kunbind", _wrap_kunbind, METH_VARARGS },
+ { (char *)"kunbind_all", _wrap_kunbind_all, METH_VARARGS },
+ { (char *)"set_reset_key", _wrap_set_reset_key, METH_VARARGS },
{ NULL, NULL }
};
static swig_type_info _swigt__p_ob__Cursors[] = {{"_p_ob__Cursors", 0, "ob::Cursors *", 0},{"_p_ob__Cursors"},{0}};
static swig_type_info _swigt__p_ob__OBScreen[] = {{"_p_ob__OBScreen", 0, "ob::OBScreen *", 0},{"_p_ob__OBScreen"},{0}};
static swig_type_info _swigt__p_otk__Style[] = {{"_p_otk__Style", 0, "otk::Style *", 0},{"_p_otk__Style"},{0}};
-static swig_type_info _swigt__p_KeyContext[] = {{"_p_KeyContext", 0, "KeyContext *", 0},{"_p_KeyContext"},{0}};
static swig_type_info _swigt__p_ob__OBFrame[] = {{"_p_ob__OBFrame", 0, "ob::OBFrame *", 0},{"_p_ob__OBFrame"},{0}};
static swig_type_info _swigt__p_XReparentEvent[] = {{"_p_XReparentEvent", 0, "XReparentEvent *", 0},{"_p_XReparentEvent"},{0}};
static swig_type_info _swigt__p_ob__OBClient[] = {{"_p_ob__OBClient", 0, "ob::OBClient *", 0},{"_p_ob__OBClient"},{0}};
static swig_type_info _swigt__p_XShapeEvent[] = {{"_p_XShapeEvent", 0, "XShapeEvent *", 0},{"_p_XShapeEvent"},{0}};
static swig_type_info _swigt__p_XConfigureRequestEvent[] = {{"_p_XConfigureRequestEvent", 0, "XConfigureRequestEvent *", 0},{"_p_XConfigureRequestEvent"},{0}};
static swig_type_info _swigt__p_otk__OtkEventHandler[] = {{"_p_otk__OtkEventHandler", 0, "otk::OtkEventHandler *", 0},{"_p_ob__OBActions", _p_ob__OBActionsTo_p_otk__OtkEventHandler},{"_p_otk__OtkEventHandler"},{"_p_ob__Openbox", _p_ob__OpenboxTo_p_otk__OtkEventHandler},{"_p_ob__OBClient", _p_ob__OBClientTo_p_otk__OtkEventHandler},{0}};
-static swig_type_info _swigt__p_ob__OBWidget[] = {{"_p_ob__OBWidget", 0, "ob::OBWidget *", 0},{"_p_ob__OBWidget"},{"_p_ob__OBClient", _p_ob__OBClientTo_p_ob__OBWidget},{0}};
static swig_type_info _swigt__p_otk__Rect[] = {{"_p_otk__Rect", 0, "otk::Rect *", 0},{"_p_otk__Rect"},{0}};
+static swig_type_info _swigt__p_ob__OBWidget[] = {{"_p_ob__OBWidget", 0, "ob::OBWidget *", 0},{"_p_ob__OBWidget"},{"_p_ob__OBClient", _p_ob__OBClientTo_p_ob__OBWidget},{0}};
static swig_type_info _swigt__p_XFocusChangeEvent[] = {{"_p_XFocusChangeEvent", 0, "XFocusChangeEvent *", 0},{"_p_XFocusChangeEvent"},{0}};
static swig_type_info _swigt__p_XClientMessageEvent[] = {{"_p_XClientMessageEvent", 0, "XClientMessageEvent *", 0},{"_p_XClientMessageEvent"},{0}};
static swig_type_info _swigt__p_otk__OBProperty[] = {{"_p_otk__OBProperty", 0, "otk::OBProperty *", 0},{"_p_otk__OBProperty"},{0}};
static swig_type_info _swigt__p_otk__OtkEventDispatcher[] = {{"_p_otk__OtkEventDispatcher", 0, "otk::OtkEventDispatcher *", 0},{"_p_otk__OtkEventDispatcher"},{"_p_ob__Openbox", _p_ob__OpenboxTo_p_otk__OtkEventDispatcher},{0}};
static swig_type_info _swigt__p_XPropertyEvent[] = {{"_p_XPropertyEvent", 0, "XPropertyEvent *", 0},{"_p_XPropertyEvent"},{0}};
static swig_type_info _swigt__p_XDestroyWindowEvent[] = {{"_p_XDestroyWindowEvent", 0, "XDestroyWindowEvent *", 0},{"_p_XDestroyWindowEvent"},{0}};
-static swig_type_info _swigt__p_PyObject[] = {{"_p_PyObject", 0, "PyObject *", 0},{"_p_PyObject"},{0}};
static swig_type_info _swigt__p_otk__BImageControl[] = {{"_p_otk__BImageControl", 0, "otk::BImageControl *", 0},{"_p_otk__BImageControl"},{0}};
+static swig_type_info _swigt__p_PyObject[] = {{"_p_PyObject", 0, "PyObject *", 0},{"_p_PyObject"},{0}};
static swig_type_info _swigt__p_ob__OBBindings[] = {{"_p_ob__OBBindings", 0, "ob::OBBindings *", 0},{"_p_ob__OBBindings"},{0}};
static swig_type_info _swigt__p_ob__MwmHints[] = {{"_p_ob__MwmHints", 0, "ob::MwmHints *", 0},{"_p_ob__MwmHints"},{0}};
static swig_type_info _swigt__p_XUnmapEvent[] = {{"_p_XUnmapEvent", 0, "XUnmapEvent *", 0},{"_p_XUnmapEvent"},{0}};
_swigt__p_ob__Cursors,
_swigt__p_ob__OBScreen,
_swigt__p_otk__Style,
-_swigt__p_KeyContext,
_swigt__p_ob__OBFrame,
_swigt__p_XReparentEvent,
_swigt__p_ob__OBClient,
_swigt__p_XShapeEvent,
_swigt__p_XConfigureRequestEvent,
_swigt__p_otk__OtkEventHandler,
-_swigt__p_ob__OBWidget,
_swigt__p_otk__Rect,
+_swigt__p_ob__OBWidget,
_swigt__p_XFocusChangeEvent,
_swigt__p_XClientMessageEvent,
_swigt__p_otk__OBProperty,
_swigt__p_otk__OtkEventDispatcher,
_swigt__p_XPropertyEvent,
_swigt__p_XDestroyWindowEvent,
-_swigt__p_PyObject,
_swigt__p_otk__BImageControl,
+_swigt__p_PyObject,
_swigt__p_ob__OBBindings,
_swigt__p_ob__MwmHints,
_swigt__p_XUnmapEvent,
/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
static swig_const_info swig_const_table[] = {
-{ SWIG_PY_INT, (char *)"Action_ButtonPress", (long) Action_ButtonPress, 0, 0, 0},
-{ SWIG_PY_INT, (char *)"Action_Click", (long) Action_Click, 0, 0, 0},
-{ SWIG_PY_INT, (char *)"Action_DoubleClick", (long) Action_DoubleClick, 0, 0, 0},
-{ SWIG_PY_INT, (char *)"Action_EnterWindow", (long) Action_EnterWindow, 0, 0, 0},
-{ SWIG_PY_INT, (char *)"Action_LeaveWindow", (long) Action_LeaveWindow, 0, 0, 0},
-{ SWIG_PY_INT, (char *)"Action_KeyPress", (long) Action_KeyPress, 0, 0, 0},
-{ SWIG_PY_INT, (char *)"Action_MouseMotion", (long) Action_MouseMotion, 0, 0, 0},
-{ SWIG_PY_INT, (char *)"Action_NewWindow", (long) Action_NewWindow, 0, 0, 0},
-{ SWIG_PY_INT, (char *)"Action_CloseWindow", (long) Action_CloseWindow, 0, 0, 0},
-{ SWIG_PY_INT, (char *)"Type_Frame", (long) Type_Frame, 0, 0, 0},
-{ SWIG_PY_INT, (char *)"Type_Titlebar", (long) Type_Titlebar, 0, 0, 0},
-{ SWIG_PY_INT, (char *)"Type_Handle", (long) Type_Handle, 0, 0, 0},
-{ SWIG_PY_INT, (char *)"Type_Plate", (long) Type_Plate, 0, 0, 0},
-{ SWIG_PY_INT, (char *)"Type_Label", (long) Type_Label, 0, 0, 0},
-{ SWIG_PY_INT, (char *)"Type_MaximizeButton", (long) Type_MaximizeButton, 0, 0, 0},
-{ SWIG_PY_INT, (char *)"Type_CloseButton", (long) Type_CloseButton, 0, 0, 0},
-{ SWIG_PY_INT, (char *)"Type_IconifyButton", (long) Type_IconifyButton, 0, 0, 0},
-{ SWIG_PY_INT, (char *)"Type_StickyButton", (long) Type_StickyButton, 0, 0, 0},
-{ SWIG_PY_INT, (char *)"Type_LeftGrip", (long) Type_LeftGrip, 0, 0, 0},
-{ SWIG_PY_INT, (char *)"Type_RightGrip", (long) Type_RightGrip, 0, 0, 0},
-{ SWIG_PY_INT, (char *)"Type_Window", (long) Type_Window, 0, 0, 0},
-{ SWIG_PY_INT, (char *)"Type_Root", (long) Type_Root, 0, 0, 0},
{ SWIG_PY_INT, (char *)"Openbox_State_Starting", (long) ob::Openbox::State_Starting, 0, 0, 0},
{ SWIG_PY_INT, (char *)"Openbox_State_Normal", (long) ob::Openbox::State_Normal, 0, 0, 0},
{ SWIG_PY_INT, (char *)"Openbox_State_Exiting", (long) ob::Openbox::State_Exiting, 0, 0, 0},
{ SWIG_PY_INT, (char *)"OBClient_State_Toggle", (long) ob::OBClient::State_Toggle, 0, 0, 0},
{ SWIG_PY_INT, (char *)"OBClient_event_mask", (long) ob::OBClient::event_mask, 0, 0, 0},
{ SWIG_PY_INT, (char *)"OBClient_no_propagate_mask", (long) ob::OBClient::no_propagate_mask, 0, 0, 0},
+{ SWIG_PY_INT, (char *)"MC_Frame", (long) ob::MC_Frame, 0, 0, 0},
+{ SWIG_PY_INT, (char *)"MC_Titlebar", (long) ob::MC_Titlebar, 0, 0, 0},
+{ SWIG_PY_INT, (char *)"MC_Window", (long) ob::MC_Window, 0, 0, 0},
+{ SWIG_PY_INT, (char *)"MC_MaximizeButton", (long) ob::MC_MaximizeButton, 0, 0, 0},
+{ SWIG_PY_INT, (char *)"MC_CloseButton", (long) ob::MC_CloseButton, 0, 0, 0},
+{ SWIG_PY_INT, (char *)"MC_IconifyButton", (long) ob::MC_IconifyButton, 0, 0, 0},
+{ SWIG_PY_INT, (char *)"MC_StickyButton", (long) ob::MC_StickyButton, 0, 0, 0},
+{ SWIG_PY_INT, (char *)"MC_Grip", (long) ob::MC_Grip, 0, 0, 0},
+{ SWIG_PY_INT, (char *)"MC_Root", (long) ob::MC_Root, 0, 0, 0},
+{ SWIG_PY_INT, (char *)"MC_MenuItem", (long) ob::MC_MenuItem, 0, 0, 0},
+{ SWIG_PY_INT, (char *)"NUM_MOUSE_CONTEXT", (long) ob::NUM_MOUSE_CONTEXT, 0, 0, 0},
+{ SWIG_PY_INT, (char *)"MousePress", (long) ob::MousePress, 0, 0, 0},
+{ SWIG_PY_INT, (char *)"MouseClick", (long) ob::MouseClick, 0, 0, 0},
+{ SWIG_PY_INT, (char *)"MouseDoubleClick", (long) ob::MouseDoubleClick, 0, 0, 0},
+{ SWIG_PY_INT, (char *)"MouseMotion", (long) ob::MouseMotion, 0, 0, 0},
+{ SWIG_PY_INT, (char *)"NUM_MOUSE_ACTION", (long) ob::NUM_MOUSE_ACTION, 0, 0, 0},
+{ SWIG_PY_INT, (char *)"KC_Menu", (long) ob::KC_Menu, 0, 0, 0},
+{ SWIG_PY_INT, (char *)"KC_All", (long) ob::KC_All, 0, 0, 0},
+{ SWIG_PY_INT, (char *)"NUM_KEY_CONTEXT", (long) ob::NUM_KEY_CONTEXT, 0, 0, 0},
{ SWIG_PY_INT, (char *)"X_PROTOCOL", (long) 11, 0, 0, 0},
{ SWIG_PY_INT, (char *)"X_PROTOCOL_REVISION", (long) 0, 0, 0, 0},
{ SWIG_PY_INT, (char *)"None", (long) 0L, 0, 0, 0},
typedef struct {
PyObject_HEAD;
- OBActions::ActionType action;
+ MouseAction action;
Window window;
- OBWidget::WidgetType type;
+ MouseContext context;
unsigned int state;
unsigned int button;
int xroot;
return PyLong_FromLong(self->window);
}
-PyObject *ActionData_target(ActionData *self, PyObject *args)
+PyObject *ActionData_context(ActionData *self, PyObject *args)
{
- if(!PyArg_ParseTuple(args,":target")) return NULL;
- return PyLong_FromLong((int)self->type);
+ if(!PyArg_ParseTuple(args,":context")) return NULL;
+ return PyLong_FromLong((int)self->context);
}
PyObject *ActionData_modifiers(ActionData *self, PyObject *args)
"Return the action being executed."},
{"window", (PyCFunction)ActionData_window, METH_VARARGS,
"Return the client window id."},
- {"target", (PyCFunction)ActionData_target, METH_VARARGS,
- "Return the target type that the action is occuring on."},
+ {"context", (PyCFunction)ActionData_context, METH_VARARGS,
+ "Return the context that the action is occuring in."},
{"modifiers", (PyCFunction)ActionData_modifiers, METH_VARARGS,
"Return the modifier keys state."},
{"button", (PyCFunction)ActionData_button, METH_VARARGS,
Py_DECREF(arglist);
}
-void python_callback(PyObject *func, OBActions::ActionType action,
- Window window, OBWidget::WidgetType type,
+void python_callback(PyObject *func, MouseAction action,
+ Window window, MouseContext context,
unsigned int state, unsigned int button,
int xroot, int yroot, Time time)
{
ActionData *data = PyObject_New(ActionData, &ActionData_Type);
data->action = action;
data->window = window;
- data->type = type;
+ data->context= context;
data->state = state;
data->button = button;
data->xroot = xroot;
return true;
}
+// ************************************* //
+// Stuff for calling from Python scripts //
+// ************************************* //
+
+/*
+PyObject * python_register(int action, PyObject *func, bool infront = false)
+{
+ if (!PyCallable_Check(func)) {
+ PyErr_SetString(PyExc_TypeError, "Invalid callback function.");
+ return NULL;
+ }
+
+ if (!ob::Openbox::instance->actions()->registerCallback(
+ (ob::OBActions::ActionType)action, func, infront)) {
+ PyErr_SetString(PyExc_RuntimeError, "Unable to register action callback.");
+ return NULL;
+ }
+ Py_INCREF(Py_None); return Py_None;
+}
+
+PyObject *unregister(int action, PyObject *func)
+{
+ if (!PyCallable_Check(func)) {
+ PyErr_SetString(PyExc_TypeError, "Invalid callback function.");
+ return NULL;
+ }
+
+ if (!ob::Openbox::instance->actions()->unregisterCallback(
+ (ob::OBActions::ActionType)action, func)) {
+ PyErr_SetString(PyExc_RuntimeError, "Unable to unregister action callback.");
+ return NULL;
+ }
+ Py_INCREF(Py_None); return Py_None;
+}
+
+PyObject *unregister_all(int action)
+{
+ if (!ob::Openbox::instance->actions()->unregisterAllCallbacks(
+ (ob::OBActions::ActionType)action)) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "Unable to unregister action callbacks.");
+ return NULL;
+ }
+ Py_INCREF(Py_None); return Py_None;
+}
+*/
+PyObject * mbind(const std::string &button, ob::MouseContext context,
+ ob::MouseAction action, PyObject *func)
+{
+ if (!PyCallable_Check(func)) {
+ PyErr_SetString(PyExc_TypeError, "Invalid callback function.");
+ return NULL;
+ }
+
+ if (!ob::Openbox::instance->bindings()->addButton(button, context,
+ action, func)) {
+ PyErr_SetString(PyExc_RuntimeError,"Unable to add binding.");
+ return NULL;
+ }
+ Py_INCREF(Py_None); return Py_None;
+}
+
+PyObject * kbind(PyObject *keylist, ob::KeyContext context, PyObject *func)
+{
+ if (!PyCallable_Check(func)) {
+ PyErr_SetString(PyExc_TypeError, "Invalid callback function.");
+ return NULL;
+ }
+ if (!PyList_Check(keylist)) {
+ PyErr_SetString(PyExc_TypeError, "Invalid keylist. Not a list.");
+ return NULL;
+ }
+
+ ob::OBBindings::StringVect vectkeylist;
+ for (int i = 0, end = PyList_Size(keylist); i < end; ++i) {
+ PyObject *str = PyList_GetItem(keylist, i);
+ if (!PyString_Check(str)) {
+ PyErr_SetString(PyExc_TypeError,
+ "Invalid keylist. It must contain only strings.");
+ return NULL;
+ }
+ vectkeylist.push_back(PyString_AsString(str));
+ }
+
+ if (!ob::Openbox::instance->bindings()->add(vectkeylist, func)) {
+ PyErr_SetString(PyExc_RuntimeError,"Unable to add binding.");
+ return NULL;
+ }
+ Py_INCREF(Py_None); return Py_None;
+}
+
+PyObject * kunbind(PyObject *keylist)
+{
+ if (!PyList_Check(keylist)) {
+ PyErr_SetString(PyExc_TypeError, "Invalid keylist. Not a list.");
+ return NULL;
+ }
+
+ ob::OBBindings::StringVect vectkeylist;
+ for (int i = 0, end = PyList_Size(keylist); i < end; ++i) {
+ PyObject *str = PyList_GetItem(keylist, i);
+ if (!PyString_Check(str)) {
+ PyErr_SetString(PyExc_TypeError,
+ "Invalid keylist. It must contain only strings.");
+ return NULL;
+ }
+ vectkeylist.push_back(PyString_AsString(str));
+ }
+
+ ob::Openbox::instance->bindings()->remove(vectkeylist);
+ Py_INCREF(Py_None); return Py_None;
+}
+
+void kunbind_all()
+{
+ ob::Openbox::instance->bindings()->removeAll();
+}
+
+void set_reset_key(const std::string &key)
+{
+ ob::Openbox::instance->bindings()->setResetKey(key);
+}
}
@brief wee
*/
-#include "actions.hh"
-#include "widget.hh"
-#include "bindings.hh"
-
extern "C" {
+#include <X11/Xlib.h>
#include <Python.h>
}
#include <string>
+#include <vector>
namespace ob {
MC_Grip,
MC_Root,
MC_MenuItem,
- MC_All,
NUM_MOUSE_CONTEXT
-}
+};
+
+enum MouseAction {
+ MousePress,
+ MouseClick,
+ MouseDoubleClick,
+ MouseMotion,
+ NUM_MOUSE_ACTION
+};
+
enum KeyContext {
KC_Menu,
KC_All,
NUM_KEY_CONTEXT
-}
+};
#ifndef SWIG
void python_init(char *argv0);
void python_destroy();
bool python_exec(const std::string &path);
-void python_callback(PyObject *func, OBActions::ActionType action,
- Window window, OBWidget::WidgetType type,
+void python_callback(PyObject *func, MouseAction action,
+ Window window, MouseContext context,
unsigned int state, unsigned int button,
int xroot, int yroot, Time time);
bool python_get_stringlist(const char *name, std::vector<std::string> *value);
#endif
+PyObject * mbind(const std::string &button, ob::MouseContext context,
+ ob::MouseAction action, PyObject *func);
+
+PyObject * kbind(PyObject *keylist, ob::KeyContext context, PyObject *func);
+PyObject * kunbind(PyObject *keylist);
+void kunbind_all();
+void set_reset_key(const std::string &key);
+
}
#endif // __python_hh
clients.push_back(client);
// update the root properties
setClientList();
+
+ Openbox::instance->bindings()->grabButtons(true, client);
}
{
OBFrame *frame = client->frame;
+ Openbox::instance->bindings()->grabButtons(false, client);
+
// XXX: pass around focus if this window was focused
// remove from the wm's map