Skip to content

Commit

Permalink
Fixed situation when events was eaten by CInput
Browse files Browse the repository at this point in the history
Now they work properly and we can safely flush events.
  • Loading branch information
Xottab-DUTY committed Jul 20, 2018
1 parent dda98b1 commit cbe6db8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 23 deletions.
1 change: 1 addition & 0 deletions src/xrEngine/Device_create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ void CRenderDevice::UpdateWindowProps(bool windowed)
SDL_SetWindowGrab(m_sdlWnd, SDL_TRUE);

UpdateWindowRect();
SDL_FlushEvents(SDL_WINDOWEVENT, SDL_SYSWMEVENT);
}


Expand Down
25 changes: 14 additions & 11 deletions src/xrEngine/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,21 +350,22 @@ void CRenderDevice::message_loop()
case SDL_WINDOWEVENT_MOVED:
UpdateWindowRect();
break;
/*case SDL_WINDOWEVENT_RESIZED:
string32 buff;
xr_sprintf(buff, sizeof(buff), "vid_mode %dx%d", event.window.data1, event.window.data2);
Console->Execute(buff);
[[fallthrough]];*/

case SDL_WINDOWEVENT_EXPOSED:
Reset(true);
break;

case SDL_WINDOWEVENT_RESIZED:
case SDL_WINDOWEVENT_SIZE_CHANGED:
UpdateWindowRect();
OnWM_Activate(1, event.window.data2);
{
if (!psDeviceFlags.is(rsFullscreen))
{
string32 buff;
xr_sprintf(buff, sizeof(buff), "vid_mode %dx%d", event.window.data1, event.window.data2);
Console->Execute(buff);
Reset();
}
else
UpdateWindowRect();

break;
}

case SDL_WINDOWEVENT_SHOWN:
case SDL_WINDOWEVENT_ENTER:
Expand All @@ -389,6 +390,7 @@ void CRenderDevice::message_loop()
}

on_idle();
SDL_PumpEvents();
}
}

Expand Down Expand Up @@ -416,6 +418,7 @@ void CRenderDevice::Run()
seqAppStart.Process();
GEnv.Render->ClearTarget();
splash::hide();
SDL_FlushEvents(SDL_WINDOWEVENT, SDL_SYSWMEVENT);
SDL_ShowWindow(m_sdlWnd);
SDL_RaiseWindow(m_sdlWnd);
pInput->ClipCursor(true);
Expand Down
13 changes: 1 addition & 12 deletions src/xrEngine/xr_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,8 @@ void CInput::OnFrame(void)
stats.FrameTime.Begin();
dwCurTime = RDEVICE.TimerAsync_MMT();

while (SDL_PollEvent(&event))
while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_KEYDOWN, SDL_MOUSEWHEEL))
{
BOOL b_break_cycle = false;

switch (event.type)
{
case SDL_KEYDOWN: {
Expand Down Expand Up @@ -310,16 +308,7 @@ void CInput::OnFrame(void)
cbStack.back()->IR_OnMouseWheel(event.wheel.y);
}
break;
case SDL_QUIT: // go to outside event loop
event.type = SDL_QUIT;
SDL_PushEvent(&event);
b_break_cycle = TRUE;
break;
default: break;
}

if (b_break_cycle)
break;
}

#ifndef _EDITOR
Expand Down

0 comments on commit cbe6db8

Please sign in to comment.