- printf("GUILE: MOTION: win %lx type %d modifiers %u x %d y %d\n",
- (long)e.window, (w ? w->type():-1), e.state, _dx, _dy);
-
- OBClient *c = Openbox::instance->findClient(e.window);
- if (w && c) {
- switch (w->type()) {
- case OBWidget::Type_Titlebar:
- case OBWidget::Type_Label:
- c->move(_posqueue[0]->clientarea.x() + _dx,
- _posqueue[0]->clientarea.y() + _dy);
- break;
- case OBWidget::Type_LeftGrip:
- c->resize(OBClient::TopRight,
- _posqueue[0]->clientarea.width() - _dx,
- _posqueue[0]->clientarea.height() + _dy);
- break;
- case OBWidget::Type_RightGrip:
- c->resize(OBClient::TopLeft,
- _posqueue[0]->clientarea.width() + _dx,
- _posqueue[0]->clientarea.height() + _dy);
+ // 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,
+ (OBWidget::WidgetType)(w ? w->type():-1),
+ e.state, (unsigned)-1, e.x_root, e.y_root, e.time);
+}
+
+void OBActions::mapRequestHandler(const XMapRequestEvent &e)
+{
+ doCallback(Action_NewWindow, e.window, (OBWidget::WidgetType)-1,
+ 0, 0, 0, 0, 0);
+}
+
+void OBActions::unmapHandler(const XUnmapEvent &e)
+{
+ (void)e;
+ doCallback(Action_CloseWindow, e.window, (OBWidget::WidgetType)-1,
+ 0, 0, 0, 0, 0);
+}
+
+void OBActions::destroyHandler(const XDestroyWindowEvent &e)
+{
+ (void)e;
+ doCallback(Action_CloseWindow, e.window, (OBWidget::WidgetType)-1,
+ 0, 0, 0, 0, 0);
+}
+
+void OBActions::doCallback(ActionType action, Window window,
+ OBWidget::WidgetType type, unsigned int state,
+ unsigned int button, int xroot, int yroot,
+ Time time)
+{
+ std::pair<CallbackMap::iterator, CallbackMap::iterator> it_pair =
+ _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);
+}
+
+bool OBActions::registerCallback(ActionType action, PyObject *func,
+ bool atfront)
+{
+ if (action < 0 || action >= OBActions::NUM_ACTIONS ||
+ action == OBActions::Action_KeyPress) {
+ return false;
+ }
+ if (!func)
+ return false;
+
+ std::pair<CallbackMap::iterator, CallbackMap::iterator> it_pair =
+ _callbacks.equal_range(action);
+
+ CallbackMap::iterator it;
+ for (it = it_pair.first; it != it_pair.second; ++it)
+ if (it->second == func)