mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 17:05:38 +00:00
app/internal/window: [macOS] simplify NewWindow
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -292,26 +292,23 @@ func gio_onFinishLaunching() {
|
|||||||
func NewWindow(win Callbacks, opts *Options) error {
|
func NewWindow(win Callbacks, opts *Options) error {
|
||||||
<-launched
|
<-launched
|
||||||
errch := make(chan error)
|
errch := make(chan error)
|
||||||
var window *window
|
|
||||||
runOnMain(func() {
|
runOnMain(func() {
|
||||||
w, err := newWindow(win, opts)
|
w, err := newWindow(win, opts)
|
||||||
window = w
|
if err != nil {
|
||||||
errch <- err
|
errch <- err
|
||||||
})
|
return
|
||||||
if err := <-errch; err != nil {
|
}
|
||||||
return err
|
|
||||||
}
|
|
||||||
runOnMain(func() {
|
|
||||||
// Window sizes is in unscaled screen coordinates, not device pixels.
|
// Window sizes is in unscaled screen coordinates, not device pixels.
|
||||||
cfg := configFor(1.0)
|
cfg := configFor(1.0)
|
||||||
width := cfg.Px(opts.Width)
|
width := cfg.Px(opts.Width)
|
||||||
height := cfg.Px(opts.Height)
|
height := cfg.Px(opts.Height)
|
||||||
title := C.CString(opts.Title)
|
title := C.CString(opts.Title)
|
||||||
defer C.free(unsafe.Pointer(title))
|
defer C.free(unsafe.Pointer(title))
|
||||||
nextTopLeft = C.gio_createWindow(window.view, title, C.CGFloat(width), C.CGFloat(height), nextTopLeft)
|
errch <- nil
|
||||||
win.SetDriver(window)
|
nextTopLeft = C.gio_createWindow(w.view, title, C.CGFloat(width), C.CGFloat(height), nextTopLeft)
|
||||||
|
win.SetDriver(w)
|
||||||
})
|
})
|
||||||
return nil
|
return <-errch
|
||||||
}
|
}
|
||||||
|
|
||||||
func newWindow(win Callbacks, opts *Options) (*window, error) {
|
func newWindow(win Callbacks, opts *Options) (*window, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user