func (c *Client) Close() { if strIndex("WM_DELETE_WINDOW", c.protocols) > -1 { wm_protocols, err := xprop.Atm(wm.X, "WM_PROTOCOLS") if err != nil { logger.Warning.Println(err) return } wm_del_win, err := xprop.Atm(wm.X, "WM_DELETE_WINDOW") if err != nil { logger.Warning.Println(err) return } cm, err := xevent.NewClientMessage(32, c.Id(), wm_protocols, int(wm_del_win)) if err != nil { logger.Warning.Println(err) return } err = xproto.SendEventChecked(wm.X.Conn(), false, c.Id(), 0, string(cm.Bytes())).Check() if err != nil { logger.Message.Printf("Could not send WM_DELETE_WINDOW "+ "ClientMessage because: %s", err) } } else { c.win.Kill() // HULK SMASH! } }
func ClientEvent(c *xgb.Conn, root, w xproto.Window, a xproto.Atom, data ...interface{}) error { evMask := (xproto.EventMaskSubstructureNotify | xproto.EventMaskSubstructureRedirect) cm, err := mkClientMessage(32, w, a, data...) if err != nil { return err } return xproto.SendEventChecked(c, false, root, uint32(evMask), string(cm.Bytes())).Check() }
func sendClientMessage(xWin xp.Window, atom xp.Atom) { check(xp.SendEventChecked(xConn, false, xWin, xp.EventMaskNoEvent, string(xp.ClientMessageEvent{ Format: 32, Window: xWin, Type: atomWMProtocols, Data: xp.ClientMessageDataUnionData32New([]uint32{ uint32(atom), uint32(eventTime), 0, 0, 0, }), }.Bytes()), )) }
func handleConfigureRequest(e xp.ConfigureRequestEvent) { mask, values := uint16(0), []uint32(nil) if w := findWindow(func(w *window) bool { return w.xWin == e.Window }); w != nil { cne := xp.ConfigureNotifyEvent{ Event: w.xWin, Window: w.xWin, X: w.rect.X, Y: w.rect.Y, Width: w.rect.Width, Height: w.rect.Height, } check(xp.SendEventChecked(xConn, false, w.xWin, xp.EventMaskStructureNotify, string(cne.Bytes()))) return } if e.ValueMask&xp.ConfigWindowX != 0 { mask |= xp.ConfigWindowX values = append(values, uint32(e.X)) } if e.ValueMask&xp.ConfigWindowY != 0 { mask |= xp.ConfigWindowY values = append(values, uint32(e.Y)) } if e.ValueMask&xp.ConfigWindowWidth != 0 { mask |= xp.ConfigWindowWidth values = append(values, uint32(e.Width)) } if e.ValueMask&xp.ConfigWindowHeight != 0 { mask |= xp.ConfigWindowHeight values = append(values, uint32(e.Height)) } if e.ValueMask&xp.ConfigWindowBorderWidth != 0 { mask |= xp.ConfigWindowBorderWidth values = append(values, uint32(e.BorderWidth)) } if e.ValueMask&xp.ConfigWindowSibling != 0 { mask |= xp.ConfigWindowSibling values = append(values, uint32(e.Sibling)) } if e.ValueMask&xp.ConfigWindowStackMode != 0 { mask |= xp.ConfigWindowStackMode values = append(values, uint32(e.StackMode)) } check(xp.ConfigureWindowChecked(xConn, e.Window, mask, values)) }
// SendRootEvent takes a type implementing the xgb.Event interface, converts it // to raw X bytes, and sends it to the root window using the SendEvent request. func SendRootEvent(xu *xgbutil.XUtil, ev xgb.Event, evMask uint32) error { return xproto.SendEventChecked(xu.Conn(), false, xu.RootWin(), evMask, string(ev.Bytes())).Check() }