summaryrefslogtreecommitdiff
path: root/init.go
diff options
context:
space:
mode:
Diffstat (limited to 'init.go')
-rw-r--r--init.go22
1 files changed, 14 insertions, 8 deletions
diff --git a/init.go b/init.go
index ef29827..ad1c1ee 100644
--- a/init.go
+++ b/init.go
@@ -197,12 +197,6 @@ func main() {
// this hack is to wait for the application to send something
// before trying to do anything. todo: rethink this someday
func waitOK() {
- defer func() {
- if r := recover(); r != nil {
- fmt.Fprintln(outf, "INIT PLUGIN recovered in r", r)
- return
- }
- }()
for {
if me.ok {
return
@@ -238,12 +232,24 @@ func refreshGocui() {
}()
var lastRefresh time.Time
lastRefresh = time.Now()
+ me.refresh = false
for {
time.Sleep(100 * time.Millisecond)
// log.Info("refresh checking ok")
if !me.ok {
continue
}
+
+ // redraw the windows if something has changed
+ if time.Since(lastRefresh) > 1000*time.Millisecond {
+ if me.refresh {
+ log.Info("refresh triggered")
+ me.newWindowTrigger <- me.treeRoot.TK.(*guiWidget)
+ me.refresh = false
+ }
+ }
+
+ // this code updates the clock
if time.Since(lastRefresh) > 1000*time.Millisecond {
// artificially pause clock while dragging.
// this is a reminder to make this refresh code smarter
@@ -289,9 +295,9 @@ func newWindowTrigger() {
select {
case tk := <-me.newWindowTrigger:
// log.Log(NOW, "newWindowTrigger() got new window", tk.cuiName)
- time.Sleep(200 * time.Millisecond)
+ // time.Sleep(200 * time.Millisecond)
waitOK()
- time.Sleep(200 * time.Millisecond)
+ // time.Sleep(200 * time.Millisecond)
redoWindows(me.FirstWindowW, me.FirstWindowH)
me.firstWindowOk = true
if !me.stdout.init {