mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-25 06:47:19 +00:00
[client] app: move SDL window event handing out of main.c
This commit is contained in:
parent
31c42e3676
commit
570abeda52
@ -65,6 +65,10 @@ static bool sdlEventFilter(SDL_Event * event)
|
||||
{
|
||||
switch(event->type)
|
||||
{
|
||||
case SDL_QUIT:
|
||||
app_handleCloseEvent();
|
||||
return true;
|
||||
|
||||
case SDL_MOUSEMOTION:
|
||||
// stop motion events during the warp out of the window
|
||||
if (sdl.exiting)
|
||||
@ -75,19 +79,42 @@ static bool sdlEventFilter(SDL_Event * event)
|
||||
app_handleMouseGrabbed(event->motion.xrel, event->motion.yrel);
|
||||
else
|
||||
app_handleMouseNormal(event->motion.xrel, event->motion.yrel);
|
||||
break;
|
||||
return true;
|
||||
|
||||
case SDL_WINDOWEVENT:
|
||||
{
|
||||
switch(event->window.event)
|
||||
{
|
||||
/* after leave re-enable warp and cursor processing */
|
||||
case SDL_WINDOWEVENT_ENTER:
|
||||
app_handleWindowEnter();
|
||||
return true;
|
||||
|
||||
case SDL_WINDOWEVENT_LEAVE:
|
||||
sdl.exiting = false;
|
||||
return false;
|
||||
app_handleWindowLeave();
|
||||
return true;
|
||||
|
||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||
app_handleFocusEvent(true);
|
||||
return true;
|
||||
|
||||
case SDL_WINDOWEVENT_FOCUS_LOST:
|
||||
app_handleFocusEvent(false);
|
||||
return true;
|
||||
|
||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||
case SDL_WINDOWEVENT_RESIZED:
|
||||
app_handleResizeEvent(event->window.data1, event->window.data2);
|
||||
return true;
|
||||
|
||||
case SDL_WINDOWEVENT_MOVED:
|
||||
app_updateWindowPos(event->window.data1, event->window.data2);
|
||||
return true;
|
||||
|
||||
case SDL_WINDOWEVENT_CLOSE:
|
||||
app_handleCloseEvent();
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -1338,52 +1338,6 @@ int eventFilter(void * userdata, SDL_Event * event)
|
||||
|
||||
switch(event->type)
|
||||
{
|
||||
case SDL_QUIT:
|
||||
{
|
||||
if (!params.ignoreQuit)
|
||||
{
|
||||
DEBUG_INFO("Quit event received, exiting...");
|
||||
g_state.state = APP_STATE_SHUTDOWN;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
case SDL_WINDOWEVENT:
|
||||
{
|
||||
switch(event->window.event)
|
||||
{
|
||||
case SDL_WINDOWEVENT_ENTER:
|
||||
app_handleWindowEnter();
|
||||
break;
|
||||
|
||||
case SDL_WINDOWEVENT_LEAVE:
|
||||
app_handleWindowLeave();
|
||||
break;
|
||||
|
||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||
app_handleFocusEvent(true);
|
||||
break;
|
||||
|
||||
case SDL_WINDOWEVENT_FOCUS_LOST:
|
||||
app_handleFocusEvent(false);
|
||||
break;
|
||||
|
||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||
case SDL_WINDOWEVENT_RESIZED:
|
||||
app_handleResizeEvent(event->window.data1, event->window.data2);
|
||||
break;
|
||||
|
||||
case SDL_WINDOWEVENT_MOVED:
|
||||
app_updateWindowPos(event->window.data1, event->window.data2);
|
||||
break;
|
||||
|
||||
case SDL_WINDOWEVENT_CLOSE:
|
||||
app_handleCloseEvent();
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
case SDL_KEYDOWN:
|
||||
{
|
||||
SDL_Scancode sc = event->key.keysym.scancode;
|
||||
|
Loading…
Reference in New Issue
Block a user