Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[X11] relative mouse value is jumpy when pointer change window #1928

Closed
SDLBugzilla opened this issue Feb 11, 2021 · 1 comment
Closed

[X11] relative mouse value is jumpy when pointer change window #1928

SDLBugzilla opened this issue Feb 11, 2021 · 1 comment
Assignees
Milestone

Comments

@SDLBugzilla
Copy link
Collaborator

SDLBugzilla commented Feb 11, 2021

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: 2.0.3
Reported for operating system, platform: Linux, x86_64

Comments on the original bug report:

On 2015-07-23 06:09:56 +0000, Cengiz wrote:

Created attachment 2223
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)

On 2016-01-08 06:24:10 +0000, Ryan C. Gordon wrote:

This patch is now https://hg.libsdl.org/SDL/rev/e1f07cbb3c86, thanks!

--ryan.

On 2016-01-08 06:26:11 +0000, Ryan C. Gordon wrote:

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.

@slouken slouken removed the bug label May 11, 2022
@icculus icculus self-assigned this Aug 22, 2022
@icculus icculus added this to the 2.26.0 milestone Aug 22, 2022
@icculus
Copy link
Collaborator

icculus commented Aug 22, 2022

Need to run this test program on Windows, Wayland, Mac, and see what happens, then close this bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants