Bugfix: doubles are not supported correctly in SDNA, double click
introduced one in wmWindow.last_click_time. Moved this to the wmEvent struct, which now no is in DNA, was needed for RNA wrapping but not needed anymore.
This commit is contained in:
@@ -154,10 +154,7 @@ typedef struct wmWindow {
|
||||
short cursor; /* current mouse cursor type */
|
||||
short lastcursor; /* for temp waitcursor */
|
||||
short addmousemove; /* internal: tag this for extra mousemove event, makes cursors/buttons active on UI switching */
|
||||
|
||||
short last_type; /* last event information, used for click */
|
||||
short last_val;
|
||||
double last_click_time; /* for double click */
|
||||
short pad2[2];
|
||||
|
||||
struct wmEvent *eventstate; /* storage for event system */
|
||||
|
||||
@@ -345,40 +342,6 @@ typedef struct wmOperator {
|
||||
/* wmOperator flag */
|
||||
#define OP_GRAB_POINTER 1
|
||||
|
||||
/* ************** wmEvent ************************ */
|
||||
/* for read-only rna access, dont save this */
|
||||
|
||||
/* each event should have full modifier state */
|
||||
/* event comes from eventmanager and from keymap */
|
||||
typedef struct wmEvent {
|
||||
struct wmEvent *next, *prev;
|
||||
|
||||
short type; /* event code itself (short, is also in keymap) */
|
||||
short val; /* press, release, scrollvalue */
|
||||
short x, y; /* mouse pointer position, screen coord */
|
||||
short mval[2]; /* region mouse position, name convention pre 2.5 :) */
|
||||
short prevx, prevy; /* previous mouse pointer position */
|
||||
short unicode; /* future, ghost? */
|
||||
char ascii; /* from ghost */
|
||||
char pad;
|
||||
|
||||
/* modifier states */
|
||||
short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */
|
||||
short keymodifier; /* rawkey modifier */
|
||||
|
||||
short pad1;
|
||||
|
||||
/* keymap item, set by handler (weak?) */
|
||||
const char *keymap_idname;
|
||||
|
||||
/* custom data */
|
||||
short custom; /* custom data type, stylus, 6dof, see wm_event_types.h */
|
||||
short customdatafree;
|
||||
int pad2;
|
||||
void *customdata; /* ascii, unicode, mouse coords, angles, vectors, dragdrop info */
|
||||
|
||||
} wmEvent;
|
||||
|
||||
typedef enum wmRadialControlMode {
|
||||
WM_RADIALCONTROL_SIZE,
|
||||
WM_RADIALCONTROL_STRENGTH,
|
||||
|
||||
@@ -701,6 +701,8 @@ static void rna_def_event(BlenderRNA *brna)
|
||||
RNA_def_struct_ui_text(srna, "Event", "Window Manager Event");
|
||||
RNA_def_struct_sdna(srna, "wmEvent");
|
||||
|
||||
RNA_define_verify_sdna(0); // not in sdna
|
||||
|
||||
/* strings */
|
||||
prop= RNA_def_property(srna, "ascii", PROP_STRING, PROP_NONE);
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
@@ -764,6 +766,8 @@ static void rna_def_event(BlenderRNA *brna)
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "oskey", 1);
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
RNA_def_property_ui_text(prop, "OS Key", "True when the Cmd key is held.");
|
||||
|
||||
RNA_define_verify_sdna(1); // not in sdna
|
||||
}
|
||||
|
||||
static void rna_def_window(BlenderRNA *brna)
|
||||
|
||||
@@ -288,6 +288,44 @@ typedef struct wmGesture {
|
||||
/* customdata for lasso is short array */
|
||||
} wmGesture;
|
||||
|
||||
/* ************** wmEvent ************************ */
|
||||
|
||||
/* each event should have full modifier state */
|
||||
/* event comes from eventmanager and from keymap */
|
||||
typedef struct wmEvent {
|
||||
struct wmEvent *next, *prev;
|
||||
|
||||
short type; /* event code itself (short, is also in keymap) */
|
||||
short val; /* press, release, scrollvalue */
|
||||
short x, y; /* mouse pointer position, screen coord */
|
||||
short mval[2]; /* region mouse position, name convention pre 2.5 :) */
|
||||
short unicode; /* future, ghost? */
|
||||
char ascii; /* from ghost */
|
||||
char pad;
|
||||
|
||||
/* previous state */
|
||||
short prevtype;
|
||||
short prevval;
|
||||
short prevx, prevy;
|
||||
double prevclicktime;
|
||||
|
||||
/* modifier states */
|
||||
short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */
|
||||
short keymodifier; /* rawkey modifier */
|
||||
|
||||
short pad1;
|
||||
|
||||
/* keymap item, set by handler (weak?) */
|
||||
const char *keymap_idname;
|
||||
|
||||
/* custom data */
|
||||
short custom; /* custom data type, stylus, 6dof, see wm_event_types.h */
|
||||
short customdatafree;
|
||||
int pad2;
|
||||
void *customdata; /* ascii, unicode, mouse coords, angles, vectors, dragdrop info */
|
||||
|
||||
} wmEvent;
|
||||
|
||||
/* ************** custom wmEvent data ************** */
|
||||
typedef struct wmTabletData {
|
||||
int Active; /* 0=EVT_TABLET_NONE, 1=EVT_TABLET_STYLUS, 2=EVT_TABLET_ERASER */
|
||||
|
||||
@@ -1177,9 +1177,9 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
|
||||
if (wm_action_not_handled(action) && event->val == KM_RELEASE) {
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
|
||||
if (win && win->last_type == event->type && win->last_val == KM_PRESS) {
|
||||
if (win && win->eventstate->prevtype == event->type && win->eventstate->prevval == KM_PRESS) {
|
||||
/* test for double click first */
|
||||
if ((PIL_check_seconds_timer() - win->last_click_time) * 1000 < U.dbl_click_time) {
|
||||
if ((PIL_check_seconds_timer() - win->eventstate->prevclicktime) * 1000 < U.dbl_click_time) {
|
||||
event->val = KM_DBL_CLICK;
|
||||
action |= wm_handlers_do(C, event, handlers);
|
||||
}
|
||||
@@ -1381,26 +1381,26 @@ void wm_event_do_handlers(bContext *C)
|
||||
/* mousemove and timer events don't overwrite last type */
|
||||
if (event->type != MOUSEMOVE && !ISTIMER(event->type)) {
|
||||
if (wm_action_not_handled(action)) {
|
||||
if (win->last_type == event->type) {
|
||||
if (win->eventstate->prevtype == event->type) {
|
||||
/* set click time on first click (press -> release) */
|
||||
if (win->last_val == KM_PRESS && event->val == KM_RELEASE) {
|
||||
win->last_click_time = PIL_check_seconds_timer();
|
||||
if (win->eventstate->prevval == KM_PRESS && event->val == KM_RELEASE) {
|
||||
win->eventstate->prevclicktime = PIL_check_seconds_timer();
|
||||
}
|
||||
} else {
|
||||
/* reset click time if event type not the same */
|
||||
win->last_click_time = 0;
|
||||
win->eventstate->prevclicktime = 0;
|
||||
}
|
||||
|
||||
win->last_val = event->val;
|
||||
win->last_type = event->type;
|
||||
win->eventstate->prevval = event->val;
|
||||
win->eventstate->prevtype = event->type;
|
||||
} else if (event->val == KM_CLICK) { /* keep click for double click later */
|
||||
win->last_type = event->type;
|
||||
win->last_val = event->val;
|
||||
win->last_click_time = PIL_check_seconds_timer();
|
||||
win->eventstate->prevtype = event->type;
|
||||
win->eventstate->prevval = event->val;
|
||||
win->eventstate->prevclicktime = PIL_check_seconds_timer();
|
||||
} else { /* reset if not */
|
||||
win->last_type = -1;
|
||||
win->last_val = 0;
|
||||
win->last_click_time = 0;
|
||||
win->eventstate->prevtype = -1;
|
||||
win->eventstate->prevval = 0;
|
||||
win->eventstate->prevclicktime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user