当前位置: 首页>>代码示例>>Golang>>正文


Golang xwindow.New函数代码示例

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


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

示例1: MakeDraggable

// drag around windows with the mouse.
func MakeDraggable(X *xgbutil.XUtil, win xproto.Window) {
	// utility window for movement
	xwin := xwindow.New(X, win)

	// state
	var offsetX, offsetY int
	var lastX, lastY int

	// saves initial click location
	startDrag := func(X *xgbutil.XUtil, rootX, rootY, eventX, eventY int) (bool, xproto.Cursor) {
		offsetX = eventX
		offsetY = eventY
		lastX = rootX
		lastY = rootY

		// apparently the cursor is just ID 0
		return true, 0
	}
	// moves the window
	stepDrag := func(X *xgbutil.XUtil, rootX, rootY, eventX, eventY int) {
		// maintain mouse position within window
		toX := rootX - offsetX
		toY := rootY - offsetY

		// move window
		xwin.Move(toX, toY)
	}
	stopDrag := func(X *xgbutil.XUtil, rx, ry, ex, ey int) {}

	// actually bind handler to window
	mousebind.Drag(X, win, win, "1", true, startDrag, stepDrag, stopDrag)
	log.Printf("MakeDraggable: activated window %v\n", xwin)
}
开发者ID:justjake,项目名称:j3,代码行数:34,代码来源:action.go

示例2: detachXid

