+ WidgetBase *w = dynamic_cast<WidgetBase*>
+ (openbox->findHandler(e.window));
+ if (!w) return;
+
+ if (!_dragging) {
+ long threshold;
+ int dx = x_root - _posqueue[0]->pos.x();
+ int dy = y_root - _posqueue[0]->pos.y();
+ // XXX: dont get this from python every time!
+ if (!python_get_long("drag_threshold", &threshold))
+ threshold = 0;
+ if (!(std::abs(dx) >= threshold || std::abs(dy) >= threshold))
+ return; // not at the threshold yet
+ }
+ _dragging = true; // in a drag now
+
+ // check if the movement is more than the threshold
+
+ // run the MOTION python hook
+ // kill off the Button1Mask etc, only want the modifiers
+ unsigned int state = e.state & (ControlMask | ShiftMask | Mod1Mask |
+ Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask);
+ unsigned int button = _posqueue[0]->button;
+ int screen;
+ Client *c = openbox->findClient(e.window);
+ if (c)
+ screen = c->screen();
+ else
+ screen = otk::display->findScreen(e.root)->screen();
+ MouseData data(screen, c, e.time, state, button, w->mcontext(),
+ MouseAction::Motion, x_root, y_root,
+ _posqueue[0]->pos, _posqueue[0]->clientarea);
+ openbox->bindings()->fireButton(&data);
+}