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

Linux: Embedded form cannot receive mouse events #12221

Open
niuzhaosen opened this issue Feb 8, 2025 · 11 comments
Open

Linux: Embedded form cannot receive mouse events #12221

niuzhaosen opened this issue Feb 8, 2025 · 11 comments

Comments

@niuzhaosen
Copy link

niuzhaosen commented Feb 8, 2025

Linux: Embedded window cannot receive mouse events

Image
windows:Embedded window in Windows can receive mouse events, but cannot receive keyboard events

@niuzhaosen
Copy link
Author

Image
This is the focus window for Windows printing, and you can see that the keyboard focus has not been obtained

@niuzhaosen
Copy link
Author

Image
This is the focus window printed by Linux, and you can see that neither the keyboard focus nor the mouse focus has been obtained

@niuzhaosen
Copy link
Author

SDL 2.30.8

@niuzhaosen
Copy link
Author

I tried the latest 2.30.12 and the result is still the same

@niuzhaosen
Copy link
Author

SDL_SetMouseFocus
SDL_SetKeyboardFocus
这两个方法能否对外暴漏呢

@slouken
Copy link
Collaborator

slouken commented Feb 8, 2025

I believe this is fixed with SDL3.

@niuzhaosen
Copy link
Author

niuzhaosen commented Feb 10, 2025

我相信 SDL3 已经解决了这个问题。

Do you remember the question I asked you last time? Is there only one px embedded in the form on Linux? That's a bug in SDL3.
#11885

I mainly used the C # language to write the program, and sdl2 would have better support for C #. Can this be fixed in sdl2.
#12211
Observe the manifestation of sdl2 compatibility mode

@slouken
Copy link
Collaborator

slouken commented Feb 10, 2025

Can you share your project so we can debug here? If you need to do it privately, you can send e-mail to [email protected].

@niuzhaosen
Copy link
Author

niuzhaosen commented Feb 11, 2025

Can you share your project so we can debug here? If you need to do it privately, you can send e-mail to [email protected].

`Sdl sdl = Sdl.GetApi();
sdl.CaptureMouse(SdlBool.True);
var window = sdl.CreateWindowFrom((void*)test.Handle);
var renderer = sdl.CreateRenderer(window, -1, (uint)RendererFlags.Accelerated);
System.Threading.Thread t = new System.Threading.Thread(() =>
{

while (true)
{
    Console.WriteLine("MouseFocus:" + (long)sdl.GetMouseFocus());                    
    int x = 0, y = 0;
    uint z = sdl.GetGlobalMouseState(ref x, ref y);
    Console.WriteLine(x + "-" + y + "-" + z);

    int x1 = 0, y1 = 0;
    uint z1 = sdl.GetMouseState(ref x1, ref y1);
    Console.WriteLine(x1 + "-" + y1 + "-" + z1);
    Event e = new Event();
    while (sdl.PollEvent(&e) != 0)
    {
        Console.WriteLine((EventType)e.Type);

    }



    System.Threading.Thread.Sleep(10);

}

});
t.Start();`

Under Windows, the mouse focus can be obtained normally, and getmousestate can obtain coordinates,
In Linux, the mouse focus cannot be obtained, and getmousestate cannot obtain coordinates, but GetGlobalMouseState can obtain coordinates

@niuzhaosen
Copy link
Author

niuzhaosen commented Feb 11, 2025

Can you share your project so we can debug here? If you need to do it privately, you can send e-mail to [email protected].

It seems to only appear when creating window from, and no exceptions were found when using create window
@slouken

@niuzhaosen
Copy link
Author

Can you share your project so we can debug here? If you need to do it privately, you can send e-mail to [email protected].

#157
This seems to be a legacy bug that existed a long time ago

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

2 participants