Skip to content

Commit cbe6db8

Browse files
committed
Fixed situation when events was eaten by CInput
Now they work properly and we can safely flush events.
1 parent dda98b1 commit cbe6db8

File tree

3 files changed

+16
-23
lines changed

3 files changed

+16
-23
lines changed

src/xrEngine/Device_create.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ void CRenderDevice::UpdateWindowProps(bool windowed)
130130
SDL_SetWindowGrab(m_sdlWnd, SDL_TRUE);
131131

132132
UpdateWindowRect();
133+
SDL_FlushEvents(SDL_WINDOWEVENT, SDL_SYSWMEVENT);
133134
}
134135

135136

src/xrEngine/device.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -350,21 +350,22 @@ void CRenderDevice::message_loop()
350350
case SDL_WINDOWEVENT_MOVED:
351351
UpdateWindowRect();
352352
break;
353-
/*case SDL_WINDOWEVENT_RESIZED:
354-
string32 buff;
355-
xr_sprintf(buff, sizeof(buff), "vid_mode %dx%d", event.window.data1, event.window.data2);
356-
Console->Execute(buff);
357-
[[fallthrough]];*/
358-
359-
case SDL_WINDOWEVENT_EXPOSED:
360-
Reset(true);
361-
break;
362353

363354
case SDL_WINDOWEVENT_RESIZED:
364355
case SDL_WINDOWEVENT_SIZE_CHANGED:
365-
UpdateWindowRect();
366-
OnWM_Activate(1, event.window.data2);
356+
{
357+
if (!psDeviceFlags.is(rsFullscreen))
358+
{
359+
string32 buff;
360+
xr_sprintf(buff, sizeof(buff), "vid_mode %dx%d", event.window.data1, event.window.data2);
361+
Console->Execute(buff);
362+
Reset();
363+
}
364+
else
365+
UpdateWindowRect();
366+
367367
break;
368+
}
368369

369370
case SDL_WINDOWEVENT_SHOWN:
370371
case SDL_WINDOWEVENT_ENTER:
@@ -389,6 +390,7 @@ void CRenderDevice::message_loop()
389390
}
390391

391392
on_idle();
393+
SDL_PumpEvents();
392394
}
393395
}
394396

@@ -416,6 +418,7 @@ void CRenderDevice::Run()
416418
seqAppStart.Process();
417419
GEnv.Render->ClearTarget();
418420
splash::hide();
421+
SDL_FlushEvents(SDL_WINDOWEVENT, SDL_SYSWMEVENT);
419422
SDL_ShowWindow(m_sdlWnd);
420423
SDL_RaiseWindow(m_sdlWnd);
421424
pInput->ClipCursor(true);

src/xrEngine/xr_input.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,8 @@ void CInput::OnFrame(void)
247247
stats.FrameTime.Begin();
248248
dwCurTime = RDEVICE.TimerAsync_MMT();
249249

250-
while (SDL_PollEvent(&event))
250+
while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_KEYDOWN, SDL_MOUSEWHEEL))
251251
{
252-
BOOL b_break_cycle = false;
253-
254252
switch (event.type)
255253
{
256254
case SDL_KEYDOWN: {
@@ -310,16 +308,7 @@ void CInput::OnFrame(void)
310308
cbStack.back()->IR_OnMouseWheel(event.wheel.y);
311309
}
312310
break;
313-
case SDL_QUIT: // go to outside event loop
314-
event.type = SDL_QUIT;
315-
SDL_PushEvent(&event);
316-
b_break_cycle = TRUE;
317-
break;
318-
default: break;
319311
}
320-
321-
if (b_break_cycle)
322-
break;
323312
}
324313

325314
#ifndef _EDITOR

0 commit comments

Comments
 (0)