本文整理汇总了Golang中github.com/BurntSushi/xgbutil/xevent.Quit函数的典型用法代码示例。如果您正苦于以下问题:Golang Quit函数的具体用法?Golang Quit怎么用?Golang Quit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Quit函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: grabKeyboardAndMouse
func grabKeyboardAndMouse(m *Manager) {
if m == nil {
return
}
//go func() {
X, err := xgbutil.NewConn()
if err != nil {
logger.Info("Get New Connection Failed:", err)
return
}
keybind.Initialize(X)
mousebind.Initialize(X)
err = keybind.GrabKeyboard(X, X.RootWin())
if err != nil {
logger.Info("Grab Keyboard Failed:", err)
return
}
grabAllMouseButton(X)
xevent.ButtonPressFun(
func(X *xgbutil.XUtil, e xevent.ButtonPressEvent) {
dbus.Emit(m, "KeyReleaseEvent", "")
ungrabAllMouseButton(X)
keybind.UngrabKeyboard(X)
logger.Info("Button Press Event")
xevent.Quit(X)
}).Connect(X, X.RootWin())
xevent.KeyPressFun(
func(X *xgbutil.XUtil, e xevent.KeyPressEvent) {
value := parseKeyEnvent(X, e.State, e.Detail)
pressKeyStr = value
dbus.Emit(m, "KeyPressEvent", value)
}).Connect(X, X.RootWin())
xevent.KeyReleaseFun(
func(X *xgbutil.XUtil, e xevent.KeyReleaseEvent) {
if strings.ToLower(pressKeyStr) == "super_l" ||
strings.ToLower(pressKeyStr) == "super_r" {
pressKeyStr = "Super"
}
dbus.Emit(m, "KeyReleaseEvent", pressKeyStr)
pressKeyStr = ""
ungrabAllMouseButton(X)
keybind.UngrabKeyboard(X)
logger.Infof("Key: %s\n", pressKeyStr)
xevent.Quit(X)
}).Connect(X, X.RootWin())
xevent.Main(X)
//}()
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:56,代码来源:grab.go
示例2: Run
func (cmd Quit) Run() gribble.Value {
return syncRun(func() gribble.Value {
logger.Message.Println("The User has told us to quit.")
xevent.Quit(wm.X)
return nil
})
}
开发者ID:BurntSushi,项目名称:wingo,代码行数:7,代码来源:commands.go
示例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)
})
win.Map()
if err != nil {
log.Fatal(err)
}
return win
}
开发者ID:remogatto,项目名称:egl,代码行数:27,代码来源:xorg_test.go
示例4: newWindow
func newWindow(X *xgbutil.XUtil) {
win, err := xwindow.Generate(X)
if err != nil {
log.Fatal(err)
}
win.Create(X.RootWin(), 0, 0, 200, 200,
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)
Done <- true
})
win.Map()
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)
}
}
开发者ID:remogatto,项目名称:egles,代码行数:28,代码来源:window.go
示例5: create
// create creates the window, initializes the keybind and mousebind packages
// and sets up the window to act like a real top-level client.
func (w *window) create() {
keybind.Initialize(w.X)
mousebind.Initialize(w.X)
err := w.CreateChecked(w.X.RootWin(), 0, 0, flagWidth, flagHeight,
xproto.CwBackPixel, 0xffffff)
if err != nil {
errLg.Fatalf("Could not create window: %s", err)
}
// Make the window close gracefully using the WM_DELETE_WINDOW protocol.
w.WMGracefulClose(func(w *xwindow.Window) {
xevent.Detach(w.X, w.Id)
keybind.Detach(w.X, w.Id)
mousebind.Detach(w.X, w.Id)
w.Destroy()
xevent.Quit(w.X)
})
// Set WM_STATE so it is interpreted as top-level and is mapped.
err = icccm.WmStateSet(w.X, w.Id, &icccm.WmState{
State: icccm.StateNormal,
})
if err != nil { // not a fatal error
lg("Could not set WM_STATE: %s", err)
}
// _NET_WM_STATE = _NET_WM_STATE_NORMAL
ewmh.WmStateSet(w.X, w.Id, []string{"_NET_WM_STATE_NORMAL"})
// Set the name to something.
w.nameSet("Decoding all images...")
w.Map()
}
开发者ID:BurntSushi,项目名称:imgv,代码行数:37,代码来源:win.go
示例6: showOne
func showOne(testNum int) {
X, err := xgbutil.NewConn()
if err != nil {
log.Fatal(err)
}
fname := testImages[testNum]
fmt.Printf("Working on %s\n", fname)
file, err := os.Open(testDir + fname)
if err != nil {
log.Fatal(err)
}
defer file.Close()
// Decode the image.
img, _, err := image.Decode(file)
if err != nil {
log.Fatal(err)
}
ximg := xgraphics.NewConvert(X, img)
ximg.XShowExtra(fname, true)
xevent.Main(X)
time.Sleep(4 * time.Second)
xevent.Quit(X)
}
开发者ID:ishawge,项目名称:bmp,代码行数:25,代码来源:bmpic.go
示例7: 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
}
开发者ID:remogatto,项目名称:egl-examples,代码行数:35,代码来源:init.go
示例8: showAll
func showAll() {
X, err := xgbutil.NewConn()
if err != nil {
log.Fatal(err)
}
for i := 0; i < len(testImages); i++ {
fname := testImages[i]
fmt.Printf("%d Working on %s\n", i, fname)
file, err := os.Open(testDir + fname)
if err != nil {
continue
}
defer file.Close()
var img image.Image
// Decode the image.
// using true forces bmp decoder, otherwise whatever is registered for ext is used
// result slightly different if non-bmps fed to it
if true {
img, err = bmp.Decode(file)
} else {
img, _, err = image.Decode(file)
}
if err != nil {
continue
}
ximg := xgraphics.NewConvert(X, img)
ximg.XShowExtra(fname, true)
time.Sleep(1 * time.Second)
}
xevent.Main(X)
time.Sleep(4 * time.Second)
xevent.Quit(X)
}
开发者ID:ishawge,项目名称:bmp,代码行数:34,代码来源:bmpic.go
示例9: endKeyBinding
func endKeyBinding() {
if X == nil {
return
}
stopXRecord()
grabMediaKeys(false)
grabKeyPairs(getSystemKeyPairs(), false)
grabKeyPairs(getCustomKeyPairs(), false)
xevent.Quit(X)
X = nil
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:12,代码来源:main.go
示例10: showImage
// This is a slightly modified version of xgraphics.XShowExtra that does
// not set any resize constraints on the window (so that it can go
// fullscreen).
func showImage(im *xgraphics.Image, name string, quit bool) *xwindow.Window {
if len(name) == 0 {
name = "xgbutil Image Window"
}
w, h := im.Rect.Dx(), im.Rect.Dy()
win, err := xwindow.Generate(im.X)
if err != nil {
xgbutil.Logger.Printf("Could not generate new window id: %s", err)
return nil
}
// Create a very simple window with dimensions equal to the image.
win.Create(im.X.RootWin(), 0, 0, w, h, 0)
// Make this window close gracefully.
win.WMGracefulClose(func(w *xwindow.Window) {
xevent.Detach(w.X, w.Id)
keybind.Detach(w.X, w.Id)
mousebind.Detach(w.X, w.Id)
w.Destroy()
if quit {
xevent.Quit(w.X)
}
})
// Set WM_STATE so it is interpreted as a top-level window.
err = icccm.WmStateSet(im.X, win.Id, &icccm.WmState{
State: icccm.StateNormal,
})
if err != nil { // not a fatal error
xgbutil.Logger.Printf("Could not set WM_STATE: %s", err)
}
// Set _NET_WM_NAME so it looks nice.
err = ewmh.WmNameSet(im.X, win.Id, name)
if err != nil { // not a fatal error
xgbutil.Logger.Printf("Could not set _NET_WM_NAME: %s", err)
}
// Paint our image before mapping.
im.XSurfaceSet(win.Id)
im.XDraw()
im.XPaint(win.Id)
// Now we can map, since we've set all our properties.
// (The initial map is when the window manager starts managing.)
win.Map()
return win
}
开发者ID:auroralaboratories,项目名称:corona-api,代码行数:55,代码来源:main.go
示例11: 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
}
开发者ID:nick-fedesna,项目名称:egles,代码行数:42,代码来源:window.go
示例12: newWindow
// newWindow creates the window, initializes the keybind and mousebind packages
// and sets up the window to act like a real top-level client.
func newWindow(X *xgbutil.XUtil) *Window {
w, err := xwindow.Generate(X)
if err != nil {
errLg.Fatalf("Could not create window: %s", err)
}
keybind.Initialize(w.X)
mousebind.Initialize(w.X)
err = w.CreateChecked(w.X.RootWin(), 0, 0, 600, 600, xproto.CwBackPixel, 0xffffff)
if err != nil {
errLg.Fatalf("Could not create window: %s", err)
}
// Make the window close gracefully using the WM_DELETE_WINDOW protocol.
w.WMGracefulClose(func(w *xwindow.Window) {
xevent.Detach(w.X, w.Id)
keybind.Detach(w.X, w.Id)
mousebind.Detach(w.X, w.Id)
w.Destroy()
xevent.Quit(w.X)
})
// Set WM_STATE so it is interpreted as top-level and is mapped.
err = icccm.WmStateSet(w.X, w.Id, &icccm.WmState{State: icccm.StateNormal})
if err != nil {
lg("Could not set WM_STATE: %s", err)
}
// _NET_WM_STATE = _NET_WM_STATE_NORMAL
// not needed because we we set FS later anyway?
//ewmh.WmStateSet(w.X, w.Id, []string{"_NET_WM_STATE_NORMAL"})
w.Map()
err = ewmh.WmStateReq(w.X, w.Id, ewmh.StateToggle, "_NET_WM_STATE_FULLSCREEN")
if err != nil {
lg("Failed to go FullScreen:", err)
}
return &Window{w}
}
开发者ID:uriel,项目名称:vimg,代码行数:43,代码来源:win.go
示例13: showNamed
func showNamed(fname string) {
fmt.Printf("Working on %s\n", fname)
file, err := os.Open(fname)
if err != nil {
log.Fatal(err)
}
defer file.Close()
X, err := xgbutil.NewConn()
if err != nil {
log.Fatal(err)
}
// Decode the image.
img, _, err := image.Decode(file)
if err != nil {
log.Fatal(err)
}
ximg := xgraphics.NewConvert(X, img)
ximg.XShowExtra(fname, true)
xevent.Main(X)
time.Sleep(4 * time.Second)
xevent.Quit(X)
}
开发者ID:ishawge,项目名称:bmp,代码行数:23,代码来源:bmpic.go
示例14: NewWindow
func NewWindow() *Window {
win, err := xwindow.Generate(X)
if err != nil {
log.Fatal("cannot generate window %v\n", err)
return nil
}
width, height := 800, 600
win.Create(X.RootWin(), 0, 0, width, height, xproto.CwBackPixel, 0x0)
win.WMGracefulClose(func(w *xwindow.Window) {
xevent.Detach(w.X, w.Id)
keybind.Detach(w.X, w.Id)
mousebind.Detach(w.X, w.Id)
w.Destroy()
xevent.Quit(w.X)
})
icccm.WmStateSet(X, win.Id, &icccm.WmState{
State: icccm.StateNormal,
})
win.Listen(xproto.EventMaskKeyPress)
win.Clear(0, 0, 0, 0)
win.Map()
self := &Window{
win,
nil,
false,
nil,
}
self.bindKeys()
return self
}
开发者ID:reusee,项目名称:yokan,代码行数:36,代码来源:window.go
示例15: disown
// disown responds to SelectionClear events on our dummy window.
// This means another window manager is trying to run, so quit.
func disown(X *xgbutil.XUtil, ev xevent.SelectionClearEvent) {
logger.Message.Println(
"Some other window manager is replacing us. Exiting...")
xevent.Quit(X)
}
开发者ID:mkrull,项目名称:wingo,代码行数:7,代码来源:ownership.go
示例16: main
func main() {
X, err := xgbutil.NewConn()
if err != nil {
log.Println(err)
return
}
//Initialize the keybind package
keybind.Initialize(X)
//Create a window
win, err := xwindow.Generate(X)
if err != nil {
log.Fatalf("Could not generate a new window X id: %s", err)
}
win.Create(X.RootWin(), 0, 0, 1024, 768, xproto.CwBackPixel, 0x606060ff)
// Listen for Key{Press,Release} events.
win.Listen(xproto.EventMaskKeyPress, xproto.EventMaskKeyRelease)
// Map the window. This is what makes it on the screen
win.Map()
//Make a ...callback... for the events and connect
xevent.KeyPressFun(
func(X *xgbutil.XUtil, e xevent.KeyPressEvent) {
modStr := keybind.ModifierString(e.State)
keyStr := keybind.LookupString(X, e.State, e.Detail)
if len(modStr) > 0 {
log.Printf("Key: %s-%s\n", modStr, keyStr)
} else {
log.Println("Key:", keyStr)
}
if keybind.KeyMatch(X, "Escape", e.State, e.Detail) {
if e.State&xproto.ModMaskControl > 0 {
log.Println("Control-Escape detected. Quitting...")
xevent.Quit(X)
}
}
}).Connect(X, win.Id)
//So here i'm going to try to make a image..'
img := xgraphics.New(X, image.Rect(0, 0, 1024, 768))
err = img.XSurfaceSet(win.Id)
if err != nil {
log.Printf("Error while setting window surface to image %d: %s\n",
win, err)
} else {
log.Printf("Window %d surface set to image OK\n", win)
}
// I /think/ XDraw actually sends data to server?
img.XDraw()
// I /think/ XPaint tells the server to paint image to window
img.XPaint(win.Id)
//Start the routine that updates the window
go updater(img, win)
//This seems to start a main loop for listening to xevents
xevent.Main(X)
}
开发者ID:auroralaboratories,项目名称:corona-api,代码行数:64,代码来源:main.go
示例17: makeWindow
func makeWindow(ximage *xgraphics.Image) (*xwindow.Window, *bool) {
w, h := ximage.Rect.Dx(), ximage.Rect.Dy()
window, err := xwindow.Generate(ximage.X)
if err != nil {
xgbutil.Logger.Printf("Could not generate new window id: %s", err)
return nil, nil
}
window.Create(ximage.X.RootWin(), 0, 0, w, h, xproto.CwBackPixel, 0x00000000)
window.Listen(xproto.EventMaskExposure,
xproto.EventMaskKeyPress,
xproto.EventMaskStructureNotify,
xproto.EventMaskVisibilityChange)
window.WMGracefulClose(func(w *xwindow.Window) {
xevent.Detach(w.X, w.Id)
keybind.Detach(w.X, w.Id)
mousebind.Detach(w.X, w.Id)
w.Destroy()
xevent.Quit(w.X)
})
err = icccm.WmStateSet(ximage.X, window.Id, &icccm.WmState{
State: icccm.StateNormal,
})
if err != nil {
xgbutil.Logger.Printf("Could not set WM_STATE: %s", err)
}
err = ewmh.WmNameSet(ximage.X, window.Id, "Computer System Monitor")
if err != nil {
xgbutil.Logger.Printf("Could not set _NET_WM_NAME: %s", err)
}
err = keybind.KeyPressFun(
func(X *xgbutil.XUtil, ev xevent.KeyPressEvent) {
err := ewmh.WmStateReq(ximage.X, window.Id, ewmh.StateToggle,
"_NET_WM_STATE_FULLSCREEN")
if err != nil {
log.Fatal(err)
}
}).Connect(ximage.X, window.Id, "f", false)
if err != nil {
log.Fatal(err)
}
xevent.ExposeFun(
func(xu *xgbutil.XUtil, event xevent.ExposeEvent) {
ximage.XExpPaint(window.Id, 0, 0)
}).Connect(ximage.X, window.Id)
obscured := false
xevent.VisibilityNotifyFun(
func(xu *xgbutil.XUtil, event xevent.VisibilityNotifyEvent) {
obscured = event.State == xproto.VisibilityFullyObscured
}).Connect(ximage.X, window.Id)
window.Map()
return window, &obscured
}
开发者ID:pointlander,项目名称:csm,代码行数:62,代码来源:csm.go
示例18: Quit
// Quit terminates the main event loop.
func (app *DockApp) Quit() {
xevent.Quit(app.x)
}
开发者ID:bmatsuo,项目名称:dockapp-go,代码行数:4,代码来源:dockapp.go
示例19: main
func main() {
X, err := xgbutil.NewConn()
fatal(err)
// Remember to always initialize the keybind package before usage.
keybind.Initialize(X)
// We create a benign parent window. Its only value in this example is
// instructional. In particular, it shows how to have a sub-window get
// focus using the ICCCM WM_TAKE_FOCUS protocol. (Since by default,
// the window manager will assign focus to your top-level window.)
// The real magic happens below with the WMTakeFocus method call.
parentWin, err := xwindow.Create(X, X.RootWin())
fatal(err)
// NewInput creates a new input window and handles all of the text drawing
// for you. It can be any width, but the height will be automatically
// determined by the height extents of the font size chosen.
input := text.NewInput(X, parentWin.Id, width, padding, font, fontSize,
fontColor, bgColor)
parentWin.Resize(input.Geom.Width(), input.Geom.Height())
// Make sure X reports KeyPress events when this window is focused.
input.Listen(xproto.EventMaskKeyPress)
// Listen to KeyPress events. If it's a BackSpace, remove the last
// character in the input box. If it's "Return" quit. If it's "Escape",
// clear the input box.
// Otherwise, try to add the key pressed to the input box.
// (Not all key presses correspond to a single character that is added.)
xevent.KeyPressFun(
func(X *xgbutil.XUtil, ev xevent.KeyPressEvent) {
mods, kc := ev.State, ev.Detail
switch {
case keybind.KeyMatch(X, "BackSpace", mods, kc):
input.Remove()
case keybind.KeyMatch(X, "Return", mods, kc):
log.Println("Return has been pressed.")
log.Printf("The current text is: %s", string(input.Text))
log.Println("Quitting...")
xevent.Quit(X)
case keybind.KeyMatch(X, "Escape", mods, kc):
input.Reset()
default:
input.Add(mods, kc)
}
}).Connect(X, input.Id)
// Implement the WM_DELETE_WINDOW protocol.
parentWin.WMGracefulClose(func(w *xwindow.Window) {
xevent.Quit(X)
})
// Implement the WM_TAKE_FOCUS protocol. The callback function provided
// is executed when a valid WM_TAKE_FOCUS ClientMessage event has been
// received from the window manager.
// According to ICCCM Section 4.2.7, this is one of the three valid ways
// of setting input focus to a sub-window. (It's also easiest since it
// doesn't require us to monitor FocusChange events. EW.)
// If you have multiple sub-windows that can be focused, this callback
// function is where the logic would go to pick which sub-window should
// be focused upon receipt of a WM_TAKE_FOCUS message.
parentWin.WMTakeFocus(func(w *xwindow.Window, tstamp xproto.Timestamp) {
input.FocusParent(tstamp)
})
// Map the window and start the main X event loop.
input.Map()
parentWin.Map()
xevent.Main(X)
}
开发者ID:mkrull,项目名称:wingo,代码行数:71,代码来源:main.go
示例20: stop
func (wa *fullScreenWorkaround) stop() {
xevent.Quit(wa.xu)
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:3,代码来源:workaround_fullscreen.go
注:本文中的github.com/BurntSushi/xgbutil/xevent.Quit函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论