• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang xproto.Drawable函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/BurntSushi/xgb/xproto.Drawable函数的典型用法代码示例。如果您正苦于以下问题:Golang Drawable函数的具体用法?Golang Drawable怎么用?Golang Drawable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Drawable函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: NewTexture

func (s *screenImpl) NewTexture(size image.Point) (screen.Texture, error) {
	w, h := int64(size.X), int64(size.Y)
	if w < 0 || maxShmSide < w || h < 0 || maxShmSide < h || maxShmSize < 4*w*h {
		return nil, fmt.Errorf("x11driver: invalid texture size %v", size)
	}

	xm, err := xproto.NewPixmapId(s.xc)
	if err != nil {
		return nil, fmt.Errorf("x11driver: xproto.NewPixmapId failed: %v", err)
	}
	xp, err := render.NewPictureId(s.xc)
	if err != nil {
		return nil, fmt.Errorf("x11driver: xproto.NewPictureId failed: %v", err)
	}

	t := &textureImpl{
		s:    s,
		size: size,
		xm:   xm,
		xp:   xp,
	}

	xproto.CreatePixmap(s.xc, textureDepth, xm, xproto.Drawable(s.window32), uint16(w), uint16(h))
	render.CreatePicture(s.xc, xp, xproto.Drawable(xm), s.pictformat32, 0, nil)
	render.SetPictureFilter(s.xc, xp, uint16(len("bilinear")), "bilinear", nil)
	return t, nil
}
开发者ID:jmptrader,项目名称:exp,代码行数:27,代码来源:screen.go


示例2: adjustSize

// adjustSize takes a client and dimensions, and adjust them so that they'll
// account for window decorations. For example, if you want a window to be
// 200 pixels wide, a window manager will typically determine that as
// you wanting the *client* to be 200 pixels wide. The end result is that
// the client plus decorations ends up being
// (200 + left decor width + right decor width) pixels wide. Which is probably
// not what you want. Therefore, transform 200 into
// 200 - decoration window width - client window width.
// Similarly for height.
func adjustSize(xu *xgbutil.XUtil, win xproto.Window,
	w, h int) (int, int, error) {

	// raw client geometry
	cGeom, err := RawGeometry(xu, xproto.Drawable(win))
	if err != nil {
		return 0, 0, err
	}

	// geometry with decorations
	pGeom, err := RawGeometry(xu, xproto.Drawable(win))
	if err != nil {
		return 0, 0, err
	}

	neww := w - (pGeom.Width() - cGeom.Width())
	newh := h - (pGeom.Height() - cGeom.Height())
	if neww < 1 {
		neww = 1
	}
	if newh < 1 {
		newh = 1
	}
	return neww, newh, nil
}
开发者ID:auroralaboratories,项目名称:corona-api,代码行数:34,代码来源:ewmh.go


示例3: NewIcccmIcon

// NewIcccmIcon converts two pixmap ids (icon_pixmap and icon_mask in the
// WM_HINTS properts) to a single xgraphics.Image.
// It is okay for one of iconPixmap or iconMask to be 0, but not both.
// You should probably use xgraphics.FindIcon instead of this directly.
func NewIcccmIcon(X *xgbutil.XUtil, iconPixmap,
	iconMask xproto.Pixmap) (*Image, error) {

	if iconPixmap == 0 && iconMask == 0 {
		return nil, fmt.Errorf("NewIcccmIcon: At least one of iconPixmap or " +
			"iconMask must be non-zero, but both are 0.")
	}

	var pximg, mximg *Image
	var err error

	// Get the xgraphics.Image for iconPixmap.
	if iconPixmap != 0 {
		pximg, err = NewDrawable(X, xproto.Drawable(iconPixmap))
		if err != nil {
			return nil, err
		}
	}

	// Now get the xgraphics.Image for iconMask.
	if iconMask != 0 {
		mximg, err = NewDrawable(X, xproto.Drawable(iconMask))
		if err != nil {
			return nil, err
		}
	}

	// Now merge them together if both were specified.
	switch {
	case pximg != nil && mximg != nil:
		r := pximg.Bounds()

		var x, y int
		var bgra, maskBgra BGRA
		for x = r.Min.X; x < r.Max.X; x++ {
			for y = r.Min.Y; y < r.Max.Y; y++ {
				maskBgra = mximg.At(x, y).(BGRA)
				bgra = pximg.At(x, y).(BGRA)
				if maskBgra.A == 0 {
					pximg.SetBGRA(x, y, BGRA{
						B: bgra.B,
						G: bgra.G,
						R: bgra.R,
						A: 0,
					})
				}
			}
		}
		return pximg, nil
	case pximg != nil:
		return pximg, nil
	case mximg != nil:
		return mximg, nil
	}

	panic("unreachable")
}
开发者ID:JessonChan,项目名称:xgbutil,代码行数:61,代码来源:new.go


