Revert "Don't sleep in the event thread"
This commit is contained in:
parent
a9a6270982
commit
30fef298bb
|
@ -57,15 +57,19 @@ void cX11Window::XEventThread()
|
|||
while (win)
|
||||
{
|
||||
XEvent event;
|
||||
XNextEvent(dpy, &event);
|
||||
switch (event.type)
|
||||
for (int num_events = XPending(dpy); num_events > 0; num_events--)
|
||||
{
|
||||
case ConfigureNotify:
|
||||
XResizeWindow(dpy, win, event.xconfigure.width, event.xconfigure.height);
|
||||
GLInterface->SetBackBufferDimensions(event.xconfigure.width, event.xconfigure.height);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
XNextEvent(dpy, &event);
|
||||
switch (event.type)
|
||||
{
|
||||
case ConfigureNotify:
|
||||
XResizeWindow(dpy, win, event.xconfigure.width, event.xconfigure.height);
|
||||
GLInterface->SetBackBufferDimensions(event.xconfigure.width, event.xconfigure.height);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
Common::SleepCurrentThread(20);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -199,69 +199,72 @@ class PlatformX11 : public Platform
|
|||
{
|
||||
XEvent event;
|
||||
KeySym key;
|
||||
XNextEvent(dpy, &event);
|
||||
switch (event.type)
|
||||
for (int num_events = XPending(dpy); num_events > 0; num_events--)
|
||||
{
|
||||
case KeyPress:
|
||||
key = XLookupKeysym((XKeyEvent*)&event, 0);
|
||||
if (key == XK_Escape)
|
||||
XNextEvent(dpy, &event);
|
||||
switch (event.type)
|
||||
{
|
||||
if (Core::GetState() == Core::CORE_RUN)
|
||||
case KeyPress:
|
||||
key = XLookupKeysym((XKeyEvent*)&event, 0);
|
||||
if (key == XK_Escape)
|
||||
{
|
||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
|
||||
XUndefineCursor(dpy, win);
|
||||
Core::SetState(Core::CORE_PAUSE);
|
||||
if (Core::GetState() == Core::CORE_RUN)
|
||||
{
|
||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
|
||||
XUndefineCursor(dpy, win);
|
||||
Core::SetState(Core::CORE_PAUSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
|
||||
XDefineCursor(dpy, win, blankCursor);
|
||||
Core::SetState(Core::CORE_RUN);
|
||||
}
|
||||
}
|
||||
else
|
||||
else if ((key == XK_Return) && (event.xkey.state & Mod1Mask))
|
||||
{
|
||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
|
||||
XDefineCursor(dpy, win, blankCursor);
|
||||
Core::SetState(Core::CORE_RUN);
|
||||
}
|
||||
}
|
||||
else if ((key == XK_Return) && (event.xkey.state & Mod1Mask))
|
||||
{
|
||||
fullscreen = !fullscreen;
|
||||
X11Utils::ToggleFullscreen(dpy, win);
|
||||
fullscreen = !fullscreen;
|
||||
X11Utils::ToggleFullscreen(dpy, win);
|
||||
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
||||
XRRConfig->ToggleDisplayMode(fullscreen);
|
||||
XRRConfig->ToggleDisplayMode(fullscreen);
|
||||
#endif
|
||||
}
|
||||
else if (key >= XK_F1 && key <= XK_F8)
|
||||
{
|
||||
int slot_number = key - XK_F1 + 1;
|
||||
if (event.xkey.state & ShiftMask)
|
||||
State::Save(slot_number);
|
||||
else
|
||||
State::Load(slot_number);
|
||||
}
|
||||
else if (key == XK_F9)
|
||||
Core::SaveScreenShot();
|
||||
else if (key == XK_F11)
|
||||
State::LoadLastSaved();
|
||||
else if (key == XK_F12)
|
||||
{
|
||||
if (event.xkey.state & ShiftMask)
|
||||
State::UndoLoadState();
|
||||
else
|
||||
State::UndoSaveState();
|
||||
}
|
||||
break;
|
||||
case FocusIn:
|
||||
rendererHasFocus = true;
|
||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor &&
|
||||
Core::GetState() != Core::CORE_PAUSE)
|
||||
XDefineCursor(dpy, win, blankCursor);
|
||||
break;
|
||||
case FocusOut:
|
||||
rendererHasFocus = false;
|
||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
|
||||
XUndefineCursor(dpy, win);
|
||||
break;
|
||||
case ClientMessage:
|
||||
if ((unsigned long) event.xclient.data.l[0] == XInternAtom(dpy, "WM_DELETE_WINDOW", False))
|
||||
running = false;
|
||||
break;
|
||||
}
|
||||
else if (key >= XK_F1 && key <= XK_F8)
|
||||
{
|
||||
int slot_number = key - XK_F1 + 1;
|
||||
if (event.xkey.state & ShiftMask)
|
||||
State::Save(slot_number);
|
||||
else
|
||||
State::Load(slot_number);
|
||||
}
|
||||
else if (key == XK_F9)
|
||||
Core::SaveScreenShot();
|
||||
else if (key == XK_F11)
|
||||
State::LoadLastSaved();
|
||||
else if (key == XK_F12)
|
||||
{
|
||||
if (event.xkey.state & ShiftMask)
|
||||
State::UndoLoadState();
|
||||
else
|
||||
State::UndoSaveState();
|
||||
}
|
||||
break;
|
||||
case FocusIn:
|
||||
rendererHasFocus = true;
|
||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor &&
|
||||
Core::GetState() != Core::CORE_PAUSE)
|
||||
XDefineCursor(dpy, win, blankCursor);
|
||||
break;
|
||||
case FocusOut:
|
||||
rendererHasFocus = false;
|
||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
|
||||
XUndefineCursor(dpy, win);
|
||||
break;
|
||||
case ClientMessage:
|
||||
if ((unsigned long) event.xclient.data.l[0] == XInternAtom(dpy, "WM_DELETE_WINDOW", False))
|
||||
running = false;
|
||||
break;
|
||||
}
|
||||
if (!fullscreen)
|
||||
{
|
||||
|
@ -274,6 +277,7 @@ class PlatformX11 : public Platform
|
|||
(unsigned int *)&SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowHeight,
|
||||
&borderDummy, &depthDummy);
|
||||
}
|
||||
usleep(100000);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue