diff --git a/minigui.d b/minigui.d index 87d85f8..8fab081 100644 --- a/minigui.d +++ b/minigui.d @@ -1226,7 +1226,23 @@ class Widget { child.privatePaint(painter, painter.originX, painter.originY); } - void redraw() { + static class RedrawEvent {} + __gshared re = new RedrawEvent(); + + private bool redrawRequested; + final void redraw() { + redrawRequested = true; + + if(this.parentWindow) { + auto sw = this.parentWindow.win; + assert(sw !is null); + if(!sw.eventQueued!RedrawEvent) + sw.postEvent(re); + } + } + + void actualRedraw() { + redrawRequested = false; if(!showing) return; assert(parentWindow !is null); @@ -1984,6 +2000,10 @@ class Window : Widget { super(null); this.win = win; + win.addEventListener((Widget.RedrawEvent) { + this.actualRedraw(); + }); + this.width = win.width; this.height = win.height; this.parentWindow = this;