From 30fef298bb4da0c09bcdb42c567e40a459ebb5c7 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Fri, 5 Sep 2014 00:50:40 -0500 Subject: [PATCH] Revert "Don't sleep in the event thread" --- .../Core/DolphinWX/GLInterface/X11_Util.cpp | 20 +-- Source/Core/DolphinWX/MainNoGUI.cpp | 114 +++++++++--------- 2 files changed, 71 insertions(+), 63 deletions(-) diff --git a/Source/Core/DolphinWX/GLInterface/X11_Util.cpp b/Source/Core/DolphinWX/GLInterface/X11_Util.cpp index d743cd1f1b..e2f2bbadd6 100644 --- a/Source/Core/DolphinWX/GLInterface/X11_Util.cpp +++ b/Source/Core/DolphinWX/GLInterface/X11_Util.cpp @@ -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); } } diff --git a/Source/Core/DolphinWX/MainNoGUI.cpp b/Source/Core/DolphinWX/MainNoGUI.cpp index c804bd45bf..42f5586170 100644 --- a/Source/Core/DolphinWX/MainNoGUI.cpp +++ b/Source/Core/DolphinWX/MainNoGUI.cpp @@ -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); } }