github.com/cybriq/giocore@v0.0.7-0.20210703034601-cfb9cb5f3900/app/internal/wm/os_unix.go (about)

     1  // SPDX-License-Identifier: Unlicense OR MIT
     2  
     3  // +build linux,!android freebsd openbsd
     4  
     5  package wm
     6  
     7  import (
     8  	"errors"
     9  )
    10  
    11  type ViewEvent struct{}
    12  
    13  func Main() {
    14  	select {}
    15  }
    16  
    17  type windowDriver func(Callbacks, *Options) error
    18  
    19  // Instead of creating files with build tags for each combination of wayland +/- x11
    20  // let each driver initialize these variables with their own version of createWindow.
    21  var wlDriver, x11Driver windowDriver
    22  
    23  func NewWindow(window Callbacks, opts *Options) error {
    24  	var errFirst error
    25  	for _, d := range []windowDriver{x11Driver, wlDriver} {
    26  		if d == nil {
    27  			continue
    28  		}
    29  		err := d(window, opts)
    30  		if err == nil {
    31  			return nil
    32  		}
    33  		if errFirst == nil {
    34  			errFirst = err
    35  		}
    36  	}
    37  	if errFirst != nil {
    38  		return errFirst
    39  	}
    40  	return errors.New("app: no window driver available")
    41  }
    42  
    43  func (_ ViewEvent) ImplementsEvent() {}