Skip to content

Commit f67b5ec

Browse files
authored
go-gl/glfw v3.3 support (#298)
* go-gl/glfw v3.3 support * add content scale callback * chore: udpate glfw version tag * feat: custom PixelRatio calculation * revert scaling * update go.mod AWESOME! fixes #373
1 parent 03dc634 commit f67b5ec

18 files changed

+23
-43
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Updating Go is simple and Go [seldomly has backwards-incompatible changes](https
8181

8282
### GLFW version
8383

84-
This project uses go-gl/glfw for GLFW v3.2.
84+
This project uses go-gl/glfw for GLFW v3.3.
8585

8686
## License
8787

Diff for: application.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"time"
99
"unsafe"
1010

11-
"github.com/go-gl/glfw/v3.2/glfw"
11+
"github.com/go-gl/glfw/v3.3/glfw"
1212
"github.com/pkg/errors"
1313

1414
"github.com/go-flutter-desktop/go-flutter/embedder"
@@ -119,6 +119,7 @@ func (a *Application) Run() error {
119119
glfw.WindowHint(glfw.Visible, glfw.False)
120120
}
121121

122+
glfw.WindowHint(glfw.ScaleToMonitor, glfw.True)
122123
if a.config.windowAlwaysOnTop {
123124
glfw.WindowHint(glfw.Floating, glfw.True)
124125
}
@@ -310,7 +311,6 @@ func (a *Application) Run() error {
310311
})
311312
})
312313
})
313-
// TODO: when moving to glfw 3.3, also use glfwSetWindowContentScaleCallback
314314

315315
// Attach glfw window callbacks for text input
316316
a.window.SetKeyCallback(

Diff for: glfw.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"unsafe"
99

1010
"github.com/go-flutter-desktop/go-flutter/embedder"
11-
"github.com/go-gl/glfw/v3.2/glfw"
11+
"github.com/go-gl/glfw/v3.3/glfw"
1212
)
1313

1414
// dpPerInch defines the amount of display pixels per inch as defined for Flutter.

Diff for: go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.12
55
require (
66
github.com/davecgh/go-spew v1.1.1
77
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7
8-
github.com/go-gl/glfw v0.0.0-20200222043503-6f7a984d4dc4
8+
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4
99
github.com/pkg/errors v0.9.1
1010
github.com/stretchr/testify v1.5.1
1111
)

Diff for: go.sum

+3-13
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,14 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
33
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
44
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7 h1:SCYMcCJ89LjRGwEa0tRluNRiMjZHalQZrVrvTbPh+qw=
55
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7/go.mod h1:482civXOzJJCPzJ4ZOX/pwvXBWSnzD4OKMdH4ClKGbk=
6-
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1 h1:QbL/5oDUmRBzO9/Z7Seo6zf912W/a6Sr4Eu0G/3Jho0=
7-
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
8-
github.com/go-gl/glfw v0.0.0-20200221102942-eb749776b5d7 h1:uyLPeqcUL3PEnrv7h5Z+eCoKgx+rIWlgP1SWLwb5J00=
9-
github.com/go-gl/glfw v0.0.0-20200221102942-eb749776b5d7/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
10-
github.com/go-gl/glfw v0.0.0-20200222043503-6f7a984d4dc4 h1:5Bg3HS4orH8S9vQARwWJHnEkz0dvhRKf3xxGlyDpjhE=
11-
github.com/go-gl/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
12-
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
13-
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
14-
github.com/pkg/errors v0.9.0 h1:J8lpUdobwIeCI7OiSxHqEwJUKvJwicL5+3v1oe2Yb4k=
15-
github.com/pkg/errors v0.9.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
6+
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4 h1:WtGNWLvXpe6ZudgnXrq0barxBImvnnJoMEhXAzcbM0I=
7+
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
168
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
179
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
1810
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1911
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
2012
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
21-
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
22-
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
23-
github.com/stretchr/testify v1.5.0/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
13+
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
2414
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
2515
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
2616
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

Diff for: internal/opengl/opengl.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"unsafe"
1111

1212
"github.com/go-gl/gl/v3.3-core/gl"
13-
"github.com/go-gl/glfw/v3.2/glfw"
13+
"github.com/go-gl/glfw/v3.3/glfw"
1414
)
1515

1616
// const exposed to go-flutter

Diff for: key-events.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"fmt"
66

77
"github.com/go-flutter-desktop/go-flutter/plugin"
8-
"github.com/go-gl/glfw/v3.2/glfw"
8+
"github.com/go-gl/glfw/v3.3/glfw"
99
)
1010

1111
const keyEventChannelName = "flutter/keyevent"

Diff for: keyboard.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package flutter
22

3-
import "github.com/go-gl/glfw/v3.2/glfw"
3+
import "github.com/go-gl/glfw/v3.3/glfw"
44

