| Summary: | [X11] relative mouse value is jumpy when pointer change window | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Cengiz <yaakuro> |
| Component: | events | Assignee: | Ryan C. Gordon <icculus> |
| Status: | ASSIGNED --- | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | icculus, sezeroz |
| Version: | 2.0.3 | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Attachments: | relative mouse value is jumpy when pointer change window | ||
This patch is now https://hg.libsdl.org/SDL/rev/e1f07cbb3c86, thanks! --ryan. This patch appears to solve the problem for X11, but I have a suspicion this bug hits other platforms, too. I'll look into resetting last_x/last_y in SDL_OnWindowEnter() before I resolve this bug fully, but we appear good to go in the place we're specifically seeing this issue (multi-window UnrealEd on Linux). --ryan. |
Created attachment 2223 [details] relative mouse value is jumpy when pointer change window Hi there, hi icculus. I think you know already about this. Here the issue in short. When the mouse pointer leaves a window and enters another window the xrel, yrel values jumps. Here a print out: WindowID: 2, abs=(319, 64) rel=(320, -5) WindowID: 2, abs=(318, 64) rel=(-1, 0) WindowID: 2, abs=(319, 64) rel=(1, 0) WindowID: 2, abs=(319, 64) rel=(1, 0) WindowID: 3, abs=(0, 64) rel=(-320, 0) WindowID: 3, abs=(1, 64) rel=(1, 0) WindowID: 3, abs=(2, 64) rel=(1, 0) WindowID: 3, abs=(3, 64) rel=(1, 0) WindowID: 3, abs=(2, 64) rel=(-1, 0) WindowID: 3, abs=(1, 64) rel=(-1, 0) WindowID: 3, abs=(0, 64) rel=(-1, 0) WindowID: 3, abs=(0, 64) rel=(-1, 0) WindowID: 2, abs=(319, 62) rel=(320, -2) WindowID: 2, abs=(318, 62) rel=(-1, 0) WindowID: 2, abs=(317, 62) rel=(-1, 0) WindowID: 2, abs=(318, 62) rel=(1, 0) WindowID: 2, abs=(319, 62) rel=(1, 0) WindowID: 2, abs=(319, 62) rel=(1, 0) WindowID: 3, abs=(0, 64) rel=(-320, 2) WindowID: 3, abs=(1, 64) rel=(1, 0) WindowID: 3, abs=(2, 64) rel=(1, 0) As you can see the jump happens when pointer changes the window. This happens for the y direction too. Here my test code: #include <SDL.h> #include <stdio.h> int main(int argc, char **argv) { SDL_Init(SDL_INIT_EVERYTHING); SDL_Window* window1 = SDL_CreateWindow("Window 1", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,320, 200, 0); SDL_Window* window2 = SDL_CreateWindow("Window 2", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 320, 200, 0); while(true) { SDL_Event e; if(SDL_PollEvent(&e)) { if(e.type == SDL_QUIT) { break; } else if(e.type == SDL_KEYDOWN) { break; } else if(e.type == SDL_MOUSEMOTION) { printf("WindowID: %d, abs=(%d, %d) rel=(%d, %d)\n", e.window.windowID, (int)e.motion.x, (int)e.motion.y, (int)e.motion.xrel, (int)e.motion.yrel); } } } SDL_DestroyWindow(window1); SDL_DestroyWindow(window2); SDL_Quit(); return 0; } Just move one window away from the other and move the pointer from one window to the other. In the attachment I put a fix. Not sure if that is the best solution but it works. Entering a window should reset the last_x, last_y variables of the mouse pointer. Cengiz (yaakuro)