[Bf-blender-cvs] [6f6347e] master: Revert modal operation of cursor. This change was far less innocent than was first thought and could mess up tweaking events for the left mouse.

Antony Riakiotakis noreply at git.blender.org
Thu Aug 14 10:45:15 CEST 2014


Commit: 6f6347e4372770d57a932cf2c390be8489146a76
Author: Antony Riakiotakis
Date:   Thu Aug 14 10:45:00 2014 +0200
Branches: master
https://developer.blender.org/rB6f6347e4372770d57a932cf2c390be8489146a76

Revert modal operation of cursor. This change was far less innocent than
was first thought and could mess up tweaking events for the left mouse.

===================================================================

M	source/blender/editors/sculpt_paint/paint_curve.c
M	source/blender/editors/space_view3d/view3d_edit.c

===================================================================

diff --git a/source/blender/editors/sculpt_paint/paint_curve.c b/source/blender/editors/sculpt_paint/paint_curve.c
index 217c88c..8c7c3b1 100644
--- a/source/blender/editors/sculpt_paint/paint_curve.c
+++ b/source/blender/editors/sculpt_paint/paint_curve.c
@@ -744,44 +744,31 @@ void PAINTCURVE_OT_draw(wmOperatorType *ot)
 	ot->flag = OPTYPE_UNDO;
 }
 
-static int paintcurve_cursor_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+static int paintcurve_cursor_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
 {
-	op->customdata = SET_INT_IN_POINTER(event->type);
-	WM_event_add_modal_handler(C, op);
-
-	return OPERATOR_RUNNING_MODAL;
-}
-
-static int paintcurve_cursor_modal(bContext *C, wmOperator *op, const wmEvent *event)
-{
-	if (event->type == GET_INT_FROM_POINTER(op->customdata) && event->val == KM_RELEASE)
-		return OPERATOR_FINISHED;
-
-	if (event->type == MOUSEMOVE) {
-		PaintMode mode = BKE_paintmode_get_active_from_context(C);
-
-		switch (mode) {
-			case PAINT_TEXTURE_2D:
-			{
-				ARegion *ar = CTX_wm_region(C);
-				SpaceImage *sima = CTX_wm_space_image(C);
-				float location[2];
-
-				if (!sima)
-					return OPERATOR_CANCELLED;
-
-				UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &location[0], &location[1]);
-				copy_v2_v2(sima->cursor, location);
-				WM_event_add_notifier(C, NC_SPACE | ND_SPACE_IMAGE, NULL);
-				break;
-			}
-			default:
-				ED_view3d_cursor3d_update(C, event->mval);
-				break;
+	PaintMode mode = BKE_paintmode_get_active_from_context(C);
+	
+	switch (mode) {
+		case PAINT_TEXTURE_2D:
+		{
+			ARegion *ar = CTX_wm_region(C);
+			SpaceImage *sima = CTX_wm_space_image(C);
+			float location[2];
+			
+			if (!sima)
+				return OPERATOR_CANCELLED;
+			
+			UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &location[0], &location[1]);
+			copy_v2_v2(sima->cursor, location);
+			WM_event_add_notifier(C, NC_SPACE | ND_SPACE_IMAGE, NULL);
+			break;
 		}
+		default:
+			ED_view3d_cursor3d_update(C, event->mval);
+			break;
 	}
-
-	return OPERATOR_RUNNING_MODAL;
+	
+	return OPERATOR_FINISHED;
 }
 
 void PAINTCURVE_OT_cursor(wmOperatorType *ot)
@@ -793,7 +780,6 @@ void PAINTCURVE_OT_cursor(wmOperatorType *ot)
 
 	/* api callbacks */
 	ot->invoke = paintcurve_cursor_invoke;
-	ot->modal = paintcurve_cursor_modal;
 	ot->poll = paint_curve_poll;
 
 	/* flags */
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 5988473..6cd2e7b 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -4488,32 +4488,11 @@ void ED_view3d_cursor3d_update(bContext *C, const int mval[2])
 		WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene);
 }
 
-static int view3d_cursor3d_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+static int view3d_cursor3d_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
 {
 	ED_view3d_cursor3d_update(C, event->mval);
-	op->customdata = SET_INT_IN_POINTER(event->type);
-	WM_event_add_modal_handler(C, op);
 
-	return OPERATOR_RUNNING_MODAL;
-}
-
-static int view3d_cursor3d_modal(bContext *C, wmOperator *op, const wmEvent *event)
-{
-	int event_type = GET_INT_FROM_POINTER(op->customdata);
-
-	if (event->type == event_type) {
-		return OPERATOR_FINISHED;
-	}
-
-	switch (event->type) {
-		case MOUSEMOVE:
-			ED_view3d_cursor3d_update(C, event->mval);
-			break;
-		case LEFTMOUSE:
-			return OPERATOR_FINISHED;
-	}
-
-	return OPERATOR_RUNNING_MODAL;
+	return OPERATOR_FINISHED;	
 }
 
 void VIEW3D_OT_cursor3d(wmOperatorType *ot)
@@ -4526,7 +4505,6 @@ void VIEW3D_OT_cursor3d(wmOperatorType *ot)
 
 	/* api callbacks */
 	ot->invoke = view3d_cursor3d_invoke;
-	ot->modal  = view3d_cursor3d_modal;
 
 	ot->poll = ED_operator_view3d_active;




More information about the Bf-blender-cvs mailing list