本文整理汇总了Golang中github.com/BurntSushi/xgbutil/xwindow.Window.WMGracefulClose方法的典型用法代码示例。如果您正苦于以下问题:Golang Window.WMGracefulClose方法的具体用法?Golang Window.WMGracefulClose怎么用?Golang Window.WMGracefulClose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/BurntSushi/xgbutil/xwindow.Window
的用法示例。
在下文中一共展示了Window.WMGracefulClose方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
})
win.Map()
if err != nil {
log.Fatal(err)
}
return win
}
示例3: 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
}