Skip to content

Commit

Permalink
Merge pull request #706 from gucio321/change-mainthread
Browse files Browse the repository at this point in the history
change mainthread library
  • Loading branch information
gucio321 authored Oct 20, 2023
2 parents d5bd62e + 43f2cca commit 1b679de
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 4 deletions.
2 changes: 0 additions & 2 deletions Context.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ type state struct {
type context struct {
backend imgui.Backend[imgui.GLFWWindowFlags]

// TODO: should be handled by mainthread tbh
// see https://github.com/faiface/mainthread/pull/4
isRunning bool

widgetIndexCounter int
Expand Down
3 changes: 1 addition & 2 deletions MasterWindow.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"runtime"

imgui "github.com/AllenDang/cimgui-go"
"github.com/faiface/mainthread"
"golang.org/x/image/colornames"
)

Expand Down Expand Up @@ -230,7 +229,7 @@ func (w *MasterWindow) render() {
// Run should be called at the end of main function, after setting
// up the master window.
func (w *MasterWindow) Run(loopFunc func()) {
mainthread.Run(func() {
mainthreadCallPlatform(func() {
Context.isRunning = true
w.updateFunc = loopFunc

Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8
github.com/sahilm/fuzzy v0.1.0
github.com/stretchr/testify v1.8.4
golang.design/x/hotkey v0.4.1
golang.org/x/image v0.13.0
gopkg.in/eapache/queue.v1 v1.1.0
)
Expand All @@ -19,6 +20,7 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.design/x/mainthread v0.3.0 // indirect
golang.org/x/sys v0.5.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ github.com/sahilm/fuzzy v0.1.0 h1:FzWGaw2Opqyu+794ZQ9SYifWv2EIXpwP4q8dY1kDAwI=
github.com/sahilm/fuzzy v0.1.0/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
golang.design/x/hotkey v0.4.1 h1:zLP/2Pztl4WjyxURdW84GoZ5LUrr6hr69CzJFJ5U1go=
golang.design/x/hotkey v0.4.1/go.mod h1:M8SGcwFYHnKRa83FpTFQoZvPO5vVT+kWPztFqTQKmXA=
golang.design/x/mainthread v0.3.0 h1:UwFus0lcPodNpMOGoQMe87jSFwbSsEY//CA7yVmu4j8=
golang.design/x/mainthread v0.3.0/go.mod h1:vYX7cF2b3pTJMGM/hc13NmN6kblKnf4/IyvHeu259L0=
golang.org/x/image v0.13.0 h1:3cge/F/QTkNLauhf2QoE9zp+7sr+ZcL4HnoZmdwg9sg=
golang.org/x/image v0.13.0/go.mod h1:6mmbMOeV28HuMTgA6OSRkdXKYw/t5W9Uwn2Yv1r3Yxk=
golang.org/x/sys v0.0.0-20201022201747-fb209a7c41cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand Down
10 changes: 10 additions & 0 deletions mainthread_all.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//go:build !darwin
// +build !darwin

package giu

import "github.com/faiface/mainthread"

func mainthreadCallPlatform(c func()) {
mainthread.Run(c)
}
10 changes: 10 additions & 0 deletions mainthread_mac.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//go:build darwin
// +build darwin

package giu

import "golang.design/x/hotkey/mainthread"

func mainthreadCallPlatform(c func()) {
mainthread.Call(c)
}

0 comments on commit 1b679de

Please sign in to comment.