From: Václav Slavík Date: Thu, 15 Nov 2001 23:50:04 +0000 (+0000) Subject: wxMGL bugfixes: X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/88f2a7714a3a6d5b5da9494f3eede8b49f978cca wxMGL bugfixes: - timers weren't scheduled properly - wxSizeEvent was sent even though the physical dimensions didn't change - wxDC had bugs in device origin computations git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12436 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/mgl/dc.cpp b/src/mgl/dc.cpp index 0a25df8aa3..6d1111607d 100644 --- a/src/mgl/dc.cpp +++ b/src/mgl/dc.cpp @@ -337,7 +337,7 @@ bool wxDC::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const wxCHECK_MSG( col, FALSE, _T("NULL colour parameter in wxDC::GetPixel")); uchar r, g, b; - m_MGLDC->unpackColorFast(m_MGLDC->getPixel(XLOG2DEV(x), XLOG2DEV(y)), + m_MGLDC->unpackColorFast(m_MGLDC->getPixel(XLOG2DEV(x), YLOG2DEV(y)), r, g, b); col->Set(r, g, b); return TRUE; @@ -373,8 +373,8 @@ void wxDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) m_MGLDC->makeCurrent(); // will go away with MGL6.0 if ( !m_penSelected ) SelectPen(); - m_MGLDC->lineExt(XLOG2DEV(x1) + m_penOfsX, XLOG2DEV(y1) + m_penOfsY, - XLOG2DEV(x2) + m_penOfsX, XLOG2DEV(y2) + m_penOfsY,FALSE); + m_MGLDC->lineExt(XLOG2DEV(x1) + m_penOfsX, YLOG2DEV(y1) + m_penOfsY, + XLOG2DEV(x2) + m_penOfsX, YLOG2DEV(y2) + m_penOfsY,FALSE); CalcBoundingBox(x1, y1); CalcBoundingBox(x2, y2); } diff --git a/src/mgl/evtloop.cpp b/src/mgl/evtloop.cpp index e4b4f26373..153f3b0400 100644 --- a/src/mgl/evtloop.cpp +++ b/src/mgl/evtloop.cpp @@ -76,22 +76,21 @@ void wxEventLoopImpl::Dispatch() { event_t evt; - MGL_wmUpdateDC(g_winMng); - // VS: The code bellow is equal to MGL's EVT_halt implementation, with // two things added: sleeping (busy waiting is stupid, lets make CPU's // life a bit easier) and timers updating // EVT_halt(&evt, EVT_EVERYEVT); - do + for (;;) { - EVT_pollJoystick(); - EVT_getNext(&evt, EVT_EVERYEVT); #if wxUSE_TIMER wxTimer::NotifyTimers(); + MGL_wmUpdateDC(g_winMng); #endif + EVT_pollJoystick(); + if ( EVT_getNext(&evt, EVT_EVERYEVT) ) break; PM_sleep(10); - } while (!(evt.what & EVT_EVERYEVT)); + } // end of EVT_halt MGL_wmProcessEvent(g_winMng, &evt); diff --git a/src/mgl/timer.cpp b/src/mgl/timer.cpp index f56c8459c8..1f38baa482 100644 --- a/src/mgl/timer.cpp +++ b/src/mgl/timer.cpp @@ -16,6 +16,7 @@ #if wxUSE_TIMER +#include "wx/log.h" #include "wx/mgl/private.h" extern "C" ulong _EVT_getTicks(); @@ -55,6 +56,9 @@ void wxTimerScheduler::QueueTimer(wxTimerDesc *desc, unsigned long when) desc->shotTime = when; desc->running = TRUE; + wxLogTrace("mgl_timer", "queued timer %p at tick %i", + desc->timer, when); + if ( m_timers ) { wxTimerDesc *d = m_timers; @@ -90,13 +94,20 @@ void wxTimerScheduler::NotifyTimers() { unsigned long now = _EVT_getTicks(); wxTimerDesc *desc; + + wxLogTrace("mgl_timer", "notifying timers, time is %i", now); while ( m_timers && m_timers->shotTime <= now ) { desc = m_timers; - desc->timer->Notify(); + bool oneShot = desc->timer->IsOneShot(); RemoveTimer(desc); - if ( !desc->timer->IsOneShot() ) + + desc->timer->Notify(); + wxLogTrace("mgl_timer", "notified timer %p sheduled for %i", + desc->timer, desc->shotTime); + + if ( !oneShot ) { QueueTimer(desc, now + desc->timer->GetInterval()); } @@ -120,6 +131,7 @@ void wxTimer::Init() if ( ms_timersCnt++ == 0 ) ms_scheduler = new wxTimerScheduler; m_desc = new wxTimerDesc(this); + wxLogTrace("mgl_timer", "--added timer (count=%i)", ms_timersCnt); } wxTimer::~wxTimer() @@ -133,6 +145,7 @@ wxTimer::~wxTimer() ms_scheduler = NULL; } delete m_desc; + wxLogTrace("mgl_timer", "--removed timer (count=%i)", ms_timersCnt); } bool wxTimer::IsRunning() const @@ -142,6 +155,9 @@ bool wxTimer::IsRunning() const bool wxTimer::Start(int millisecs, bool oneShot) { + wxLogTrace("mgl_timer", "started timer %p: %i ms, oneshot=%i", + this, millisecs, oneShot); + if ( !wxTimerBase::Start(millisecs, oneShot) ) return FALSE; diff --git a/src/mgl/window.cpp b/src/mgl/window.cpp index 3f98b46db1..830b19167d 100644 --- a/src/mgl/window.cpp +++ b/src/mgl/window.cpp @@ -929,11 +929,15 @@ void wxWindowMGL::DoSetSize(int x, int y, int width, int height, int sizeFlags) } } - DoMoveWindow(x, y, width, height); + if ( m_wnd->x != x || m_wnd->y != y || + (int)m_wnd->width != width || (int)m_wnd->height != height ) + { + DoMoveWindow(x, y, width, height); - wxSizeEvent event(wxSize(width, height), GetId()); - event.SetEventObject(this); - GetEventHandler()->ProcessEvent(event); + wxSizeEvent event(wxSize(width, height), GetId()); + event.SetEventObject(this); + GetEventHandler()->ProcessEvent(event); + } } void wxWindowMGL::DoSetClientSize(int width, int height)