Skip to content

Commit

Permalink
still broken. ug
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Gallant (Ocelot) authored and Andrew Gallant (Ocelot) committed May 30, 2012
1 parent cf6350f commit d09162c
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 253 deletions.
44 changes: 21 additions & 23 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

type client struct {
window *window
window *xwindow.Window
workspace *workspace
layer int
name, vname, wmname string
Expand All @@ -40,7 +40,7 @@ type client struct {
wmclass *icccm.WmClass

stateStore map[string]*clientState
promptStore map[string]*window
promptStore map[string]*xwindow.Window

frame Frame
frameNada *frameNada
Expand All @@ -51,7 +51,7 @@ type client struct {

func newClient(id xproto.Window) *client {
return &client{
window: newWindow(id),
window: xwindow.New(X, id),
workspace: nil,
layer: stackDefault,
name: "",
Expand All @@ -73,7 +73,7 @@ func newClient(id xproto.Window) *client {
transientFor: 0,
wmclass: nil,
stateStore: make(map[string]*clientState),
promptStore: make(map[string]*window),
promptStore: make(map[string]*xwindow.Window),
frame: nil,
frameNada: nil,
frameSlim: nil,
Expand All @@ -90,7 +90,7 @@ func (c *client) unmanage() {
c.frame.Destroy()
c.setWmState(icccm.StateWithdrawn)

xevent.Detach(X, c.window.id)
xevent.Detach(X, c.window.Id)
c.promptRemove()
WM.stackRemove(c)
WM.clientRemove(c)
Expand All @@ -116,7 +116,7 @@ func (c *client) Map() {
if c.Mapped() {
return
}
c.window.map_()
c.window.Map()
c.frame.Map()
c.isMapped = true
c.initMap = true
Expand Down Expand Up @@ -167,7 +167,7 @@ func (c *client) setWmState(state int) {
return
}

err := icccm.WmStateSet(X, c.window.id, &icccm.WmState{State: state})
err := icccm.WmStateSet(X, c.Id(), &icccm.WmState{State: state})
if err != nil {
var stateStr string
switch state {
Expand Down Expand Up @@ -199,16 +199,16 @@ func (c *client) Close() {
return
}

cm, err := xevent.NewClientMessage(32, c.window.id, wm_protocols,
cm, err := xevent.NewClientMessage(32, c.Id(), wm_protocols,
int(wm_del_win))
if err != nil {
logger.Warning.Println(err)
return
}

xproto.SendEvent(X.Conn(), false, c.window.id, 0, string(cm.Bytes()))
xproto.SendEvent(X.Conn(), false, c.Id(), 0, string(cm.Bytes()))
} else {
c.window.kill()
c.window.Kill()
}
}

Expand All @@ -229,7 +229,7 @@ func (c *client) Alive() bool {
continue
}

wid := c.Win().id
wid := c.Id()
ev := everr.Event
if um, ok := ev.(xproto.UnmapNotifyEvent); ok && um.Window == wid {
if ignore <= 0 {
Expand All @@ -245,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, xproto.Drawable(c.window.id))
_, err := xwindow.RawGeometry(X, xproto.Drawable(c.Id()))
if err != nil {
return false
}
Expand All @@ -262,7 +262,7 @@ func (c *client) ForceWorkspace() {
func (c *client) Focus() {
if c.hints.Flags&icccm.HintInput > 0 && c.hints.Input == 1 {
c.ForceWorkspace()
c.window.focus()
c.window.Focus()
c.Focused()
} else if strIndex("WM_TAKE_FOCUS", c.protocols) > -1 {
c.ForceWorkspace()
Expand All @@ -279,16 +279,14 @@ func (c *client) Focus() {
return
}

cm, err := xevent.NewClientMessage(32, c.window.id,
wm_protocols,
int(wm_take_focus),
int(X.TimeGet()))
cm, err := xevent.NewClientMessage(32, c.Id(),
wm_protocols, int(wm_take_focus), int(X.TimeGet()))
if err != nil {
logger.Warning.Println(err)
return
}

xproto.SendEvent(X.Conn(), false, c.window.id, 0, string(cm.Bytes()))
xproto.SendEvent(X.Conn(), false, c.Id(), 0, string(cm.Bytes()))

c.Focused()
}
Expand Down Expand Up @@ -370,7 +368,7 @@ func (c *client) updateProperty(ev xevent.PropertyNotifyEvent) {
c.transientFor = transientFor
}
case "_NET_WM_USER_TIME":
newTime, err := ewmh.WmUserTimeGet(X, c.window.id)
newTime, err := ewmh.WmUserTimeGet(X, c.Id())
showVals(c.lastTime, newTime)
if err == nil {
c.lastTime = newTime
Expand Down Expand Up @@ -447,11 +445,11 @@ func (c *client) FrameFull() {
}

func (c *client) Geom() xrect.Rect {
return c.window.geom
return c.window.Geom
}

func (c *client) Id() xproto.Window {
return c.window.id
return c.window.Id
}

func (c *client) Layer() int {
Expand All @@ -475,10 +473,10 @@ func (c *client) Name() string {
return "N/A"
}

func (c *client) Win() *window {
func (c *client) Win() *xwindow.Window {
return c.window
}

func (c *client) String() string {
return fmt.Sprintf("%s (%X)", c.Name(), c.window.id)
return fmt.Sprintf("%s (%X)", c.Name(), c.Id())
}
11 changes: 6 additions & 5 deletions frame.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/BurntSushi/xgbutil/xevent"
"github.com/BurntSushi/xgbutil/xgraphics"
"github.com/BurntSushi/xgbutil/xrect"
"github.com/BurntSushi/xgbutil/xwindow"
)

const (
Expand All @@ -30,7 +31,7 @@ type Frame interface {
On()
Parent() *frameParent
ParentId() xproto.Window
ParentWin() *window
ParentWin() *xwindow.Window
State() int
Active()
Inactive()
Expand All @@ -52,7 +53,7 @@ type Frame interface {
}

type frameParent struct {
window *window
window *xwindow.Window
client *client
}

Expand All @@ -75,20 +76,20 @@ func newParent(c *client) *frameParent {
return p
}

func (p *frameParent) Win() *window {
func (p *frameParent) Win() *xwindow.Window {
return p.window
}

// framePiece contains the information required to show *any* piece of the
// decorations. Basically, it contains the raw X window and pixmaps for each
// of the available states for quick switching.
type framePiece struct {
win *window
win *xwindow.Window
imgActive xproto.Pixmap
imgInactive xproto.Pixmap
}

func newFramePiece(win *window, imgA, imgI xproto.Pixmap) framePiece {
func newFramePiece(win *xwindow.Window, imgA, imgI xproto.Pixmap) framePiece {
return framePiece{win: win, imgActive: imgA, imgInactive: imgI}
}

Expand Down
3 changes: 2 additions & 1 deletion frame_abst.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/BurntSushi/xgb/xproto"

"github.com/BurntSushi/xgbutil/xrect"
"github.com/BurntSushi/xgbutil/xwindow"
)

type abstFrame struct {
Expand Down Expand Up @@ -70,7 +71,7 @@ func (f *abstFrame) ParentId() xproto.Window {
return f.parent.window.id
}

func (f *abstFrame) ParentWin() *window {
func (f *abstFrame) ParentWin() *xwindow.Window {
return f.parent.window
}

Expand Down
3 changes: 2 additions & 1 deletion frame_borders_pieces.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"github.com/BurntSushi/xgb/xproto"

"github.com/BurntSushi/xgbutil/xgraphics"
"github.com/BurntSushi/xgbutil/xwindow"
)

func (f *frameBorders) newPieceWindow(ident string,
cursor xproto.Cursor) *window {
cursor xproto.Cursor) *xwindow.Window {

mask := xproto.CwBackPixmap | xproto.CwEventMask | xproto.CwCursor
vals := []uint32{xproto.BackPixmapParentRelative,
Expand Down
5 changes: 4 additions & 1 deletion frame_full_pieces.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import (
"github.com/BurntSushi/xgb/xproto"

"github.com/BurntSushi/xgbutil/xgraphics"
"github.com/BurntSushi/xgbutil/xwindow"
)

func (f *frameFull) newPieceWindow(ident string, cursor xproto.Cursor) *window {
func (f *frameFull) newPieceWindow(ident string,
cursor xproto.Cursor) *xwindow.Window {

mask := xproto.CwBackPixmap | xproto.CwEventMask | xproto.CwCursor
vals := []uint32{xproto.BackPixmapParentRelative,
xproto.EventMaskButtonPress | xproto.EventMaskButtonRelease |
Expand Down
10 changes: 9 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,15 @@ func main() {
xevent.MapRequestFun(clientMapRequest).Connect(X, ROOT.id)

// Oblige configure requests from windows we don't manage.
xevent.ConfigureRequestFun(configureRequest).Connect(X, ROOT.id)
xevent.ConfigureRequestFun(
func(X *xgbutil.XUtil, ev xevent.ConfigureRequestEvent) {
flags := int(ev.ValueMask) &
^int(xproto.ConfigWindowSibling) &
^int(xproto.ConfigWindowStack)
xwindow.New(ev.Window).Configure(flags,
int(ev.X), int(ev.Y), int(ev.Width), int(ev.Height),
ev.Sibling, ev.StackMode)
}).Connect(X, ROOT.id)

// Listen to Root client message events.
// We satisfy EWMH with these AND it also provides a mechanism
Expand Down
7 changes: 4 additions & 3 deletions prompt_cycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/BurntSushi/xgbutil/keybind"
"github.com/BurntSushi/xgbutil/xevent"
"github.com/BurntSushi/xgbutil/xgraphics"
"github.com/BurntSushi/xgbutil/xwindow"

"github.com/BurntSushi/wingo/logger"
)
Expand All @@ -17,9 +18,9 @@ type promptCycle struct {
grabbedMods uint16
clients []*client
fontHeight int
top *window
bTop, bBot, bLft, bRht *window
iconBorder *window
top *xwindow.Window
bTop, bBot, bLft, bRht *xwindow.Window
iconBorder *xwindow.Window
}

func (pc *promptCycle) Id() xproto.Window {
Expand Down
23 changes: 12 additions & 11 deletions prompt_select.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/BurntSushi/xgbutil/keybind"
"github.com/BurntSushi/xgbutil/xevent"
"github.com/BurntSushi/xgbutil/xgraphics"
"github.com/BurntSushi/xgbutil/xwindow"

"github.com/BurntSushi/wingo/logger"
)
Expand All @@ -51,7 +52,7 @@ type promptSelectListFun func() []*promptSelectGroup
// prompt under a specific heading.
type promptSelectGroup struct {
label string
win *window
win *xwindow.Window
items []*promptSelectItem
}

Expand All @@ -70,10 +71,10 @@ func newPromptSelectGroup(label string, win *window,

// promptSelectItem represents a single *selectable* item in a prompt.
type promptSelectItem struct {
text string // visually displayed and used for tab completion
action func() // performed when this item is selected
active *window // window w/ image when selected
inactive *window // window w/ image when not selected
text string // visually displayed and used for tab completion
action func() // performed when this item is selected
active *xwindow.Window // window w/ image when selected
inactive *xwindow.Window // window w/ image when not selected
}

func newPromptSelectItem(text string, action func(),
Expand All @@ -98,13 +99,13 @@ type promptSelect struct {
prefixSearch bool // whether prefix or substring search
groups []*promptSelectGroup
itemsShowing []*promptSelectItem
top *window
top *xwindow.Window
input *textInput
labVisible *window
labHidden *window
bInp *window
bTop, bBot *window
bLft, bRht *window
labVisible *xwindow.Window
labHidden *xwindow.Window
bInp *xwindow.Window
bTop, bBot *xwindow.Window
bLft, bRht *xwindow.Window
}

// Id returns the parent window of this prompt.
Expand Down
3 changes: 2 additions & 1 deletion render_text.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"code.google.com/p/freetype-go/freetype/truetype"

"github.com/BurntSushi/xgbutil/xgraphics"
"github.com/BurntSushi/xgbutil/xwindow"

"github.com/BurntSushi/wingo/logger"
)
Expand All @@ -18,7 +19,7 @@ import (
const renderTextBreathe = 5

type textInput struct {
win *window
win *xwindow.Window
img *wImg
text []rune
bgColor int
Expand Down
3 changes: 2 additions & 1 deletion state_workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/BurntSushi/xgbutil/ewmh"
"github.com/BurntSushi/xgbutil/xrect"
"github.com/BurntSushi/xgbutil/xwindow"

"github.com/BurntSushi/wingo/logger"
)
Expand All @@ -22,7 +23,7 @@ type workspace struct {
name string // note that this does not have to be unique
head int // the most recent physical head this workspace was on
active bool
promptStore map[string]*window
promptStore map[string]*xwindow.Window
state int // the default placement policy of this workspace
floaters []layout
tilers []layout
Expand Down
Loading

0 comments on commit d09162c

Please sign in to comment.