+ if (!e.same_screen) return; // this just gets stupid
+
+ if (e.window != _press.win) return;
+
+ 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 = ce.x_root;
+ y_root = ce.y_root;
+ }
+
+ int screen;
+ Client *c = openbox->findClient(e.window);
+ if (c)
+ screen = c->screen();
+ else
+ screen = otk::display->findScreen(e.root)->screen();
+
+ if (!_dragging) {
+ int dx = x_root - _press.pos.x();
+ int dy = y_root - _press.pos.y();
+ long threshold = 0;
+ python_get_long("drag_threshold", &threshold);
+ 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 = _press.button;
+ MouseData data(screen, c, e.time, state, button, context,
+ MouseAction::Motion, x_root, y_root,
+ _press.pos, _press.clientarea);
+ openbox->bindings()->fireButton(&data);