Skip to content

Commit

Permalink
Add a workaround to NSRunLoop freezing during window resize on macOS
Browse files Browse the repository at this point in the history
Fixes issue #12
  • Loading branch information
andydotxyz committed Jul 20, 2018
1 parent 6c00de5 commit a4e4ae2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions desktop/cfuncs.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,22 @@ package desktop
// Gateway callback functions
static Eina_Bool
_immediate_iterate(void *data EINA_UNUSED)
{
ecore_main_loop_iterate();
// only tick once
return ECORE_CALLBACK_CANCEL;
}
void onWindowResize_cgo(Ecore_Evas *ee)
{
void onWindowResize(Ecore_Evas*);
onWindowResize(ee);
// On macOS the resize freezes NSRunLoop, so call iterate right away
ecore_timer_add(0.001, _immediate_iterate, NULL);
}
void onWindowMove_cgo(Ecore_Evas *ee)
Expand Down
3 changes: 3 additions & 0 deletions desktop/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ func onWindowResize(ee *C.Ecore_Evas) {
canvas := w.canvas.(*eflCanvas)
canvas.size = fyne.NewSize(int(float32(ww)/canvas.Scale()), int(float32(hh)/canvas.Scale()))
canvas.resizeContent()

// part of a NSRunLoop hack for macOS
drawDirty()
}

//export onWindowMove
Expand Down

0 comments on commit a4e4ae2

Please sign in to comment.