Exemple #1
0
func main() {
	X, _ := xgbutil.NewConn()

	active, err := ewmh.ActiveWindowGet(X)

	wmName, err := icccm.WmNameGet(X, active)
	showTest("WM_NAME get", wmName, err)

	err = icccm.WmNameSet(X, active, "hooblah")
	wmName, _ = icccm.WmNameGet(X, active)
	showTest("WM_NAME set", wmName, err)

	wmNormHints, err := icccm.WmNormalHintsGet(X, active)
	showTest("WM_NORMAL_HINTS get", wmNormHints, err)

	wmNormHints.Width += 5
	err = icccm.WmNormalHintsSet(X, active, wmNormHints)
	showTest("WM_NORMAL_HINTS set", wmNormHints, err)

	wmHints, err := icccm.WmHintsGet(X, active)
	showTest("WM_HINTS get", wmHints, err)

	wmHints.InitialState = icccm.StateNormal
	err = icccm.WmHintsSet(X, active, wmHints)
	showTest("WM_NORMAL_HINTS set", wmHints, err)

	wmClass, err := icccm.WmClassGet(X, active)
	showTest("WM_CLASS get", wmClass, err)

	wmClass.Instance = "hoopdy hoop"
	err = icccm.WmClassSet(X, active, wmClass)
	showTest("WM_CLASS set", wmClass, err)

	wmTrans, err := icccm.WmTransientForGet(X, active)
	showTest("WM_TRANSIENT_FOR get", wmTrans, err)

	wmProts, err := icccm.WmProtocolsGet(X, active)
	showTest("WM_PROTOCOLS get", wmProts, err)

	wmClient, err := icccm.WmClientMachineGet(X, active)
	showTest("WM_CLIENT_MACHINE get", wmClient, err)

	err = icccm.WmClientMachineSet(X, active, "Leopard")
	wmClient, _ = icccm.WmClientMachineGet(X, active)
	showTest("WM_CLIENT_MACHINE set", wmClient, err)

	wmState, err := icccm.WmStateGet(X, active)
	showTest("WM_STATE get", wmState, err)

	wmState.Icon = xproto.Window(8365538)
	wmState.State = icccm.StateNormal
	err = icccm.WmStateSet(X, active, wmState)
	wmState, _ = icccm.WmStateGet(X, active)
	showTest("WM_STATE set", wmState, err)
}
func (app *RuntimeApp) Activate(x, y int32) error {
	//TODO: handle multiple xids
	switch {
	case !contains(app.state, "_NET_WM_STATE_FOCUSED"):
		activateWindow(app.CurrentInfo.Xid)
	case contains(app.state, "_NET_WM_STATE_FOCUSED"):
		s, err := icccm.WmStateGet(XU, app.CurrentInfo.Xid)
		if err != nil {
			logger.Info("WmStateGetError:", s, err)
			return err
		}
		switch s.State {
		case icccm.StateIconic:
			s.State = icccm.StateNormal
			icccm.WmStateSet(XU, app.CurrentInfo.Xid, s)
		case icccm.StateNormal:
			activeXid, _ := ewmh.ActiveWindowGet(XU)
			logger.Debugf("%s, 0x%x(c), 0x%x(a), %v", app.Id,
				app.CurrentInfo.Xid, activeXid, app.state)
			if len(app.xids) == 1 {
				s.State = icccm.StateIconic
				iconifyWindow(app.CurrentInfo.Xid)
			} else {
				logger.Warningf("activeXid is 0x%x, current is 0x%x", activeXid,
					app.CurrentInfo.Xid)
				if activeXid == app.CurrentInfo.Xid {
					x := app.findNextLeader()
					ewmh.ActiveWindowReq(XU, x)
				}
			}
		}
	}
	return nil
}