コード例 #1
0
ファイル: desktop.go プロジェクト: achille-roussel/go-vu
func (self *display) NewWindow(c *driver.WindowConfig) (w driver.Window, err error) {
	if c == nil {
		c = driver.DefaultWindowConfig()
	}

	win := &window{
		events: make(chan interface{}, 1000),
	}

	// We have to lock the event mutex before creating the window to ensure we
	// can add the new window's event channel before the first events get fired.
	self.evmtx.Lock()

	if win.id, err = createWindow(c); err != nil {
		self.evmtx.Unlock()
		return
	}

	// We register the window event channel to keep track of where events have to
	// be dispatched.
	self.evmap[win.id] = win.events
	self.evmtx.Unlock()

	// The display doesn't retain window objects, if the object gets garbage
	// collected we shouldn't keep a reference to
	runtime.SetFinalizer(win, self.deregister)

	w = win
	return
}
コード例 #2
0
ファイル: shiny.go プロジェクト: achille-roussel/go-vu
func (self display) NewWindow(c *driver.WindowConfig) (w driver.Window, err error) {
	if c == nil {
		c = driver.DefaultWindowConfig()
	}

	win := window{
		events: make(chan interface{}, 10),
	}

	if win.window, err = self.screen.NewWindow(&screen.NewWindowOptions{
		Width:  int(c.Size.W),
		Height: int(c.Size.H),
	}); err != nil {
		return
	}

	go win.run()
	w = win
	return
}