Second attempt at fixing #19335: holding down backspace in the
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 21 Sep 2009 15:51:29 +0000 (15:51 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 21 Sep 2009 15:51:29 +0000 (15:51 +0000)
text editor creates squares on some systems. Based on info from
Martin, it appears the keymodifier is being set when it shouldn't.
I think this is happening become some systems may be generating
KM_PRESS events without a matching KM_RELEASE?

Also ignore ascii values 1-32 now instead of 14-32, not sure why
they were included now in 2.5 because they were not in 2.4, but
I don't see a reason to do it. This fixes squares when pressing
e.g. ctrl+b or ctrl+n.

source/blender/windowmanager/intern/wm_event_system.c

index 6b07e384f661681853e92decef0d0a12b9fe123b..4acfe1e524a42d6bd2cd8304b99c1a6349469624 100644 (file)
@@ -1600,7 +1600,7 @@ void wm_event_add_ghostevent(wmWindow *win, int type, void *customdata)
                        event.val= (type==GHOST_kEventKeyDown)?KM_PRESS:KM_RELEASE;
                        
                        /* exclude arrow keys, esc, etc from text input */
-                       if(type==GHOST_kEventKeyUp || (event.ascii<32 && event.ascii>14))
+                       if(type==GHOST_kEventKeyUp || (event.ascii<32 && event.ascii>0))
                                event.ascii= '\0';
                        
                        /* modifiers */
@@ -1630,6 +1630,13 @@ void wm_event_add_ghostevent(wmWindow *win, int type, void *customdata)
                                else if(event.val==KM_RELEASE && event.keymodifier==event.type)
                                        event.keymodifier= evt->keymodifier= 0;
                        }
+
+                       /* this case happens on some systems that on holding a key pressed,
+                          generate press events without release, we still want to keep the
+                          modifier in win->eventstate, but for the press event of the same
+                          key we don't want the key modifier */
+                       if(event.keymodifier == event.type)
+                               event.keymodifier= 0;
                        
                        /* if test_break set, it catches this. XXX Keep global for now? */
                        if(event.type==ESCKEY)