// _NET_WM_STATE req extra func WmStateReqExtra(xu *xgbutil.XUtil, win xproto.Window, action int, first string, second string, source int) (err error) { var atom1, atom2 xproto.Atom atom1, err = xprop.Atom(xu, first, false) if err != nil { return err } if len(second) > 0 { atom2, err = xprop.Atom(xu, second, false) if err != nil { return err } } else { atom2 = 0 } return ClientEvent(xu, win, "_NET_WM_STATE", action, int(atom1), int(atom2), source) }
func (l *Listener) Initialize() error { if l.X == nil { return fmt.Errorf("X must not be nil.") } if typeAtom == 0 && typeAtomBegin == 0 { var err error typeAtom, err = xprop.Atom(l.X, "_NET_STARTUP_INFO", false) if err != nil { return err } typeAtomBegin, err = xprop.Atom(l.X, "_NET_STARTUP_INFO_BEGIN", false) if err != nil { return err } } if l.Callbacks == nil { return fmt.Errorf("Callbacks must not be nil") } if err := xwindow.New(l.X, l.X.RootWin()).Listen(xproto.EventMaskPropertyChange); err != nil { return err } l.msgBuff = make(map[xproto.Window][]byte) xevent.HookFun(func(_ *xgbutil.XUtil, ev interface{}) bool { return l.hook(ev) }).Connect(l.X) return nil }
func (sock *XEmbedSocket) sendMessage(msg XEmbedMessage, detail, data1, data2 int) (err error) { if xembedAtom == 0 { xembedAtom, err = xprop.Atom(sock.X, "_XEMBED", false) if err != nil { return } } clientMsg, err := xevent.NewClientMessage(32, sock.id, xembedAtom, detail, data1, data2) if err == nil { xproto.SendEvent(sock.X.Conn(), false, sock.id, xproto.EventMaskNoEvent, string(clientMsg.Bytes())) } return }
// Creates a new XSettings object, and initializes it with data populated // from the settings manager that is currently active. func New(X *xgbutil.XUtil) (*XSettings, error) { var err error if atomXSettings == 0 { atomXSettings, err = xprop.Atom(X, "_XSETTINGS_S0", false) if err != nil { return nil, err } } settings := &XSettings{ X: X, } if err = settings.Refresh(); err != nil { return nil, err } return settings, nil }
func New(X *xgbutil.XUtil) (*SystemTray, error) { tray := &SystemTray{ X: X, } var err error if sysTrayAtom == 0 { sysTrayAtom, err = xprop.Atom(X, "_NET_SYSTEM_TRAY_S0", false) if err != nil { return nil, err } } if sysTrayMsgAtom == 0 { sysTrayMsgAtom, err = xprop.Atom(X, "_NET_SYSTEM_TRAY_OPCODE", false) if err != nil { return nil, err } } if managerEventAtom == 0 { managerEventAtom, err = xprop.Atom(X, "MANAGER", false) if err != nil { return nil, err } } tray.wid, err = xwindow.Create(X, X.RootWin()) if err != nil { return nil, err } ts, err := currentTime(X) if err != nil { return nil, err } X.TimeSet(ts) // tray.wid.Listen(xproto.EventMaskNoEvent | xproto.EventMaskPropertyChange) err = xproto.SetSelectionOwnerChecked(tray.X.Conn(), tray.wid.Id, sysTrayAtom, tray.X.TimeGet()).Check() if err != nil { return nil, err } reply, err := xproto.GetSelectionOwner(X.Conn(), sysTrayAtom).Reply() if err != nil { return nil, err } if reply.Owner != tray.wid.Id { return nil, fmt.Errorf("Could not get ownership of the thingy-thing.") } evt, err := xevent.NewClientMessage(32, X.RootWin(), managerEventAtom, int(X.TimeGet()), int(sysTrayAtom), int(tray.wid.Id)) if err != nil { return nil, err } if err = xevent.SendRootEvent(X, evt, xproto.EventMaskStructureNotify); err != nil { return nil, err } xevent.ClientMessageFun(func(_ *xgbutil.XUtil, ev xevent.ClientMessageEvent) { tray.event(ev) }).Connect(tray.X, tray.wid.Id) return tray, nil }