WM: init simulated event from win->eventstate
authorCampbell Barton <ideasman42@gmail.com>
Fri, 8 Feb 2019 08:00:51 +0000 (19:00 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 8 Feb 2019 08:01:30 +0000 (19:01 +1100)
Ghost event handling code works this way.

source/blender/makesrna/intern/rna_wm_api.c

index 80d97b4acf2af4156b4e4c08c8dabeef6b5b4b3b..c6196adc8eee6b2a700fa6fde59beeb502355329 100644 (file)
@@ -521,7 +521,7 @@ static wmEvent *rna_Window_event_add_simulate(
                }
        }
 
-       wmEvent e = {NULL};
+       wmEvent e = *win->eventstate;
        e.type = type;
        e.val = value;
        e.x = x;
@@ -532,12 +532,13 @@ static wmEvent *rna_Window_event_add_simulate(
        e.alt = alt;
        e.oskey = oskey;
 
-       const wmEvent *evt = win->eventstate;
-       e.prevx = evt->x;
-       e.prevy = evt->y;
-       e.prevval = evt->val;
-       e.prevtype = evt->type;
+       e.prevx = win->eventstate->x;
+       e.prevy = win->eventstate->y;
+       e.prevval = win->eventstate->val;
+       e.prevtype = win->eventstate->type;
 
+       e.ascii = '\0';
+       e.utf8_buf[0] = '\0';
        if (unicode != NULL) {
                e.ascii = ascii;
                STRNCPY(e.utf8_buf, unicode);