private void EventLoop() { XCbWindow = XCreateSimpleWindow(XDisplay, XRootWindow, 0, 0, 1, 1, 0, UIntPtr.Zero, UIntPtr.Zero); XFlush(XDisplay); XSelectInput(XDisplay, XCbWindow, EventMask.PropertyChangeMask | EventMask.KeyPressMask | EventMask.PointerMotionMask); int timeout_usec = Settings.XServerPollRateMS * 1000; //TODO - poll raw socket properly. XEvent evt = new XEvent(); while (!disposedValue) { timeval v = new timeval(); v.tv_usec = timeout_usec; int num = select(0, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, ref v); while (XPending(XDisplay) > 0) { XNextEvent(XDisplay, ref evt); EventArrived?.Invoke(evt); } } ISLogger.Write("Exiting X eventloop"); if (XCbWindow != default) { XDestroyWindow(XDisplay, XCbWindow); } XCloseDisplay(XDisplay); }
/// <summary> /// This method will be exposed to the Javascript environment. It is /// invoked in the Javascript environment when some event of interest /// happens. /// </summary> /// <param name="eventName">The name of the event.</param> /// <param name="eventData">Data provided by the invoker pertaining to the event.</param> /// <remarks> /// By default RaiseEvent will be translated to raiseEvent as a javascript function. /// This is configurable when calling RegisterJsObject by setting camelCaseJavascriptNames; /// </remarks> public void RaiseEvent(string eventName, dynamic eventData) { EventArrived?.Invoke(eventName, eventData); }