[#19978] Can not switch view with keymaps while emulate numpad is activated; in modes...
authorMartin Poirier <theeth@yahoo.com>
Thu, 14 Jan 2010 18:15:12 +0000 (18:15 +0000)
committerMartin Poirier <theeth@yahoo.com>
Thu, 14 Jan 2010 18:15:12 +0000 (18:15 +0000)
Was caused by event emulation (numpad and mmb) happening separately at each level of the keymap, so brush selection was latching on the event before it had time to test emulated values with view navigation entries (at a lower level in the hierarchy).

After discussion with Matt, decided that event emulation should be done at the root of the event loop, replacing the event with the emulated values. This is much more predictable and more logical as far as event emulation goes.

source/blender/windowmanager/intern/wm_event_system.c

index a940c6054fa24b97d2f016065881bd426c34b620..456f0b62a3095564edf56aff6170d06ea5db5f58 100644 (file)
@@ -768,47 +768,41 @@ int WM_userdef_event_map(int kmitype)
        return kmitype;
 }
 
-static int wm_eventmatch(wmEvent *winevent, wmKeyMapItem *kmi)
+static void wm_eventemulation(wmEvent *event)
 {
-       int kmitype= WM_userdef_event_map(kmi->type);
-
-       if(kmi->flag & KMI_INACTIVE) return 0;
-
-       /* exception for middlemouse emulation */
-       if((U.flag & USER_TWOBUTTONMOUSE) && (kmi->type == MIDDLEMOUSE)) {
-               if(winevent->type == LEFTMOUSE && winevent->alt) {
-                       wmKeyMapItem tmp= *kmi;
-
-                       tmp.type= winevent->type;
-                       tmp.alt= winevent->alt;
-                       if(wm_eventmatch(winevent, &tmp))
-                               return 1;
+       /* middlemouse emulation */
+       if(U.flag & USER_TWOBUTTONMOUSE) {
+               if(event->type == LEFTMOUSE && event->alt) {
+                       event->type = MIDDLEMOUSE;
+                       event->alt = 0;
                }
        }
-       /* exception for numpad emulation */
-       else if(U.flag & USER_NONUMPAD) {
-               wmKeyMapItem tmp= *kmi;
-
-               switch(kmi->type) {
-                       case PAD0: tmp.type = ZEROKEY; break;
-                       case PAD1: tmp.type = ONEKEY; break;
-                       case PAD2: tmp.type = TWOKEY; break;
-                       case PAD3: tmp.type = THREEKEY; break;
-                       case PAD4: tmp.type = FOURKEY; break;
-                       case PAD5: tmp.type = FIVEKEY; break;
-                       case PAD6: tmp.type = SIXKEY; break;
-                       case PAD7: tmp.type = SEVENKEY; break;
-                       case PAD8: tmp.type = EIGHTKEY; break;
-                       case PAD9: tmp.type = NINEKEY; break;
-                       case PADMINUS: tmp.type = MINUSKEY; break;
-                       case PADPLUSKEY: tmp.type = EQUALKEY; break;
-                       case PADSLASHKEY: tmp.type = BACKSLASHKEY; break;
-               }
 
-               if(tmp.type != kmi->type)
-                       if(wm_eventmatch(winevent, &tmp))
-                               return 1;
+       /* numpad emulation */
+       if(U.flag & USER_NONUMPAD) {
+               switch(event->type) {
+                       case ZEROKEY: event->type = PAD0; break;
+                       case ONEKEY: event->type = PAD1; break;
+                       case TWOKEY: event->type = PAD2; break;
+                       case THREEKEY: event->type = PAD3; break;
+                       case FOURKEY: event->type = PAD4; break;
+                       case FIVEKEY: event->type = PAD5; break;
+                       case SIXKEY: event->type = PAD6; break;
+                       case SEVENKEY: event->type = PAD7; break;
+                       case EIGHTKEY: event->type = PAD8; break;
+                       case NINEKEY: event->type = PAD9; break;
+                       case MINUSKEY: event->type = PADMINUS; break;
+                       case EQUALKEY: event->type = PADPLUSKEY; break;
+                       case BACKSLASHKEY: event->type = PADSLASHKEY; break;
+               }
        }
+}
+
+static int wm_eventmatch(wmEvent *winevent, wmKeyMapItem *kmi)
+{
+       int kmitype= WM_userdef_event_map(kmi->type);
+
+       if(kmi->flag & KMI_INACTIVE) return 0;
 
        /* the matching rules */
        if(kmitype==KM_TEXTINPUT)
@@ -1335,6 +1329,8 @@ void wm_event_do_handlers(bContext *C)
                while( (event= win->queue.first) ) {
                        int action = WM_HANDLER_CONTINUE;
 
+                       wm_eventemulation(event);
+
                        CTX_wm_window_set(C, win);
                        
                        /* we let modal handlers get active area/region, also wm_paintcursor_test needs it */