mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-23 19:15:36 +00:00
MouseButtonUp and MouseMove fixes
MouseMove no longer leaves the window borders when the cursor is invisible. MouseButtonUp events are now reported even when they occur outside the window. This aligns SDL2 behavior with the native drivers.
This commit is contained in:
parent
b077597bc1
commit
5051190b01
|
@ -211,6 +211,15 @@ namespace OpenTK.Platform.SDL2
|
|||
static void ProcessButtonEvent(Sdl2NativeWindow window, SDL.SDL_Event ev)
|
||||
{
|
||||
bool button_pressed = ev.button.state == SDL.SDL_PRESSED;
|
||||
|
||||
// We need MouseUp events to be reported even if they occur
|
||||
// outside the window. SetWindowGrab ensures we get them.
|
||||
if (window.CursorVisible)
|
||||
{
|
||||
SDL.SDL_SetWindowGrab(window.window.Handle,
|
||||
button_pressed ? SDL.SDL_bool.SDL_TRUE : SDL.SDL_bool.SDL_FALSE);
|
||||
}
|
||||
|
||||
switch (ev.button.button)
|
||||
{
|
||||
case (byte)SDL.SDL_BUTTON_LEFT:
|
||||
|
@ -244,16 +253,7 @@ namespace OpenTK.Platform.SDL2
|
|||
|
||||
static void ProcessMotionEvent(Sdl2NativeWindow window, SDL.SDL_Event ev)
|
||||
{
|
||||
if (window.CursorVisible)
|
||||
{
|
||||
window.mouse.Position = new Point(ev.motion.x, ev.motion.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
window.mouse.Position = new Point(
|
||||
window.mouse.X + ev.motion.xrel,
|
||||
window.mouse.Y + ev.motion.yrel);
|
||||
}
|
||||
}
|
||||
|
||||
static void ProcessWheelEvent(Sdl2NativeWindow window, SDL.SDL_Event ev)
|
||||
|
|
Loading…
Reference in a new issue