How to access the message queue in Mono on a Linux machine?

215 views Asked by At

I'm writing a game in C# and Mono. I execute the game loop and render whenever the window is idle (that is to say, when the message queue is empty). I understand how to do this on Windows (use P/Invoke to import PeekMessage from "User32.dll"), but I don't know how to get the same information about the state of the message queue on a Linux build. I've browsed the Mono repo on Github, and it doesn't look like direct access to the message queue is exposed. The version of Linux I'm running is Peppermint, if that helps. Any guidance on this would be much appreciated.

bool WindowIsIdle()
{
    #if Windows
        NativeMessage result;
        return PeekMessage(out result, IntPtr.Zero, 0, 0, 0) == 0;
    #elif Linux
    return false; //how can I get this information?
    #endif
}

#if Windows
    //Imports a native Win32 function for checking the windows message queue
    [System.Runtime.InteropServices.DllImport("User32.dll")]
    static extern int PeekMessage(out NativeMessage message, IntPtr handle, uint filterMin, uint filterMax, uint remove);

    struct NativeMessage
    {
        IntPtr Handle;
        uint Message;
        IntPtr WParameter;
        IntPtr LParameter;
        uint Time;
        Point Location;
    }
#endif
0

There are 0 answers