func NewWindow(width, height int) (w *Window, err error) { w = new(Window) w.width, w.height = width, height w.buffer = image.NewRGBA(image.Rectangle{image.Point{0, 0}, image.Point{width, height}}) w.xu, err = xgbutil.Dial("") if err != nil { return } w.conn = w.xu.Conn() screen := w.xu.Screen() w.id = w.conn.NewId() w.conn.CreateWindow(xgb.WindowClassCopyFromParent, w.id, screen.Root, 600, 500, uint16(width), uint16(height), 0, xgb.WindowClassInputOutput, screen.RootVisual, 0, []uint32{}) xwindow.Listen(w.xu, w.id, AllEventsMask) keyMap, modMap := keybind.MapsGet(w.xu) w.xu.KeyMapSet(keyMap) w.xu.ModMapSet(modMap) w.events = make(chan interface{}) w.SetIcon(Gordon) w.SetIconName("Go") go w.handleEvents() return }
func NewWindow(width, height int) (w *Window, err error) { w = new(Window) w.width, w.height = width, height w.xu, err = xgbutil.NewConn() if err != nil { return } w.conn = w.xu.Conn() screen := w.xu.Screen() w.win, err = xwindow.Generate(w.xu) if err != nil { return } err = w.win.CreateChecked(screen.Root, 600, 500, width, height, 0) if err != nil { return } w.win.Listen(AllEventsMask) err = icccm.WmProtocolsSet(w.xu, w.win.Id, []string{"WM_DELETE_WINDOW"}) if err != nil { fmt.Println(err) err = nil } w.bufferLck = &sync.Mutex{} w.buffer = xgraphics.New(w.xu, image.Rect(0, 0, width, height)) w.buffer.XSurfaceSet(w.win.Id) keyMap, modMap := keybind.MapsGet(w.xu) keybind.KeyMapSet(w.xu, keyMap) keybind.ModMapSet(w.xu, modMap) w.events = make(chan interface{}) w.SetIcon(Gordon) w.SetIconName("Go") go w.handleEvents() return }