本文整理汇总了Golang中github.com/BurntSushi/xgbutil/xwindow.RootGeometry函数的典型用法代码示例。如果您正苦于以下问题:Golang RootGeometry函数的具体用法?Golang RootGeometry怎么用?Golang RootGeometry使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RootGeometry函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ApplyStruts
func (hds *Heads) ApplyStruts(clients Clients) {
hds.workarea = make(xinerama.Heads, len(hds.geom))
for i, hd := range hds.geom {
hds.workarea[i] = xrect.New(hd.X(), hd.Y(), hd.Width(), hd.Height())
}
rgeom := xwindow.RootGeometry(hds.X)
for i := 0; i < clients.Len(); i++ {
c := clients.Get(i)
strut, _ := ewmh.WmStrutPartialGet(hds.X, c.Id())
if strut == nil {
continue
}
xrect.ApplyStrut(hds.workarea, rgeom.Width(), rgeom.Height(),
strut.Left, strut.Right, strut.Top, strut.Bottom,
strut.LeftStartY, strut.LeftEndY,
strut.RightStartY, strut.RightEndY,
strut.TopStartX, strut.TopEndX,
strut.BottomStartX, strut.BottomEndX)
}
for _, wrk := range hds.workspaces.Wrks {
wrk.Place()
}
}
示例2: query
func query(X *xgbutil.XUtil) xinerama.Heads {
if X.ExtInitialized("XINERAMA") {
heads, err := xinerama.PhysicalHeads(X)
if err != nil || len(heads) == 0 {
if err == nil {
logger.Warning.Printf("Could not find any physical heads " +
"with the Xinerama extension.")
} else {
logger.Warning.Printf("Could not load physical heads via "+
"Xinerama: %s", err)
}
logger.Warning.Printf("Assuming one head with size equivalent " +
"to the root window.")
} else {
return heads
}
}
// If we're here, then something went wrong or the Xinerama extension
// isn't available. So query the root window for its geometry and use that.
rgeom := xwindow.RootGeometry(X)
return xinerama.Heads{
xrect.New(rgeom.X(), rgeom.Y(), rgeom.Width(), rgeom.Height()),
}
}
示例3: main
func main() {
X, err := xgbutil.NewConn()
if err != nil {
log.Fatalln(err)
}
// The message box uses the keybind module, so we must initialize it.
keybind.Initialize(X)
// Creating a new message prompt is as simple as supply an X connection,
// a theme and a configuration. We use built in defaults here.
msgPrompt := prompt.NewMessage(X,
prompt.DefaultMessageTheme, prompt.DefaultMessageConfig)
// Show maps the message prompt window.
// If a duration is specified, the window does NOT acquire focus and
// automatically disappears after the specified time.
// If a duration is not specified (i.e., '0'), then the window is mapped,
// and acquires focus. It does not disappear until it loses focus or when
// the user hits the "confirm" or "cancel" keys (usually "enter" and
// "escape").
timeout := 2 * time.Second // or "0" for no timeout.
msgPrompt.Show(xwindow.RootGeometry(X), "Hello, world!", timeout, hidden)
xevent.Main(X)
}
示例4: ewmhDesktopGeometry
func ewmhDesktopGeometry() {
rgeom := xwindow.RootGeometry(X)
ewmh.DesktopGeometrySet(X,
&ewmh.DesktopGeometry{
Width: rgeom.Width(),
Height: rgeom.Height(),
})
}
示例5: getPrimaryScreenBestResolution
func getPrimaryScreenBestResolution() (w uint16, h uint16) {
// if connect to x failed, just return 1024x768
w, h = 1024, 768
XU, err := xgbutil.NewConn()
if err != nil {
return
}
err = randr.Init(XU.Conn())
if err != nil {
return
}
_, err = randr.QueryVersion(XU.Conn(), 1, 4).Reply()
if err != nil {
return
}
Root := xproto.Setup(XU.Conn()).DefaultScreen(XU.Conn()).Root
resources, err := randr.GetScreenResources(XU.Conn(), Root).Reply()
if err != nil {
return
}
bestModes := make([]uint32, 0)
for _, output := range resources.Outputs {
reply, err := randr.GetOutputInfo(XU.Conn(), output, 0).Reply()
if err == nil && reply.NumModes > 1 {
bestModes = append(bestModes, uint32(reply.Modes[0]))
}
}
w, h = 0, 0
for _, m := range resources.Modes {
for _, id := range bestModes {
if id == m.Id {
bw, bh := m.Width, m.Height
if w == 0 || h == 0 {
w, h = bw, bh
} else if uint32(bw)*uint32(bh) < uint32(w)*uint32(h) {
w, h = bw, bh
}
}
}
}
if w == 0 || h == 0 {
// get resource failed, use root window's geometry
rootRect := xwindow.RootGeometry(XU)
w, h = uint16(rootRect.Width()), uint16(rootRect.Height())
}
if w == 0 || h == 0 {
w, h = 1024, 768 // default value
}
logger.Debugf("primary screen's best resolution is %dx%d", w, h)
return
}
示例6: HeadGeom
func (wrk *Sticky) HeadGeom() xrect.Rect {
return xwindow.RootGeometry(wrk.X)
}