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


Golang Image.XSurfaceSet方法代碼示例

本文整理匯總了Golang中github.com/BurntSushi/xgbutil/xgraphics.Image.XSurfaceSet方法的典型用法代碼示例。如果您正苦於以下問題:Golang Image.XSurfaceSet方法的具體用法?Golang Image.XSurfaceSet怎麽用?Golang Image.XSurfaceSet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/BurntSushi/xgbutil/xgraphics.Image的用法示例。


在下文中一共展示了Image.XSurfaceSet方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: 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

示例2: SetRoot

// SetRoot sets the given background as the root window background.
func SetRoot(X *xgbutil.XUtil, bg *xgraphics.Image) error {
	root := X.RootWin()
	if err := bg.XSurfaceSet(root); err != nil {
		return err
	}
	bg.XDraw()
	bg.XPaint(root)
	// FIXME: This doesn't set the pixmap persistently. As soon as the program
	// exits, the pixmap is destroyed. Find a way to make it persistent.
	xprop.ChangeProp32(X, root, "_XROOTPMAP_ID", "PIXMAP", uint(bg.Pixmap))
	xprop.ChangeProp32(X, root, "ESETROOT_PMAP_ID", "PIXMAP", uint(bg.Pixmap))
	return nil
}
開發者ID:proxypoke,項目名稱:chiwa,代碼行數:14,代碼來源:background.go


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