gio/app/internal/window/os_unix.go -rw-r--r-- 837 bytes View raw
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// SPDX-License-Identifier: Unlicense OR MIT

// +build linux,!android freebsd

package window

import (
	"errors"
)

var mainDone = make(chan struct{})

func Main() {
	<-mainDone
}

// instead of creating files with build tags for each combination of wayland +/- x11
// let each driver initialize these variables with their own version of createWindow.
var wlDriver, x11Driver func(Callbacks, *Options) error

func NewWindow(window Callbacks, opts *Options) error {
	var errFirst, err error
	if wlDriver != nil {
		if err = wlDriver(window, opts); err == nil {
			return nil
		}
		errFirst = err
	}
	if x11Driver != nil {
		if err = x11Driver(window, opts); err == nil {
			return nil
		}
		if errFirst == nil {
			errFirst = err
		}
	}
	if errFirst != nil {
		return errFirst
	}
	return errors.New("app: no window driver available")
}