Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/windowmanager/intern/wm_event_system.c')
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c67
1 files changed, 42 insertions, 25 deletions
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index fcda06a7c2d..a9a248f027b 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -91,8 +91,9 @@
#include "DEG_depsgraph.h"
-/* Motion in pixels allowed before we don't consider single/double click. */
-#define WM_EVENT_CLICK_WIGGLE_ROOM 2
+/* Motion in pixels allowed before we don't consider single/double click,
+ * or detect the start of a tweak event. */
+#define WM_EVENT_CLICK_TWEAK_THRESHOLD (U.tweak_threshold * U.dpi_fac)
static void wm_notifier_clear(wmNotifier *note);
static void update_tablet_data(wmWindow *win, wmEvent *event);
@@ -1769,14 +1770,6 @@ void WM_event_remove_handlers(bContext *C, ListBase *handlers)
int WM_userdef_event_map(int kmitype)
{
switch (kmitype) {
- case SELECTMOUSE:
- return (U.flag & USER_LMOUSESELECT) ? LEFTMOUSE : RIGHTMOUSE;
- case ACTIONMOUSE:
- return (U.flag & USER_LMOUSESELECT) ? RIGHTMOUSE : LEFTMOUSE;
- case EVT_TWEAK_A:
- return (U.flag & USER_LMOUSESELECT) ? EVT_TWEAK_R : EVT_TWEAK_L;
- case EVT_TWEAK_S:
- return (U.flag & USER_LMOUSESELECT) ? EVT_TWEAK_L : EVT_TWEAK_R;
case WHEELOUTMOUSE:
return (U.uiflag & USER_WHEELZOOMDIR) ? WHEELUPMOUSE : WHEELDOWNMOUSE;
case WHEELINMOUSE:
@@ -1794,14 +1787,6 @@ int WM_userdef_event_map(int kmitype)
int WM_userdef_event_type_from_keymap_type(int kmitype)
{
switch (kmitype) {
- case SELECTMOUSE:
- return (U.flag & USER_LMOUSESELECT) ? LEFTMOUSE : RIGHTMOUSE;
- case ACTIONMOUSE:
- return (U.flag & USER_LMOUSESELECT) ? RIGHTMOUSE : LEFTMOUSE;
- case EVT_TWEAK_S:
- return (U.flag & USER_LMOUSESELECT) ? LEFTMOUSE : RIGHTMOUSE;
- case EVT_TWEAK_A:
- return (U.flag & USER_LMOUSESELECT) ? RIGHTMOUSE : LEFTMOUSE;
case EVT_TWEAK_L:
return LEFTMOUSE;
case EVT_TWEAK_M:
@@ -2628,11 +2613,16 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
if (wm_action_not_handled(action)) {
if (event->check_drag) {
wmWindow *win = CTX_wm_window(C);
- if ((abs(event->x - win->eventstate->prevclickx)) >= U.tweak_threshold ||
- (abs(event->y - win->eventstate->prevclicky)) >= U.tweak_threshold)
+ if ((abs(event->x - win->eventstate->prevclickx)) >= WM_EVENT_CLICK_TWEAK_THRESHOLD ||
+ (abs(event->y - win->eventstate->prevclicky)) >= WM_EVENT_CLICK_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;
@@ -2642,6 +2632,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;
@@ -2681,9 +2673,16 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
(win->eventstate->prevval == KM_PRESS) &&
(win->eventstate->check_click == true))
{
- if ((abs(event->x - win->eventstate->prevclickx)) <= WM_EVENT_CLICK_WIGGLE_ROOM &&
- (abs(event->y - win->eventstate->prevclicky)) <= WM_EVENT_CLICK_WIGGLE_ROOM)
+ if ((abs(event->x - win->eventstate->prevclickx)) < WM_EVENT_CLICK_TWEAK_THRESHOLD &&
+ (abs(event->y - win->eventstate->prevclicky)) < WM_EVENT_CLICK_TWEAK_THRESHOLD)
{
+ /* 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");
@@ -2691,6 +2690,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;
@@ -3662,6 +3663,22 @@ static void wm_eventemulation(wmEvent *event)
}
}
+/* applies the global tablet pressure correction curve */
+float wm_pressure_curve(float pressure)
+{
+ if (U.pressure_threshold_max != 0.0f) {
+ pressure /= U.pressure_threshold_max;
+ }
+
+ CLAMP(pressure, 0.0f, 1.0f);
+
+ if (U.pressure_softness != 0.0f) {
+ pressure = powf(pressure, powf(4.0f, -U.pressure_softness));
+ }
+
+ return pressure;
+}
+
/* adds customdata to event */
static void update_tablet_data(wmWindow *win, wmEvent *event)
{
@@ -3672,7 +3689,7 @@ static void update_tablet_data(wmWindow *win, wmEvent *event)
struct wmTabletData *wmtab = MEM_mallocN(sizeof(wmTabletData), "customdata tablet");
wmtab->Active = (int)td->Active;
- wmtab->Pressure = td->Pressure;
+ wmtab->Pressure = wm_pressure_curve(td->Pressure);
wmtab->Xtilt = td->Xtilt;
wmtab->Ytilt = td->Ytilt;
@@ -3767,8 +3784,8 @@ static bool wm_event_is_double_click(wmEvent *event, const wmEvent *event_state)
(event->val == KM_PRESS))
{
if ((ISMOUSE(event->type) == false) ||
- ((abs(event->x - event_state->prevclickx)) <= WM_EVENT_CLICK_WIGGLE_ROOM &&
- (abs(event->y - event_state->prevclicky)) <= WM_EVENT_CLICK_WIGGLE_ROOM))
+ ((abs(event->x - event_state->prevclickx)) < WM_EVENT_CLICK_TWEAK_THRESHOLD &&
+ (abs(event->y - event_state->prevclicky)) < WM_EVENT_CLICK_TWEAK_THRESHOLD))
{
if ((PIL_check_seconds_timer() - event_state->prevclicktime) * 1000 < U.dbl_click_time) {
return true;