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:
@@ -33,7 +33,7 @@ class WXDLLEXPORT wxKeyEvent;
|
||||
class WXDLLEXPORT wxLog;
|
||||
class WXDLLEXPORT wxEventLoop;
|
||||
class WXDLLEXPORT wxXVisualInfo;
|
||||
class wxXVisualInfoMap;
|
||||
class wxPerDisplayDataMap;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// the wxApp class for Motif - see wxAppBase for more details
|
||||
@@ -85,10 +85,11 @@ public:
|
||||
|
||||
// Motif-specific
|
||||
WXAppContext GetAppContext() const { return m_appContext; }
|
||||
WXWidget GetTopLevelWidget() const { return m_topLevelWidget; }
|
||||
WXWidget GetTopLevelWidget();
|
||||
WXColormap GetMainColormap(WXDisplay* display);
|
||||
WXDisplay* GetInitialDisplay() const { return m_initialDisplay; }
|
||||
long GetMaxRequestSize() const { return m_maxRequestSize; }
|
||||
|
||||
void SetTopLevelWidget(WXDisplay* display, WXWidget widget);
|
||||
|
||||
// This handler is called when a property change event occurs
|
||||
virtual void HandlePropertyChange(WXEvent *event);
|
||||
@@ -96,18 +97,13 @@ public:
|
||||
wxXVisualInfo* GetVisualInfo(WXDisplay* display);
|
||||
|
||||
private:
|
||||
static long sm_lastMessageTime;
|
||||
int m_nCmdShow;
|
||||
|
||||
wxEventLoop* m_eventLoop;
|
||||
|
||||
// Motif-specific
|
||||
WXAppContext m_appContext;
|
||||
WXWidget m_topLevelWidget;
|
||||
WXColormap m_mainColormap;
|
||||
WXDisplay* m_initialDisplay;
|
||||
long m_maxRequestSize;
|
||||
wxXVisualInfoMap* m_visualInfoMap;
|
||||
wxPerDisplayDataMap* m_perDisplayData;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
@@ -154,14 +154,18 @@ wxSize wxDoGetSingleTextCtrlBestSize( Widget textWidget,
|
||||
const wxWindow* window );
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// executes one main loop iteration (implemented in src/motif/evtloop.cpp)
|
||||
// event-related functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class wxEventLoop;
|
||||
|
||||
// executes one main loop iteration (implemented in src/motif/evtloop.cpp)
|
||||
// returns true if the loop should be exited
|
||||
bool wxDoEventLoopIteration( wxEventLoop& evtLoop );
|
||||
|
||||
// Consume all events until no more left
|
||||
void wxFlushEvents(WXDisplay* display);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// macros to avoid casting WXFOO to Foo all the time
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@@ -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;
|
||||
|
@@ -121,7 +121,7 @@ void wxCheckBox::ChangeBackgroundColour()
|
||||
XmNforeground, g_itemColors[wxFORE_INDEX].pixel,
|
||||
NULL);
|
||||
|
||||
int selectPixel = wxBLACK->AllocColour(wxGetDisplay());
|
||||
int selectPixel = wxBLACK->AllocColour(XtDisplay((Widget)m_mainWidget));
|
||||
|
||||
// Better to have the checkbox selection in black, or it's
|
||||
// hard to determine what state it is in.
|
||||
|
@@ -305,8 +305,8 @@ bool wxDialog::Show( bool show )
|
||||
else
|
||||
XtUnmanageChild((Widget)m_mainWidget) ;
|
||||
|
||||
XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()));
|
||||
XSync(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), FALSE);
|
||||
XFlush(XtDisplay((Widget)m_mainWidget));
|
||||
XSync(XtDisplay((Widget)m_mainWidget), FALSE);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -319,6 +319,9 @@ int wxDialog::ShowModal()
|
||||
|
||||
Show(TRUE);
|
||||
|
||||
// after the event loop ran, the widget might already have been destroyed
|
||||
WXDisplay* display = (WXDisplay*)XtDisplay( (Widget)m_mainWidget );
|
||||
|
||||
if (m_modalShowing)
|
||||
return 0;
|
||||
m_eventLoop = new wxEventLoop;
|
||||
@@ -329,12 +332,7 @@ int wxDialog::ShowModal()
|
||||
m_eventLoop->Run();
|
||||
|
||||
// Now process all events in case they get sent to a destroyed dialog
|
||||
XSync(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), FALSE);
|
||||
while (m_eventLoop->Pending())
|
||||
{
|
||||
XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()));
|
||||
m_eventLoop->Dispatch();
|
||||
}
|
||||
wxFlushEvents( display );
|
||||
|
||||
delete m_eventLoop;
|
||||
m_eventLoop = NULL;
|
||||
|
@@ -234,7 +234,7 @@ void ProcessXEvent(XEvent* event)
|
||||
* window is recieved. Prevents flicker as windows are resized.
|
||||
*/
|
||||
|
||||
Display *disp = XtDisplay((Widget) wxTheApp->GetTopLevelWidget());
|
||||
Display *disp = event->xany.display;
|
||||
Window win = event->xany.window;
|
||||
XEvent report;
|
||||
|
||||
@@ -260,7 +260,7 @@ bool CheckForAccelerator(XEvent* event)
|
||||
{
|
||||
// Find a wxWindow for this window
|
||||
// TODO: should get display for the window, not the current display
|
||||
Widget widget = XtWindowToWidget((Display*) wxGetDisplay(),
|
||||
Widget widget = XtWindowToWidget(event->xany.display,
|
||||
event->xany.window);
|
||||
wxWindow* win = NULL;
|
||||
|
||||
@@ -294,7 +294,7 @@ bool CheckForKeyDown(XEvent* event)
|
||||
{
|
||||
if (event->xany.type == KeyPress)
|
||||
{
|
||||
Widget widget = XtWindowToWidget((Display*) wxGetDisplay(),
|
||||
Widget widget = XtWindowToWidget(event->xany.display,
|
||||
event->xany.window);
|
||||
wxWindow* win = NULL;
|
||||
|
||||
@@ -320,7 +320,7 @@ bool CheckForKeyUp(XEvent* event)
|
||||
{
|
||||
if (event->xany.type == KeyRelease)
|
||||
{
|
||||
Widget widget = XtWindowToWidget((Display*) wxGetDisplay(),
|
||||
Widget widget = XtWindowToWidget(event->xany.display,
|
||||
event->xany.window);
|
||||
wxWindow* win = NULL;
|
||||
|
||||
|
@@ -227,9 +227,7 @@ int wxFileDialog::ShowModal()
|
||||
// static char fileBuf[512];
|
||||
Widget parentWidget = (Widget) 0;
|
||||
if (m_parent)
|
||||
{
|
||||
parentWidget = (Widget) m_parent->GetTopWidget();
|
||||
}
|
||||
else
|
||||
parentWidget = (Widget) wxTheApp->GetTopLevelWidget();
|
||||
// prepare the arg list
|
||||
@@ -349,28 +347,25 @@ int wxFileDialog::ShowModal()
|
||||
wxEndBusyCursor();
|
||||
|
||||
XtAddGrab(XtParent(fileSel), TRUE, FALSE);
|
||||
XtAppContext context = (XtAppContext) wxTheApp->GetAppContext();
|
||||
XEvent event;
|
||||
while (!m_fileSelectorReturned)
|
||||
{
|
||||
XtAppProcessEvent((XtAppContext) wxTheApp->GetAppContext(), XtIMAll);
|
||||
XtAppNextEvent(context, &event);
|
||||
XtDispatchEvent(&event);
|
||||
}
|
||||
XtRemoveGrab(XtParent(fileSel));
|
||||
|
||||
XmUpdateDisplay((Widget) wxTheApp->GetTopLevelWidget()); // Experimental
|
||||
// XmUpdateDisplay((Widget) wxTheApp->GetTopLevelWidget()); // Experimental
|
||||
|
||||
Display* display = XtDisplay(fileSel);
|
||||
|
||||
// XtDestroyWidget(fileSel);
|
||||
XtUnmapWidget(XtParent(fileSel));
|
||||
XtDestroyWidget(XtParent(fileSel));
|
||||
|
||||
// Now process all events, because otherwise
|
||||
// this might remain on the screen
|
||||
XSync(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), FALSE);
|
||||
while (XtAppPending((XtAppContext) wxTheApp->GetAppContext()))
|
||||
{
|
||||
XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()));
|
||||
XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event);
|
||||
XtDispatchEvent(&event);
|
||||
}
|
||||
wxFlushEvents(display);
|
||||
|
||||
m_path = m_fileSelectorAnswer;
|
||||
m_fileName = wxFileNameFromPath(m_fileSelectorAnswer);
|
||||
|
@@ -88,10 +88,6 @@ static void wxFrameMapProc(Widget frameShell, XtPointer clientData,
|
||||
extern wxList wxModelessWindows;
|
||||
extern wxList wxPendingDelete;
|
||||
|
||||
// TODO: this should be tidied so that any frame can be the
|
||||
// top frame
|
||||
// static bool wxTopLevelUsed = FALSE;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxWin macros
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -120,7 +116,6 @@ void wxFrame::Init()
|
||||
m_mainWidget = (WXWidget) NULL;;
|
||||
m_workArea = (WXWidget) NULL;;
|
||||
m_clientArea = (WXWidget) NULL;;
|
||||
// m_visibleStatus = TRUE;
|
||||
}
|
||||
|
||||
bool wxFrame::Create(wxWindow *parent,
|
||||
@@ -206,25 +201,13 @@ bool wxFrame::DoCreate( wxWindow* parent, wxWindowID id,
|
||||
long style,
|
||||
const wxString& name )
|
||||
{
|
||||
static bool wxTopLevelUsed = FALSE; /* this is global */
|
||||
WXWidget frameShell;
|
||||
Widget frameShell;
|
||||
|
||||
if (wxTopLevelUsed)
|
||||
{
|
||||
// Change suggested by Matthew Flatt
|
||||
frameShell = (WXWidget)XtAppCreateShell( name,
|
||||
wxTheApp->GetClassName(),
|
||||
topLevelShellWidgetClass,
|
||||
(Display*) wxGetDisplay(),
|
||||
frameShell = XtCreatePopupShell( name, topLevelShellWidgetClass,
|
||||
(Widget)wxTheApp->GetTopLevelWidget(),
|
||||
NULL, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
frameShell = wxTheApp->GetTopLevelWidget();
|
||||
wxTopLevelUsed = TRUE;
|
||||
}
|
||||
|
||||
XtVaSetValues((Widget) frameShell,
|
||||
XtVaSetValues(frameShell,
|
||||
// Allows menu to resize
|
||||
XmNallowShellResize, True,
|
||||
XmNdeleteResponse, XmDO_NOTHING,
|
||||
@@ -232,10 +215,10 @@ bool wxFrame::DoCreate( wxWindow* parent, wxWindowID id,
|
||||
XmNiconic, (style & wxICONIZE) ? TRUE : FALSE,
|
||||
NULL);
|
||||
|
||||
m_frameShell = frameShell;
|
||||
m_frameShell = (WXWidget)frameShell;
|
||||
|
||||
m_mainWidget = (WXWidget) XtVaCreateManagedWidget("main_window",
|
||||
xmMainWindowWidgetClass, (Widget) frameShell,
|
||||
xmMainWindowWidgetClass, frameShell,
|
||||
XmNresizePolicy, XmRESIZE_NONE,
|
||||
NULL);
|
||||
|
||||
@@ -266,11 +249,11 @@ bool wxFrame::DoCreate( wxWindow* parent, wxWindowID id,
|
||||
XtFree( (char *)ptr );
|
||||
|
||||
/* Part of show-&-hide fix */
|
||||
XtAddEventHandler( (Widget)frameShell, StructureNotifyMask,
|
||||
XtAddEventHandler( frameShell, StructureNotifyMask,
|
||||
False, (XtEventHandler)wxFrameMapProc,
|
||||
(XtPointer)this );
|
||||
|
||||
XtRealizeWidget((Widget) frameShell);
|
||||
XtRealizeWidget(frameShell);
|
||||
|
||||
wxAddWindowToTable( (Widget)m_workArea, this);
|
||||
wxAddWindowToTable( (Widget)m_clientArea, this);
|
||||
|
@@ -377,7 +377,7 @@ void wxRadioBox::ChangeBackgroundColour()
|
||||
{
|
||||
wxWindow::ChangeBackgroundColour();
|
||||
|
||||
int selectPixel = wxBLACK->AllocColour(wxGetDisplay());
|
||||
int selectPixel = wxBLACK->AllocColour(XtDisplay((Widget)m_mainWidget));
|
||||
|
||||
int i;
|
||||
for (i = 0; i < m_noItems; i++)
|
||||
|
@@ -160,7 +160,7 @@ void wxRadioButton::ChangeBackgroundColour()
|
||||
wxWindow::ChangeBackgroundColour();
|
||||
|
||||
// What colour should this be?
|
||||
int selectPixel = wxBLACK->AllocColour(wxGetDisplay());
|
||||
int selectPixel = wxBLACK->AllocColour(XtDisplay((Widget)m_mainWidget));
|
||||
|
||||
XtVaSetValues ((Widget) GetMainWidget(),
|
||||
XmNselectColor, selectPixel,
|
||||
|
@@ -23,22 +23,11 @@
|
||||
#include "wx/setup.h"
|
||||
#include "wx/utils.h"
|
||||
#include "wx/app.h"
|
||||
#include "wx/msgdlg.h"
|
||||
#include "wx/cursor.h"
|
||||
#include "wx/dcmemory.h"
|
||||
#include "wx/bitmap.h"
|
||||
#include "wx/evtloop.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
#include <pwd.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
|
||||
#if (defined(__SUNCC__) || defined(__CLCC__))
|
||||
#include <sysent.h>
|
||||
@@ -88,57 +77,20 @@ static char *GetIniFile (char *dest, const char *filename);
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Consume all events until no more left
|
||||
void wxFlushEvents()
|
||||
void wxFlushEvents(WXDisplay* wxdisplay)
|
||||
{
|
||||
Display *display = (Display*) wxGetDisplay();
|
||||
Display *display = (Display*)wxdisplay;
|
||||
wxEventLoop evtLoop;
|
||||
|
||||
XSync (display, FALSE);
|
||||
|
||||
// XtAppPending returns availability of events AND timers/inputs, which
|
||||
// are processed via callbacks, so XtAppNextEvent will not return if
|
||||
// there are no events. So added '& XtIMXEvent' - Sergey.
|
||||
while (XtAppPending ((XtAppContext) wxTheApp->GetAppContext()) & XtIMXEvent)
|
||||
while (evtLoop.Pending())
|
||||
{
|
||||
XFlush (XtDisplay ((Widget) wxTheApp->GetTopLevelWidget()));
|
||||
// Jan Lessner: works better when events are non-X events
|
||||
XtAppProcessEvent((XtAppContext) wxTheApp->GetAppContext(), XtIMXEvent);
|
||||
XFlush (display);
|
||||
evtLoop.Dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
// Check whether this window wants to process messages, e.g. Stop button
|
||||
// in long calculations.
|
||||
bool wxCheckForInterrupt(wxWindow *wnd)
|
||||
{
|
||||
wxCHECK_MSG( wnd, FALSE, "NULL window in wxCheckForInterrupt" );
|
||||
|
||||
Display *dpy=(Display*) wnd->GetXDisplay();
|
||||
Window win=(Window) wnd->GetXWindow();
|
||||
XEvent event;
|
||||
XFlush(dpy);
|
||||
if (wnd->GetMainWidget())
|
||||
{
|
||||
XmUpdateDisplay((Widget)(wnd->GetMainWidget()));
|
||||
}
|
||||
|
||||
bool hadEvents = FALSE;
|
||||
while( XCheckMaskEvent(dpy,
|
||||
ButtonPressMask|ButtonReleaseMask|ButtonMotionMask|
|
||||
PointerMotionMask|KeyPressMask|KeyReleaseMask,
|
||||
&event) )
|
||||
{
|
||||
if ( event.xany.window == win )
|
||||
{
|
||||
hadEvents = TRUE;
|
||||
|
||||
XtDispatchEvent(&event);
|
||||
}
|
||||
}
|
||||
|
||||
return hadEvents;
|
||||
}
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxExecute stuff
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -175,7 +127,7 @@ int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
|
||||
void wxBell()
|
||||
{
|
||||
// Use current setting for the bell
|
||||
XBell ((Display*) wxGetDisplay(), 0);
|
||||
XBell (wxGlobalDisplay(), 0);
|
||||
}
|
||||
|
||||
int wxGetOsVersion(int *majorVsn, int *minorVsn)
|
||||
@@ -184,7 +136,7 @@ int wxGetOsVersion(int *majorVsn, int *minorVsn)
|
||||
// This code is WRONG!! Does NOT return the
|
||||
// Motif version of the libs but the X protocol
|
||||
// version!
|
||||
Display *display = XtDisplay ((Widget) wxTheApp->GetTopLevelWidget());
|
||||
Display *display = wxGlobalDisplay();
|
||||
if (majorVsn)
|
||||
*majorVsn = ProtocolVersion (display);
|
||||
if (minorVsn)
|
||||
@@ -337,7 +289,7 @@ bool wxGetResource(const wxString& section, const wxString& entry, char **value,
|
||||
{
|
||||
if (!wxResourceDatabase)
|
||||
{
|
||||
Display *display = (Display*) wxGetDisplay();
|
||||
Display *display = wxGlobalDisplay();
|
||||
wxXMergeDatabases (wxTheApp, display);
|
||||
}
|
||||
|
||||
@@ -549,8 +501,8 @@ void wxGetMousePosition( int* x, int* y )
|
||||
#else
|
||||
XMotionEvent xev;
|
||||
Window root, child;
|
||||
XQueryPointer((Display*) wxGetDisplay(),
|
||||
DefaultRootWindow((Display*) wxGetDisplay()),
|
||||
XQueryPointer(wxGlobalDisplay(),
|
||||
DefaultRootWindow(wxGlobalDisplay()),
|
||||
&root, &child,
|
||||
&(xev.x_root), &(xev.y_root),
|
||||
&(xev.x), &(xev.y),
|
||||
@@ -569,7 +521,7 @@ bool wxColourDisplay()
|
||||
// Returns depth of screen
|
||||
int wxDisplayDepth()
|
||||
{
|
||||
Display *dpy = (Display*) wxGetDisplay();
|
||||
Display *dpy = wxGlobalDisplay();
|
||||
|
||||
return DefaultDepth (dpy, DefaultScreen (dpy));
|
||||
}
|
||||
@@ -577,7 +529,7 @@ int wxDisplayDepth()
|
||||
// Get size of display
|
||||
void wxDisplaySize(int *width, int *height)
|
||||
{
|
||||
Display *dpy = (Display*) wxGetDisplay();
|
||||
Display *dpy = wxGlobalDisplay();
|
||||
|
||||
if ( width )
|
||||
*width = DisplayWidth (dpy, DefaultScreen (dpy));
|
||||
@@ -587,7 +539,7 @@ void wxDisplaySize(int *width, int *height)
|
||||
|
||||
void wxDisplaySizeMM(int *width, int *height)
|
||||
{
|
||||
Display *dpy = (Display*) wxGetDisplay();
|
||||
Display *dpy = wxGlobalDisplay();
|
||||
|
||||
if ( width )
|
||||
*width = DisplayWidthMM(dpy, DefaultScreen (dpy));
|
||||
@@ -615,8 +567,6 @@ WXDisplay *wxGetDisplay()
|
||||
{
|
||||
if (gs_currentDisplay)
|
||||
return gs_currentDisplay;
|
||||
if (wxTheApp && wxTheApp->GetTopLevelWidget())
|
||||
return XtDisplay ((Widget) wxTheApp->GetTopLevelWidget());
|
||||
else if (wxTheApp)
|
||||
return wxTheApp->GetInitialDisplay();
|
||||
return NULL;
|
||||
@@ -1064,6 +1014,7 @@ char wxFindMnemonic (const char *s)
|
||||
char mnem = 0;
|
||||
int len = strlen (s);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
if (s[i] == '&')
|
||||
@@ -1083,17 +1034,16 @@ char wxFindMnemonic (const char *s)
|
||||
|
||||
char* wxFindAccelerator( const char *s )
|
||||
{
|
||||
#if 1
|
||||
// VZ: this function returns incorrect keysym which completely breaks kbd
|
||||
// handling
|
||||
return NULL;
|
||||
|
||||
#if 0
|
||||
#else
|
||||
// The accelerator text is after the \t char.
|
||||
while (*s && *s != '\t')
|
||||
s++;
|
||||
if (*s == '\0')
|
||||
return (NULL);
|
||||
s++;
|
||||
s = strchr( s, '\t' );
|
||||
|
||||
if( !s ) return NULL;
|
||||
|
||||
/*
|
||||
Now we need to format it as X standard:
|
||||
|
||||
@@ -1104,62 +1054,68 @@ char * wxFindAccelerator (const char *s)
|
||||
Alt+k --> Meta<Key>k
|
||||
Ctrl+Shift+A --> Ctrl Shift<Key>A
|
||||
|
||||
and handle Ctrl-N & similia
|
||||
*/
|
||||
|
||||
static char buf[256];
|
||||
buf[0] = '\0';
|
||||
char *tmp = copystring (s);
|
||||
s = tmp;
|
||||
char *p = tmp;
|
||||
|
||||
while (1)
|
||||
buf[0] = '\0';
|
||||
wxString tmp = s + 1; // skip TAB
|
||||
size_t index = 0;
|
||||
|
||||
while( index < tmp.length() )
|
||||
{
|
||||
while (*p && *p != '+')
|
||||
p++;
|
||||
if (*p)
|
||||
{
|
||||
*p = '\0';
|
||||
if (buf[0])
|
||||
strcat (buf, " ");
|
||||
if (strcmp (s, "Alt"))
|
||||
strcat (buf, s);
|
||||
else
|
||||
strcat (buf, "Meta");
|
||||
s = p++;
|
||||
}
|
||||
else
|
||||
size_t plus = tmp.find( '+', index );
|
||||
size_t minus = tmp.find( '-', index );
|
||||
|
||||
// neither '+' nor '-', add <Key>
|
||||
if( plus == wxString::npos && minus == wxString::npos )
|
||||
{
|
||||
strcat( buf, "<Key>" );
|
||||
strcat (buf, s);
|
||||
break;
|
||||
}
|
||||
}
|
||||
delete[]tmp;
|
||||
strcat( buf, tmp.c_str() + index );
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
// OK: npos is big and positive
|
||||
size_t sep = wxMin( plus, minus );
|
||||
wxString mod = tmp.substr( index, sep - index );
|
||||
|
||||
// Ctrl -> Ctrl
|
||||
// Shift -> Shift
|
||||
// Alt -> Meta
|
||||
if( mod == "Alt" )
|
||||
mod = "Meta";
|
||||
|
||||
if( buf[0] )
|
||||
strcat( buf, " " );
|
||||
|
||||
strcat( buf, mod.c_str() );
|
||||
|
||||
index = sep + 1;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
XmString wxFindAcceleratorText (const char *s)
|
||||
{
|
||||
#if 1
|
||||
// VZ: this function returns incorrect keysym which completely breaks kbd
|
||||
// handling
|
||||
return NULL;
|
||||
|
||||
#if 0
|
||||
#else
|
||||
// The accelerator text is after the \t char.
|
||||
while (*s && *s != '\t')
|
||||
s++;
|
||||
if (*s == '\0')
|
||||
return (NULL);
|
||||
s++;
|
||||
XmString text = XmStringCreateSimple ((char *)s);
|
||||
return text;
|
||||
s = strchr( s, '\t' );
|
||||
|
||||
if( !s ) return NULL;
|
||||
|
||||
return wxStringToXmString( s + 1 ); // skip TAB!
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// Change a widget's foreground and background colours.
|
||||
|
||||
void wxDoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour)
|
||||
{
|
||||
// When should we specify the foreground, if it's calculated
|
||||
@@ -1206,14 +1162,6 @@ extern void wxDoChangeFont(WXWidget widget, wxFont& font)
|
||||
|
||||
}
|
||||
|
||||
bool wxWindowIsVisible(Window win)
|
||||
{
|
||||
XWindowAttributes wa;
|
||||
XGetWindowAttributes(wxGlobalDisplay(), win, &wa);
|
||||
|
||||
return (wa.map_state == IsViewable);
|
||||
}
|
||||
|
||||
wxString wxXmStringToString( const XmString& xmString )
|
||||
{
|
||||
char *txt;
|
||||
|
@@ -2337,7 +2337,7 @@ bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win,
|
||||
|
||||
// check for a double click
|
||||
//
|
||||
long dclickTime = XtGetMultiClickTime(wxGlobalDisplay());
|
||||
long dclickTime = XtGetMultiClickTime(xevent->xany.display);
|
||||
long ts = wxevent.GetTimestamp();
|
||||
|
||||
int buttonLast = win->GetLastClickedButton();
|
||||
@@ -2624,7 +2624,7 @@ wxWindow* wxFindWindowAtPointer(wxPoint& pt)
|
||||
// Get the current mouse position.
|
||||
wxPoint wxGetMousePosition()
|
||||
{
|
||||
Display *display = (Display*) wxGetDisplay();
|
||||
Display *display = wxGlobalDisplay();
|
||||
Window rootWindow = RootWindowOfScreen (DefaultScreenOfDisplay(display));
|
||||
Window rootReturn, childReturn;
|
||||
int rootX, rootY, winX, winY;
|
||||
|
Reference in New Issue
Block a user