示例4: XExpPaint

// XExpPaint achieves a similar result as XPaint and XSurfaceSet, but
// uses CopyArea instead of setting a background pixmap and using ClearArea.
// CreatePixmap must be called before using XExpPaint.
// XExpPaint can be called on sub-images.
// x and y correspond to the destination x and y to copy the image to.
//
// This should not be used on the same image with XSurfaceSet and XPaint.
func (im *Image) XExpPaint(wid xproto.Window, x, y int) {
	if im.Pixmap == 0 {
		return
	}
	xproto.CopyArea(im.X.Conn(),
		xproto.Drawable(im.Pixmap), xproto.Drawable(wid), im.X.GC(),
		int16(im.Rect.Min.X), int16(im.Rect.Min.Y),
		int16(x), int16(y),
		uint16(im.Rect.Dx()), uint16(im.Rect.Dy()))
}
开发者ID:Sendipad,项目名称:xgbutil,代码行数:17,代码来源:xsurface.go


示例5: main

func main() {
	X, err := xgbutil.NewConn()
	if err != nil {
		log.Fatal(err)
	}

	// Use the "NewDrawable" constructor to create an xgraphics.Image value
	// from a drawable. (Usually this is done with pixmaps, but drawables
	// can also be windows.)
	ximg, err := xgraphics.NewDrawable(X, xproto.Drawable(X.RootWin()))
	if err != nil {
		log.Fatal(err)
	}

	// Shows the screenshot in a window.
	ximg.XShowExtra("Screenshot", true)

	// If you'd like to save it as a png, use:
	// err = ximg.SavePng("screenshot.png")
	// if err != nil {
	// log.Fatal(err)
	// }

	xevent.Main(X)
}
开发者ID:auroralaboratories,项目名称:corona-api,代码行数:25,代码来源:main.go


示例6: update

func (m *MotionRecorder) update() {
	geo, _ := xproto.GetGeometry(m.Window.Conn, xproto.Drawable(m.root)).Reply()

	if geo != nil {
		m.Resize(geo.Width, geo.Height)
	}
}
开发者ID:wSCP,项目名称:scpwm-old,代码行数:7,代码来源:pointer.go


示例7: addTrayIcon