55
// KeyboardQwertyLayout is the default key for shortcuts (US-layout)
66
var KeyboardQwertyLayout = KeyboardShortcuts{

Diff for: lifecycle.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55

66
"github.com/go-flutter-desktop/go-flutter/plugin"
7-
"github.com/go-gl/glfw/v3.2/glfw"
7+
"github.com/go-gl/glfw/v3.3/glfw"
88
)
99

1010
const lifecycleChannelName = "flutter/lifecycle"

Diff for: option.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"image"
66
"os"
77

8-
"github.com/go-gl/glfw/v3.2/glfw"
8+
"github.com/go-gl/glfw/v3.3/glfw"
99
)
1010

1111
type config struct {
@@ -156,7 +156,7 @@ func WindowDimensionLimits(minWidth, minHeight, maxWidth, maxHeight int) Option
156156

157157
// WindowIcon sets an icon provider func, which is called during window
158158
// initialization. For tips on the kind of images to provide, see
159-
// https://godoc.org/github.com/go-gl/glfw/v3.2/glfw#Window.SetIcon
159+
// https://godoc.org/github.com/go-gl/glfw/v3.3/glfw#Window.SetIcon
160160
func WindowIcon(iconProivder func() ([]image.Image, error)) Option {
161161
return func(c *config) {
162162
c.windowIconProvider = iconProivder

Diff for: platform.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package flutter
33
import (
44
"encoding/json"
55

6-
"github.com/go-gl/glfw/v3.2/glfw"
6+
"github.com/go-gl/glfw/v3.3/glfw"
77
"github.com/pkg/errors"
88

99
"github.com/go-flutter-desktop/go-flutter/internal/tasker"
@@ -85,11 +85,8 @@ func (p *platformPlugin) handleClipboardGetData(arguments interface{}) (reply in
8585

8686
var clipText string
8787
p.glfwTasker.Do(func() {
88-
clipText, err = p.window.GetClipboardString()
88+
clipText = p.window.GetClipboardString()
8989
})
90-
if err != nil {
91-
return nil, errors.Wrap(err, "failed to get string from clipboard")
92-
}
9390

9491
reply = struct {
9592
Text string `json:"text"`

Diff for: plugin.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package flutter
22

33
import (
4-
"github.com/go-gl/glfw/v3.2/glfw"
4+
"github.com/go-gl/glfw/v3.3/glfw"
55

66
"github.com/go-flutter-desktop/go-flutter/plugin"
77
)

Diff for: pop.go

+1-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package flutter
22

33
import (
4-
"fmt"
5-
64
"github.com/pkg/errors"
75
)
86

@@ -47,14 +45,9 @@ func (p *platformPlugin) handleSystemNavigatorPop(arguments interface{}) (reply
4745
})
4846
return nil, nil
4947
case PopBehaviorIconify:
50-
var err error
5148
p.glfwTasker.Do(func() {
52-
err = p.window.Iconify()
49+
p.window.Iconify()
5350
})
54-
if err != nil {
55-
fmt.Printf("go-flutter: error on iconifying window: %v\n", err)
56-
return nil, errors.Wrap(err, "failed to iconify window")
57-
}
5851
return nil, nil
5952
case PopBehaviorClose:
6053
p.glfwTasker.Do(func() {

Diff for: textinput.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"unicode"
77

88
"github.com/go-flutter-desktop/go-flutter/plugin"
9-
"github.com/go-gl/glfw/v3.2/glfw"
9+
"github.com/go-gl/glfw/v3.3/glfw"
1010
"github.com/pkg/errors"
1111
)
1212

Diff for: textinput_darwin.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package flutter
22

3-
import "github.com/go-gl/glfw/v3.2/glfw"
3+
import "github.com/go-gl/glfw/v3.3/glfw"
44

55
func (p *keyboardShortcutsGLFW) isModifier() bool {
66
return p.mod&glfw.ModSuper != 0

Diff for: textinput_linux.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package flutter
22

3-
import "github.com/go-gl/glfw/v3.2/glfw"
3+
import "github.com/go-gl/glfw/v3.3/glfw"
44

55
func (p *keyboardShortcutsGLFW) isModifier() bool {
66
return p.mod&glfw.ModControl != 0

Diff for: textinput_windows.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package flutter
22

3-
import "github.com/go-gl/glfw/v3.2/glfw"
3+
import "github.com/go-gl/glfw/v3.3/glfw"
44

55
func (p *keyboardShortcutsGLFW) isModifier() bool {
66
return p.mod&glfw.ModControl != 0

Diff for: texture-registry.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/go-flutter-desktop/go-flutter/embedder"
88
"github.com/go-flutter-desktop/go-flutter/internal/opengl"
99
"github.com/go-flutter-desktop/go-flutter/internal/tasker"
10-
"github.com/go-gl/glfw/v3.2/glfw"
10+
"github.com/go-gl/glfw/v3.3/glfw"
1111
"github.com/pkg/errors"
1212
)
1313

0 commit comments

Comments
 (0)