while(!m_fExit) { XEvent event; XtAppNextEvent(m_AppContext, &event); pMutex->Lock(); { //--> Begin Critical region. XtDispatchEvent(&event); } pMutex->UnLock(); //<-- End Critical region. }
Xt event dispatch is bracketed by Lock and Unlock calls on the application serialization mutex ensuring that all Xt Event processing is done synchronized to the application.
To include an Xt event loop in your application you must:
Widget CXtEventLoop::InitializeApplication(int& argc, char** argv) { m_TopLevel = XtAppInitialize(&m_AppContext, m_sClass.c_str(), m_pOptionTable, m_nOptionCount, &argc, argv, m_ppcFallbackResources, NULL, 0); return m_TopLevel; }
This initializes the Xt library, and produces the application top level widget. You can write your member to modify the class (m_sClass), the option table (m_pOptionTable), and the application fallback resources (m_ppcFallbackResources) prior to calling CXtEventLoop::InitializeApplication
You can also detect and process application specific "Command line parameters."
The attributes of widgets and classes of widgets are defined both by explicit properties at widget creation or modification time, and by a set of defaults or "resources." The resources are loaded into a resource database from several sources:
The function SetupApplicationResources() provides a hook to allow default application resources to be loaded into the system. The call signature for this member is:
void SetupApplicationResources (Widget TopLevel);
Toplevel | is the top level widget created in InitializeApplication() |
The call signature of this member is:
void CXtEventLoop::SetupWidgetTree(Widget TopLevel)
Where:
TopLevel | is the toplevel widget. All application widgets have this widget as an ultimate parent. |