[client] app: move SDL mouse event handling out of main.c

This commit is contained in:
Geoffrey McRae 2021-01-17 14:28:50 +11:00
parent a1069ddffa
commit 41a0cfe516
2 changed files with 28 additions and 34 deletions

View File

@ -81,6 +81,34 @@ static bool sdlEventFilter(SDL_Event * event)
app_handleMouseNormal(event->motion.xrel, event->motion.yrel); app_handleMouseNormal(event->motion.xrel, event->motion.yrel);
return true; return true;
case SDL_MOUSEBUTTONDOWN:
{
int button = event->button.button;
if (button > 3)
button += 2;
app_handleButtonPress(button);
return true;
}
case SDL_MOUSEBUTTONUP:
{
int button = event->button.button;
if (button > 3)
button += 2;
app_handleButtonRelease(button);
return true;
}
case SDL_MOUSEWHEEL:
{
int button = event->wheel.y > 0 ? 4 : 5;
app_handleButtonPress(button);
app_handleButtonRelease(button);
return true;
}
case SDL_WINDOWEVENT: case SDL_WINDOWEVENT:
switch(event->window.event) switch(event->window.event)
{ {

View File

@ -1445,40 +1445,6 @@ int eventFilter(void * userdata, SDL_Event * event)
} }
break; break;
} }
case SDL_MOUSEWHEEL:
if (!app_inputEnabled() || !g_cursor.inView)
break;
if (
!spice_mouse_press (event->wheel.y > 0 ? 4 : 5) ||
!spice_mouse_release(event->wheel.y > 0 ? 4 : 5)
)
{
DEBUG_ERROR("SDL_MOUSEWHEEL: failed to send messages");
break;
}
break;
case SDL_MOUSEBUTTONDOWN:
{
int button = event->button.button;
if (button > 3)
button += 2;
app_handleButtonPress(button);
break;
}
case SDL_MOUSEBUTTONUP:
{
int button = event->button.button;
if (button > 3)
button += 2;
app_handleButtonRelease(button);
break;
}
} }
// consume all events // consume all events