diff options
| author | faiface <faiface2202@gmail.com> | 2019-05-06 11:03:48 +0200 |
|---|---|---|
| committer | faiface <faiface2202@gmail.com> | 2019-05-06 11:03:48 +0200 |
| commit | 5d2a6d661a4cedb46c29ebd7b8914be5fa327eee (patch) | |
| tree | 6110542d3820aa6436409efff736f7fe4ad7d770 /win | |
| parent | 9188837d3931cda77da4d6dc37c54ef80b43be9b (diff) | |
| download | gui-5d2a6d661a4cedb46c29ebd7b8914be5fa327eee.zip | |
win: fix macOS retina problem
Diffstat (limited to 'win')
| -rw-r--r-- | win/win.go | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -76,6 +76,21 @@ func New(opts ...Option) (*Win, error) { return nil, err } + mainthread.Call(func() { + // hiDPI hack + width, _ := w.w.GetFramebufferSize() + ratioW := width / o.width + if ratioW != 1 { + o.width /= ratioW + o.height /= ratioW + } + w.w.Destroy() + w.w, err = makeGLFWWin(&o) + }) + if err != nil { + return nil, err + } + bounds := image.Rect(0, 0, o.width, o.height) w.img = image.NewRGBA(bounds) @@ -223,7 +238,7 @@ func (w *Win) eventThread() { } }) - w.w.SetSizeCallback(func(_ *glfw.Window, width, height int) { + w.w.SetFramebufferSizeCallback(func(_ *glfw.Window, width, height int) { r := image.Rect(0, 0, width, height) w.newSize <- r w.eventsIn <- gui.Eventf("resize/%d/%d/%d/%d", r.Min.X, r.Min.Y, r.Max.X, r.Max.Y) |