Beispiel #1
0
// 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
}
Beispiel #2
0
func (m *TrayManager) tryOwner() bool {
	// Make a check, the tray application MUST be 1.
	reply, err := m.getSelectionOwner()
	if err != nil {
		logger.Error(err)
		return false
	}
	if reply.Owner != 0 {
		logger.Warning("Another System tray application is running")
		return false
	}

	timeStamp, _ := ewmh.WmUserTimeGet(TrayXU, m.owner)
	err = xproto.SetSelectionOwnerChecked(
		TrayXU.Conn(),
		m.owner,
		_NET_SYSTEM_TRAY_S0,
		xproto.Timestamp(timeStamp),
	).Check()
	if err != nil {
		logger.Warning("Set Selection Owner failed: ", err)
		return false
	}

	//owner the _NET_SYSTEM_TRAY_Sn
	logger.Info("Required _NET_SYSTEM_TRAY_S0 successful")

	m.RequireManageTrayIcons()

	xprop.ChangeProp32(
		TrayXU,
		m.owner,
		"_NET_SYSTEM_TRAY_VISUAL",
		"VISUALID",
		uint(TRAYMANAGER.visual),
	)
	xprop.ChangeProp32(
		TrayXU,
		m.owner,
		"_NET_SYSTEM_TRAY_ORIENTAION",
		"CARDINAL",
		0,
	)
	reply, err = m.getSelectionOwner()
	if err != nil {
		logger.Warning(err)
		return false
	}
	return reply.Owner != 0
}
Beispiel #3
0
// _NET_DESKTOP_LAYOUT set
func DesktopLayoutSet(xu *xgbutil.XUtil, orientation, columns, rows,
	startingCorner uint) error {

	return xprop.ChangeProp32(xu, xu.RootWin(), "_NET_DESKTOP_LAYOUT",
		"CARDINAL", orientation, columns, rows,
		startingCorner)
}
Beispiel #4
0
// WM_STATE set
func WmStateSet(xu *xgbutil.XUtil, win xproto.Window, state *WmState) error {
	raw := []int{
		state.State,
		int(state.Icon),
	}

	return xprop.ChangeProp32(xu, win, "WM_STATE", "WM_STATE", raw...)
}
Beispiel #5
0
// WM_PROTOCOLS set
func WmProtocolsSet(xu *xgbutil.XUtil, win xproto.Window,
	atomNames []string) error {

	atoms, err := xprop.StrToAtoms(xu, atomNames)
	if err != nil {
		return err
	}
	return xprop.ChangeProp32(xu, win, "WM_PROTOCOLS", "ATOM", atoms...)
}
Beispiel #6
0
// _NET_SUPPORTED set
// This will create any atoms in the argument if they don't already exist.
func SupportedSet(xu *xgbutil.XUtil, atomNames []string) error {
	atoms, err := xprop.StrToAtoms(xu, atomNames)
	if err != nil {
		return err
	}

	return xprop.ChangeProp32(xu, xu.RootWin(), "_NET_SUPPORTED", "ATOM",
		atoms...)
}
Beispiel #7
0
// _NET_WM_ICON set
func WmIconSet(xu *xgbutil.XUtil, win xproto.Window, icons []WmIcon) error {
	raw := make([]uint, 0, 10000) // start big
	for _, icon := range icons {
		raw = append(raw, icon.Width, icon.Height)
		raw = append(raw, icon.Data...)
	}

	return xprop.ChangeProp32(xu, win, "_NET_WM_ICON", "CARDINAL", raw...)
}
Beispiel #8
0
// _NET_WM_WINDOW_TYPE set
// This will create any atoms used in 'atomNames' if they don't already exist.
func WmWindowTypeSet(xu *xgbutil.XUtil, win xproto.Window,
	atomNames []string) error {

	atoms, err := xprop.StrToAtoms(xu, atomNames)
	if err != nil {
		return err
	}
	return xprop.ChangeProp32(xu, win, "_NET_WM_WINDOW_TYPE", "ATOM", atoms...)
}
Beispiel #9
0
// _NET_SHOWING_DESKTOP set
func ShowingDesktopSet(xu *xgbutil.XUtil, show bool) error {
	var showInt uint
	if show {
		showInt = 1
	} else {
		showInt = 0
	}
	return xprop.ChangeProp32(xu, xu.RootWin(), "_NET_SHOWING_DESKTOP",
		"CARDINAL", showInt)
}
Beispiel #10
0
// _NET_WM_HANDLED_ICONS set
func WmHandledIconsSet(xu *xgbutil.XUtil, handle bool) error {
	var handled uint
	if handle {
		handled = 1
	} else {
		handled = 0
	}
	return xprop.ChangeProp32(xu, xu.RootWin(), "_NET_WM_HANDLED_ICONS",
		"CARDINAL", handled)
}
Beispiel #11
0
// _NET_FRAME_EXTENTS set
func FrameExtentsSet(xu *xgbutil.XUtil, win xproto.Window,
	extents *FrameExtents) error {
	raw := make([]uint, 4)
	raw[0] = uint(extents.Left)
	raw[1] = uint(extents.Right)
	raw[2] = uint(extents.Top)
	raw[3] = uint(extents.Bottom)

	return xprop.ChangeProp32(xu, win, "_NET_FRAME_EXTENTS", "CARDINAL", raw...)
}
Beispiel #12
0
// _NET_DESKTOP_VIEWPORT set
func DesktopViewportSet(xu *xgbutil.XUtil, viewports []DesktopViewport) error {
	coords := make([]uint, len(viewports)*2)
	for i, viewport := range viewports {
		coords[i*2] = uint(viewport.X)
		coords[i*2+1] = uint(viewport.Y)
	}

	return xprop.ChangeProp32(xu, xu.RootWin(), "_NET_DESKTOP_VIEWPORT",
		"CARDINAL", coords...)
}
Beispiel #13
0
// WM_HINTS set
// Make sure to set the flags in the Hints struct correctly!
func WmHintsSet(xu *xgbutil.XUtil, win xproto.Window, hints *Hints) error {
	raw := []int{
		hints.Flags, hints.Input, hints.InitialState,
		int(hints.IconPixmap), int(hints.IconWindow),
		hints.IconX, hints.IconY,
		int(hints.IconMask),
		int(hints.WindowGroup),
	}
	return xprop.ChangeProp32(xu, win, "WM_HINTS", "WM_HINTS", raw...)
}
Beispiel #14
0
// _NET_WM_STRUT set
func WmStrutSet(xu *xgbutil.XUtil, win xproto.Window, struts *WmStrut) error {
	rawStruts := make([]uint, 4)
	rawStruts[0] = struts.Left
	rawStruts[1] = struts.Right
	rawStruts[2] = struts.Top
	rawStruts[3] = struts.Bottom

	return xprop.ChangeProp32(xu, win, "_NET_WM_STRUT", "CARDINAL",
		rawStruts...)
}
Beispiel #15
0
// WM_ICON_SIZE set
func WmIconSizeSet(xu *xgbutil.XUtil, win xproto.Window,
	icondim *IconSize) error {

	raw := []int{
		icondim.MinWidth, icondim.MinHeight,
		icondim.MaxWidth, icondim.MaxHeight,
		icondim.WidthInc, icondim.HeightInc,
	}

	return xprop.ChangeProp32(xu, win, "WM_ICON_SIZE", "WM_ICON_SIZE", raw...)
}
Beispiel #16
0
// _NET_WM_ALLOWED_ACTIONS set
func WmAllowedActionsSet(xu *xgbutil.XUtil, win xproto.Window,
	atomNames []string) error {

	atoms, err := xprop.StrToAtoms(xu, atomNames)
	if err != nil {
		return err
	}

	return xprop.ChangeProp32(xu, win, "_NET_WM_ALLOWED_ACTIONS", "ATOM",
		atoms...)
}
Beispiel #17
0
// _NET_WM_ICON_GEOMETRY set
func WmIconGeometrySet(xu *xgbutil.XUtil, win xproto.Window,
	geom *WmIconGeometry) error {

	rawGeom := make([]uint, 4)
	rawGeom[0] = uint(geom.X)
	rawGeom[1] = uint(geom.Y)
	rawGeom[2] = geom.Width
	rawGeom[3] = geom.Height

	return xprop.ChangeProp32(xu, win, "_NET_WM_ICON_GEOMETRY", "CARDINAL",
		rawGeom...)
}
Beispiel #18
0
// _NET_WORKAREA set
func WorkareaSet(xu *xgbutil.XUtil, workareas []Workarea) error {
	rects := make([]uint, len(workareas)*4)
	for i, workarea := range workareas {
		rects[i*4+0] = uint(workarea.X)
		rects[i*4+1] = uint(workarea.Y)
		rects[i*4+2] = workarea.Width
		rects[i*4+3] = workarea.Height
	}

	return xprop.ChangeProp32(xu, xu.RootWin(), "_NET_WORKAREA", "CARDINAL",
		rects...)
}
Beispiel #19
0
// _NET_WM_FULLSCREEN_MONITORS set
func WmFullscreenMonitorsSet(xu *xgbutil.XUtil, win xproto.Window,
	edges *WmFullscreenMonitors) error {

	raw := make([]uint, 4)
	raw[0] = edges.Top
	raw[1] = edges.Bottom
	raw[2] = edges.Left
	raw[3] = edges.Right

	return xprop.ChangeProp32(xu, win, "_NET_WM_FULLSCREEN_MONITORS",
		"CARDINAL", raw...)
}
Beispiel #20
0
// _NET_WM_OPAQUE_REGION set
func WmOpaqueRegionSet(xu *xgbutil.XUtil, win xproto.Window,
	regions []WmOpaqueRegion) error {

	raw := make([]uint, len(regions)*4)

	for i, region := range regions {
		raw[i*4+0] = uint(region.X)
		raw[i*4+1] = uint(region.Y)
		raw[i*4+2] = region.Width
		raw[i*4+3] = region.Height
	}

	return xprop.ChangeProp32(xu, win, "_NET_WM_OPAQUE_REGION", "CARDINAL",
		raw...)
}
Beispiel #21
0
// WM_NORMAL_HINTS set
// Make sure to set the flags in the NormalHints struct correctly!
func WmNormalHintsSet(xu *xgbutil.XUtil, win xproto.Window,
	nh *NormalHints) error {

	raw := []int{
		nh.Flags,
		nh.X, nh.Y, nh.Width, nh.Height,
		nh.MinWidth, nh.MinHeight,
		nh.MaxWidth, nh.MaxHeight,
		nh.WidthInc, nh.HeightInc,
		nh.MinAspectNum, nh.MinAspectDen,
		nh.MaxAspectNum, nh.MaxAspectDen,
		nh.BaseWidth, nh.BaseHeight,
		nh.WinGravity,
	}
	return xprop.ChangeProp32(xu, win, "WM_NORMAL_HINTS", "WM_SIZE_HINTS",
		raw...)
}
Beispiel #22
0
// _NET_WM_STRUT_PARTIAL set
func WmStrutPartialSet(xu *xgbutil.XUtil, win xproto.Window,
	struts *WmStrutPartial) error {

	rawStruts := make([]uint, 12)
	rawStruts[0] = struts.Left
	rawStruts[1] = struts.Right
	rawStruts[2] = struts.Top
	rawStruts[3] = struts.Bottom
	rawStruts[4] = struts.LeftStartY
	rawStruts[5] = struts.LeftEndY
	rawStruts[6] = struts.RightStartY
	rawStruts[7] = struts.RightEndY
	rawStruts[8] = struts.TopStartX
	rawStruts[9] = struts.TopEndX
	rawStruts[10] = struts.BottomStartX
	rawStruts[11] = struts.BottomEndX

	return xprop.ChangeProp32(xu, win, "_NET_WM_STRUT_PARTIAL", "CARDINAL",
		rawStruts...)
}
Beispiel #23
0
// _NET_VISIBLE_DESKTOPS set
func VisibleDesktopsSet(xu *xgbutil.XUtil, desktops []uint) error {
	return xprop.ChangeProp32(xu, xu.RootWin(), "_NET_VISIBLE_DESKTOPS",
		"CARDINAL", desktops...)
}
Beispiel #24
0
// _NET_WM_PID set
func WmPidSet(xu *xgbutil.XUtil, win xproto.Window, pid uint) error {
	return xprop.ChangeProp32(xu, win, "_NET_WM_PID", "CARDINAL", pid)
}
Beispiel #25
0
// _NET_CLIENT_LIST_STACKING set
func ClientListStackingSet(xu *xgbutil.XUtil, wins []xproto.Window) error {
	return xprop.ChangeProp32(xu, xu.RootWin(), "_NET_CLIENT_LIST_STACKING",
		"WINDOW", xprop.WindowToInt(wins)...)
}
Beispiel #26
0
// _NET_ACTIVE_WINDOW set
func ActiveWindowSet(xu *xgbutil.XUtil, win xproto.Window) error {
	return xprop.ChangeProp32(xu, xu.RootWin(), "_NET_ACTIVE_WINDOW", "WINDOW",
		uint(win))
}
Beispiel #27
0
// _NET_WM_DESKTOP set
func WmDesktopSet(xu *xgbutil.XUtil, win xproto.Window, desk uint) error {
	return xprop.ChangeProp32(xu, win, "_NET_WM_DESKTOP", "CARDINAL",
		uint(desk))
}
Beispiel #28
0
// _NET_VIRTUAL_ROOTS set
func VirtualRootsSet(xu *xgbutil.XUtil, wins []xproto.Window) error {
	return xprop.ChangeProp32(xu, xu.RootWin(), "_NET_VIRTUAL_ROOTS", "WINDOW",
		xprop.WindowToInt(wins)...)
}
Beispiel #29
0
// _NET_CURRENT_DESKTOP set
func CurrentDesktopSet(xu *xgbutil.XUtil, desk uint) error {
	return xprop.ChangeProp32(xu, xu.RootWin(), "_NET_CURRENT_DESKTOP",
		"CARDINAL", desk)
}
Beispiel #30
0
// _NET_SUPPORTING_WM_CHECK set
func SupportingWmCheckSet(xu *xgbutil.XUtil, win xproto.Window,
	wmWin xproto.Window) error {

	return xprop.ChangeProp32(xu, win, "_NET_SUPPORTING_WM_CHECK", "WINDOW",
		uint(wmWin))
}