Changed the way ApplicationShells are used: now wxMotif
creates one ApplicationShell per display, and makes top level windows popup childs of the ApplicationShell. Removed a couple of unused variables from wxApp. Replaced some calls to wxGetDisplay with XtDisplay(widget) or event.xany.display, and some others with wxGlobalDisplay (the latter changes are just eyecandy). Used wxFlushEvents where appropriate. Fixed (hopefully) wxFindAcceleratorText and wxFindAccelerator; for now the new version is still disabled, awaiting further testing. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20474 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -48,7 +48,20 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
WX_DECLARE_VOIDPTR_HASH_MAP( wxXVisualInfo*, wxXVisualInfoMap );
|
||||
struct wxPerDisplayData
|
||||
{
|
||||
wxPerDisplayData()
|
||||
{ m_visualInfo = NULL; m_topLevelWidget = NULL; }
|
||||
|
||||
wxXVisualInfo* m_visualInfo;
|
||||
Widget m_topLevelWidget;
|
||||
};
|
||||
|
||||
WX_DECLARE_VOIDPTR_HASH_MAP( wxPerDisplayData, wxPerDisplayDataMap );
|
||||
|
||||
static void wxTLWidgetDestroyCallback(Widget w, XtPointer clientData,
|
||||
XtPointer ptr);
|
||||
static WXWidget wxCreateTopLevelWidget( WXDisplay* display );
|
||||
|
||||
extern wxList wxPendingDelete;
|
||||
extern bool wxAddIdleCallback();
|
||||
@@ -75,8 +88,6 @@ END_EVENT_TABLE()
|
||||
}
|
||||
#endif // __WXDEBUG__
|
||||
|
||||
long wxApp::sm_lastMessageTime = 0;
|
||||
|
||||
bool wxApp::Initialize()
|
||||
{
|
||||
wxClassInfo::InitializeClasses();
|
||||
@@ -265,24 +276,25 @@ wxApp::wxApp()
|
||||
m_eventLoop = new wxEventLoop;
|
||||
m_mainColormap = (WXColormap) NULL;
|
||||
m_appContext = (WXAppContext) NULL;
|
||||
m_topLevelWidget = (WXWidget) NULL;
|
||||
m_maxRequestSize = 0;
|
||||
m_initialDisplay = (WXDisplay*) 0;
|
||||
m_visualInfoMap = new wxXVisualInfoMap;
|
||||
m_perDisplayData = new wxPerDisplayDataMap;
|
||||
}
|
||||
|
||||
wxApp::~wxApp()
|
||||
{
|
||||
delete m_eventLoop;
|
||||
|
||||
for( wxXVisualInfoMap::iterator it = m_visualInfoMap->begin(),
|
||||
end = m_visualInfoMap->end();
|
||||
for( wxPerDisplayDataMap::iterator it = m_perDisplayData->begin(),
|
||||
end = m_perDisplayData->end();
|
||||
it != end; ++it )
|
||||
{
|
||||
delete it->second;
|
||||
delete it->second.m_visualInfo;
|
||||
XtDestroyWidget( it->second.m_topLevelWidget );
|
||||
}
|
||||
|
||||
delete m_visualInfoMap;
|
||||
delete m_perDisplayData;
|
||||
|
||||
wxTheApp = NULL;
|
||||
}
|
||||
|
||||
bool wxApp::Initialized()
|
||||
@@ -493,12 +505,6 @@ bool wxApp::OnInitGui()
|
||||
gs_pfnXErrorHandler = XSetErrorHandler(wxXErrorHandler);
|
||||
#endif // __WXDEBUG__
|
||||
|
||||
wxTheApp->m_topLevelWidget =
|
||||
(WXWidget) XtAppCreateShell((String)NULL,
|
||||
wxTheApp->GetClassName().c_str(),
|
||||
applicationShellWidgetClass,dpy,
|
||||
NULL,0) ;
|
||||
|
||||
// Add general resize proc
|
||||
XtActionsRec rec;
|
||||
rec.string = "resize";
|
||||
@@ -506,7 +512,6 @@ bool wxApp::OnInitGui()
|
||||
XtAppAddActions((XtAppContext) wxTheApp->m_appContext, &rec, 1);
|
||||
|
||||
GetMainColormap(dpy);
|
||||
m_maxRequestSize = XMaxRequestSize((Display*) dpy);
|
||||
|
||||
wxAddIdleCallback();
|
||||
|
||||
@@ -531,18 +536,61 @@ WXColormap wxApp::GetMainColormap(WXDisplay* display)
|
||||
|
||||
wxXVisualInfo* wxApp::GetVisualInfo( WXDisplay* display )
|
||||
{
|
||||
wxXVisualInfoMap::iterator it = m_visualInfoMap->find( display );
|
||||
wxPerDisplayDataMap::iterator it = m_perDisplayData->find( display );
|
||||
|
||||
if( it != m_visualInfoMap->end() ) return it->second;
|
||||
if( it != m_perDisplayData->end() && it->second.m_visualInfo )
|
||||
return it->second.m_visualInfo;
|
||||
|
||||
wxXVisualInfo* vi = new wxXVisualInfo;
|
||||
wxFillXVisualInfo( vi, (Display*)display );
|
||||
|
||||
(*m_visualInfoMap)[display] = vi;
|
||||
(*m_perDisplayData)[display].m_visualInfo = vi;
|
||||
|
||||
return vi;
|
||||
}
|
||||
|
||||
static void wxTLWidgetDestroyCallback(Widget w, XtPointer clientData,
|
||||
XtPointer ptr)
|
||||
{
|
||||
if( wxTheApp )
|
||||
wxTheApp->SetTopLevelWidget( (WXDisplay*)XtDisplay(w),
|
||||
(WXWidget)NULL );
|
||||
}
|
||||
|
||||
WXWidget wxCreateTopLevelWidget( WXDisplay* display )
|
||||
{
|
||||
Widget tlw = XtAppCreateShell( (String)NULL,
|
||||
wxTheApp->GetClassName().c_str(),
|
||||
applicationShellWidgetClass,
|
||||
(Display*)display,
|
||||
NULL, 0 );
|
||||
|
||||
XtAddCallback( tlw, XmNdestroyCallback,
|
||||
(XtCallbackProc)wxTLWidgetDestroyCallback,
|
||||
(XtPointer)NULL );
|
||||
|
||||
return (WXWidget)tlw;
|
||||
}
|
||||
|
||||
WXWidget wxApp::GetTopLevelWidget()
|
||||
{
|
||||
WXDisplay* display = wxGetDisplay();
|
||||
wxPerDisplayDataMap::iterator it = m_perDisplayData->find( display );
|
||||
|
||||
if( it != m_perDisplayData->end() && it->second.m_topLevelWidget )
|
||||
return (WXWidget)it->second.m_topLevelWidget;
|
||||
|
||||
WXWidget tlw = wxCreateTopLevelWidget( display );
|
||||
SetTopLevelWidget( display, tlw );
|
||||
|
||||
return tlw;
|
||||
}
|
||||
|
||||
void wxApp::SetTopLevelWidget(WXDisplay* display, WXWidget widget)
|
||||
{
|
||||
(*m_perDisplayData)[display].m_topLevelWidget = (Widget)widget;
|
||||
}
|
||||
|
||||
void wxExit()
|
||||
{
|
||||
int retValue = 0;
|
||||
|
Reference in New Issue
Block a user