Fix incorrect drag-event threshold when releasing modifiers early
db4313610c
added support for modifier
keys to be released while dragging.
The key release events set wmEvent.prev_type which is used select the
drag threshold, causing the wrong threshold to be used.
Add wmEvent.prev_click_type which is only set when the drag begins.
This commit is contained in:
parent
4b9c77a19a
commit
90ec634135
|
@ -636,6 +636,15 @@ typedef struct wmEvent {
|
|||
short prev_type;
|
||||
/** The previous value of `val`. */
|
||||
short prev_val;
|
||||
/**
|
||||
* The previous value of #wmEvent.xy,
|
||||
* Unlike other previous state variables, this is set on any mouse motion.
|
||||
* Use `prev_click` for the value at time of pressing.
|
||||
*/
|
||||
int prev_xy[2];
|
||||
|
||||
/** The `type` at the point of the click action. */
|
||||
short prev_click_type;
|
||||
/** The time when the key is pressed, see #PIL_check_seconds_timer. */
|
||||
double prev_click_time;
|
||||
/** The location when the key is pressed (used to enforce drag thresholds). */
|
||||
|
@ -645,13 +654,6 @@ typedef struct wmEvent {
|
|||
/** The `keymodifier` at the point of the click action. */
|
||||
short prev_click_keymodifier;
|
||||
|
||||
/**
|
||||
* The previous value of #wmEvent.xy,
|
||||
* Unlike other previous state variables, this is set on any mouse motion.
|
||||
* Use `prev_click` for the value at time of pressing.
|
||||
*/
|
||||
int prev_xy[2];
|
||||
|
||||
/**
|
||||
* Modifier states.
|
||||
* #KM_SHIFT, #KM_CTRL, #KM_ALT & #KM_OSKEY is apple or windows-key.
|
||||
|
|
|
@ -260,8 +260,8 @@ bool WM_cursor_test_motion_and_update(const int mval[2])
|
|||
int WM_event_drag_threshold(const struct wmEvent *event)
|
||||
{
|
||||
int drag_threshold;
|
||||
if (ISMOUSE(event->prev_type)) {
|
||||
BLI_assert(event->prev_type != MOUSEMOVE);
|
||||
if (ISMOUSE(event->prev_click_type)) {
|
||||
BLI_assert(event->prev_click_type != MOUSEMOVE);
|
||||
/* Using the previous type is important is we want to check the last pressed/released button,
|
||||
* The `event->type` would include #MOUSEMOVE which is always the case when dragging
|
||||
* and does not help us know which threshold to use. */
|
||||
|
|
|
@ -4705,10 +4705,11 @@ static void wm_event_prev_values_set(wmEvent *event, wmEvent *event_state)
|
|||
static void wm_event_prev_click_set(wmEvent *event, wmEvent *event_state)
|
||||
{
|
||||
event->prev_click_time = event_state->prev_click_time = PIL_check_seconds_timer();
|
||||
event->prev_click_xy[0] = event_state->prev_click_xy[0] = event_state->xy[0];
|
||||
event->prev_click_xy[1] = event_state->prev_click_xy[1] = event_state->xy[1];
|
||||
event->prev_click_type = event_state->prev_click_type = event_state->type;
|
||||
event->prev_click_modifier = event_state->prev_click_modifier = event_state->modifier;
|
||||
event->prev_click_keymodifier = event_state->prev_click_keymodifier = event_state->keymodifier;
|
||||
event->prev_click_xy[0] = event_state->prev_click_xy[0] = event_state->xy[0];
|
||||
event->prev_click_xy[1] = event_state->prev_click_xy[1] = event_state->xy[1];
|
||||
}
|
||||
|
||||
static wmEvent *wm_event_add_mousemove(wmWindow *win, const wmEvent *event)
|
||||
|
|
Loading…
Reference in New Issue