Main change is that we now close X11 display on program exit: as this couldn't

be done in wxApp dtor (too early), a special module had to be created for it
and module dependencies added for the other modules which have to be cleaned
up while the display is still open.

Also a few minor formatting changes and removed a couple of unused variables
from wxApp.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42119 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-10-19 14:39:53 +00:00
parent 36751d973e
commit b886fae648
6 changed files with 117 additions and 119 deletions

View File

@@ -239,51 +239,75 @@ void wxClientDisplayRect(int *x, int *y, int *width, int *height)
wxDisplaySize(width, height);
}
wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
{
return wxGenericFindWindowAtPoint(pt);
}
// Configurable display in wxX11 and wxMotif
static WXDisplay *gs_currentDisplay = NULL;
static Display *gs_currentDisplay = NULL;
static wxString gs_displayName;
WXDisplay *wxGetDisplay()
{
if (gs_currentDisplay)
return gs_currentDisplay;
return wxApp::GetDisplay();
return (WXDisplay *)gs_currentDisplay;
}
bool wxSetDisplay(const wxString& display_name)
// close the current display
void wxCloseDisplay()
{
gs_displayName = display_name;
if ( display_name.empty() )
if ( gs_currentDisplay )
{
gs_currentDisplay = NULL;
return true;
}
else
{
Display* display = XOpenDisplay((char*) display_name.c_str());
if (display)
if ( XCloseDisplay(gs_currentDisplay) != 0 )
{
gs_currentDisplay = (WXDisplay*) display;
return true;
wxLogWarning(_("Failed to close the display \"%s\""),
gs_displayName.c_str());
}
else
return false;
gs_currentDisplay = NULL;
gs_displayName.clear();
}
}
bool wxSetDisplay(const wxString& displayName)
{
Display *
dpy = XOpenDisplay(displayName.empty() ? NULL : displayName.mb_str());
if ( !dpy )
{
wxLogError(_("Failed to open display \"%s\"."), displayName.c_str());
return false;
}
wxCloseDisplay();
gs_currentDisplay = dpy;
gs_displayName = displayName;
return true;
}
wxString wxGetDisplayName()
{
return gs_displayName;
}
wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
#include "wx/module.h"
// the module responsible for closing the X11 display at the program end
class wxX11DisplayModule : public wxModule
{
return wxGenericFindWindowAtPoint(pt);
}
public:
virtual bool OnInit() { return true; }
virtual void OnExit() { wxCloseDisplay(); }
private:
DECLARE_DYNAMIC_CLASS(wxX11DisplayModule)
};
IMPLEMENT_DYNAMIC_CLASS(wxX11DisplayModule, wxModule)
// ----------------------------------------------------------------------------
// Some colour manipulation routines