func (app *RuntimeApp) detachXid(xid xproto.Window) {
	if info, ok := app.xids[xid]; ok {
		xwindow.New(XU, xid).Listen(xproto.EventMaskNoEvent)
		xevent.Detach(XU, xid)

		if len(app.xids) == 1 {
			ENTRY_MANAGER.destroyRuntimeApp(app)
		} else {
			delete(app.xids, xid)
			if info == app.CurrentInfo {
				for _, nextInfo := range app.xids {
					if nextInfo != nil {
						app.CurrentInfo = nextInfo
						app.updateState(app.CurrentInfo.Xid)
						app.notifyChanged()
					} else {
						ENTRY_MANAGER.destroyRuntimeApp(app)
					}
					break
				}
			}
		}
	}
	if len(app.xids) == 0 {
		app.setChangedCB(nil)
	} else {
		app.notifyChanged()
	}
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:29,代码来源:runtime_apps.go

示例3: Root

func Root() {
	rwin := xwindow.New(X, X.RootWin())
	for _, c := range Clients {
		c.Unfocused()
	}
	rwin.Focus()
}
开发者ID:dlintw,项目名称:wingo,代码行数:7,代码来源:focus.go

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

示例5: isWindowOnPrimaryScreen

func isWindowOnPrimaryScreen(xid xproto.Window) bool {
	var err error

	win := xwindow.New(XU, xid)
	// include shadow
	gemo, err := win.DecorGeometry()
	if err != nil {
		logger.Debug(err)
		return false
	}

	displayRectX := (int)(displayRect.X)
	displayRectY := (int)(displayRect.Y)
	displayRectWidth := (int)(displayRect.Width)
	displayRectHeight := (int)(displayRect.Height)

	SHADOW_OFFSET := 10
	gemoX := gemo.X() + SHADOW_OFFSET
	gemoY := gemo.Y() + SHADOW_OFFSET
	isOnPrimary := gemoX+SHADOW_OFFSET >= displayRectX &&
		gemoX < displayRectX+displayRectWidth &&
		gemoY >= displayRectY &&
		gemoY < displayRectY+displayRectHeight

	logger.Debugf("isWindowOnPrimaryScreen: %dx%d, %dx%d, %v", gemo.X(),
		gemo.Y(), displayRect.X, displayRect.Y, isOnPrimary)

	return isOnPrimary
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:29,代码来源:client_manager.go

示例6: isWindowOverlapDock

func isWindowOverlapDock(xid xproto.Window) bool {
	win := xwindow.New(XU, xid)
	rect, err := win.DecorGeometry()
	if err != nil {
		logger.Warning(err)
		return false
	}

	winX := int32(rect.X())
	winY := int32(rect.Y())
	winWidth := int32(rect.Width())
	winHeight := int32(rect.Height())

	dockX := int32(displayRect.X) + (int32(displayRect.Width)-
		dockProperty.PanelWidth)/2
	dockY := int32(displayRect.Y) + int32(displayRect.Height) -
		dockProperty.Height
	dockWidth := int32(displayRect.Width)
	if DisplayModeType(setting.GetDisplayMode()) == DisplayModeModernMode {
		dockWidth = dockProperty.PanelWidth
	}

	// TODO: dock on the other side like top, left.
	return dockY < winY+winHeight &&
		dockX < winX+winWidth && dockX+dockWidth > winX
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:26,代码来源:client_manager.go

示例7: createNotify

func createNotify(X *xgbutil.XUtil, event xgb.Event) {
	ev := event.(xproto.CreateNotifyEvent)
	// values[0] = XCB_EVENT_MASK_PROPERTY_CHANGE;
	// xcb_change_window_attributes(wm->conn, id, XCB_CW_EVENT_MASK, values);
	win := xwindow.New(X, ev.Window)
	win.Listen(xproto.EventMaskPropertyChange)

	XWins[ev.Window] = &XWin{
		surfaceId: 0,
	}
}
开发者ID:fangyuanziti,项目名称:wayland-html,代码行数:11,代码来源:xwm.go

示例8: headGeom

func headGeom(X *xgbutil.XUtil) xrect.Rect {
	if X.ExtInitialized("XINERAMA") {
		heads, err := xinerama.PhysicalHeads(X)
		if err == nil {
			return heads[0]
		}
	}

	geom, err := xwindow.New(X, X.RootWin()).Geometry()
	fatal(err)
	return geom
}
开发者ID:cshapeshifter,项目名称:wingo,代码行数:12,代码来源:main.go

示例9: currentTime

// currentTime forcefully causes a PropertyNotify event to fire on the root
// window, then scans the event queue and picks up the time.
//
// It is NOT SAFE to call this function in a place other than Wingo's
// initialization. Namely, this function subverts xevent's queue and reads
// events directly from X.
func currentTime(X *xgbutil.XUtil) (xproto.Timestamp, error) {
	wmClassAtom, err := xprop.Atm(X, "WM_CLASS")
	if err != nil {
		return 0, err
	}

	stringAtom, err := xprop.Atm(X, "STRING")
	if err != nil {
		return 0, err
	}

	// Make sure we're listening to PropertyChange events on the root window.
	err = xwindow.New(X, X.RootWin()).Listen(xproto.EventMaskPropertyChange)
	if err != nil {
		return 0, fmt.Errorf(
			"Could not listen to Root window events (PropertyChange): %s", err)
	}

	// Do a zero-length append on a property as suggested by ICCCM 2.1.
	err = xproto.ChangePropertyChecked(
		X.Conn(), xproto.PropModeAppend, X.RootWin(),
		wmClassAtom, stringAtom, 8, 0, nil).Check()
	if err != nil {
		return 0, err
	}

	// Now look for the PropertyNotify generated by that zero-length append
	// and return the timestamp attached to that event.
	// Note that we do this outside of xgbutil/xevent, since ownership
	// is literally the first thing we do after connecting to X.
	// (i.e., we don't have our event handling system initialized yet.)
	timeout := time.After(3 * time.Second)
	for {
		select {
		case <-timeout:
			return 0, fmt.Errorf(
				"Expected a PropertyNotify event to get a valid timestamp, " +
					"but never received one.")
		default:
			ev, err := X.Conn().PollForEvent()
			if err != nil {
				continue
			}
			if propNotify, ok := ev.(xproto.PropertyNotifyEvent); ok {
				X.TimeSet(propNotify.Time) // why not?
				return propNotify.Time, nil
			}
			time.Sleep(100 * time.Millisecond)
		}
	}
	panic("unreachable")
}
开发者ID:mkrull,项目名称:wingo,代码行数:58,代码来源:ownership.go

示例10: NewSocket

func NewSocket(X *xgbutil.XUtil, wid xproto.Window) (*XEmbedSocket, error) {
	sock := &XEmbedSocket{
		Window: xwindow.New(X, wid),
		id:     wid,
		X:      X,
	}

	if err := sock.load(); err != nil {
		return nil, err
	}

	return sock, nil
}
开发者ID:AmandaCameron,项目名称:gobar,代码行数:13,代码来源:embedder.go

示例11: configureRequest

func configureRequest(X *xgbutil.XUtil, event xgb.Event) {
	ev := event.(xproto.ConfigureRequestEvent)
	win := xwindow.New(X, ev.Window)

	win.Configure(
		xproto.ConfigWindowX|
			xproto.ConfigWindowY|
			xproto.ConfigWindowWidth|
			xproto.ConfigWindowHeight,
		(int)(ev.X), (int)(ev.Y),
		(int)(ev.Width), (int)(ev.Height),
		ev.Sibling,
		ev.StackMode,
	)
	log.Info("configure request:", ev)
}
开发者ID:fangyuanziti,项目名称:wayland-html,代码行数:16,代码来源:xwm.go

示例12: main

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

	// Start generating other source events.
	otherChan := otherSource()

	// Start generating X events (by sending client messages to root window).
	go xSource(X)

	// Listen to those X events.
	xwindow.New(X, X.RootWin()).Listen(xproto.EventMaskSubstructureNotify)

	// Respond to those X events.
	xevent.ClientMessageFun(
		func(X *xgbutil.XUtil, ev xevent.ClientMessageEvent) {
			atmName, err := xprop.AtomName(X, ev.Type)
			if err != nil {
				log.Fatal(err)
			}
			fmt.Printf("ClientMessage: %d. %s\n", ev.Data.Data32[0], atmName)
		}).Connect(X, X.RootWin())

	// Instead of using the usual xevent.Main, we use xevent.MainPing.
	// It runs the main event loop inside a goroutine and returns ping
	// channels, which are sent benign values right before an event is
	// dequeued and right after that event has finished running all callbacks
	// associated with it, respectively.
	pingBefore, pingAfter, pingQuit := xevent.MainPing(X)
	for {
		select {
		case <-pingBefore:
			// Wait for the event to finish processing.
			<-pingAfter
		case otherVal := <-otherChan:
			fmt.Printf("Processing other event: %d\n", otherVal)
		case <-pingQuit:
			fmt.Printf("xevent loop has quit")
			return
		}
	}
}
开发者ID:auroralaboratories,项目名称:corona-api,代码行数:44,代码来源:main.go

示例13: start

func (wa *fullScreenWorkaround) start() {
	var runner func()
	runner = func() {
		w, _ := ewmh.ActiveWindowGet(wa.xu)
		wa.detectTarget(w)
		time.AfterFunc(time.Second*5, runner)
	}
	runner()

	root := xwindow.New(wa.xu, wa.xu.RootWin())
	root.Listen(xproto.EventMaskPropertyChange)
	xevent.PropertyNotifyFun(func(XU *xgbutil.XUtil, ev xevent.PropertyNotifyEvent) {
		if wa.activeWindowAtom == ev.Atom {
			w, _ := ewmh.ActiveWindowGet(XU)
			wa.detectTarget(w)
		}
	}).Connect(wa.xu, root.Id)
	xevent.Main(wa.xu)
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:19,代码来源:workaround_fullscreen.go

示例14: main

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

	clientids, err := ewmh.ClientListGet(X)
	if err != nil {
		log.Fatal(err)
	}

	for _, clientid := range clientids {
		name, err := ewmh.WmNameGet(X, clientid)
		if err != nil {
			continue
		}

		if name == "Super Hexagon" {
			HexWindow = xwindow.New(X, clientid)
			break
		}
	}

	if HexWindow == nil {
		log.Fatal("Couldn't find Super Hexagon window.")
	}

	//Create a window
	DisplayWindow, err = xwindow.Generate(X)
	if err != nil {
		log.Fatalf("Could not generate a new window X id: %s", err)
	}
	dgeom, _ := HexWindow.DecorGeometry()
	DisplayWindow.Create(X.RootWin(), 0, 0, dgeom.Width(), dgeom.Height(), xproto.CwBackPixel, 0)
	DisplayWindow.Map()

	//Start the routine that updates the window
	go updater()

	xevent.Main(X)
}
开发者ID:xthexder,项目名称:superhexagon,代码行数:42,代码来源:superhexagon.go

示例15: getViewport

func getViewport() (geom string) {
	// new X server connection
	X, err := xgbutil.NewConn()
	if err != nil {
		log.Error(err)
	}

	// get root window
	root := xwindow.New(X, X.RootWin())

	// geometry of the root window
	rgeom, err := root.Geometry()
	if err != nil {
		log.Error(err)
	}

	// Get the rectangles for each of the active physical heads.
	// These are returned sorted in order from left to right and then top
	// to bottom.
	// But first check if Xinerama is enabled. If not, use root geometry.
	var heads xinerama.Heads
	if X.ExtInitialized("XINERAMA") {
		heads, err = xinerama.PhysicalHeads(X)
		if err != nil {
			log.Error(err)
		}
	} else {
		heads = xinerama.Heads{rgeom}
	}

	// looking for the first screen, position X: 0, Y: 0
	for _, head := range heads {
		if head.X() == 0 && head.Y() == 0 {
			screenWidth = head.Width()
			screenHeight = head.Height()
		}
	}

	geom = fmt.Sprintf("%dx%d", screenWidth-165, screenHeight-165)

	return geom
}
开发者ID:cabrel,项目名称:xfcm,代码行数:42,代码来源:xfcm.go


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