[Bf-blender-cvs] [bbd4613ed94] blender2.8: Keymaps: make click event use position on button press rather than release.

Brecht Van Lommel noreply at git.blender.org
Sun Nov 18 12:31:22 CET 2018


Commit: bbd4613ed94931cd5443309d98ab8e112b64b93a
Author: Brecht Van Lommel
Date:   Sun Nov 18 12:14:55 2018 +0100
Branches: blender2.8
https://developer.blender.org/rBbbd4613ed94931cd5443309d98ab8e112b64b93a

Keymaps: make click event use position on button press rather than release.

This may improve reliability with left click select and pen input, assuming
that the place where the pen first touched the surface is closer to the
intended location than where it was released from the surface.

I'm not sure if this will make a significant difference in practice, but it
seems worth a try.

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

M	source/blender/editors/interface/interface_region_menu_pie.c
M	source/blender/windowmanager/intern/wm_event_system.c

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

diff --git a/source/blender/editors/interface/interface_region_menu_pie.c b/source/blender/editors/interface/interface_region_menu_pie.c
index 6887235f5db..b7fc1055154 100644
--- a/source/blender/editors/interface/interface_region_menu_pie.c
+++ b/source/blender/editors/interface/interface_region_menu_pie.c
@@ -152,15 +152,9 @@ uiPieMenu *UI_pie_menu_begin(struct bContext *C, const char *title, int icon, co
 
 	pie->layout = UI_block_layout(pie->block_radial, UI_LAYOUT_VERTICAL, UI_LAYOUT_PIEMENU, 0, 0, 200, 0, 0, style);
 
-	/* Open from where we started dragging. */
-	if (event->val == KM_CLICK_DRAG) {
-		pie->mx = event->prevclickx;
-		pie->my = event->prevclicky;
-	}
-	else {
-		pie->mx = event->x;
-		pie->my = event->y;
-	}
+	/* Note event->x/y is where we started dragging in case of KM_CLICK_DRAG. */
+	pie->mx = event->x;
+	pie->my = event->y;
 
 	/* create title button */
 	if (title[0]) {
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 63c45407135..f82df000288 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -2615,8 +2615,13 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
 				if ((abs(event->x - win->eventstate->prevclickx)) >= U.tweak_threshold ||
 				    (abs(event->y - win->eventstate->prevclicky)) >= U.tweak_threshold)
 				{
+					int x = event->x;
+					int y = event->y;
 					short val = event->val;
 					short type = event->type;
+
+					event->x = win->eventstate->prevclickx;
+					event->y = win->eventstate->prevclicky;
 					event->val = KM_CLICK_DRAG;
 					event->type = win->eventstate->type;
 
@@ -2626,6 +2631,8 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
 
 					event->val = val;
 					event->type = type;
+					event->x = x;
+					event->y = y;
 
 					win->eventstate->check_click = 0;
 					win->eventstate->check_drag = 0;
@@ -2668,6 +2675,13 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
 					if ((abs(event->x - win->eventstate->prevclickx)) <= WM_EVENT_CLICK_WIGGLE_ROOM &&
 					    (abs(event->y - win->eventstate->prevclicky)) <= WM_EVENT_CLICK_WIGGLE_ROOM)
 					{
+						/* Position is where the actual click happens, for more
+						 * accurate selecting in case the mouse drifts a little. */
+						int x = event->x;
+						int y = event->y;
+
+						event->x = win->eventstate->prevclickx;
+						event->y = win->eventstate->prevclicky;
 						event->val = KM_CLICK;
 
 						CLOG_INFO(WM_LOG_HANDLERS, 1, "handling CLICK");
@@ -2675,6 +2689,8 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
 						action |= wm_handlers_do_intern(C, event, handlers);
 
 						event->val = KM_RELEASE;
+						event->x = x;
+						event->y = y;
 					}
 					else {
 						win->eventstate->check_click = 0;



More information about the Bf-blender-cvs mailing list