mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 01:45:36 +00:00
ui/app,apps/gophers,apps/hello: accept nil WindowOptions in NewWindow
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+8
-1
@@ -64,7 +64,14 @@ var extraArgs string
|
||||
// ignore or adjust them.
|
||||
// If the current program is running on iOS and Android,
|
||||
// NewWindow the window previously created by the platform.
|
||||
func NewWindow(opts WindowOptions) (*Window, error) {
|
||||
func NewWindow(opts *WindowOptions) (*Window, error) {
|
||||
if opts == nil {
|
||||
opts = &WindowOptions{
|
||||
Width: ui.Dp(800),
|
||||
Height: ui.Dp(600),
|
||||
Title: "Gio program",
|
||||
}
|
||||
}
|
||||
if opts.Width.V <= 0 || opts.Height.V <= 0 {
|
||||
panic("window width and height must be larger than 0")
|
||||
}
|
||||
|
||||
@@ -381,6 +381,6 @@ func Main() {
|
||||
panic("unreachable")
|
||||
}
|
||||
|
||||
func createWindow(opts WindowOptions) (*Window, error) {
|
||||
return <- windows, nil
|
||||
func createWindow(opts *WindowOptions) (*Window, error) {
|
||||
return <-windows, nil
|
||||
}
|
||||
|
||||
+1
-1
@@ -235,7 +235,7 @@ func (w *window) setTextInput(s key.TextInputState) {
|
||||
}
|
||||
}
|
||||
|
||||
func createWindow(opts WindowOptions) (*Window, error) {
|
||||
func createWindow(opts *WindowOptions) (*Window, error) {
|
||||
return <-windows, nil
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -40,7 +40,7 @@ type windowError struct {
|
||||
err error
|
||||
}
|
||||
|
||||
var windowOpts = make(chan WindowOptions)
|
||||
var windowOpts = make(chan *WindowOptions)
|
||||
|
||||
var windows = make(chan windowError)
|
||||
|
||||
@@ -188,7 +188,7 @@ func gio_onCreate(view C.CFTypeRef) {
|
||||
windows <- windowError{window: ow}
|
||||
}
|
||||
|
||||
func createWindow(opts WindowOptions) (*Window, error) {
|
||||
func createWindow(opts *WindowOptions) (*Window, error) {
|
||||
windowOpts <- opts
|
||||
werr := <-windows
|
||||
return werr.window, werr.err
|
||||
|
||||
@@ -141,7 +141,7 @@ func Main() {
|
||||
<-mainDone
|
||||
}
|
||||
|
||||
func createWindow(opts WindowOptions) (*Window, error) {
|
||||
func createWindow(opts *WindowOptions) (*Window, error) {
|
||||
connMu.Lock()
|
||||
defer connMu.Unlock()
|
||||
if len(winMap) > 0 {
|
||||
@@ -165,7 +165,7 @@ func createWindow(opts WindowOptions) (*Window, error) {
|
||||
return w.w, nil
|
||||
}
|
||||
|
||||
func createNativeWindow(opts WindowOptions) (*window, error) {
|
||||
func createNativeWindow(opts *WindowOptions) (*window, error) {
|
||||
pipe := make([]int, 2)
|
||||
if err := syscall.Pipe2(pipe, syscall.O_NONBLOCK|syscall.O_CLOEXEC); err != nil {
|
||||
return nil, fmt.Errorf("createNativeWindow: failed to create pipe: %v", err)
|
||||
|
||||
@@ -157,7 +157,7 @@ func Main() {
|
||||
<-mainDone
|
||||
}
|
||||
|
||||
func createWindow(opts WindowOptions) (*Window, error) {
|
||||
func createWindow(opts *WindowOptions) (*Window, error) {
|
||||
onceMu.Lock()
|
||||
defer onceMu.Unlock()
|
||||
if len(winMap) > 0 {
|
||||
@@ -190,7 +190,7 @@ func createWindow(opts WindowOptions) (*Window, error) {
|
||||
return werr.window, werr.err
|
||||
}
|
||||
|
||||
func createNativeWindow(opts WindowOptions) (*window, error) {
|
||||
func createNativeWindow(opts *WindowOptions) (*window, error) {
|
||||
setProcessDPIAware()
|
||||
screenDC, err := getDC(0)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user