diff options
author | Martin Poirier <theeth@yahoo.com> | 2010-01-14 21:15:12 +0300 |
---|---|---|
committer | Martin Poirier <theeth@yahoo.com> | 2010-01-14 21:15:12 +0300 |
commit | 9e79f2d92a991e12e5314f3bbc0a20993868bd17 (patch) | |
tree | c933210b873875ec7c165636d00796806183a7da /source | |
parent | be680ae69bd17639108b9df285d276845d3f8d30 (diff) |
[#19978] Can not switch view with keymaps while emulate numpad is activated; in modes other than object and edit
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.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 68 |
1 files changed, 32 insertions, 36 deletions
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index a940c6054fa..456f0b62a30 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -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 */ |