+ MouseContext::MC context;
+ EventHandler *h = openbox->findHandler(e.window);
+ Frame *f = dynamic_cast<Frame*>(h);
+ if (f)
+ context= f->mouseContext(e.window);
+ else if (dynamic_cast<Client*>(h))
+ context = MouseContext::Window;
+ else if (dynamic_cast<Screen*>(h))
+ context = MouseContext::Root;
+ else
+ return; // not a valid mouse context
+
+ int x_root = e.x_root, y_root = e.y_root;
+
+ // compress changes to a window into a single change
+ XEvent ce;
+ while (XCheckTypedWindowEvent(**otk::display, e.window, e.type, &ce)) {
+ x_root = e.x_root;
+ y_root = e.y_root;
+ }
+
+ 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, context,
+ MouseAction::Motion, x_root, y_root,
+ _posqueue[0]->pos, _posqueue[0]->clientarea);
+ openbox->bindings()->fireButton(&data);