From 9deb9d0801a163b4bbfc15f1c173f1aaf3200df8 Mon Sep 17 00:00:00 2001 From: "Adam D. Ruppe" Date: Wed, 5 Apr 2017 23:29:58 -0400 Subject: [PATCH] huge redraw optimization --- minigui.d | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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;