shiny/driver/mtldriver: update to GLFW 3.3.2

Update to a newer v3.3/glfw pseudo-version, which uses GLFW 3.3.2.

GLFW 3.3.2 includes a fix for glfw/glfw#1543 (go-gl/glfw#262),
which makes it possible to remove the workaround for it from mtldriver.

However, there is a new regression glfw/glfw#1649 (go-gl/glfw#272).
Fortunately, it's a smaller issue. Add a temporary workaround for it.

Also update comment in two internal packages. The upstream names were
modified in https://dmitri.shuralyov.com/gpu/mtl/...$commit/11308bd612348edeca0d8fddca07bc5a4dfbb35c
to match the names used here.

Change-Id: I3199f16890efd539d62d8914b92260f8a614449a
Reviewed-on: https://go-review.googlesource.com/c/exp/+/220639
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
diff --git a/go.mod b/go.mod
index 2cc8780..65cda84 100644
--- a/go.mod
+++ b/go.mod
@@ -5,7 +5,7 @@
 require (
 	dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9
 	github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802
-	github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72
+	github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4
 	golang.org/x/image v0.0.0-20190802002840-cff245a6509b
 	golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028
 	golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b
diff --git a/go.sum b/go.sum
index 8558af0..065988e 100644
--- a/go.sum
+++ b/go.sum
@@ -2,8 +2,8 @@
 dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802 h1:1BDTz0u9nC3//pOCMdNH+CiXJVYJh5UQNCOBG7jbELc=
 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
-github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72 h1:b+9H1GAsx5RsjvDFLoS5zkNBzIQMuVKUYQDmxU3N5XE=
-github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
+github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4 h1:WtGNWLvXpe6ZudgnXrq0barxBImvnnJoMEhXAzcbM0I=
+github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
 golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
 golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
diff --git a/shiny/driver/mtldriver/internal/appkit/appkit.go b/shiny/driver/mtldriver/internal/appkit/appkit.go
index f6f6d5d..a9759a3 100644
--- a/shiny/driver/mtldriver/internal/appkit/appkit.go
+++ b/shiny/driver/mtldriver/internal/appkit/appkit.go
@@ -11,7 +11,7 @@
 // It's a minimal implementation with scope limited to
 // supporting mtldriver.
 //
-// It was copied from dmitri.shuralyov.com/gpu/mtl/example/movingtriangle/internal/ns.
+// It was copied from dmitri.shuralyov.com/gpu/mtl/example/movingtriangle/internal/appkit.
 package appkit
 
 import (
diff --git a/shiny/driver/mtldriver/internal/coreanim/coreanim.go b/shiny/driver/mtldriver/internal/coreanim/coreanim.go
index 857c5e1..46595ab 100644
--- a/shiny/driver/mtldriver/internal/coreanim/coreanim.go
+++ b/shiny/driver/mtldriver/internal/coreanim/coreanim.go
@@ -11,7 +11,7 @@
 // It's a minimal implementation with scope limited to
 // supporting mtldriver.
 //
-// It was copied from dmitri.shuralyov.com/gpu/mtl/example/movingtriangle/internal/ca.
+// It was copied from dmitri.shuralyov.com/gpu/mtl/example/movingtriangle/internal/coreanim.
 package coreanim
 
 import (
diff --git a/shiny/driver/mtldriver/mtldriver.go b/shiny/driver/mtldriver/mtldriver.go
index 2c0e3c4..16ebeef 100644
--- a/shiny/driver/mtldriver/mtldriver.go
+++ b/shiny/driver/mtldriver/mtldriver.go
@@ -55,6 +55,12 @@
 	}
 	defer glfw.Terminate()
 	glfw.WindowHint(glfw.ClientAPI, glfw.NoAPI)
+	{
+		// TODO(dmitshur): Delete this when https://github.com/go-gl/glfw/issues/272 is resolved.
+		// Post an empty event from the main thread before it can happen in a non-main thread,
+		// to work around https://github.com/glfw/glfw/issues/1649.
+		glfw.PostEmptyEvent()
+	}
 	var (
 		done            = make(chan struct{})
 		newWindowCh     = make(chan newWindowReq, 1)
@@ -67,14 +73,6 @@
 		close(done)
 		glfw.PostEmptyEvent() // Break main loop out of glfw.WaitEvents so it can receive on done.
 	}()
-	select {
-	// TODO(dmitshur): Delete this when https://github.com/go-gl/glfw/issues/262 is resolved.
-	// Wait for first window request (or done) before entering main
-	// loop to work around https://github.com/glfw/glfw/issues/1543.
-	case w := <-newWindowCh:
-		newWindowCh <- w
-	case <-done:
-	}
 	for {
 		select {
 		case <-done: