func CreateWindow(style byte, fnCmpWinActivate cmpWinActivateHandler, fb *fbdev.Framebuffer, ms *mouse.Mouse, imp chan int64, x, y, w, h int) (*Window, error) { win := &Window{ fb: fb, titleBarHeight: 20, wasClicked: false, cmpWinActHndr: fnCmpWinActivate, tbHidden: style&WS_TITLEBAR_HIDDEN != 0, bg: color.RGBA{ R: 241, G: 240, B: 238, A: gfx.A_OPAQUE, }, } win.Element = base.Element{ Id: base.GenerateId(), X: x, // relative position within the parent element Y: y, ScreenX: x, // position within the screen coordinates ScreenY: y, Width: w, Height: h, Buffer: make([]byte, w*h*4), InvMsgPipe: imp, DeactivateHndr: win.Deactivate, Children: list.New(), } ms.RegisterMouse(win.Element.Id, win.Mouse, win.activate, &win.Element.ScreenX, &win.Element.ScreenY, w, h) if !win.tbHidden { win.closeButton = win.TitleBarButton(ms, func(_ bool) { log.Debugf("Window %v exiting...", win.Id) // deregister the window win.Element.CompRemoveHdnr(win.Id) // remove mouse handlers ms.DeregisterMouse(win.Id) for v := win.Children.Front(); v != nil; v = v.Next() { ms.DeregisterMouse(v.Value.(base.IElement).GetId()) } }, w-15, 5, 10, 10) } win.Draw() return win, nil }