tksuoran's picture

Get focus?

Is there way to grab focus for my GameWindow()? I don't seem to get most events on one test system, X11 with apparently no window manager running..


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

Try the code from svn trunk. It offers a new CursorVisible property that will grab the cursor and confine it to the window.

Additionally, you will be able to use the new OpenTK.Input.Mouse/Keyboard classes to read input even without window focus (or even without a window at all).

tksuoran's picture

I see that CursorVisible = false; would call XGrabPointer(). Should this also give me keyboard focus or do I need something else for that?

Edit: Actually I want to keep the cursor visible, and just get the focus so I get the events - something to cause FocusIn, I think - I don't really know much about X11.. XSetInputFocus()?

the Fiddler's picture

You can use polled input to retrieve mouse/keyboard state regardless of input focus:

var mouse = OpenTK.Input.Mouse.GetState();
var keyboard = OpenTK.Input.Keyboard.GetState();

Input focus is determined solely by the OS, unless you grab the cursor with CursorVisible = false. (Note that you can always paint your own cursor through OpenGL - this is what games do).

migueltk's picture

I test the functionality of the property CursorVisible, simply fantastic!. Tested on Windows 7 - 32-bit and Ubuntu 10.10 - 64 Bits.
"The Fiddler", thanks for your excellent work.

tksuoran's picture

Meanwhile I simply installed twm and I was able to get focus into my app. Probably very rare that anyone would run X without a window manager..