diff --git a/client.go b/client.go index 52ff9a9..392a00d 100644 --- a/client.go +++ b/client.go @@ -3,7 +3,7 @@ package main import ( "fmt" - "code.google.com/p/jamslam-x-go-binding/xgb" + "github.com/BurntSushi/xgb/xproto" "github.com/BurntSushi/xgbutil/ewmh" "github.com/BurntSushi/xgbutil/icccm" @@ -36,7 +36,7 @@ type client struct { hints *icccm.Hints nhints *icccm.NormalHints protocols []string - transientFor xgb.Id + transientFor xproto.Window wmclass *icccm.WmClass stateStore map[string]*clientState @@ -49,7 +49,7 @@ type client struct { frameFull *frameFull } -func newClient(id xgb.Id) *client { +func newClient(id xproto.Window) *client { return &client{ window: newWindow(id), workspace: nil, @@ -206,7 +206,7 @@ func (c *client) Close() { return } - X.Conn().SendEvent(false, c.window.id, 0, cm.Bytes()) + xproto.SendEvent(X.Conn(), false, c.window.id, 0, string(cm.Bytes())) } else { c.window.kill() } @@ -219,14 +219,19 @@ func (c *client) Close() { // (unmapIgnore is incremented whenever Wingo unmaps a window. When Wingo // unmaps a window, we *don't* want to delete it, just hide it.) func (c *client) Alive() bool { - X.Flush() // fills up the XGB event queue with ready events + X.Sync() // fills up the XGB event queue with ready events xevent.Read(X, false) // fills up the xgbutil event queue without blocking // we only consider a client marked for deletion when 'ignore' reaches 0 ignore := c.unmapIgnore - for _, ev := range X.QueuePeek() { + for _, everr := range xevent.Peek(X) { + if everr.Err != nil { + continue + } + wid := c.Win().id - if unmap, ok := ev.(xgb.UnmapNotifyEvent); ok && unmap.Window == wid { + ev := everr.Event + if um, ok := ev.(xproto.UnmapNotifyEvent); ok && um.Window == wid { if ignore <= 0 { return false } @@ -240,7 +245,7 @@ func (c *client) Alive() bool { // Namely, when we know the window has been unmapped but are not sure // if it is still an X resource. func (c *client) TrulyAlive() bool { - _, err := xwindow.RawGeometry(X, c.window.id) + _, err := xwindow.RawGeometry(X, xproto.Drawable(c.window.id)) if err != nil { return false } @@ -277,13 +282,13 @@ func (c *client) Focus() { cm, err := xevent.NewClientMessage(32, c.window.id, wm_protocols, int(wm_take_focus), - int(X.GetTime())) + int(X.TimeGet())) if err != nil { logger.Warning.Println(err) return } - X.Conn().SendEvent(false, c.window.id, 0, cm.Bytes()) + xproto.SendEvent(X.Conn(), false, c.window.id, 0, string(cm.Bytes())) c.Focused() } @@ -445,7 +450,7 @@ func (c *client) Geom() xrect.Rect { return c.window.geom } -func (c *client) Id() xgb.Id { +func (c *client) Id() xproto.Window { return c.window.id } diff --git a/client_geometry.go b/client_geometry.go index b45fd1e..2d4084b 100644 --- a/client_geometry.go +++ b/client_geometry.go @@ -1,7 +1,7 @@ package main import ( - "code.google.com/p/jamslam-x-go-binding/xgb" + "github.com/BurntSushi/xgb/xproto" "github.com/BurntSushi/xgbutil/icccm" "github.com/BurntSushi/xgbutil/xrect" @@ -26,13 +26,13 @@ func (c *client) GravitizeX(x int, gravity int) int { f := c.Frame() switch { - case g == xgb.GravityStatic || g == xgb.GravityBitForget: + case g == xproto.GravityStatic || g == xproto.GravityBitForget: x -= f.Left() - case g == xgb.GravityNorth || g == xgb.GravitySouth || - g == xgb.GravityCenter: + case g == xproto.GravityNorth || g == xproto.GravitySouth || + g == xproto.GravityCenter: x -= abs(f.Left()-f.Right()) / 2 - case g == xgb.GravityNorthEast || g == xgb.GravityEast || - g == xgb.GravitySouthEast: + case g == xproto.GravityNorthEast || g == xproto.GravityEast || + g == xproto.GravitySouthEast: x -= f.Left() + f.Right() } @@ -58,13 +58,13 @@ func (c *client) GravitizeY(y int, gravity int) int { f := c.Frame() switch { - case g == xgb.GravityStatic || g == xgb.GravityBitForget: + case g == xproto.GravityStatic || g == xproto.GravityBitForget: y -= f.Top() - case g == xgb.GravityEast || g == xgb.GravityWest || - g == xgb.GravityCenter: + case g == xproto.GravityEast || g == xproto.GravityWest || + g == xproto.GravityCenter: y -= abs(f.Top()-f.Bottom()) / 2 - case g == xgb.GravitySouthEast || g == xgb.GravitySouth || - g == xgb.GravitySouthWest: + case g == xproto.GravitySouthEast || g == xproto.GravitySouth || + g == xproto.GravitySouthWest: y -= f.Top() + f.Bottom() } diff --git a/client_icon.go b/client_icon.go index 8651c17..837eacb 100644 --- a/client_icon.go +++ b/client_icon.go @@ -1,103 +1,19 @@ package main import ( - "image" - "image/color" "image/draw" - "github.com/BurntSushi/xgbutil/ewmh" - "github.com/BurntSushi/xgbutil/icccm" "github.com/BurntSushi/xgbutil/xgraphics" "github.com/BurntSushi/wingo/logger" ) -func (c *client) iconImage(width, height int) (draw.Image, draw.Image) { - var img, mask draw.Image - var iok, mok bool - - img, mask, iok, mok = c.iconTryEwmh(width, height) - if iok { - goto DONE - } - - img, mask, iok, mok = c.iconTryIcccm() - if iok { - goto DONE - } - - iok, mok = false, false - img = THEME.defaultIcon - if img != nil { - iok = true - goto DONE - } - -DONE: - // If we've got an image, great! If not, just create a completely - // transparent image. It will take up space, but it won't look - // horrendous and we won't crash. - if iok { - img = xgraphics.Scale(img, width, height) - } else { - uni := image.NewUniform(color.RGBA{0, 0, 0, 0}) - img = image.NewRGBA(image.Rect(0, 0, width, height)) - draw.Draw(img, img.Bounds(), uni, image.ZP, draw.Src) - } - - // Just as we did for img above, if we don't have a mask, create a benign - // mask in its stead. - if mok { - mask = xgraphics.Scale(mask, width, height) - } else { - uni := image.NewUniform(color.RGBA{0, 0, 0, 255}) - mask = image.NewRGBA(img.Bounds()) - draw.Draw(mask, mask.Bounds(), uni, image.ZP, draw.Src) - } - return img, mask -} - -func (c *client) iconTryEwmh(width, height int) ( - *image.RGBA, *image.RGBA, bool, bool) { - - icons, err := ewmh.WmIconGet(X, c.Id()) - if err != nil { - logger.Warning.Printf( - "Could not get EWMH icon for window %s because: %v", c, err) - return nil, nil, false, false - } - - icon := xgraphics.FindBestIcon(width, height, icons) - if icon == nil { - logger.Warning.Printf( - "Could not find any decent icon for size (%d, %d) "+ - " on window %s.", width, height, c) - return nil, nil, false, false - } - - img, mask := xgraphics.EwmhIconToImage(icon) - return img, mask, true, true -} - -func (c *client) iconTryIcccm() (*image.RGBA, *image.RGBA, bool, bool) { - if c.hints.Flags&icccm.HintIconPixmap == 0 || - c.hints.IconPixmap == 0 || c.hints.IconMask == 0 { - return nil, nil, false, false - } - - img, err := xgraphics.PixmapToImage(X, c.hints.IconPixmap) - if err != nil { - logger.Warning.Printf("Could not get IconPixmap from window %s "+ - "because: %v", c, err) - return nil, nil, false, false - } - - mask, err := xgraphics.BitmapToImage(X, c.hints.IconMask) +func (c *client) iconImage(width, height int) draw.Image { + ximg, err := xgraphics.FindIcon(X, c.Id(), width, height) if err != nil { - logger.Warning.Printf("Could not get IconMask from window %s "+ - "because: %v", c, err) - return img, nil, true, false + logger.Message.Printf("Could not find icon for '%s': %s", c, err) + ximg = xgraphics.NewConvert(X, THEME.defaultIcon) } - return img, mask, true, true + return ximg } diff --git a/client_manage.go b/client_manage.go index eef2142..1689c45 100644 --- a/client_manage.go +++ b/client_manage.go @@ -3,7 +3,7 @@ package main import ( "strings" - "code.google.com/p/jamslam-x-go-binding/xgb" + "github.com/BurntSushi/xgb/xproto" "github.com/BurntSushi/xgbutil" "github.com/BurntSushi/xgbutil/ewmh" @@ -204,8 +204,8 @@ func (c *client) initPopulate() error { func (c *client) listen() { // Listen to the client for property and structure changes. - c.window.listen(xgb.EventMaskPropertyChange | - xgb.EventMaskStructureNotify) + c.window.listen(xproto.EventMaskPropertyChange | + xproto.EventMaskStructureNotify) // attach some event handlers xevent.PropertyNotifyFun( diff --git a/command.go b/command.go index 81be96d..535e0df 100644 --- a/command.go +++ b/command.go @@ -8,7 +8,7 @@ import ( "time" "unicode" - "code.google.com/p/jamslam-x-go-binding/xgb" + "github.com/BurntSushi/xgb/xproto" "github.com/BurntSushi/xgbutil" "github.com/BurntSushi/xgbutil/xevent" @@ -174,7 +174,7 @@ func commandArgsClient(args []string) (*client, bool) { return nil, false } - goodId := xgb.Id(maybeId64) + goodId := xproto.Window(maybeId64) for _, c := range WM.clients { if c.Id() == goodId { return c, true @@ -473,7 +473,7 @@ func cmdPromptSelect(args ...string) func() { func cmdQuit() func() { return func() { logger.Message.Println("The User has told us to quit.") - X.Quit() + xevent.Quit(X) } } diff --git a/command_key.go b/command_key.go index e59e2d2..3a5cbf0 100644 --- a/command_key.go +++ b/command_key.go @@ -45,7 +45,7 @@ func (kcmd keyCommand) attach(run func()) { if kcmd.cmd == "PromptCyclePrev" || kcmd.cmd == "PromptCycleNext" { // We've got to parse the key string first and make sure // there are some modifiers; otherwise this utterly fails! - mods, _ := keybind.ParseString(X, kcmd.keyStr) + mods, _, _ := keybind.ParseString(X, kcmd.keyStr) if mods == 0 { logger.Warning.Printf("Sorry but the key binding '%s' for the %s "+ "command is invalid. It must have a modifier "+ @@ -57,22 +57,22 @@ func (kcmd keyCommand) attach(run func()) { keybind.KeyPressFun( func(X *xgbutil.XUtil, ev xevent.KeyPressEvent) { run() - }).Connect(X, ROOT.id, kcmd.keyStr) + }).Connect(X, ROOT.id, kcmd.keyStr, true) keybind.KeyPressFun( func(X *xgbutil.XUtil, ev xevent.KeyPressEvent) { run() - }).Connect(X, X.Dummy(), kcmd.keyStr) + }).Connect(X, X.Dummy(), kcmd.keyStr, true) } else { if kcmd.down { keybind.KeyPressFun( func(X *xgbutil.XUtil, ev xevent.KeyPressEvent) { run() - }).Connect(X, ROOT.id, kcmd.keyStr) + }).Connect(X, ROOT.id, kcmd.keyStr, true) } else { keybind.KeyReleaseFun( func(X *xgbutil.XUtil, ev xevent.KeyReleaseEvent) { run() - }).Connect(X, ROOT.id, kcmd.keyStr) + }).Connect(X, ROOT.id, kcmd.keyStr, true) } } } diff --git a/command_mouse.go b/command_mouse.go index 1f421d7..e1efba9 100644 --- a/command_mouse.go +++ b/command_mouse.go @@ -13,7 +13,7 @@ package main */ import ( - "code.google.com/p/jamslam-x-go-binding/xgb" + "github.com/BurntSushi/xgb/xproto" "github.com/BurntSushi/xgbutil" "github.com/BurntSushi/xgbutil/mousebind" @@ -29,7 +29,7 @@ type mouseCommand struct { direction uint32 // only used by Resize command } -func (mcmd mouseCommand) setup(c *client, wid xgb.Id) { +func (mcmd mouseCommand) setup(c *client, wid xproto.Window) { // Check if this command is a drag... If it is, it needs special attention. if mcmd.cmd == "Move" { c.setupMoveDrag(wid, mcmd.buttonStr, true) @@ -57,9 +57,11 @@ func (mcmd mouseCommand) setup(c *client, wid xgb.Id) { // setupMoveDrag does the boiler plate for registering this client's // "move" drag. -func (c *client) setupMoveDrag(dragWin xgb.Id, buttonStr string, grab bool) { +func (c *client) setupMoveDrag(dragWin xproto.Window, + buttonStr string, grab bool) { + dStart := xgbutil.MouseDragBeginFun( - func(X *xgbutil.XUtil, rx, ry, ex, ey int) (bool, xgb.Id) { + func(X *xgbutil.XUtil, rx, ry, ex, ey int) (bool, xproto.Cursor) { frameMoveBegin(c.Frame(), rx, ry, ex, ey) return true, cursorFleur }) @@ -71,16 +73,16 @@ func (c *client) setupMoveDrag(dragWin xgb.Id, buttonStr string, grab bool) { func(X *xgbutil.XUtil, rx, ry, ex, ey int) { frameMoveEnd(c.Frame(), rx, ry, ex, ey) }) - mousebind.Drag(X, dragWin, buttonStr, grab, dStart, dStep, dEnd) + mousebind.Drag(X, X.Dummy(), dragWin, buttonStr, grab, dStart, dStep, dEnd) } // setupResizeDrag does the boiler plate for registering this client's // "resize" drag. -func (c *client) setupResizeDrag(dragWin xgb.Id, buttonStr string, grab bool, - direction uint32) { +func (c *client) setupResizeDrag(dragWin xproto.Window, + buttonStr string, grab bool, direction uint32) { dStart := xgbutil.MouseDragBeginFun( - func(X *xgbutil.XUtil, rx, ry, ex, ey int) (bool, xgb.Id) { + func(X *xgbutil.XUtil, rx, ry, ex, ey int) (bool, xproto.Cursor) { return frameResizeBegin(c.Frame(), direction, rx, ry, ex, ey) }) dStep := xgbutil.MouseDragFun( @@ -91,10 +93,10 @@ func (c *client) setupResizeDrag(dragWin xgb.Id, buttonStr string, grab bool, func(X *xgbutil.XUtil, rx, ry, ex, ey int) { frameResizeEnd(c.Frame(), rx, ry, ex, ey) }) - mousebind.Drag(X, dragWin, buttonStr, grab, dStart, dStep, dEnd) + mousebind.Drag(X, X.Dummy(), dragWin, buttonStr, grab, dStart, dStep, dEnd) } -func (mcmd mouseCommand) attachClick(wid xgb.Id, run func()) { +func (mcmd mouseCommand) attachClick(wid xproto.Window, run func()) { mousebind.ButtonPressFun( func(X *xgbutil.XUtil, ev xevent.ButtonPressEvent) { // empty @@ -105,7 +107,9 @@ func (mcmd mouseCommand) attachClick(wid xgb.Id, run func()) { }).Connect(X, wid, mcmd.buttonStr, false, false) } -func (mcmd mouseCommand) attach(wid xgb.Id, run func(), propagate, grab bool) { +func (mcmd mouseCommand) attach(wid xproto.Window, run func(), + propagate, grab bool) { + if mcmd.down { mousebind.ButtonPressFun( func(X *xgbutil.XUtil, ev xevent.ButtonPressEvent) { @@ -143,7 +147,7 @@ func (c *client) frameMouseConfig() { } } -func (c *client) framePieceMouseConfig(piece string, pieceid xgb.Id) { +func (c *client) framePieceMouseConfig(piece string, pieceid xproto.Window) { for _, mcmd := range CONF.mouse[piece] { mcmd.setup(c, pieceid) } diff --git a/config_theme.go b/config_theme.go index 8557710..79595ff 100644 --- a/config_theme.go +++ b/config_theme.go @@ -173,18 +173,18 @@ func loadTheme() error { } // re-color some images - xgraphics.ColorImage(THEME.full.aCloseButton, - colorFromInt(THEME.full.aCloseColor)) - xgraphics.ColorImage(THEME.full.iCloseButton, - colorFromInt(THEME.full.iCloseColor)) - xgraphics.ColorImage(THEME.full.aMaximizeButton, - colorFromInt(THEME.full.aMaximizeColor)) - xgraphics.ColorImage(THEME.full.iMaximizeButton, - colorFromInt(THEME.full.iMaximizeColor)) - xgraphics.ColorImage(THEME.full.aMinimizeButton, - colorFromInt(THEME.full.aMinimizeColor)) - xgraphics.ColorImage(THEME.full.iMinimizeButton, - colorFromInt(THEME.full.iMinimizeColor)) + // xgraphics.ColorImage(THEME.full.aCloseButton, + // colorFromInt(THEME.full.aCloseColor)) + // xgraphics.ColorImage(THEME.full.iCloseButton, + // colorFromInt(THEME.full.iCloseColor)) + // xgraphics.ColorImage(THEME.full.aMaximizeButton, + // colorFromInt(THEME.full.aMaximizeColor)) + // xgraphics.ColorImage(THEME.full.iMaximizeButton, + // colorFromInt(THEME.full.iMaximizeColor)) + // xgraphics.ColorImage(THEME.full.aMinimizeButton, + // colorFromInt(THEME.full.aMinimizeColor)) + // xgraphics.ColorImage(THEME.full.iMinimizeButton, + // colorFromInt(THEME.full.iMinimizeColor)) // Scale some images... THEME.full.aCloseButton = xgraphics.Scale(THEME.full.aCloseButton, @@ -396,7 +396,7 @@ func setGradient(k wini.Key, clr *themeColor) { } func builtInIcon() draw.Image { - img, err := xgraphics.LoadPngFromBytes(bindata.WingoPng()) + img, err := xgraphics.NewBytes(X, bindata.WingoPng()) if err != nil { logger.Warning.Printf("Could not get built in icon image because: %v", err) @@ -406,7 +406,7 @@ func builtInIcon() draw.Image { } func builtInButton(loadBuiltIn func() []byte) draw.Image { - img, err := xgraphics.LoadPngFromBytes(loadBuiltIn()) + img, err := xgraphics.NewBytes(X, loadBuiltIn()) if err != nil { logger.Warning.Printf("Could not get built in button image because: %v", err) @@ -417,7 +417,7 @@ func builtInButton(loadBuiltIn func() []byte) draw.Image { func setImage(k wini.Key, place *draw.Image) { if v, ok := getLastString(k); ok { - img, err := xgraphics.LoadPngFromFile(v) + img, err := xgraphics.NewFileName(X, v) if err != nil { logger.Warning.Printf( "Could not load '%s' as a png image because: %v", v, err) diff --git a/cursors.go b/cursors.go index 5c4c4ed..da17ce2 100644 --- a/cursors.go +++ b/cursors.go @@ -3,28 +3,37 @@ */ package main -import "code.google.com/p/jamslam-x-go-binding/xgb" +import ( + "github.com/BurntSushi/xgb/xproto" -import "github.com/BurntSushi/xgbutil/xcursor" + "github.com/BurntSushi/xgbutil/xcursor" + + "github.com/BurntSushi/wingo/logger" +) var ( - cursorLeftPtr xgb.Id - cursorFleur xgb.Id - cursorWatch xgb.Id - cursorTopSide xgb.Id - cursorTopRightCorner xgb.Id - cursorRightSide xgb.Id - cursorBottomRightCorner xgb.Id - cursorBottomSide xgb.Id - cursorBottomLeftCorner xgb.Id - cursorLeftSide xgb.Id - cursorTopLeftCorner xgb.Id + cursorLeftPtr xproto.Cursor + cursorFleur xproto.Cursor + cursorWatch xproto.Cursor + cursorTopSide xproto.Cursor + cursorTopRightCorner xproto.Cursor + cursorRightSide xproto.Cursor + cursorBottomRightCorner xproto.Cursor + cursorBottomSide xproto.Cursor + cursorBottomLeftCorner xproto.Cursor + cursorLeftSide xproto.Cursor + cursorTopLeftCorner xproto.Cursor ) func setupCursors() { // lazy... - cc := func(cursor uint16) xgb.Id { - return xcursor.CreateCursor(X, cursor) + cc := func(cursor uint16) xproto.Cursor { + cid, err := xcursor.CreateCursor(X, cursor) + if err != nil { + logger.Warning.Printf("Could not load cursor '%d'.", cursor) + return 0 + } + return cid } cursorLeftPtr = cc(xcursor.LeftPtr) diff --git a/frame.go b/frame.go index 38b9aef..5abdc42 100644 --- a/frame.go +++ b/frame.go @@ -1,7 +1,7 @@ package main import ( - "code.google.com/p/jamslam-x-go-binding/xgb" + "github.com/BurntSushi/xgb/xproto" "github.com/BurntSushi/xgbutil/xevent" "github.com/BurntSushi/xgbutil/xgraphics" @@ -18,9 +18,9 @@ const ( type Frame interface { Client() *client ConfigureClient(flags, x, y, w, h int, - sibling xgb.Id, stackMode byte, ignoreHints bool) + sibling xproto.Window, stackMode byte, ignoreHints bool) ConfigureFrame(flags, x, y, w, h int, - sibling xgb.Id, stackMode byte, ignoreHints, sendNotify bool) + sibling xproto.Window, stackMode byte, ignoreHints, sendNotify bool) Current() bool Destroy() FrameState() int @@ -29,7 +29,7 @@ type Frame interface { Off() On() Parent() *frameParent - ParentId() xgb.Id + ParentId() xproto.Window ParentWin() *window State() int Active() @@ -57,11 +57,11 @@ type frameParent struct { } func newParent(c *client) *frameParent { - mask := xgb.CWEventMask - val := uint32(xgb.EventMaskSubstructureRedirect | - xgb.EventMaskButtonPress | xgb.EventMaskButtonRelease) + mask := xproto.CwEventMask + val := uint32(xproto.EventMaskSubstructureRedirect | + xproto.EventMaskButtonPress | xproto.EventMaskButtonRelease) if CONF.ffm { - val |= xgb.EventMaskEnterWindow + val |= xproto.EventMaskEnterWindow } parent := createWindow(X.RootWin(), mask, val) @@ -70,7 +70,7 @@ func newParent(c *client) *frameParent { client: c, } - X.Conn().ReparentWindow(c.Id(), parent.id, 0, 0) + xproto.ReparentWindow(X.Conn(), c.Id(), parent.id, 0, 0) return p } @@ -84,11 +84,11 @@ func (p *frameParent) Win() *window { // of the available states for quick switching. type framePiece struct { win *window - imgActive xgb.Id - imgInactive xgb.Id + imgActive xproto.Pixmap + imgInactive xproto.Pixmap } -func newFramePiece(win *window, imgA, imgI xgb.Id) framePiece { +func newFramePiece(win *window, imgA, imgI xproto.Pixmap) framePiece { return framePiece{win: win, imgActive: imgA, imgInactive: imgI} } @@ -99,12 +99,12 @@ func (p *framePiece) destroy() { } func (p *framePiece) active() { - p.win.change(xgb.CWBackPixmap, uint32(p.imgActive)) + p.win.change(xproto.CwBackPixmap, uint32(p.imgActive)) p.win.clear() } func (p *framePiece) inactive() { - p.win.change(xgb.CWBackPixmap, uint32(p.imgInactive)) + p.win.change(xproto.CwBackPixmap, uint32(p.imgInactive)) p.win.clear() } @@ -165,7 +165,7 @@ func FrameReset(f Frame) { // FrameMR is short for FrameMoveresize. func FrameMR(f Frame, flags int, x, y int, w, h int, ignoreHints bool) { - f.ConfigureClient(flags, x, y, w, h, xgb.Id(0), 0, ignoreHints) + f.ConfigureClient(flags, x, y, w, h, 0, 0, ignoreHints) } // FrameValidateHeight validates a height of a *frame*, which is equivalent @@ -214,7 +214,7 @@ func FrameConfigureClient(f Frame, flags, x, y, w, h int) (int, int, int, int) { // Also, the fx and fy coordinates are interpreted plainly as root window // coordinates. (No gravitization.) func FrameConfigureFrame(f Frame, flags, fx, fy, fw, fh int, - sibling xgb.Id, stackMode byte, ignoreHints bool, sendNotify bool) { + sibling xproto.Window, stackMode byte, ignoreHints bool, sendNotify bool) { cw, ch := fw, fh framex, framey, _, _ := xrect.RectPieces(f.Geom()) @@ -248,8 +248,8 @@ func FrameConfigureFrame(f Frame, flags, fx, fy, fw, fh int, f.Client().Id(), 0, framex, framey, clientw, clienth, 0, false) - X.Conn().SendEvent(false, f.Client().Id(), xgb.EventMaskStructureNotify, - configNotify.Bytes()) + xproto.SendEvent(X.Conn(), false, f.Client().Id(), + xproto.EventMaskStructureNotify, string(configNotify.Bytes())) } f.Parent().Win().configure(flags, fx, fy, fw, fh, sibling, stackMode) diff --git a/frame_abst.go b/frame_abst.go index 079810b..478ef7f 100644 --- a/frame_abst.go +++ b/frame_abst.go @@ -1,8 +1,8 @@ package main -import "code.google.com/p/jamslam-x-go-binding/xgb" - import ( + "github.com/BurntSushi/xgb/xproto" + "github.com/BurntSushi/xgbutil/xrect" ) @@ -25,7 +25,7 @@ func newFrameAbst(p *frameParent, c *client) *abstFrame { func (f *abstFrame) Destroy() { if f.Client().TrulyAlive() { - X.Conn().ReparentWindow(f.Client().Id(), ROOT.id, 0, 0) + xproto.ReparentWindow(X.Conn(), f.Client().Id(), ROOT.id, 0, 0) } f.parent.window.destroy() } @@ -66,7 +66,7 @@ func (f *abstFrame) Parent() *frameParent { return f.parent } -func (f *abstFrame) ParentId() xgb.Id { +func (f *abstFrame) ParentId() xproto.Window { return f.parent.window.id } diff --git a/frame_borders.go b/frame_borders.go index cf65a0d..dd18644 100644 --- a/frame_borders.go +++ b/frame_borders.go @@ -1,6 +1,8 @@ package main -import "code.google.com/p/jamslam-x-go-binding/xgb" +import ( + "github.com/BurntSushi/xgb/xproto" +) type frameBorders struct { *abstFrame @@ -90,7 +92,7 @@ func (f *frameBorders) Active() { f.bottomLeft.active() f.bottomRight.active() - f.ParentWin().change(xgb.CWBackPixel, uint32(0xff0000)) + f.ParentWin().change(xproto.CwBackPixel, uint32(0xff0000)) f.ParentWin().clear() } @@ -105,7 +107,7 @@ func (f *frameBorders) Inactive() { f.bottomLeft.inactive() f.bottomRight.inactive() - f.ParentWin().change(xgb.CWBackPixel, uint32(0xff0000)) + f.ParentWin().change(xproto.CwBackPixel, uint32(0xff0000)) f.ParentWin().clear() } @@ -170,14 +172,14 @@ func (f *frameBorders) Right() int { } func (f *frameBorders) ConfigureClient(flags, x, y, w, h int, - sibling xgb.Id, stackMode byte, ignoreHints bool) { + sibling xproto.Window, stackMode byte, ignoreHints bool) { x, y, w, h = FrameConfigureClient(f, flags, x, y, w, h) f.ConfigureFrame(flags, x, y, w, h, sibling, stackMode, ignoreHints, true) } func (f *frameBorders) ConfigureFrame(flags, fx, fy, fw, fh int, - sibling xgb.Id, stackMode byte, ignoreHints bool, sendNotify bool) { + sibling xproto.Window, stackMode byte, ignoreHints bool, sendNotify bool) { FrameConfigureFrame(f, flags, fx, fy, fw, fh, sibling, stackMode, ignoreHints, sendNotify) diff --git a/frame_borders_pieces.go b/frame_borders_pieces.go index 6f0e4f7..4e3ca58 100644 --- a/frame_borders_pieces.go +++ b/frame_borders_pieces.go @@ -1,16 +1,18 @@ package main -import "code.google.com/p/jamslam-x-go-binding/xgb" - import ( + "github.com/BurntSushi/xgb/xproto" + "github.com/BurntSushi/xgbutil/xgraphics" ) -func (f *frameBorders) newPieceWindow(ident string, cursor xgb.Id) *window { - mask := xgb.CWBackPixmap | xgb.CWEventMask | xgb.CWCursor - vals := []uint32{xgb.BackPixmapParentRelative, - xgb.EventMaskButtonPress | xgb.EventMaskButtonRelease | - xgb.EventMaskButtonMotion | xgb.EventMaskPointerMotion, +func (f *frameBorders) newPieceWindow(ident string, + cursor xproto.Cursor) *window { + + mask := xproto.CwBackPixmap | xproto.CwEventMask | xproto.CwCursor + vals := []uint32{xproto.BackPixmapParentRelative, + xproto.EventMaskButtonPress | xproto.EventMaskButtonRelease | + xproto.EventMaskButtonMotion | xproto.EventMaskPointerMotion, uint32(cursor)} win := createWindow(f.ParentId(), mask, vals...) @@ -20,7 +22,7 @@ func (f *frameBorders) newPieceWindow(ident string, cursor xgb.Id) *window { } func (f *frameBorders) pieceImages(borderTypes, gradientType, gradientDir, - width, height int) (xgb.Id, xgb.Id) { + width, height int) (xproto.Pixmap, xproto.Pixmap) { imgA := renderBorder(borderTypes, THEME.borders.aThinColor, THEME.borders.aBorderColor, @@ -32,7 +34,7 @@ func (f *frameBorders) pieceImages(borderTypes, gradientType, gradientDir, } func (f *frameBorders) cornerImages(borderTypes, - diagonal int) (xgb.Id, xgb.Id) { + diagonal int) (xproto.Pixmap, xproto.Pixmap) { imgA := renderCorner(borderTypes, THEME.borders.aThinColor, THEME.borders.aBorderColor, diff --git a/frame_full.go b/frame_full.go index e661dbc..310a4e5 100644 --- a/frame_full.go +++ b/frame_full.go @@ -1,7 +1,7 @@ package main import ( - "code.google.com/p/jamslam-x-go-binding/xgb" + "github.com/BurntSushi/xgb/xproto" "github.com/BurntSushi/xgbutil/xgraphics" @@ -155,7 +155,7 @@ func (f *frameFull) Active() { f.buttonMaximize.active() f.buttonMinimize.active() - f.ParentWin().change(xgb.CWBackPixel, uint32(0xffffff)) + f.ParentWin().change(xproto.CwBackPixel, uint32(0xffffff)) f.ParentWin().clear() } @@ -182,7 +182,7 @@ func (f *frameFull) Inactive() { f.buttonMaximize.inactive() f.buttonMinimize.inactive() - f.ParentWin().change(xgb.CWBackPixel, uint32(0xffffff)) + f.ParentWin().change(xproto.CwBackPixel, uint32(0xffffff)) f.ParentWin().clear() } @@ -270,7 +270,7 @@ func (f *frameFull) Right() int { } func (f *frameFull) ConfigureClient(flags, x, y, w, h int, - sibling xgb.Id, stackMode byte, ignoreHints bool) { + sibling xproto.Window, stackMode byte, ignoreHints bool) { x, y, w, h = FrameConfigureClient(f, flags, x, y, w, h) f.ConfigureFrame(flags, x, y, w, h, sibling, stackMode, ignoreHints, @@ -278,7 +278,7 @@ func (f *frameFull) ConfigureClient(flags, x, y, w, h int, } func (f *frameFull) ConfigureFrame(flags, fx, fy, fw, fh int, - sibling xgb.Id, stackMode byte, ignoreHints bool, sendNotify bool) { + sibling xproto.Window, stackMode byte, ignoreHints bool, sendNotify bool) { FrameConfigureFrame(f, flags, fx, fy, fw, fh, sibling, stackMode, ignoreHints, sendNotify) @@ -322,10 +322,10 @@ func (f *frameFull) updateIcon() { THEME.full.titleSize, THEME.full.titleSize, renderGradientVert, renderGradientRegular) - img, msk := f.Client().iconImage(THEME.full.titleSize-4, + img := f.Client().iconImage(THEME.full.titleSize-4, THEME.full.titleSize-4) - xgraphics.Blend(imgA, img, msk, 100, 2, 2) - xgraphics.Blend(imgI, img, msk, 100, 2, 2) + xgraphics.BlendOld(imgA, img, nil, 100, 2, 2) + xgraphics.BlendOld(imgI, img, nil, 100, 2, 2) if f.icon.imgActive > 0 { xgraphics.FreePixmap(X, f.icon.imgActive) diff --git a/frame_full_pieces.go b/frame_full_pieces.go index b79842d..0822e6f 100644 --- a/frame_full_pieces.go +++ b/frame_full_pieces.go @@ -1,22 +1,16 @@ package main -// import ( -// "image" -// "image/color" -// "image/draw" -// ) - -import "code.google.com/p/jamslam-x-go-binding/xgb" - import ( + "github.com/BurntSushi/xgb/xproto" + "github.com/BurntSushi/xgbutil/xgraphics" ) -func (f *frameFull) newPieceWindow(ident string, cursor xgb.Id) *window { - mask := xgb.CWBackPixmap | xgb.CWEventMask | xgb.CWCursor - vals := []uint32{xgb.BackPixmapParentRelative, - xgb.EventMaskButtonPress | xgb.EventMaskButtonRelease | - xgb.EventMaskButtonMotion | xgb.EventMaskPointerMotion, +func (f *frameFull) newPieceWindow(ident string, cursor xproto.Cursor) *window { + mask := xproto.CwBackPixmap | xproto.CwEventMask | xproto.CwCursor + vals := []uint32{xproto.BackPixmapParentRelative, + xproto.EventMaskButtonPress | xproto.EventMaskButtonRelease | + xproto.EventMaskButtonMotion | xproto.EventMaskPointerMotion, uint32(cursor)} win := createWindow(f.ParentId(), mask, vals...) @@ -33,8 +27,8 @@ func (f *frameFull) newButtonClose() framePiece { THEME.full.titleSize, THEME.full.titleSize, renderGradientVert, renderGradientRegular) - xgraphics.Blend(imgA, THEME.full.aCloseButton, nil, 100, 0, 0) - xgraphics.Blend(imgI, THEME.full.iCloseButton, nil, 100, 0, 0) + xgraphics.BlendOld(imgA, THEME.full.aCloseButton, nil, 100, 0, 0) + xgraphics.BlendOld(imgI, THEME.full.iCloseButton, nil, 100, 0, 0) win := f.newPieceWindow("close", 0) win.moveresize(DoY|DoW|DoH, @@ -52,8 +46,8 @@ func (f *frameFull) newButtonMaximize() framePiece { THEME.full.titleSize, THEME.full.titleSize, renderGradientVert, renderGradientRegular) - xgraphics.Blend(imgA, THEME.full.aMaximizeButton, nil, 100, 0, 0) - xgraphics.Blend(imgI, THEME.full.iMaximizeButton, nil, 100, 0, 0) + xgraphics.BlendOld(imgA, THEME.full.aMaximizeButton, nil, 100, 0, 0) + xgraphics.BlendOld(imgI, THEME.full.iMaximizeButton, nil, 100, 0, 0) win := f.newPieceWindow("maximize", 0) win.moveresize(DoY|DoW|DoH, @@ -71,8 +65,8 @@ func (f *frameFull) newButtonMinimize() framePiece { THEME.full.titleSize, THEME.full.titleSize, renderGradientVert, renderGradientRegular) - xgraphics.Blend(imgA, THEME.full.aMinimizeButton, nil, 100, 0, 0) - xgraphics.Blend(imgI, THEME.full.iMinimizeButton, nil, 100, 0, 0) + xgraphics.BlendOld(imgA, THEME.full.aMinimizeButton, nil, 100, 0, 0) + xgraphics.BlendOld(imgI, THEME.full.iMinimizeButton, nil, 100, 0, 0) win := f.newPieceWindow("minimize", 0) win.moveresize(DoY|DoW|DoH, @@ -122,7 +116,9 @@ func (f *frameFull) newIcon() framePiece { // on the borders of a 'full' frame. // -func (f *frameFull) borderImages(width, height int) (xgb.Id, xgb.Id) { +func (f *frameFull) borderImages( + width, height int) (xproto.Pixmap, xproto.Pixmap) { + imgA := renderBorder(0, 0, newThemeColor(THEME.full.aBorderColor), width, height, 0, 0) imgI := renderBorder(0, 0, newThemeColor(THEME.full.iBorderColor), diff --git a/frame_nada.go b/frame_nada.go index 8ca1134..2febb32 100644 --- a/frame_nada.go +++ b/frame_nada.go @@ -1,6 +1,8 @@ package main -import "code.google.com/p/jamslam-x-go-binding/xgb" +import ( + "github.com/BurntSushi/xgb/xproto" +) type frameNada struct { *abstFrame @@ -58,14 +60,14 @@ func (f *frameNada) Right() int { } func (f *frameNada) ConfigureClient(flags, x, y, w, h int, - sibling xgb.Id, stackMode byte, ignoreHints bool) { + sibling xproto.Window, stackMode byte, ignoreHints bool) { x, y, w, h = FrameConfigureClient(f, flags, x, y, w, h) f.ConfigureFrame(flags, x, y, w, h, sibling, stackMode, ignoreHints, true) } func (f *frameNada) ConfigureFrame(flags, fx, fy, fw, fh int, - sibling xgb.Id, stackMode byte, ignoreHints bool, sendNotify bool) { + sibling xproto.Window, stackMode byte, ignoreHints bool, sendNotify bool) { FrameConfigureFrame(f, flags, fx, fy, fw, fh, sibling, stackMode, ignoreHints, sendNotify) diff --git a/frame_slim.go b/frame_slim.go index 2679b54..dc31c5c 100644 --- a/frame_slim.go +++ b/frame_slim.go @@ -1,6 +1,8 @@ package main -import "code.google.com/p/jamslam-x-go-binding/xgb" +import ( + "github.com/BurntSushi/xgb/xproto" +) type frameSlim struct { *abstFrame @@ -29,12 +31,12 @@ func (f *frameSlim) On() { } func (f *frameSlim) Active() { - f.ParentWin().change(xgb.CWBackPixel, uint32(THEME.slim.aBorderColor)) + f.ParentWin().change(xproto.CwBackPixel, uint32(THEME.slim.aBorderColor)) f.ParentWin().clear() } func (f *frameSlim) Inactive() { - f.ParentWin().change(xgb.CWBackPixel, uint32(THEME.slim.iBorderColor)) + f.ParentWin().change(xproto.CwBackPixel, uint32(THEME.slim.iBorderColor)) f.ParentWin().clear() } @@ -73,14 +75,14 @@ func (f *frameSlim) Right() int { } func (f *frameSlim) ConfigureClient(flags, x, y, w, h int, - sibling xgb.Id, stackMode byte, ignoreHints bool) { + sibling xproto.Window, stackMode byte, ignoreHints bool) { x, y, w, h = FrameConfigureClient(f, flags, x, y, w, h) f.ConfigureFrame(flags, x, y, w, h, sibling, stackMode, ignoreHints, true) } func (f *frameSlim) ConfigureFrame(flags, fx, fy, fw, fh int, - sibling xgb.Id, stackMode byte, ignoreHints bool, sendNotify bool) { + sibling xproto.Window, stackMode byte, ignoreHints bool, sendNotify bool) { FrameConfigureFrame(f, flags, fx, fy, fw, fh, sibling, stackMode, ignoreHints, sendNotify) diff --git a/frame_temp.go b/frame_temp.go index 49e3e54..8d0f564 100644 --- a/frame_temp.go +++ b/frame_temp.go @@ -1,7 +1,7 @@ package main import ( - "code.google.com/p/jamslam-x-go-binding/xgb" + "github.com/BurntSushi/xgb/xproto" "github.com/BurntSushi/xgbutil/ewmh" "github.com/BurntSushi/xgbutil/xrect" @@ -45,7 +45,7 @@ func frameMoveEnd(f Frame, rx, ry, ex, ey int) { } func frameResizeBegin(f Frame, direction uint32, - rx, ry, ex, ey int) (bool, xgb.Id) { + rx, ry, ex, ey int) (bool, xproto.Cursor) { resizing := f.ResizingState() dir := direction @@ -109,7 +109,7 @@ func frameResizeBegin(f Frame, direction uint32, } // Find the right cursor - var cursor xgb.Id = 0 + var cursor xproto.Cursor = 0 switch dir { case ewmh.SizeTop: cursor = cursorTopSide diff --git a/main.go b/main.go index 26e4ba5..211d7a8 100644 --- a/main.go +++ b/main.go @@ -5,7 +5,7 @@ import ( // "os" // "runtime/pprof" - "code.google.com/p/jamslam-x-go-binding/xgb" + "github.com/BurntSushi/xgb/xproto" "github.com/BurntSushi/xgbutil" "github.com/BurntSushi/xgbutil/ewmh" @@ -36,7 +36,7 @@ func main() { // pprof.StartCPUProfile(f) // defer pprof.StopCPUProfile() - X, err = xgbutil.Dial("") + X, err = xgbutil.NewConn() if err != nil { logger.Error.Println(err) logger.Error.Println("Error connecting to X, quitting...") @@ -94,10 +94,10 @@ func main() { setupCursors() // Listen to Root. It is all-important. - ROOT.listen(xgb.EventMaskPropertyChange | - xgb.EventMaskStructureNotify | - xgb.EventMaskSubstructureNotify | - xgb.EventMaskSubstructureRedirect) + ROOT.listen(xproto.EventMaskPropertyChange | + xproto.EventMaskStructureNotify | + xproto.EventMaskSubstructureNotify | + xproto.EventMaskSubstructureRedirect) // Update state when the root window changes size xevent.ConfigureNotifyFun(rootGeometryChange).Connect(X, ROOT.id) diff --git a/misc.go b/misc.go index badf63f..7ce8274 100644 --- a/misc.go +++ b/misc.go @@ -5,7 +5,7 @@ import ( "strconv" "strings" - "code.google.com/p/jamslam-x-go-binding/xgb" + "github.com/BurntSushi/xgb/xproto" "github.com/BurntSushi/xgbutil/keybind" @@ -36,7 +36,7 @@ func cliIndex(needle *client, haystack []*client) int { // keyMatch is a utility function for comparing two keysym strings for equality. // It automatically converts a (mods, byte) pair to a string. -func keyMatch(target string, mods uint16, keycode xgb.Keycode) bool { +func keyMatch(target string, mods uint16, keycode xproto.Keycode) bool { guess := keybind.LookupString(X, mods, keycode) return strings.ToLower(guess) == strings.ToLower(target) } diff --git a/prompt_cycle.go b/prompt_cycle.go index ea53a2a..45a9b1f 100644 --- a/prompt_cycle.go +++ b/prompt_cycle.go @@ -1,7 +1,7 @@ package main import ( - "code.google.com/p/jamslam-x-go-binding/xgb" + "github.com/BurntSushi/xgb/xproto" "github.com/BurntSushi/xgbutil" "github.com/BurntSushi/xgbutil/keybind" @@ -22,7 +22,7 @@ type promptCycle struct { iconBorder *window } -func (pc *promptCycle) Id() xgb.Id { +func (pc *promptCycle) Id() xproto.Window { return pc.top.id } @@ -44,11 +44,11 @@ func newPromptCycle() *promptCycle { bLft.moveresize(DoX|DoY|DoW, 0, 0, bs, 0) bRht.moveresize(DoY|DoW, 0, 0, bs, 0) - top.change(xgb.CWBackPixel, uint32(THEME.prompt.bgColor)) - bTop.change(xgb.CWBackPixel, uint32(THEME.prompt.borderColor)) - bBot.change(xgb.CWBackPixel, uint32(THEME.prompt.borderColor)) - bLft.change(xgb.CWBackPixel, uint32(THEME.prompt.borderColor)) - bRht.change(xgb.CWBackPixel, uint32(THEME.prompt.borderColor)) + top.change(xproto.CwBackPixel, uint32(THEME.prompt.bgColor)) + bTop.change(xproto.CwBackPixel, uint32(THEME.prompt.borderColor)) + bBot.change(xproto.CwBackPixel, uint32(THEME.prompt.borderColor)) + bLft.change(xproto.CwBackPixel, uint32(THEME.prompt.borderColor)) + bRht.change(xproto.CwBackPixel, uint32(THEME.prompt.borderColor)) // actual mapping doesn't happen until top is mapped bTop.map_() @@ -147,10 +147,10 @@ func (pc *promptCycle) highlight() { } if i == pc.selected { - iconPar.change(xgb.CWBackPixel, uint32(THEME.prompt.borderColor)) + iconPar.change(xproto.CwBackPixel, uint32(THEME.prompt.borderColor)) winTitle.map_() } else { - iconPar.change(xgb.CWBackPixel, uint32(THEME.prompt.bgColor)) + iconPar.change(xproto.CwBackPixel, uint32(THEME.prompt.bgColor)) winTitle.unmap() } iconPar.clear() @@ -184,7 +184,7 @@ func (pc *promptCycle) show(keyStr string, activeWrk, visible, } // save the modifiers used to initially start this prompt - pc.grabbedMods, _ = keybind.ParseString(X, keyStr) + pc.grabbedMods, _, _ = keybind.ParseString(X, keyStr) bs := THEME.prompt.borderSize cbs := THEME.prompt.cycleIconBorderSize is := THEME.prompt.cycleIconSize @@ -192,7 +192,7 @@ func (pc *promptCycle) show(keyStr string, activeWrk, visible, // To the top! if len(WM.stack) > 0 { - pc.top.configure(DoStack, 0, 0, 0, 0, 0, xgb.StackModeAbove) + pc.top.configure(DoStack, 0, 0, 0, 0, 0, xproto.StackModeAbove) } // get our screen geometry so we can position ourselves @@ -337,7 +337,7 @@ func (c *client) promptCycleAdd() { } c.promptStore["cycle_border"] = createWindow( - PROMPTS.cycle.Id(), xgb.CWBackPixel, uint32(THEME.prompt.bgColor)) + PROMPTS.cycle.Id(), xproto.CwBackPixel, uint32(THEME.prompt.bgColor)) c.promptStore["cycle_border"].moveresize( DoW|DoH, 0, 0, THEME.prompt.cycleIconSize+2*THEME.prompt.cycleIconBorderSize, @@ -390,10 +390,10 @@ func (c *client) promptCycleUpdateIcon() { cbs := THEME.prompt.cycleIconBorderSize alpha := THEME.prompt.cycleIconTransparency // value checked at startup - img, mask := c.iconImage(iconSize, iconSize) + img := c.iconImage(iconSize, iconSize) - imgAct := xgraphics.BlendBg(img, mask, 100, bgc) - imgInact := xgraphics.BlendBg(img, mask, alpha, bgc) + imgAct := xgraphics.BlendBg(img, nil, 100, bgc) + imgInact := xgraphics.BlendBg(img, nil, alpha, bgc) if w, ok := c.promptStore["cycle_act"]; ok { xgraphics.PaintImg(X, w.id, imgAct) @@ -433,7 +433,7 @@ func (c *client) promptCycleUpdateName() { bs+padding, bs+padding, ew, eh) c.promptStore["cycle_title"].configure( DoSibling|DoStack, 0, 0, 0, 0, - PROMPTS.cycle.bRht.id, xgb.StackModeBelow) + PROMPTS.cycle.bRht.id, xproto.StackModeBelow) // Set the largest font size we've seen. PROMPTS.cycle.fontHeight = max(PROMPTS.cycle.fontHeight, eh) diff --git a/prompt_select.go b/prompt_select.go index 3f3c815..83e9f2f 100644 --- a/prompt_select.go +++ b/prompt_select.go @@ -26,7 +26,7 @@ package main import ( "strings" - "code.google.com/p/jamslam-x-go-binding/xgb" + "github.com/BurntSushi/xgb/xproto" "github.com/BurntSushi/xgbutil" "github.com/BurntSushi/xgbutil/keybind" @@ -108,7 +108,7 @@ type promptSelect struct { } // Id returns the parent window of this prompt. -func (ps *promptSelect) Id() xgb.Id { +func (ps *promptSelect) Id() xproto.Window { return ps.top.id } @@ -138,12 +138,12 @@ func newPromptSelect() *promptSelect { bLft.moveresize(DoX|DoY|DoW, 0, 0, bs, 0) bRht.moveresize(DoY|DoW, 0, 0, bs, 0) - top.change(xgb.CWBackPixel, uint32(THEME.prompt.bgColor)) - bInp.change(xgb.CWBackPixel, uint32(THEME.prompt.borderColor)) - bTop.change(xgb.CWBackPixel, uint32(THEME.prompt.borderColor)) - bBot.change(xgb.CWBackPixel, uint32(THEME.prompt.borderColor)) - bLft.change(xgb.CWBackPixel, uint32(THEME.prompt.borderColor)) - bRht.change(xgb.CWBackPixel, uint32(THEME.prompt.borderColor)) + top.change(xproto.CwBackPixel, uint32(THEME.prompt.bgColor)) + bInp.change(xproto.CwBackPixel, uint32(THEME.prompt.borderColor)) + bTop.change(xproto.CwBackPixel, uint32(THEME.prompt.borderColor)) + bBot.change(xproto.CwBackPixel, uint32(THEME.prompt.borderColor)) + bLft.change(xproto.CwBackPixel, uint32(THEME.prompt.borderColor)) + bRht.change(xproto.CwBackPixel, uint32(THEME.prompt.borderColor)) // actual mapping doesn't happen until top is mapped bInp.map_() @@ -210,7 +210,7 @@ func newPromptSelect() *promptSelect { if len(ps.itemsShowing) == 0 { break } - if mods&xgb.ModMaskShift > 0 { + if mods&xproto.ModMaskShift > 0 { if ps.selected == -1 { ps.selected++ } @@ -323,7 +323,7 @@ func (ps *promptSelect) show(listFun promptSelectListFun, // To the top! if len(WM.stack) > 0 { - ps.top.configure(DoStack, 0, 0, 0, 0, 0, xgb.StackModeAbove) + ps.top.configure(DoStack, 0, 0, 0, 0, 0, xproto.StackModeAbove) } ps.showing = true @@ -530,13 +530,13 @@ func (wrk *workspace) promptSelectUpdateName() { // Don't let text overlap borders. wrk.promptStore["select_active"].configure( DoSibling|DoStack, 0, 0, 0, 0, - PROMPTS.slct.bRht.id, xgb.StackModeBelow) + PROMPTS.slct.bRht.id, xproto.StackModeBelow) wrk.promptStore["select_inactive"].configure( DoSibling|DoStack, 0, 0, 0, 0, - PROMPTS.slct.bRht.id, xgb.StackModeBelow) + PROMPTS.slct.bRht.id, xproto.StackModeBelow) wrk.promptStore["select_label"].configure( DoSibling|DoStack, 0, 0, 0, 0, - PROMPTS.slct.bRht.id, xgb.StackModeBelow) + PROMPTS.slct.bRht.id, xproto.StackModeBelow) } // createWorkspaceLabels creates the "Visible" and "Hidden" labels used @@ -568,10 +568,10 @@ func (ps *promptSelect) createWorkspaceLabels() { // Don't let text overlap borders. ps.labVisible.configure( DoSibling|DoStack, 0, 0, 0, 0, - ps.bRht.id, xgb.StackModeBelow) + ps.bRht.id, xproto.StackModeBelow) ps.labHidden.configure( DoSibling|DoStack, 0, 0, 0, 0, - ps.bRht.id, xgb.StackModeBelow) + ps.bRht.id, xproto.StackModeBelow) } // promptSelectListClients generates a list of clients grouped by workspace. @@ -712,8 +712,8 @@ func (c *client) promptSelectUpdateName() { // Don't let text overlap borders. c.promptStore["select_active"].configure( DoSibling|DoStack, 0, 0, 0, 0, - PROMPTS.slct.bRht.id, xgb.StackModeBelow) + PROMPTS.slct.bRht.id, xproto.StackModeBelow) c.promptStore["select_inactive"].configure( DoSibling|DoStack, 0, 0, 0, 0, - PROMPTS.slct.bRht.id, xgb.StackModeBelow) + PROMPTS.slct.bRht.id, xproto.StackModeBelow) } diff --git a/state.go b/state.go index 7fb2b99..d77a6af 100644 --- a/state.go +++ b/state.go @@ -3,7 +3,7 @@ package main import ( "strings" - "code.google.com/p/jamslam-x-go-binding/xgb" + "github.com/BurntSushi/xgb/xproto" "github.com/BurntSushi/xgbutil/ewmh" "github.com/BurntSushi/xgbutil/xinerama" @@ -72,7 +72,7 @@ func (wm *state) clientRemove(c *client) { func (wm *state) updateEwmhClients() { numWins := len(wm.clients) - winList := make([]xgb.Id, numWins) + winList := make([]xproto.Window, numWins) for i, c := range wm.clients { winList[i] = c.Win().id } @@ -93,7 +93,7 @@ func (wm *state) focused() *client { return nil } -func (wm *state) unfocusExcept(id xgb.Id) { +func (wm *state) unfocusExcept(id xproto.Window) { // Go in reverse to make switching appear quicker in the common case // if there are a lot of windows. for i := len(wm.focus) - 1; i >= 0; i-- { diff --git a/state_stack.go b/state_stack.go index a851f77..425000c 100644 --- a/state_stack.go +++ b/state_stack.go @@ -1,7 +1,7 @@ package main import ( - "code.google.com/p/jamslam-x-go-binding/xgb" + "github.com/BurntSushi/xgb/xproto" "github.com/BurntSushi/xgbutil/ewmh" @@ -30,7 +30,7 @@ const ( // root window. func (wm *state) updateEwmhStacking() { numWins := len(wm.stack) - winList := make([]xgb.Id, numWins) + winList := make([]xproto.Window, numWins) for i, c := range wm.stack { winList[numWins-i-1] = c.Win().id } @@ -54,11 +54,13 @@ func (wm *state) stackUpdate(clients []*client) { if i == len(wm.stack)-1 { wm.stack[i].Frame().ConfigureClient( DoSibling|DoStack, 0, 0, 0, 0, - wm.stack[i-1].Frame().ParentId(), xgb.StackModeBelow, false) + wm.stack[i-1].Frame().ParentId(), + xproto.StackModeBelow, false) } else { wm.stack[i].Frame().ConfigureClient( DoSibling|DoStack, 0, 0, 0, 0, - wm.stack[i+1].Frame().ParentId(), xgb.StackModeAbove, false) + wm.stack[i+1].Frame().ParentId(), + xproto.StackModeAbove, false) } } } @@ -98,7 +100,7 @@ func (wm *state) stackRaise(c *client, configure bool) { if configure { c.Frame().ConfigureClient(DoSibling|DoStack, 0, 0, 0, 0, c2.Frame().ParentId(), - xgb.StackModeAbove, false) + xproto.StackModeAbove, false) } wm.stack = append(wm.stack[:i], append([]*client{c}, wm.stack[i:]...)...) @@ -114,7 +116,7 @@ func (wm *state) stackRaise(c *client, configure bool) { c.Frame().ConfigureClient( DoSibling|DoStack, 0, 0, 0, 0, wm.stack[len(wm.stack)-1].Frame().ParentId(), - xgb.StackModeBelow, false) + xproto.StackModeBelow, false) } wm.stack = append(wm.stack, c) } diff --git a/window.go b/window.go index b578be5..f5d5f20 100644 --- a/window.go +++ b/window.go @@ -1,51 +1,57 @@ package main -import "image" +import ( + "image" -import "code.google.com/p/jamslam-x-go-binding/xgb" + "github.com/BurntSushi/xgb/xproto" -import ( "github.com/BurntSushi/xgbutil" "github.com/BurntSushi/xgbutil/xevent" "github.com/BurntSushi/xgbutil/xgraphics" "github.com/BurntSushi/xgbutil/xrect" "github.com/BurntSushi/xgbutil/xwindow" + + "github.com/BurntSushi/wingo/logger" ) type window struct { - id xgb.Id + id xproto.Window geom xrect.Rect } const ( - DoX = xgb.ConfigWindowX - DoY = xgb.ConfigWindowY - DoW = xgb.ConfigWindowWidth - DoH = xgb.ConfigWindowHeight - DoBorder = xgb.ConfigWindowBorderWidth - DoSibling = xgb.ConfigWindowSibling - DoStack = xgb.ConfigWindowStackMode + DoX = xproto.ConfigWindowX + DoY = xproto.ConfigWindowY + DoW = xproto.ConfigWindowWidth + DoH = xproto.ConfigWindowHeight + DoBorder = xproto.ConfigWindowBorderWidth + DoSibling = xproto.ConfigWindowSibling + DoStack = xproto.ConfigWindowStackMode ) -func newWindow(id xgb.Id) *window { +func newWindow(id xproto.Window) *window { return &window{ id: id, geom: xrect.New(0, 0, 1, 1), } } -func createWindow(parent xgb.Id, masks int, vals ...uint32) *window { - wid := X.Conn().NewId() +func createWindow(parent xproto.Window, masks int, vals ...uint32) *window { + wid, err := xproto.NewWindowId(X.Conn()) + if err != nil { + logger.Error.Printf("Could not create window: %s", err) + return nil + } scrn := X.Screen() - X.Conn().CreateWindow(scrn.RootDepth, wid, parent, 0, 0, 1, 1, 0, - xgb.WindowClassInputOutput, scrn.RootVisual, + xproto.CreateWindow(X.Conn(), scrn.RootDepth, wid, parent, 0, 0, 1, 1, 0, + xproto.WindowClassInputOutput, scrn.RootVisual, uint32(masks), vals) return newWindow(wid) } -func createImageWindow(parent xgb.Id, img image.Image, +func createImageWindow(parent xproto.Window, img image.Image, masks int, vals ...uint32) *window { newWin := createWindow(parent, masks, vals...) @@ -58,28 +64,29 @@ func createImageWindow(parent xgb.Id, img image.Image, } func (w *window) listen(masks int) { - xwindow.Listen(X, w.id, masks) + xproto.ChangeWindowAttributes(X.Conn(), w.id, + xproto.CwEventMask, []uint32{uint32(masks)}) } func (w *window) map_() { - X.Conn().MapWindow(w.id) + xproto.MapWindow(X.Conn(), w.id) } func (w *window) unmap() { - X.Conn().UnmapWindow(w.id) + xproto.UnmapWindow(X.Conn(), w.id) } func (w *window) change(masks int, vals ...uint32) { - X.Conn().ChangeWindowAttributes(w.id, uint32(masks), vals) + xproto.ChangeWindowAttributes(X.Conn(), w.id, uint32(masks), vals) } func (w *window) clear() { - X.Conn().ClearArea(false, w.id, 0, 0, 0, 0) + xproto.ClearArea(X.Conn(), false, w.id, 0, 0, 0, 0) } func (w *window) geometry() (xrect.Rect, error) { var err error - w.geom, err = xwindow.RawGeometry(X, w.id) + w.geom, err = xwindow.RawGeometry(X, xproto.Drawable(w.id)) if err != nil { return nil, err } @@ -87,16 +94,16 @@ func (w *window) geometry() (xrect.Rect, error) { } func (w *window) kill() { - X.Conn().KillClient(uint32(w.id)) + xproto.KillClient(X.Conn(), uint32(w.id)) } func (w *window) destroy() { - X.Conn().DestroyWindow(w.id) + xproto.DestroyWindow(X.Conn(), w.id) xevent.Detach(X, w.id) } func (w *window) focus() { - X.Conn().SetInputFocus(xgb.InputFocusPointerRoot, w.id, 0) + xproto.SetInputFocus(X.Conn(), xproto.InputFocusPointerRoot, w.id, 0) } // moveresize is a wrapper around configure that only accepts parameters @@ -104,7 +111,7 @@ func (w *window) focus() { func (win *window) moveresize(flags, x, y, w, h int) { // Kill any hopes of stacking flags = (flags & ^DoSibling) & ^DoStack - win.configure(flags, x, y, w, h, xgb.Id(0), 0) + win.configure(flags, x, y, w, h, 0, 0) } // configure is the method version of 'configure'. @@ -112,7 +119,7 @@ func (win *window) moveresize(flags, x, y, w, h int) { // geometry. (We don't want another set of 'if' statements because it // needs to be as efficient as possible.) func (win *window) configure(flags, x, y, w, h int, - sibling xgb.Id, stackMode byte) { + sibling xproto.Window, stackMode byte) { vals := []uint32{} @@ -150,14 +157,14 @@ func (win *window) configure(flags, x, y, w, h int, return } - X.Conn().ConfigureWindow(win.id, uint16(flags), vals) + xproto.ConfigureWindow(X.Conn(), win.id, uint16(flags), vals) } // configure is a nice wrapper around ConfigureWindow. // We purposefully omit 'BorderWidth' because I don't think it's ever used // any more. -func configure(window xgb.Id, flags, x, y, w, h int, - sibling xgb.Id, stackMode byte) { +func configure(window xproto.Window, flags, x, y, w, h int, + sibling xproto.Window, stackMode byte) { vals := []uint32{} @@ -186,7 +193,7 @@ func configure(window xgb.Id, flags, x, y, w, h int, vals = append(vals, uint32(stackMode)) } - X.Conn().ConfigureWindow(window, uint16(flags), vals) + xproto.ConfigureWindow(X.Conn(), window, uint16(flags), vals) } // configureRequest responds to generic configure requests from windows that diff --git a/wingo-cmd/main.go b/wingo-cmd/main.go index 7b4562f..58abf9e 100644 --- a/wingo-cmd/main.go +++ b/wingo-cmd/main.go @@ -24,7 +24,7 @@ import ( "strings" "time" - "code.google.com/p/jamslam-x-go-binding/xgb" + "github.com/BurntSushi/xgb/xproto" "github.com/BurntSushi/xgbutil" "github.com/BurntSushi/xgbutil/ewmh" @@ -93,7 +93,7 @@ func main() { }).Connect(X, X.RootWin()) // Listen to Root property change events - xwindow.Listen(X, X.RootWin(), xgb.EventMaskPropertyChange) + xwindow.Listen(X, X.RootWin(), xproto.EventMaskPropertyChange) go xevent.Main(X)