當前位置: 首頁>>代碼示例>>Golang>>正文


Golang xevent.Quit函數代碼示例

本文整理匯總了Golang中github.com/BurntSushi/xgbutil/xevent.Quit函數的典型用法代碼示例。如果您正苦於以下問題:Golang Quit函數的具體用法?Golang Quit怎麽用?Golang Quit使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Quit函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的github.com/BurntSushi/xgbutil/xevent.Quit函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。