Skip to content


When using OpenTK + SDL2, any consequent GameWindow will not fire Mouse events #5

IstrebiteI opened this Issue · 4 comments

2 participants


When using OpenTK with SDL2, any GameWindow opened after first will not fire Mouse events. Works fine with just OpenTK.

I've got a GameWindow inheriting class that has "Mouse.ButtonDown += Mouse_ButtonDown;" in it's OnLoad. If I spawn more than one window of this class (in sucession - first window closed then second one opened) then this event will no longer fire.


I tested with the following code but wasn't able to reproduce. Mouse events fire for all 5 windows (both native and sdl2 backends).

Does this match the code you are using?

using OpenTK;
public class Test {
        class SimpleWindow : GameWindow
            protected override void OnLoad(EventArgs e)
                Mouse.ButtonDown += (sender, e2) =>
                    Debug.Print("{{{0},{1}}}:{2}", e2.X, e2.Y, e2.Button);

        public static void Main(string[] args)
            using (Toolkit.Init())
                for (int i = 0; i < 5; i++)
                    using (var gw = new SimpleWindow())

Indeed, it happens in a more complex program but not in the simple one. I'll try to deduce what exactly is causing it and report back.


Wierd. It actually happens if you CursorVisible = false in the OnLoad. And seems to be related somehow to the fact that window has no focus (if you alt-tab out and in the window, it will start to process events)


Hmm, rather, it happens in the next window if previous window was Close()'d with CursorVisible = false. If you set it to true in Exit() then it works fine.

@thefiddler thefiddler added a commit that closed this issue
@thefiddler thefiddler Fixed #5
We need to release the cursor before closing a GameWindow, otherwise
subsequent GameWindows may fail to receive mouse events.
@thefiddler thefiddler added a commit that referenced this issue
@thefiddler thefiddler Workaround for #5
WS_CLIPCHILDREN and WS_CLIPSIBLINGS appear to cause flickering on
specific video cards. OpenGL appears to work correctly without these, so
we'll disable them to return to OpenTK 1.0 behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.