func (m *TrayManager) addTrayIcon(xid xproto.Window) {
	m.checkValid()
	for _, id := range m.TrayIcons {
		if xproto.Window(id) == xid {
			return
		}
	}

	if d, err := damage.NewDamageId(TrayXU.Conn()); err != nil {
		return
	} else {
		m.dmageInfo[xid] = d
		if err := damage.CreateChecked(TrayXU.Conn(), d, xproto.Drawable(xid), damage.ReportLevelRawRectangles).Check(); err != nil {
			logger.Debug("DamageCreate Failed:", err)
			return
		}
	}
	composite.RedirectWindow(TrayXU.Conn(), xid, composite.RedirectAutomatic)

	m.TrayIcons = append(m.TrayIcons, uint32(xid))
	icon := xwindow.New(TrayXU, xid)
	icon.Listen(xproto.EventMaskVisibilityChange | damage.Notify | xproto.EventMaskStructureNotify)
	icon.Change(xproto.CwBackPixel, 0)

	name, err := ewmh.WmNameGet(TrayXU, xid)
	if err != nil {
		logger.Debug("WmNameGet failed:", err, xid)
	}
	m.nameInfo[xid] = name
	m.notifyInfo[xid] = true
	dbus.Emit(m, "Added", uint32(xid))
	logger.Infof("Added try icon: \"%s\"(%d)", name, uint32(xid))
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:33,代码来源:traymanager.go


示例8: initWindow32

func (s *screenImpl) initWindow32() error {
	visualid, err := findVisual(s.xsi, 32)
	if err != nil {
		return err
	}
	colormap, err := xproto.NewColormapId(s.xc)
	if err != nil {
		return fmt.Errorf("x11driver: xproto.NewColormapId failed: %v", err)
	}
	if err := xproto.CreateColormapChecked(
		s.xc, xproto.ColormapAllocNone, colormap, s.xsi.Root, visualid).Check(); err != nil {
		return fmt.Errorf("x11driver: xproto.CreateColormap failed: %v", err)
	}
	s.window32, err = xproto.NewWindowId(s.xc)
	if err != nil {
		return fmt.Errorf("x11driver: xproto.NewWindowId failed: %v", err)
	}
	s.gcontext32, err = xproto.NewGcontextId(s.xc)
	if err != nil {
		return fmt.Errorf("x11driver: xproto.NewGcontextId failed: %v", err)
	}
	const depth = 32
	xproto.CreateWindow(s.xc, depth, s.window32, s.xsi.Root,
		0, 0, 1, 1, 0,
		xproto.WindowClassInputOutput, visualid,
		// The CwBorderPixel attribute seems necessary for depth == 32. See
		// http://stackoverflow.com/questions/3645632/how-to-create-a-window-with-a-bit-depth-of-32
		xproto.CwBorderPixel|xproto.CwColormap,
		[]uint32{0, uint32(colormap)},
	)
	xproto.CreateGC(s.xc, s.gcontext32, xproto.Drawable(s.window32), 0, nil)
	return nil
}
开发者ID:jmptrader,项目名称:exp,代码行数:33,代码来源:screen.go


示例9: RootGeometry

// RootGeometry gets the geometry of the root window. It will panic on failure.
func RootGeometry(xu *xgbutil.XUtil) xrect.Rect {
	geom, err := RawGeometry(xu, xproto.Drawable(xu.RootWin()))
	if err != nil {
		panic(err)
	}
	return geom
}
开发者ID:auroralaboratories,项目名称:corona-api,代码行数:8,代码来源:xwindow.go


示例10: BufferSwapCompleteEventNew

// BufferSwapCompleteEventNew constructs a BufferSwapCompleteEvent value that implements xgb.Event from a byte slice.
func BufferSwapCompleteEventNew(buf []byte) xgb.Event {
	v := BufferSwapCompleteEvent{}
	b := 1 // don't read event number

	b += 1 // padding

	v.Sequence = xgb.Get16(buf[b:])
	b += 2

	v.EventType = xgb.Get16(buf[b:])
	b += 2

	b += 2 // padding

	v.Drawable = xproto.Drawable(xgb.Get32(buf[b:]))
	b += 4

	v.UstHi = xgb.Get32(buf[b:])
	b += 4

	v.UstLo = xgb.Get32(buf[b:])
	b += 4

	v.MscHi = xgb.Get32(buf[b:])
	b += 4

	v.MscLo = xgb.Get32(buf[b:])
	b += 4

	v.Sbc = xgb.Get32(buf[b:])
	b += 4

	return v
}
开发者ID:varialus,项目名称:xgb,代码行数:35,代码来源:dri2.go


示例11: NewDrawable

// NewDrawable converts an X drawable into a xgraphics.Image.
// This is used in NewIcccmIcon.
func NewDrawable(X *xgbutil.XUtil, did xproto.Drawable) (*Image, error) {
	// Get the geometry of the pixmap for use in the GetImage request.
	pgeom, err := xwindow.RawGeometry(X, xproto.Drawable(did))
	if err != nil {
		return nil, err
	}

	// Get the image data for each pixmap.
	pixmapData, err := xproto.GetImage(X.Conn(), xproto.ImageFormatZPixmap,
		did,
		0, 0, uint16(pgeom.Width()), uint16(pgeom.Height()),
		(1<<32)-1).Reply()
	if err != nil {
		return nil, err
	}

	// Now create the xgraphics.Image and populate it with data from
	// pixmapData and maskData.
	ximg := New(X, image.Rect(0, 0, pgeom.Width(), pgeom.Height()))

	// We'll try to be a little flexible with the image format returned,
	// but not completely flexible.
	err = readDrawableData(X, ximg, did, pixmapData,
		pgeom.Width(), pgeom.Height())
	if err != nil {
		return nil, err
	}

	return ximg, nil
}
开发者ID:JessonChan,项目名称:xgbutil,代码行数:32,代码来源:new.go


示例12: CompletionEventNew

// CompletionEventNew constructs a CompletionEvent value that implements xgb.Event from a byte slice.
func CompletionEventNew(buf []byte) xgb.Event {
	v := CompletionEvent{}
	b := 1 // don't read event number

	b += 1 // padding

	v.Sequence = xgb.Get16(buf[b:])
	b += 2

	v.Drawable = xproto.Drawable(xgb.Get32(buf[b:]))
	b += 4

	v.MinorEvent = xgb.Get16(buf[b:])
	b += 2

	v.MajorEvent = buf[b]
	b += 1

	b += 1 // padding

	v.Shmseg = Seg(xgb.Get32(buf[b:]))
	b += 4

	v.Offset = xgb.Get32(buf[b:])
	b += 4

	return v
}
开发者ID:varialus,项目名称:xgb,代码行数:29,代码来源:shm.go


示例13: NotifyEventNew

// NotifyEventNew constructs a NotifyEvent value that implements xgb.Event from a byte slice.
func NotifyEventNew(buf []byte) xgb.Event {
	v := NotifyEvent{}
	b := 1 // don't read event number

	v.Level = buf[b]
	b += 1

	v.Sequence = xgb.Get16(buf[b:])
	b += 2

	v.Drawable = xproto.Drawable(xgb.Get32(buf[b:]))
	b += 4

	v.Damage = Damage(xgb.Get32(buf[b:]))
	b += 4

	v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:]))
	b += 4

	v.Area = xproto.Rectangle{}
	b += xproto.RectangleRead(buf[b:], &v.Area)

	v.Geometry = xproto.Rectangle{}
	b += xproto.RectangleRead(buf[b:], &v.Geometry)

	return v
}
开发者ID:BurntSushi,项目名称:xgb,代码行数:28,代码来源:damage.go


