more tweaks to avoid editor flicker under Mac OS X

svn: r7737
This commit is contained in:
Matthew Flatt 2007-11-15 13:26:31 +00:00
parent 1adc9702e8
commit 169ee4cbd1
2 changed files with 42 additions and 2 deletions

View File

@ -533,17 +533,25 @@ void WakeUpMrEd()
nothing and return 0. */
static unsigned long lastTime;
static int wne_delay_on;
static unsigned long wne_delay_until;
static int TransferQueue(int all)
{
EventRecord e;
unsigned long tc;
int sleep_time = 0;
int delay_time = 0;
/* Don't call WaitNextEvent() too often. */
if (TickCount() <= lastTime + delay_time)
tc = TickCount();
if (tc <= lastTime + delay_time)
return 0;
if (wne_delay_on && (tc < wne_delay_until))
return 0;
wne_delay_on = 0;
while (WNE(&e, dispatched ? ((double)sleep_time/60.0) : 0)) {
QueueTransferredEvent(&e);
}
@ -553,6 +561,26 @@ static int TransferQueue(int all)
return 1;
}
void wxStartRefreshSequence(void)
{
/* Editors are not buffered offscreen under Mac OS X, instead
relying on the OS's buffering of all windows, which are updated
on WNE boundaries. To avoid flicker, avoid calling WNE in the
middle of an editor refresh. The refresh might get stuck,
though, so we only wait a little while. */
if (!wne_delay_on) {
wne_delay_until = TickCount() + 10;
}
wne_delay_on++;
}
void wxEndRefreshSequence(void)
{
if (wne_delay_on)
--wne_delay_on;
}
static void MrDequeue(MrQueueElem *q)
{
if (q->prev)

View File

@ -27,6 +27,14 @@
static wxMemoryDC *wx_canvasless_offscreen;
#ifdef wx_mac
extern void wxStartRefreshSequence(void);
extern void wxEndRefreshSequence(void);
#else
# define wxStartRefreshSequence() /* empty */
# define wxEndRefreshSequence() /* empty */
#endif
extern void *MrEdGetWindowContext(wxWindow *w);
class SimpleScroll
@ -812,6 +820,8 @@ void wxMediaCanvas::Redraw(double localx, double localy, double fw, double fh)
if (!media || media->printing)
return;
wxStartRefreshSequence();
GetView(&x, &y, &w, &h);
right = x + w;
@ -851,6 +861,8 @@ void wxMediaCanvas::Redraw(double localx, double localy, double fw, double fh)
media->SetAdmin(oldadmin);
}
}
wxEndRefreshSequence();
}
Bool wxMediaCanvas::ScrollTo(double localx, double localy, double fw, double fh,