wxX11:
INtroduced OnInternalIdle as per wxGTK so that users cannot as easily lill the internals. Fixed pop-up transient window. Removed some #if 0 here and there. Made refresh code work in idle instead of directly. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14176 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -134,10 +134,15 @@ public:
|
|||||||
// smaller
|
// smaller
|
||||||
virtual wxPoint GetClientAreaOrigin() const;
|
virtual wxPoint GetClientAreaOrigin() const;
|
||||||
|
|
||||||
protected:
|
// I don't want users to override what's done in idle so everything that
|
||||||
// event handlers (not virtual by design)
|
// has to be done in idle time in order for wxX11 to work is done in
|
||||||
void OnIdle(wxIdleEvent& event);
|
// OnInternalIdle
|
||||||
|
virtual void OnInternalIdle();
|
||||||
|
|
||||||
|
// For compatibility across platforms (not in event table)
|
||||||
|
void OnIdle(wxIdleEvent& WXUNUSED(event)) {}
|
||||||
|
|
||||||
|
protected:
|
||||||
// Makes an adjustment to the window position (for example, a frame that has
|
// Makes an adjustment to the window position (for example, a frame that has
|
||||||
// a toolbar that it manages itself).
|
// a toolbar that it manages itself).
|
||||||
virtual void AdjustForParentClientOrigin(int& x, int& y, int sizeFlags);
|
virtual void AdjustForParentClientOrigin(int& x, int& y, int sizeFlags);
|
||||||
|
@@ -515,7 +515,8 @@ bool wxApp::SendIdleEvents( wxWindow* win )
|
|||||||
|
|
||||||
node = node->Next();
|
node = node->Next();
|
||||||
}
|
}
|
||||||
return needMore ;
|
|
||||||
|
return needMore;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxApp::MainLoop()
|
int wxApp::MainLoop()
|
||||||
|
@@ -515,7 +515,8 @@ bool wxApp::SendIdleEvents( wxWindow* win )
|
|||||||
|
|
||||||
node = node->Next();
|
node = node->Next();
|
||||||
}
|
}
|
||||||
return needMore ;
|
|
||||||
|
return needMore;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxApp::MainLoop()
|
int wxApp::MainLoop()
|
||||||
|
@@ -446,12 +446,9 @@ void wxApp::ProcessXEvent(WXEvent* _event)
|
|||||||
{
|
{
|
||||||
if (win)
|
if (win)
|
||||||
{
|
{
|
||||||
|
// Schedule update for later
|
||||||
win->GetUpdateRegion().Union( event->xexpose.x, event->xexpose.y,
|
win->GetUpdateRegion().Union( event->xexpose.x, event->xexpose.y,
|
||||||
event->xexpose.width, event->xexpose.height);
|
event->xexpose.width, event->xexpose.height);
|
||||||
if (event->xexpose.count == 0)
|
|
||||||
{
|
|
||||||
win->X11SendPaintEvents(); // TODO let an idle handler do that
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -547,41 +544,28 @@ void wxApp::HandlePropertyChange(WXEvent *event)
|
|||||||
|
|
||||||
void wxApp::OnIdle(wxIdleEvent& event)
|
void wxApp::OnIdle(wxIdleEvent& event)
|
||||||
{
|
{
|
||||||
static bool inOnIdle = FALSE;
|
static bool s_inOnIdle = FALSE;
|
||||||
|
|
||||||
// Avoid recursion (via ProcessEvent default case)
|
// Avoid recursion (via ProcessEvent default case)
|
||||||
if (inOnIdle)
|
if (s_inOnIdle)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
inOnIdle = TRUE;
|
s_inOnIdle = TRUE;
|
||||||
|
|
||||||
// If there are pending events, we must process them: pending events
|
// Resend in the main thread events which have been prepared in other
|
||||||
// are either events to the threads other than main or events posted
|
// threads
|
||||||
// with wxPostEvent() functions
|
|
||||||
// GRG: I have moved this here so that all pending events are processed
|
|
||||||
// before starting to delete any objects. This behaves better (in
|
|
||||||
// particular, wrt wxPostEvent) and is coherent with wxGTK's current
|
|
||||||
// behaviour. Also removed the '#if wxUSE_THREADS' around it.
|
|
||||||
// Changed Mar/2000 before 2.1.14
|
|
||||||
|
|
||||||
// Flush pending events.
|
|
||||||
ProcessPendingEvents();
|
ProcessPendingEvents();
|
||||||
|
|
||||||
// 'Garbage' collection of windows deleted with Close().
|
// 'Garbage' collection of windows deleted with Close()
|
||||||
DeletePendingObjects();
|
DeletePendingObjects();
|
||||||
|
|
||||||
// flush the logged messages if any
|
|
||||||
wxLog *pLog = wxLog::GetActiveTarget();
|
|
||||||
if ( pLog != NULL && pLog->HasPendingMessages() )
|
|
||||||
pLog->Flush();
|
|
||||||
|
|
||||||
// Send OnIdle events to all windows
|
// Send OnIdle events to all windows
|
||||||
bool needMore = SendIdleEvents();
|
bool needMore = SendIdleEvents();
|
||||||
|
|
||||||
if (needMore)
|
if (needMore)
|
||||||
event.RequestMore(TRUE);
|
event.RequestMore(TRUE);
|
||||||
|
|
||||||
inOnIdle = FALSE;
|
s_inOnIdle = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWakeUpIdle()
|
void wxWakeUpIdle()
|
||||||
@@ -615,7 +599,10 @@ bool wxApp::SendIdleEvents(wxWindow* win)
|
|||||||
|
|
||||||
wxIdleEvent event;
|
wxIdleEvent event;
|
||||||
event.SetEventObject(win);
|
event.SetEventObject(win);
|
||||||
win->ProcessEvent(event);
|
|
||||||
|
win->GetEventHandler()->ProcessEvent(event);
|
||||||
|
|
||||||
|
win->OnInternalIdle();
|
||||||
|
|
||||||
if (event.MoreRequested())
|
if (event.MoreRequested())
|
||||||
needMore = TRUE;
|
needMore = TRUE;
|
||||||
@@ -629,7 +616,8 @@ bool wxApp::SendIdleEvents(wxWindow* win)
|
|||||||
|
|
||||||
node = node->Next();
|
node = node->Next();
|
||||||
}
|
}
|
||||||
return needMore ;
|
|
||||||
|
return needMore;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxApp::DeletePendingObjects()
|
void wxApp::DeletePendingObjects()
|
||||||
|
@@ -225,7 +225,6 @@ void wxWindowDC::SetUpDC()
|
|||||||
m_textGC = (WXGC*) wxGetPoolGC( (Window) m_window, wxTEXT_SCREEN );
|
m_textGC = (WXGC*) wxGetPoolGC( (Window) m_window, wxTEXT_SCREEN );
|
||||||
m_bgGC = (WXGC*) wxGetPoolGC( (Window) m_window, wxBG_SCREEN );
|
m_bgGC = (WXGC*) wxGetPoolGC( (Window) m_window, wxBG_SCREEN );
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
else
|
else
|
||||||
if (m_isMemDC && (((wxMemoryDC*)this)->m_selected.GetDepth() == 1))
|
if (m_isMemDC && (((wxMemoryDC*)this)->m_selected.GetDepth() == 1))
|
||||||
{
|
{
|
||||||
@@ -234,7 +233,6 @@ void wxWindowDC::SetUpDC()
|
|||||||
m_textGC = (WXGC*) wxGetPoolGC( (Window) m_window, wxTEXT_MONO );
|
m_textGC = (WXGC*) wxGetPoolGC( (Window) m_window, wxTEXT_MONO );
|
||||||
m_bgGC = (WXGC*) wxGetPoolGC( (Window) m_window, wxBG_MONO );
|
m_bgGC = (WXGC*) wxGetPoolGC( (Window) m_window, wxBG_MONO );
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_penGC = (WXGC*) wxGetPoolGC( (Window) m_window, wxPEN_COLOUR );
|
m_penGC = (WXGC*) wxGetPoolGC( (Window) m_window, wxPEN_COLOUR );
|
||||||
@@ -342,8 +340,6 @@ void wxWindowDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
|
|||||||
|
|
||||||
CalcBoundingBox(x1, y1);
|
CalcBoundingBox(x1, y1);
|
||||||
CalcBoundingBox(x2, y2);
|
CalcBoundingBox(x2, y2);
|
||||||
|
|
||||||
wxLogDebug("Drawing line at %d, %d -> %d, %d", XLOG2DEV(x1), YLOG2DEV(y1), XLOG2DEV(x2), YLOG2DEV(y2) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -751,7 +747,6 @@ void wxWindowDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord h
|
|||||||
|
|
||||||
CalcBoundingBox( x, y );
|
CalcBoundingBox( x, y );
|
||||||
CalcBoundingBox( x + width, y + height );
|
CalcBoundingBox( x + width, y + height );
|
||||||
wxLogDebug("Drawing rectangle at %d, %d (%dx%d)", x, y, width, height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowDC::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius )
|
void wxWindowDC::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius )
|
||||||
@@ -1535,14 +1530,14 @@ void wxWindowDC::SetBrush( const wxBrush &brush )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
XSetFillStyle( (Display*) m_display, (GC) m_brushGC, FillStippled );
|
XSetFillStyle( (Display*) m_display, (GC) m_brushGC, FillStippled );
|
||||||
// XSetStipple( (Display*) m_display, (GC) m_brushGC, (Pixmap) m_brush.GetStipple()->GetBitmap() );
|
XSetStipple( (Display*) m_display, (GC) m_brushGC, (Pixmap) m_brush.GetStipple()->GetBitmap() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
|
if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
|
||||||
{
|
{
|
||||||
XSetFillStyle( (Display*) m_display, (GC) m_textGC, FillOpaqueStippled );
|
XSetFillStyle( (Display*) m_display, (GC) m_textGC, FillOpaqueStippled );
|
||||||
// XSetStipple( (Display*) m_display, (GC) m_textGC, (Pixmap) m_brush.GetStipple()->GetMask()->GetBitmap() );
|
XSetStipple( (Display*) m_display, (GC) m_textGC, (Pixmap) m_brush.GetStipple()->GetMask()->GetBitmap() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_HATCH(m_brush.GetStyle()))
|
if (IS_HATCH(m_brush.GetStyle()))
|
||||||
@@ -1586,7 +1581,7 @@ void wxWindowDC::SetBackground( const wxBrush &brush )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
XSetFillStyle( (Display*) m_display, (GC) m_bgGC, FillStippled );
|
XSetFillStyle( (Display*) m_display, (GC) m_bgGC, FillStippled );
|
||||||
// XSetStipple( (Display*) m_display, (GC) m_bgGC, (Pixmap) m_backgroundBrush.GetStipple()->GetBitmap() );
|
XSetStipple( (Display*) m_display, (GC) m_bgGC, (Pixmap) m_backgroundBrush.GetStipple()->GetBitmap() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -62,13 +62,12 @@ bool wxPopupWindow::Create( wxWindow *parent, int style )
|
|||||||
|
|
||||||
long xattributes_mask =
|
long xattributes_mask =
|
||||||
CWOverrideRedirect |
|
CWOverrideRedirect |
|
||||||
|
CWSaveUnder |
|
||||||
CWBorderPixel | CWBackPixel;
|
CWBorderPixel | CWBackPixel;
|
||||||
xattributes.background_pixel = BlackPixel( xdisplay, xscreen );
|
xattributes.background_pixel = BlackPixel( xdisplay, xscreen );
|
||||||
xattributes.border_pixel = BlackPixel( xdisplay, xscreen );
|
xattributes.border_pixel = BlackPixel( xdisplay, xscreen );
|
||||||
|
xattributes.override_redirect = True;
|
||||||
// Trying True in order to stop WM decorating it
|
xattributes.save_under = True;
|
||||||
//xattributes.override_redirect = False;
|
|
||||||
xattributes.override_redirect = TRUE;
|
|
||||||
|
|
||||||
Window xwindow = XCreateWindow( xdisplay, xparent, pos.x, pos.y, size.x, size.y,
|
Window xwindow = XCreateWindow( xdisplay, xparent, pos.x, pos.y, size.x, size.y,
|
||||||
0, DefaultDepth(xdisplay,xscreen), InputOutput, xvisual, xattributes_mask, &xattributes );
|
0, DefaultDepth(xdisplay,xscreen), InputOutput, xvisual, xattributes_mask, &xattributes );
|
||||||
|
@@ -49,12 +49,6 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// constants
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
static const int SCROLL_MARGIN = 4;
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// global variables for this module
|
// global variables for this module
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -78,7 +72,6 @@ IMPLEMENT_ABSTRACT_CLASS(wxWindowX11, wxWindowBase)
|
|||||||
|
|
||||||
BEGIN_EVENT_TABLE(wxWindowX11, wxWindowBase)
|
BEGIN_EVENT_TABLE(wxWindowX11, wxWindowBase)
|
||||||
EVT_SYS_COLOUR_CHANGED(wxWindowX11::OnSysColourChanged)
|
EVT_SYS_COLOUR_CHANGED(wxWindowX11::OnSysColourChanged)
|
||||||
EVT_IDLE(wxWindowX11::OnIdle)
|
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -895,13 +888,12 @@ void wxWindowX11::GetTextExtent(const wxString& string,
|
|||||||
int *descent, int *externalLeading,
|
int *descent, int *externalLeading,
|
||||||
const wxFont *theFont) const
|
const wxFont *theFont) const
|
||||||
{
|
{
|
||||||
wxFont *fontToUse = (wxFont *)theFont;
|
wxFont fontToUse = m_font;
|
||||||
if (!fontToUse)
|
if (theFont) fontToUse = *theFont;
|
||||||
fontToUse = (wxFont *) & m_font;
|
|
||||||
|
|
||||||
wxCHECK_RET( fontToUse->Ok(), "valid window font needed" );
|
wxCHECK_RET( fontToUse.Ok(), wxT("invalid font") );
|
||||||
|
|
||||||
WXFontStructPtr pFontStruct = theFont->GetFontStruct(1.0, GetXDisplay());
|
WXFontStructPtr pFontStruct = fontToUse.GetFontStruct(1.0, GetXDisplay());
|
||||||
|
|
||||||
int direction, ascent, descent2;
|
int direction, ascent, descent2;
|
||||||
XCharStruct overall;
|
XCharStruct overall;
|
||||||
@@ -913,7 +905,7 @@ void wxWindowX11::GetTextExtent(const wxString& string,
|
|||||||
&ascent, &descent2, &overall);
|
&ascent, &descent2, &overall);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
XTextExtents((XFontStruct*) pFontStruct, string, slen,
|
XTextExtents((XFontStruct*) pFontStruct, string.c_str(), slen,
|
||||||
&direction, &ascent, &descent2, &overall);
|
&direction, &ascent, &descent2, &overall);
|
||||||
|
|
||||||
if ( x )
|
if ( x )
|
||||||
@@ -958,16 +950,13 @@ void wxWindowX11::Refresh(bool eraseBack, const wxRect *rect)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int height,width;
|
int height,width;
|
||||||
GetSize( &width, &height );
|
GetSize( &width, &height );
|
||||||
|
|
||||||
// Schedule for later Updating in ::Update() or ::OnInternalIdle().
|
// Schedule for later Updating in ::Update() or ::OnInternalIdle().
|
||||||
m_updateRegion.Clear();
|
m_updateRegion.Clear();
|
||||||
m_updateRegion.Union( 0, 0, width, height );
|
m_updateRegion.Union( 0, 0, width, height );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actually don't schedule yet..
|
|
||||||
Update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowX11::Update()
|
void wxWindowX11::Update()
|
||||||
@@ -1019,6 +1008,8 @@ void wxWindowX11::X11SendPaintEvents()
|
|||||||
paint_event.SetEventObject( this );
|
paint_event.SetEventObject( this );
|
||||||
GetEventHandler()->ProcessEvent( paint_event );
|
GetEventHandler()->ProcessEvent( paint_event );
|
||||||
|
|
||||||
|
m_updateRegion.Clear();
|
||||||
|
|
||||||
m_clipPaintRegion = FALSE;
|
m_clipPaintRegion = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1045,8 +1036,11 @@ void wxWindowX11::OnSysColourChanged(wxSysColourChangedEvent& event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowX11::OnIdle(wxIdleEvent& WXUNUSED(event))
|
void wxWindowX11::OnInternalIdle()
|
||||||
{
|
{
|
||||||
|
// Update invalidated regions.
|
||||||
|
Update();
|
||||||
|
|
||||||
// This calls the UI-update mechanism (querying windows for
|
// This calls the UI-update mechanism (querying windows for
|
||||||
// menu/toolbar/control state information)
|
// menu/toolbar/control state information)
|
||||||
UpdateWindowUI();
|
UpdateWindowUI();
|
||||||
|
Reference in New Issue
Block a user