From a7b03fd2cd91b2f194ec34e25f043fb65f3dc33f Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Tue, 16 Mar 2010 13:30:52 +0000 Subject: [PATCH] Implement pausing (with the Escape key) for the NoGUI build in linux. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5203 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DolphinWX/Src/MainNoGUI.cpp | 38 +++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/Source/Core/DolphinWX/Src/MainNoGUI.cpp b/Source/Core/DolphinWX/Src/MainNoGUI.cpp index d30ab1113e..b139c48cf8 100644 --- a/Source/Core/DolphinWX/Src/MainNoGUI.cpp +++ b/Source/Core/DolphinWX/Src/MainNoGUI.cpp @@ -58,12 +58,46 @@ void Host_NotifyMapLoaded(){} void Host_ShowJitResults(unsigned int address){} +#if defined(HAVE_X11) && HAVE_X11 +void X11_SendClientEvent(const char *message) +{ + XEvent event; + Display *dpy = (Display *)Core::GetWindowHandle(); + Window win = *(Window *)Core::GetXWindow(); + + // Init X event structure for client message + event.xclient.type = ClientMessage; + event.xclient.format = 32; + event.xclient.data.l[0] = XInternAtom(dpy, message, False); + + // Send the event + if (!XSendEvent(dpy, win, False, False, &event)) + ERROR_LOG(VIDEO, "Failed to send message %s to the emulator window.\n", message); +} +#endif + Common::Event updateMainFrameEvent; void Host_Message(int Id) { #if defined(HAVE_X11) && HAVE_X11 - if (Id == WM_USER_STOP) - updateMainFrameEvent.Set(); + switch (Id) + { + case WM_USER_STOP: + updateMainFrameEvent.Set(); + break; + case WM_USER_PAUSE: + if (Core::GetState() == Core::CORE_RUN) + { + X11_SendClientEvent("PAUSE"); + Core::SetState(Core::CORE_PAUSE); + } + else + { + X11_SendClientEvent("RESUME"); + Core::SetState(Core::CORE_RUN); + } + break; + } #endif }