func showAll() { X, err := xgbutil.NewConn() if err != nil { log.Fatal(err) } for i := 0; i < len(testImages); i++ { fname := testImages[i] fmt.Printf("%d Working on %s\n", i, fname) file, err := os.Open(testDir + fname) if err != nil { continue } defer file.Close() var img image.Image // Decode the image. // using true forces bmp decoder, otherwise whatever is registered for ext is used // result slightly different if non-bmps fed to it if true { img, err = bmp.Decode(file) } else { img, _, err = image.Decode(file) } if err != nil { continue } ximg := xgraphics.NewConvert(X, img) ximg.XShowExtra(fname, true) time.Sleep(1 * time.Second) } xevent.Main(X) time.Sleep(4 * time.Second) xevent.Quit(X) }
func main() { X, err := xgbutil.NewConn() if err != nil { log.Fatal(err) } // Create window for receiving compressed MotionNotify events. cwin := newWindow(X, 0x00ff00) // Attach event handler for MotionNotify that compresses events. xevent.MotionNotifyFun( func(X *xgbutil.XUtil, ev xevent.MotionNotifyEvent) { ev = compressMotionNotify(X, ev) fmt.Printf("COMPRESSED: (EventX %d, EventY %d)\n", ev.EventX, ev.EventY) time.Sleep(workTime) }).Connect(X, cwin.Id) // Create window for receiving uncompressed MotionNotify events. uwin := newWindow(X, 0xff0000) // Attach event handler for MotionNotify that does not compress events. xevent.MotionNotifyFun( func(X *xgbutil.XUtil, ev xevent.MotionNotifyEvent) { fmt.Printf("UNCOMPRESSED: (EventX %d, EventY %d)\n", ev.EventX, ev.EventY) time.Sleep(workTime) }).Connect(X, uwin.Id) xevent.Main(X) }
func main() { // If we just need the keybindings, print them and be done. if flagKeybindings { for _, keyb := range keybinds { fmt.Printf("%-10s %s\n", keyb.key, keyb.desc) } fmt.Printf("%-10s %s\n", "mouse", "Left mouse button will pan the image.") os.Exit(0) } // Run the CPU profile if we're instructed to. if len(flagProfile) > 0 { f, err := os.Create(flagProfile) if err != nil { errLg.Fatal(err) } pprof.StartCPUProfile(f) defer pprof.StopCPUProfile() } // Whoops! if flag.NArg() == 0 { fmt.Fprint(os.Stderr, "\n") errLg.Print("No images specified.\n\n") usage() } // Connect to X and quit if we fail. X, err := xgbutil.NewConn() if err != nil { errLg.Fatal(err) } // Create the X window before starting anything so that the user knows // something is going on. window := newWindow(X) // Decode all images (in parallel). names, imgs := decodeImages(findFiles(flag.Args())) // Die now if we don't have any images! if len(imgs) == 0 { errLg.Fatal("No images specified could be shown. Quitting...") } // Auto-size the window if appropriate. if flagAutoResize { window.Resize(imgs[0].Bounds().Dx(), imgs[0].Bounds().Dy()) } // Create the canvas and start the image goroutines. chans := canvas(X, window, names, len(imgs)) for i, img := range imgs { go newImage(X, names[i], img, i, chans.imgLoadChans[i], chans.imgChan) } // Start the main X event loop. xevent.Main(X) }
func main() { X, err := xgbutil.NewConn() if err != nil { log.Fatalln(err) } // The message box uses the keybind module, so we must initialize it. keybind.Initialize(X) // Creating a new message prompt is as simple as supply an X connection, // a theme and a configuration. We use built in defaults here. msgPrompt := prompt.NewMessage(X, prompt.DefaultMessageTheme, prompt.DefaultMessageConfig) // Show maps the message prompt window. // If a duration is specified, the window does NOT acquire focus and // automatically disappears after the specified time. // If a duration is not specified (i.e., '0'), then the window is mapped, // and acquires focus. It does not disappear until it loses focus or when // the user hits the "confirm" or "cancel" keys (usually "enter" and // "escape"). timeout := 2 * time.Second // or "0" for no timeout. msgPrompt.Show(xwindow.RootGeometry(X), "Hello, world!", timeout, hidden) xevent.Main(X) }
func NewDisplay(width, height, border, heading int, name string) (*Display, error) { d := new(Display) d.w = float64(width) d.h = float64(height) d.bord = float64(border) d.head = float64(heading) X, err := xgbutil.NewConn() if err != nil { return nil, err } keybind.Initialize(X) d.ximg = xgraphics.New(X, image.Rect( 0, 0, border*2+width, border*2+heading+height)) err = d.ximg.CreatePixmap() if err != nil { return nil, err } painter := NewXimgPainter(d.ximg) d.gc = draw2d.NewGraphicContextWithPainter(d.ximg, painter) d.gc.Save() d.gc.SetStrokeColor(color.White) d.gc.SetFillColor(color.White) d.gc.Clear() d.wid = d.ximg.XShowExtra(name, true) d.x = X go func() { xevent.Main(X) }() return d, nil }
// NewImage returns a new image canvas // that draws to the given image. The // minimum point of the given image // should probably be 0,0. func NewImage(img draw.Image, name string) (*Canvas, error) { w := float64(img.Bounds().Max.X - img.Bounds().Min.X) h := float64(img.Bounds().Max.Y - img.Bounds().Min.Y) X, err := xgbutil.NewConn() if err != nil { return nil, err } keybind.Initialize(X) ximg := xgraphics.New(X, image.Rect(0, 0, int(w), int(h))) err = ximg.CreatePixmap() if err != nil { return nil, err } painter := NewPainter(ximg) gc := draw2d.NewGraphicContextWithPainter(ximg, painter) gc.SetDPI(dpi) gc.Scale(1, -1) gc.Translate(0, -h) wid := ximg.XShowExtra(name, true) go func() { xevent.Main(X) }() c := &Canvas{ Canvas: vgimg.NewWith(vgimg.UseImageWithContext(img, gc)), x: X, ximg: ximg, wid: wid, } vg.Initialize(c) return c, nil }
func run() error { Xu, err := xgbutil.NewConn() if err != nil { return err } defer Xu.Conn().Close() keybind.Initialize(Xu) if err := randr.Init(Xu.Conn()); err != nil { return err } audio, err := newAudio(Xu) if err != nil { return err } defer audio.Close() brightness, err := newBrightness(Xu) if err != nil { return err } defer brightness.Close() xevent.Main(Xu) return nil }
func main() { X, err := xgbutil.NewConn() if err != nil { log.Fatal(err) } // Use the "NewDrawable" constructor to create an xgraphics.Image value // from a drawable. (Usually this is done with pixmaps, but drawables // can also be windows.) ximg, err := xgraphics.NewDrawable(X, xproto.Drawable(X.RootWin())) if err != nil { log.Fatal(err) } // Shows the screenshot in a window. ximg.XShowExtra("Screenshot", true) // If you'd like to save it as a png, use: // err = ximg.SavePng("screenshot.png") // if err != nil { // log.Fatal(err) // } xevent.Main(X) }
func showOne(testNum int) { X, err := xgbutil.NewConn() if err != nil { log.Fatal(err) } fname := testImages[testNum] fmt.Printf("Working on %s\n", fname) file, err := os.Open(testDir + fname) if err != nil { log.Fatal(err) } defer file.Close() // Decode the image. img, _, err := image.Decode(file) if err != nil { log.Fatal(err) } ximg := xgraphics.NewConvert(X, img) ximg.XShowExtra(fname, true) xevent.Main(X) time.Sleep(4 * time.Second) xevent.Quit(X) }
func main() { X, _ = xgbutil.NewConn() go newGradientWindow(200, 200) go newGradientWindow(400, 400) xevent.Main(X) }
func main() { X, err := xgbutil.NewConn() if err != nil { log.Fatal(err) } // Load some font. You may need to change the path depending upon your // system configuration. fontReader, err := os.Open(fontPath) if err != nil { log.Fatal(err) } // Now parse the font. font, err := xgraphics.ParseFont(fontReader) if err != nil { log.Fatal(err) } // Create some canvas. ximg := xgraphics.New(X, image.Rect(0, 0, canvasWidth, canvasHeight)) ximg.For(func(x, y int) xgraphics.BGRA { return bg }) // Now write the text. _, _, err = ximg.Text(10, 10, fg, size, font, msg) if err != nil { log.Fatal(err) } // Compute extents of first line of text. _, firsth := xgraphics.Extents(font, size, msg) // Now show the image in its own window. win := ximg.XShowExtra("Drawing text using xgraphics", true) // Now draw some more text below the above and demonstrate how to update // only the region we've updated. _, _, err = ximg.Text(10, 10+firsth, fg, size, font, "Some more text.") if err != nil { log.Fatal(err) } // Now compute extents of the second line of text, so we know which region // to update. secw, sech := xgraphics.Extents(font, size, "Some more text.") // Now repaint on the region that we drew text on. Then update the screen. bounds := image.Rect(10, 10+firsth, 10+secw, 10+firsth+sech) ximg.SubImage(bounds).XDraw() ximg.XPaint(win.Id) // All we really need to do is block, which could be achieved using // 'select{}'. Invoking the main event loop however, will emit error // message if anything went seriously wrong above. xevent.Main(X) }
func main() { X, err := xgbutil.NewConn() if err != nil { log.Fatal(err) } keybind.Initialize(X) // call once before using keybind package // Read an example gopher image into a regular png image. img, _, err := image.Decode(bytes.NewBuffer(gopher.GopherPng())) if err != nil { log.Fatal(err) } // Now convert it into an X image. ximg := xgraphics.NewConvert(X, img) // Now show it in a new window. // We set the window title and tell the program to quit gracefully when // the window is closed. // There is also a convenience method, XShow, that requires no parameters. win := showImage(ximg, "The Go Gopher!", true) // Listen for key press events. win.Listen(xproto.EventMaskKeyPress) err = keybind.KeyPressFun( func(X *xgbutil.XUtil, ev xevent.KeyPressEvent) { println("fullscreen!") err := ewmh.WmStateReq(X, win.Id, ewmh.StateToggle, "_NET_WM_STATE_FULLSCREEN") if err != nil { log.Fatal(err) } }).Connect(X, win.Id, "f", false) if err != nil { log.Fatal(err) } err = keybind.KeyPressFun( func(X *xgbutil.XUtil, ev xevent.KeyPressEvent) { println("quit fullscreen!") err := ewmh.WmStateReq(X, win.Id, ewmh.StateToggle, "_NET_WM_STATE_FULLSCREEN") if err != nil { log.Fatal(err) } }).Connect(X, win.Id, "Escape", false) if err != nil { log.Fatal(err) } // If we don't block, the program will end and the window will disappear. // We could use a 'select{}' here, but xevent.Main will emit errors if // something went wrong, so use that instead. xevent.Main(X) }
func grabKeyboardAndMouse(m *Manager) { if m == nil { return } //go func() { X, err := xgbutil.NewConn() if err != nil { logger.Info("Get New Connection Failed:", err) return } keybind.Initialize(X) mousebind.Initialize(X) err = keybind.GrabKeyboard(X, X.RootWin()) if err != nil { logger.Info("Grab Keyboard Failed:", err) return } grabAllMouseButton(X) xevent.ButtonPressFun( func(X *xgbutil.XUtil, e xevent.ButtonPressEvent) { dbus.Emit(m, "KeyReleaseEvent", "") ungrabAllMouseButton(X) keybind.UngrabKeyboard(X) logger.Info("Button Press Event") xevent.Quit(X) }).Connect(X, X.RootWin()) xevent.KeyPressFun( func(X *xgbutil.XUtil, e xevent.KeyPressEvent) { value := parseKeyEnvent(X, e.State, e.Detail) pressKeyStr = value dbus.Emit(m, "KeyPressEvent", value) }).Connect(X, X.RootWin()) xevent.KeyReleaseFun( func(X *xgbutil.XUtil, e xevent.KeyReleaseEvent) { if strings.ToLower(pressKeyStr) == "super_l" || strings.ToLower(pressKeyStr) == "super_r" { pressKeyStr = "Super" } dbus.Emit(m, "KeyReleaseEvent", pressKeyStr) pressKeyStr = "" ungrabAllMouseButton(X) keybind.UngrabKeyboard(X) logger.Infof("Key: %s\n", pressKeyStr) xevent.Quit(X) }).Connect(X, X.RootWin()) xevent.Main(X) //}() }
func initialize() { X, err := xgbutil.NewConn() if err != nil { log.Fatal(err) } mousebind.Initialize(X) xWindow := newWindow(X, INITIAL_WINDOW_WIDTH, INITIAL_WINDOW_HEIGHT) go xevent.Main(X) xorg.Initialize( egl.NativeWindowType(uintptr(xWindow.Id)), xorg.DefaultConfigAttributes, xorg.DefaultContextAttributes) }
func main() { X, err := xgbutil.NewConn() if err != nil { log.Fatalf("Could not connect to X: %v", err) } keybind.Initialize(X) keybind.KeyPressFun( func(X *xgbutil.XUtil, e xevent.KeyPressEvent) { fmt.Println("Key press!") }).Connect(X, X.RootWin(), "Mod4-j") xevent.Main(X) }
func initEGL(controlCh *controlCh, width, height int) *platform.EGLState { X, err := xgbutil.NewConn() if err != nil { panic(err) } mousebind.Initialize(X) keybind.Initialize(X) xWindow := newWindow(controlCh, X, width, height) go xevent.Main(X) return xorg.Initialize( egl.NativeWindowType(uintptr(xWindow.Id)), xorg.DefaultConfigAttributes, xorg.DefaultContextAttributes, ) }
func main() { X, err := xgbutil.NewConn() fatal(err) keybind.Initialize(X) slct := prompt.NewSelect(X, prompt.DefaultSelectTheme, prompt.DefaultSelectConfig) // Create some artifical groups to use. artGroups := []prompt.SelectGroup{ slct.NewStaticGroup("Group 1"), slct.NewStaticGroup("Group 2"), slct.NewStaticGroup("Group 3"), slct.NewStaticGroup("Group 4"), slct.NewStaticGroup("Group 5"), } // And now create some artificial items. items := []*item{ newItem("andrew", 1), newItem("bruce", 2), newItem("kaitlyn", 3), newItem("cauchy", 4), newItem("plato", 1), newItem("platonic", 2), newItem("andrew gallant", 3), newItem("Andrew Gallant", 4), newItem("Andrew", 1), newItem("jim", 1), newItem("jimmy", 2), newItem("jimbo", 3), } groups := make([]*prompt.SelectGroupItem, len(artGroups)) for i, artGroup := range artGroups { groups[i] = slct.AddGroup(artGroup) } for _, item := range items { item.promptItem = slct.AddChoice(item) } geom := headGeom(X) keybind.KeyPressFun( func(X *xgbutil.XUtil, ev xevent.KeyPressEvent) { showGroups := newGroups(groups, items) slct.Show(geom, prompt.TabCompletePrefix, showGroups) }).Connect(X, X.RootWin(), selectActivate, true) println("Loaded...") xevent.Main(X) }
func main() { // Connect to the X server using the DISPLAY environment variable. X, err := xgbutil.NewConn() if err != nil { log.Fatal(err) } // Anytime the keybind (mousebind) package is used, keybind.Initialize // *should* be called once. It isn't strictly necessary, but allows your // keybindings to persist even if the keyboard mapping is changed during // run-time. (Assuming you're using the xevent package's event loop.) // It also handles the case when your modifier map is changed. keybind.Initialize(X) // Create a new window. We will listen for key presses and translate them // only when this window is in focus. (Similar to how `xev` works.) win, err := xwindow.Generate(X) if err != nil { log.Fatalf("Could not generate a new window X id: %s", err) } win.Create(X.RootWin(), 0, 0, 500, 500, xproto.CwBackPixel, 0xffffffff) // Listen for Key{Press,Release} events. win.Listen(xproto.EventMaskKeyPress, xproto.EventMaskKeyRelease) // Map the window. win.Map() // Notice that we use xevent.KeyPressFun instead of keybind.KeyPressFun, // because we aren't trying to make a grab *and* because we want to listen // to *all* key press events, rather than just a particular key sequence // that has been pressed. xevent.KeyPressFun( func(X *xgbutil.XUtil, e xevent.KeyPressEvent) { // keybind.LookupString does the magic of implementing parts of // the X Keyboard Encoding to determine an english representation // of the modifiers/keycode tuple. // N.B. It's working for me, but probably isn't 100% correct in // all environments yet. log.Println("Key:", keybind.LookupString(X, e.State, e.Detail)) }).Connect(X, win.Id) // Finally, start the main event loop. This will route any appropriate // KeyPressEvents to your callback function. log.Println("Program initialized. Start pressing keys!") xevent.Main(X) }
func main() { // winw, winh := 128, 128 time.Sleep(time.Nanosecond) X, err := xgbutil.NewConn() if err != nil { log.Fatal(err) } libre := xproto.Window(0x4a0001d) xclock := xproto.Window(0x480000a) showIcon(X, libre, "libre") showIcon(X, xclock, "xclock") xevent.Main(X) }
func main() { X, err := xgbutil.NewConn() if err != nil { log.Fatal(err) } // Get the list of window ids managed by the window manager. clients, err := ewmh.ClientListGet(X) if err != nil { log.Fatal(err) } // For each client, try to find its icon. If we find one, blend it with // a nice background color and show it in its own window. // Otherwise, skip it. for _, wid := range clients { // FindIcon will find an icon closest to the size specified. // If one can't be found, the resulting image will be scaled // automatically. // To avoid scaling the icon, specify '0' for both the width and height. // In this case, the largest icon found will be returned. xicon, err := xgraphics.FindIcon(X, wid, iconWidth, iconHeight) if err != nil { log.Printf("Could not find icon for window %d.", wid) continue } // Get the name of this client. (It will be set as the icon window's // name.) name, err := ewmh.WmNameGet(X, wid) if err != nil { // not a fatal error log.Println(err) name = "" } // Blend a pink background color so its easy to see that alpha blending // works. xgraphics.BlendBgColor(xicon, color.RGBA{0xff, 0x0, 0xff, 0xff}) xicon.XShowExtra(name, false) } // All we really need to do is block, so a 'select{}' would be sufficient. // But running the event loop will emit errors if anything went wrong. xevent.Main(X) }
func initialize() { var err error X, err := xgbutil.NewConn() if err != nil { log.Fatal(err) } mousebind.Initialize(X) newWindow(X) go xevent.Main(X) display = egl.GetDisplay(egl.DEFAULT_DISPLAY) if ok := egl.Initialize(display, nil, nil); !ok { egl.LogError(egl.GetError()) } if ok := egl.ChooseConfig(display, attr, &config, 1, &numConfig); !ok { egl.LogError(egl.GetError()) } if ok := egl.GetConfigAttrib(display, config, egl.NATIVE_VISUAL_ID, &vid); !ok { egl.LogError(egl.GetError()) } egl.BindAPI(egl.OPENGL_ES_API) context = egl.CreateContext(display, config, egl.NO_CONTEXT, nil) surface = egl.CreateWindowSurface(display, config, egl.NativeWindowType(uintptr(X.RootWin())), nil) var val egl.Int if ok := egl.QuerySurface(display, &val, egl.WIDTH, surface); !ok { egl.LogError(egl.GetError()) } if ok := egl.QuerySurface(display, &val, egl.HEIGHT, surface); !ok { egl.LogError(egl.GetError()) } if ok := egl.GetConfigAttrib(display, config, egl.SURFACE_TYPE, &val); !ok { egl.LogError(egl.GetError()) } gl.ClearColor(0.0, 0, 0, 1.0) p := Program(FragmentShader(fsh), VertexShader(vsh)) gl.UseProgram(p) gl.BindAttribLocation(p, gl.Uint(attrPos), "pos") gl.BindAttribLocation(p, gl.Uint(attrColor), "color") uMatrix = gl.Int(gl.GetUniformLocation(p, "modelviewProjection")) }
func BindKeys(keymap map[string]string) { X, err := xgbutil.NewConn() if err != nil { log.Fatal(err) } keybind.Initialize(X) for k, v := range keymap { v := v err = keybind.KeyPressFun(func(X *xgbutil.XUtil, e xevent.KeyPressEvent) { h.broadcast <- v }).Connect(X, X.RootWin(), k, true) if err != nil { log.Fatal(err) } } log.Println("Program initialized. Start pressing keys!") xevent.Main(X) }
func main() { X, err := xgbutil.NewConn() if err != nil { log.Fatal(err) } keybind.Initialize(X) currentuser, err := user.Current() if err != nil { log.Fatal(err) } configfile := currentuser.HomeDir + "/.config/hotkeys.conf.json" watcher, err := inotify.NewWatcher() if err != nil { log.Fatal(err) } err = watcher.AddWatch(configfile, inotify.IN_CLOSE_WRITE) if err != nil { log.Fatal(err) } go func() { for { select { case ev := <-watcher.Event: log.Println(ev) err := bindall(configfile, X) if err != nil { log.Println(err) continue } case err := <-watcher.Error: log.Println("error:", err) } } }() err = bindall(configfile, X) if err != nil { log.Panicln(err) } xevent.Main(X) }
func main() { X, err := xgbutil.NewConn() if err != nil { log.Fatal(err) } // Anytime the mousebind (keybind) package is used, mousebind.Initialize // *should* be called once. In the case of the mousebind package, this // isn't strictly necessary (currently!), but the 'Drag' features of // the mousebind package won't work without it. mousebind.Initialize(X) // Create two windows to prove we can close one while keeping the // other alive. newWindow(X) newWindow(X) xevent.Main(X) }
func (wa *fullScreenWorkaround) start() { var runner func() runner = func() { w, _ := ewmh.ActiveWindowGet(wa.xu) wa.detectTarget(w) time.AfterFunc(time.Second*5, runner) } runner() root := xwindow.New(wa.xu, wa.xu.RootWin()) root.Listen(xproto.EventMaskPropertyChange) xevent.PropertyNotifyFun(func(XU *xgbutil.XUtil, ev xevent.PropertyNotifyEvent) { if wa.activeWindowAtom == ev.Atom { w, _ := ewmh.ActiveWindowGet(XU) wa.detectTarget(w) } }).Connect(wa.xu, root.Id) xevent.Main(wa.xu) }
func main() { var err error X, err = xgbutil.NewConn() if err != nil { log.Fatal(err) } clientids, err := ewmh.ClientListGet(X) if err != nil { log.Fatal(err) } for _, clientid := range clientids { name, err := ewmh.WmNameGet(X, clientid) if err != nil { continue } if name == "Super Hexagon" { HexWindow = xwindow.New(X, clientid) break } } if HexWindow == nil { log.Fatal("Couldn't find Super Hexagon window.") } //Create a window DisplayWindow, err = xwindow.Generate(X) if err != nil { log.Fatalf("Could not generate a new window X id: %s", err) } dgeom, _ := HexWindow.DecorGeometry() DisplayWindow.Create(X.RootWin(), 0, 0, dgeom.Width(), dgeom.Height(), xproto.CwBackPixel, 0) DisplayWindow.Map() //Start the routine that updates the window go updater() xevent.Main(X) }
func main() { X, err := xgbutil.NewConn() failMeMaybe(err) tray, err := NewSystemTray(X) failMeMaybe(err) hdlr := &Handler{ X: X, } hdlr.Window, err = xwindow.Create(X, X.RootWin()) failMeMaybe(err) hdlr.Window.Move(0, 24) hdlr.Window.Map() tray.Handler = hdlr xevent.Main(X) }
func Start() { if _manager != nil { return } logger.BeginTracing() initGSettings() err := StartKeyBinding() if err != nil { logger.Error("failed start keybinding:", err) logger.EndTracing() finiGSettings() return } _manager = newManager() if _manager == nil { logger.Error("Create keybinding manager failed") finiGSettings() endKeyBinding() return } err = dbus.InstallOnSession(_manager) if err != nil { logger.Error("Install DBus Failed:", err) finalize() return } err = dbus.InstallOnSession(_manager.mediaKey) if err != nil { logger.Error("Install DBus Failed:", err) finalize() return } go xevent.Main(X) }
func main() { X, err := xgbutil.NewConn() fatal(err) keybind.Initialize(X) cycle := prompt.NewCycle(X, prompt.DefaultCycleTheme, prompt.DefaultCycleConfig) clients, err := ewmh.ClientListStackingGet(X) fatal(err) items := make([]*prompt.CycleItem, 0) for i := len(clients) - 1; i >= 0; i-- { item := cycle.AddChoice(newWindow(X, cycle.Id(), clients[i])) items = append(items, item) } keyHandlers(X, cycle, items) println("Loaded...") xevent.Main(X) }
func main() { rand.Seed(time.Now().UnixNano()) X, err := xgbutil.NewConn() if err != nil { log.Fatal(err) } // Create three gradient windows of varying size with random colors. // Waiting a little bit inbetween seems to increase the diversity of the // random colors. newGradientWindow(X, 200, 200, newRandomColor(), newRandomColor()) time.Sleep(500 * time.Millisecond) newGradientWindow(X, 400, 400, newRandomColor(), newRandomColor()) time.Sleep(500 * time.Millisecond) newGradientWindow(X, 600, 600, newRandomColor(), newRandomColor()) xevent.Main(X) }