LukasBanana / LLGL

Low Level Graphics Library (LLGL) is a thin abstraction layer for the modern graphics APIs OpenGL, Direct3D, Vulkan, and Metal
BSD 3-Clause "New" or "Revised" License
2.03k stars 135 forks source link

Win32Window message loop filtering problem #92

Closed conradax closed 1 year ago

conradax commented 1 year ago

OS: Windows 10 22H2 19045.3324

With Chinese IME activated, Pressing a Key(even Esc) will freeze LLGL window's input, And user cannot change IME. (But rendering is fine) In this "freezing" status, Win32WindowCallback only recieves WM_INPUT 0x00FF message when mouse moving.

I found a similar problem on stackoverflow and get a link to a blog post. After changing wnd_ to nullptr, problem disappeared. https://github.com/LukasBanana/LLGL/blob/b5acac50f4a7b24ab6b5eb21ebfcb8e3cc0e2f30/sources/Platform/Win32/Win32Window.cpp#L344-L353 I'm not sure if this is the correct solution. The example Multi Context which has 2 windows, seems fine with the fix.

LukasBanana commented 1 year ago

Thanks for the details. I think I'll have to refactor the entire main loop like @beldenfox suggested in this ticket a few years ago https://github.com/LukasBanana/LLGL/issues/65#issuecomment-913012400. Some platforms don't implement this correctly for a per-window scenario anyway so this should be moved out of the window instances.

Maybe having this as a static function in the Surface interface would be a good place. So moving from this:

while (window->ProcessEvents()) {
  ...
}

... to this:

while (window->IsShown()) {
  LLGL::Surface::ProcessEvents();
  ...
}
LukasBanana commented 1 year ago

This should be fixed with 651c31e. The public interface of Surface::ProcessEvents() has been refactored to a static function handling all window events.