示例14: Geometry

// Geometry retrieves an up-to-date version of the this window's geometry.
// It also loads the geometry into the Geom member of Window.
func (w *Window) Geometry() (xrect.Rect, error) {
	geom, err := RawGeometry(w.X, xproto.Drawable(w.Id))
	if err != nil {
		return nil, err
	}
	w.Geom = geom
	return geom, err
}
开发者ID:auroralaboratories,项目名称:corona-api,代码行数:10,代码来源:xwindow.go


示例15: drawFrameBorders

func (k *workspace) drawFrameBorders() {
	if k.fullscreen || k.listing == listWorkspaces {
		return
	}
	setForeground(colorUnfocused)
	rects := k.mainFrame.appendRectangles(nil)
	check(xp.PolyRectangleChecked(xConn, xp.Drawable(desktopXWin), desktopXGC, rects))
	setForeground(colorFocused)
	k.focusedFrame.drawBorder()
}
开发者ID:minusnine,项目名称:taowm,代码行数:10,代码来源:geom.go


示例16: NewScreenSaver

func NewScreenSaver() *ScreenSaver {
	s := &ScreenSaver{inhibitors: make(map[uint32]inhibitor)}
	s.xu, _ = xgbutil.NewConn()
	screensaver.Init(s.xu.Conn())
	screensaver.QueryVersion(s.xu.Conn(), 1, 0)
	screensaver.SelectInput(s.xu.Conn(), xproto.Drawable(s.xu.RootWin()), screensaver.EventNotifyMask|screensaver.EventCycleMask)
	dpms.Init(s.xu.Conn())

	go s.loop()
	return s
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:11,代码来源:screensaver.go


示例17: DecorGeometry

// DecorGeometry retrieves the client's width and height including decorations.
// This can be tricky. In a non-parenting window manager, the width/height of
// a client can be found by inspecting the client directly. In a reparenting
// window manager like Openbox, the parent of the client reflects the true
// width/height. Still yet, in KWin, it's the parent of the parent of the
// client that reflects the true width/height.
// The idea then is to traverse up the tree until we hit the root window.
// Therefore, we're at a top-level window which should accurately reflect
// the width/height.
func (w *Window) DecorGeometry() (xrect.Rect, error) {
	parent := w
	for {
		tempParent, err := parent.Parent()
		if err != nil || tempParent.Id == w.X.RootWin() {
			break
		}
		parent = tempParent
	}
	return RawGeometry(w.X, xproto.Drawable(parent.Id))
}
开发者ID:auroralaboratories,项目名称:corona-api,代码行数:20,代码来源:ewmh.go


示例18: InvalidateBuffersEventNew

// InvalidateBuffersEventNew constructs a InvalidateBuffersEvent value that implements xgb.Event from a byte slice.
func InvalidateBuffersEventNew(buf []byte) xgb.Event {
	v := InvalidateBuffersEvent{}
	b := 1 // don't read event number

	b += 1 // padding

	v.Sequence = xgb.Get16(buf[b:])
	b += 2

	v.Drawable = xproto.Drawable(xgb.Get32(buf[b:]))
	b += 4

	return v
}
开发者ID:varialus,项目名称:xgb,代码行数:15,代码来源:dri2.go


示例19: Redraw

func (w *Window) Redraw() {
	/* Hide X11 borders */
	var mask uint16 = xproto.ConfigWindowBorderWidth
	values := make([]uint32, 1)
	values[0] = 0
	xproto.ConfigureWindow(w.conn, w.id, mask, values)

	wdt, hgh := int16(w.geom.W), int16(w.geom.H)
	/* Drawing background */
	bg := xproto.Rectangle{0, 0, uint16(wdt), uint16(hgh)}
	bgs := make([]xproto.Rectangle, 1)
	bgs[0] = bg
	xproto.PolyFillRectangle(w.conn, xproto.Drawable(w.id), w.gc.bg, bgs)

	/* Drawing borders */
	vertices := make([]xproto.Point, 5)
	vertices[0].X = 0
	vertices[0].Y = 0
	vertices[1].X = wdt
	vertices[1].Y = 0
	vertices[2].X = wdt
	vertices[2].Y = hgh
	vertices[3].X = 0
	vertices[3].Y = hgh
	vertices[4].X = 0
	vertices[4].Y = 0
	xproto.PolyLine(w.conn, xproto.CoordModeOrigin, xproto.Drawable(w.id), w.gc.bc, vertices)

	/* Drawing text */
	hline := int16(w.gc.fontHeight)
	x, y := int16(w.gc.border), int16(w.gc.border+w.gc.fontUp)
	for _, line := range w.lines {
		xproto.ImageText8(w.conn, byte(len(line)), xproto.Drawable(w.id),
			w.gc.fg, x, y, line)
		y += hline
	}
}
开发者ID:lucas8,项目名称:notifier,代码行数:37,代码来源:window.go


示例20: WriteWindowImage

func (self *SessionModule) WriteWindowImage(window_id string, w io.Writer) error {
	if id, err := self.toX11WindowId(window_id); err == nil {
		drawable := xproto.Drawable(id)

		if image, err := xgraphics.NewDrawable(self.X, drawable); err == nil {
			image.XSurfaceSet(id)
			image.XDraw()

			return image.WritePng(w)
		} else {
			return err
		}
	} else {
		return err
	}
}
开发者ID:auroralaboratories,项目名称:corona-api,代码行数:16,代码来源:window.go



注:本文中的github.com/BurntSushi/xgb/xproto.Drawable函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang xproto.GetWindowAttributes函数代码示例发布时间:2022-05-24
下一篇:
Golang xproto.CreateWindow函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap