+ point_x->update((int64_t)(output_x));
+ point_y->update((int64_t)(output_y));
+ CriKeyPoints &points = plugin->config.points;
+
+ if( dragging > 0 ) {
+ switch( event->type ) {
+ case ButtonPress: {
+ int button_no = event->xbutton.button;
+ int hot_point = -1;
+ if( button_no == RIGHT_BUTTON ) {
+ hot_point = plugin->new_point();
+ CriKeyPoint *pt = points[hot_point];
+ pt->x = output_x; pt->y = output_y;
+ point_list->update(hot_point);
+ break;
+ }
+ int sz = points.size();
+ if( hot_point < 0 && sz > 0 ) {
+ CriKeyPoint *pt = points[hot_point=0];
+ double dist = DISTANCE(output_x,output_y, pt->x,pt->y);
+ for( int i=1; i<sz; ++i ) {
+ pt = points[i];
+ double d = DISTANCE(output_x,output_y, pt->x,pt->y);
+ if( d >= dist ) continue;
+ dist = d; hot_point = i;
+ }
+ pt = points[hot_point];
+ float px = (pt->x - track_w / 2) * projector_z + projector_x;
+ float py = (pt->y - track_h / 2) * projector_z + projector_y;
+ dist = DISTANCE(px, py, cursor_x,cursor_y);
+ if( dist >= HANDLE_W ) hot_point = -1;
+ }
+ if( hot_point >= 0 && sz > 0 ) {
+ CriKeyPoint *pt = points[hot_point];
+ point_list->set_point(hot_point, PT_X, pt->x = output_x);
+ for( int i=0; i<sz; ++i ) {
+ pt = points[i];
+ pt->e = i==hot_point ? !pt->e : 0;
+ point_list->set_point(i, PT_E, pt->e ? "*" : "");
+ }
+ point_list->update_list(hot_point);
+ }
+ break; }
+ case MotionNotify: {
+ int hot_point = point_list->get_selection_number(0, 0);
+ if( hot_point >= 0 && hot_point < points.size() ) {
+ CriKeyPoint *pt = points[hot_point];
+ if( pt->x == output_x && pt->y == output_y ) break;
+ point_list->set_point(hot_point, PT_X, pt->x = output_x);
+ point_list->set_point(hot_point, PT_Y, pt->y = output_y);
+ point_x->update(pt->x);
+ point_y->update(pt->y);
+ point_list->update_list(hot_point);
+ }
+ break; }
+ }
+ }
+ else {
+ switch( event->type ) {
+ case MotionNotify: {
+ float dx = output_x - last_x, dy = output_y - last_y;
+ int sz = points.size();
+ for( int i=0; i<sz; ++i ) {
+ CriKeyPoint *pt = points[i];
+ point_list->set_point(i, PT_X, pt->x += dx);
+ point_list->set_point(i, PT_Y, pt->y += dy);
+ }
+ int hot_point = point_list->get_selection_number(0, 0);
+ if( hot_point >= 0 && hot_point < sz ) {
+ CriKeyPoint *pt = points[hot_point];
+ point_x->update(pt->x);
+ point_y->update(pt->y);
+ point_list->update_list(hot_point);
+ }
+ break; }
+ }
+ }
+
+ last_x = output_x; last_y = output_y;
+ if( !grab_event_count() )
+ send_configure_change();
+ else
+ pending_config = 1;