func (d *Desktop) Tile(conn *xgb.Conn) { if d.Head == 0 { if d.Clients == nil { return } d.Head = d.Clients[0] d.Clients = d.Clients[1:] } wsplit := uint32(.8 * float64(d.W)) // The second argument to ConfigureWindow is the valuemask // where we decide which values to change // 1|2|3|4 says that we want to change the window's X, Y, W and H conn.ConfigureWindow(d.Head, 1|2|3|4, []uint32{0, 0, wsplit, uint32(d.H)}) if d.Clients != nil { n := 1 for y := 0; y <= d.H; y += int(float64(d.H) / float64(len(d.Clients))) { conn.ConfigureWindow(d.Clients[n-1], 1|2|3|4, []uint32{wsplit, uint32(y), uint32(d.W) - wsplit, uint32(float64(d.H) / float64(len(d.Clients)))}) n += 1 if n > len(d.Clients) { return } } } }
func handleEvents(c *xgb.Conn) { for { event, err := c.WaitForEvent() if err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } switch event.(type) { case xgb.KeyPressEvent: mapping, err := c.GetKeyboardMapping(event.(xgb.KeyPressEvent).Detail, 1) if err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } if handleKeyPressEvent(mapping.Keysyms[0]) == true { return } } } }
func createWindow(c *xgb.Conn) { win := c.NewId() mask := uint32(xgb.CWEventMask) values := []uint32{1, xgb.EventMaskKeyPress} c.CreateWindow( 0, win, c.DefaultScreen().Root, 0, 0, 1, 1, 0, xgb.WindowClassInputOutput, 0, mask, values) c.MapWindow(win) }
// STUB func kill_client(conn *xgb.Conn) { conn.DestroyWindow(0) }