| Summary: | Keys send two keydown events at once | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Marisa <saniukeokusainaya> |
| Component: | events | Assignee: | Alex Baines <alex> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | 2.0.5 | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Attachments: |
skip resent filtered keys
don't skip sending text for resent events |
||
|
Description
Marisa
2016-10-31 18:11:06 UTC
Duplicate of https://bugzilla.libsdl.org/show_bug.cgi?id=3472 ? I have investigated that bug and it's unrelated to my case.
I do not use ibus, but rather uim, which seems to be responsible for this happening.
Instead of one keydown and one keyup event being sent at the same time like in that bug, I get two keydowns, one of them with the repeat flag.
I wrote a program to show this:
#include <SDL.h>
int main( void )
{
SDL_Init(SDL_INIT_VIDEO);
SDL_Window *w = SDL_CreateWindow("keydown",SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,256,256,SDL_WINDOW_SHOWN);
SDL_Event e;
int quit = 0;
while ( !quit )
{
while ( SDL_PollEvent(&e) )
{
if ( e.type == SDL_QUIT ) quit = 1;
else if ( e.type == SDL_KEYDOWN )
{
printf("keydown:\n scancode %u\n repeat %u\n",
e.key.keysym.scancode,e.key.repeat);
if ( e.key.keysym.scancode == 41 ) quit = 1;
}
else if ( e.type == SDL_KEYUP )
{
printf("keyup:\n scancode %u\n repeat %u\n",
e.key.keysym.scancode,e.key.repeat);
}
}
}
SDL_DestroyWindow(w);
SDL_Quit();
}
The output when I do a single press of enter is:
keydown:
scancode 40
repeat 0
keydown:
scancode 40
repeat 1
keyup:
scancode 40
repeat 0
If I unset XMODIFIERS (which is set to @im=uim), the repeated keydown does not happen.
Alex, can you look into this? Thanks! Created attachment 2597 [details]
skip resent filtered keys
I believe this fixes it.
Fixed, thanks! https://hg.libsdl.org/SDL/rev/251691cfeaa0 Created attachment 2598 [details]
don't skip sending text for resent events
I realized overnight that my patch probably broke text input events with UIM, and I confirmed that it does. Can't believe I overlooked that... I've been making stupid mistakes in these patches recently, sorry.
Anyway, *this* one seems to fix it properly. Knowing my luck it probably breaks something else.
Got it, thanks! https://hg.libsdl.org/SDL/rev/8b8a45c000f9 |