github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/exp/shiny/driver/windriver/windriver.go (about)

     1  // Copyright 2015 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // +build windows
     6  
     7  package windriver
     8  
     9  import (
    10  	"golang.org/x/exp/shiny/driver/internal/errscreen"
    11  	"golang.org/x/exp/shiny/driver/internal/win32"
    12  	"golang.org/x/exp/shiny/screen"
    13  )
    14  
    15  // TODO(andlabs): Should the Windows API code be split into a
    16  // separate package internal/winbackend so gldriver can use it too?
    17  
    18  // Main is called by the program's main function to run the graphical
    19  // application.
    20  //
    21  // It calls f on the Screen, possibly in a separate goroutine, as some OS-
    22  // specific libraries require being on 'the main thread'. It returns when f
    23  // returns.
    24  func Main(f func(screen.Screen)) {
    25  	if err := win32.Main(func() { f(theScreen) }); err != nil {
    26  		f(errscreen.Stub(err))
    27  	}
    28  }