本文整理匯總了Golang中github.com/BurntSushi/xgbutil/xwindow.Window.Listen方法的典型用法代碼示例。如果您正苦於以下問題:Golang Window.Listen方法的具體用法?Golang Window.Listen怎麽用?Golang Window.Listen使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/BurntSushi/xgbutil/xwindow.Window
的用法示例。
在下文中一共展示了Window.Listen方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: newWindow
func newWindow(controlCh *controlCh, X *xgbutil.XUtil, width, height int) *xwindow.Window {
var (
err error
win *xwindow.Window
)
win, err = xwindow.Generate(X)
if err != nil {
panic(err)
}
win.Create(X.RootWin(), 0, 0, width, height,
xproto.CwBackPixel|xproto.CwEventMask,
0, xproto.EventMaskButtonRelease)
// Xorg application exits when the window is closed.
win.WMGracefulClose(
func(w *xwindow.Window) {
xevent.Detach(w.X, w.Id)
mousebind.Detach(w.X, w.Id)
w.Destroy()
xevent.Quit(X)
controlCh.exit <- true
})
// In order to get ConfigureNotify events, we must listen to the window
// using the 'StructureNotify' mask.
win.Listen(xproto.EventMaskButtonPress |
xproto.EventMaskButtonRelease |
xproto.EventMaskKeyPress |
xproto.EventMaskKeyRelease |
xproto.EventMaskStructureNotify)
win.Map()
return win
}
示例2: newWindow
func newWindow(X *xgbutil.XUtil, width, height int) *xwindow.Window {
var (
err error
win *xwindow.Window
)
win, err = xwindow.Generate(X)
if err != nil {
log.Fatal(err)
}
win.Create(X.RootWin(), 0, 0, width, height,
xproto.CwBackPixel|xproto.CwEventMask,
0, xproto.EventMaskButtonRelease)
win.WMGracefulClose(
func(w *xwindow.Window) {
xevent.Detach(w.X, w.Id)
mousebind.Detach(w.X, w.Id)
// w.Destroy()
xevent.Quit(X)
application.Exit()
})
// In order to get ConfigureNotify events, we must listen to the window
// using the 'StructureNotify' mask.
win.Listen(xproto.EventMaskStructureNotify)
win.Map()
xevent.ConfigureNotifyFun(
func(X *xgbutil.XUtil, ev xevent.ConfigureNotifyEvent) {
reshape(int(ev.Width), int(ev.Height))
}).Connect(X, win.Id)
// err = mousebind.ButtonReleaseFun(
// func(X *xgbutil.XUtil, ev xevent.ButtonReleaseEvent) {
// newWindow(X)
// }).Connect(X, win.Id, "1", false, false)
if err != nil {
log.Fatal(err)
}
return win
}