- OBWidget *w = dynamic_cast<OBWidget*>
- (Openbox::instance->findHandler(e.window));
- assert(w); // everything should be a widget
+ 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