The proper solution to this (on Windows) has to be implemented on the native side. When a mouse button is pressed, the Win32 API function SetCapture
should be called. This guarantees that the window will continue receiving mouse button events even when the mouse is outside the window and does not block other windows from getting those same events. Then, when a button up event is received, ReleaseCapture
should be called. Using this approach will allow LWJGL's internal mouse button state to remain consistent and not interfere with other programs.
There are likely alternatives for the other OSes, if it is an issue there. The GLFW library
uses this approach on Windows and AFAIK behaves consistently across its supported platforms.