Skip to content
This repository
Browse code

some cleanup and starting on explicit support for EWMH

  • Loading branch information...
commit 85d9565cebd5bea2fa88d96df013b5eeb98f12bd 1 parent 8b9c14e
Andrew Gallant authored
24 wingo.go → main.go
@@ -81,9 +81,6 @@ func main() {
81 81 WM = newState()
82 82 WM.headsLoad()
83 83
84   - // Set supported atoms
85   - ewmh.SupportedSet(X, []string{"_NET_WM_ICON"})
86   -
87 84 // Attach all global key bindings
88 85 attachAllKeys()
89 86
@@ -123,3 +120,24 @@ func main() {
123 120 // pprof.WriteHeapProfile(f)
124 121 // f.Close()
125 122 }
  123 +
  124 +func set_supported() {
  125 + // Purposefully NOT supported
  126 + // _NET_DESKTOP_GEOMETRY, _NET_DESKTOP_VIEWPORT, _NET_VIRTUAL_ROOTS
  127 +
  128 + // Some day...
  129 + // _NET_DESKTOP_LAYOUT, _NET_SHOWING_DESKTOP
  130 +
  131 + // breadcrumb: _NET_ACTIVE_WINDOW, _NET_WORKAREA,
  132 + // _NET_SUPPORTING_WM_CHECK,
  133 +
  134 + supported := []string{
  135 + "_NET_SUPPORTED", "_NET_CLIENT_LIST", "_NET_CLIENT_LIST_STACKING",
  136 + "_NET_NUMBER_OF_DESKTOPS", "_NET_CURRENT_DESKTOP",
  137 + "_NET_DESKTOP_NAMES",
  138 +
  139 + "_NET_WM_ICON",
  140 + }
  141 + // Set supported atoms
  142 + ewmh.SupportedSet(X, supported)
  143 +}
34 state.go
@@ -23,23 +23,33 @@ type state struct {
23 23 }
24 24
25 25 func newState() *state {
26   - stickyWrk := newWorkspace(-1)
27   - stickyWrk.nameSet("Sticky")
28   -
29   - wrks := make(workspaces, len(CONF.workspaces))
30   - for i, wrkName := range CONF.workspaces {
31   - wrks[i] = newWorkspace(i)
32   - wrks[i].nameSet(wrkName)
33   - }
34   -
35   - return &state{
  26 + wm := &state{
36 27 clients: make([]*client, 0),
37 28 stack: make([]*client, 0),
38 29 focus: make([]*client, 0),
39 30 heads: nil,
40   - workspaces: wrks,
41   - stickyWrk: stickyWrk,
  31 + workspaces: make(workspaces, 0, len(CONF.workspaces)),
  32 + stickyWrk: nil,
  33 + }
  34 +
  35 + // Add the special workspace that holds windows that are always visible
  36 + wm.stickyWrk = newWorkspace(-1)
  37 + wm.stickyWrk.nameSet("Sticky")
  38 +
  39 + for i, wrkName := range CONF.workspaces {
  40 + wm.workspaceAdd(i, wrkName)
42 41 }
  42 +
  43 + return wm
  44 +}
  45 +
  46 +func (wm *state) workspaceAdd(id int, name string) {
  47 + wrk := newWorkspace(id)
  48 + wrk.nameSet(name)
  49 + wm.workspaces = append(wm.workspaces, wrk)
  50 +
  51 + ewmh.NumberOfDesktopsSet(X, len(wm.workspaces))
  52 + wm.ewmhUpdateDesktopNames()
43 53 }
44 54
45 55 func (wm *state) clientAdd(c *client) {
24 state_ewmh.go
... ... @@ -0,0 +1,24 @@
  1 +package main
  2 +
  3 +import (
  4 + "fmt"
  5 + "strings"
  6 +
  7 + "github.com/BurntSushi/xgbutil/ewmh"
  8 +)
  9 +
  10 +func (wm *state) ewmhUpdateDesktopNames() {
  11 + if wm == nil || wm.workspaces == nil {
  12 + return // still starting up
  13 + }
  14 +
  15 + names := make([]string, len(wm.workspaces))
  16 + for i, wrk := range wm.workspaces {
  17 + if len(strings.TrimSpace(wrk.name)) == 0 {
  18 + names[i] = fmt.Sprintf("Default workspace %d", i)
  19 + } else {
  20 + names[i] = wrk.name
  21 + }
  22 + }
  23 + ewmh.DesktopNamesSet(X, names)
  24 +}
10 state_head.go
... ... @@ -1,6 +1,8 @@
1 1 package main
2 2
3 3 import (
  4 + "fmt"
  5 +
4 6 "github.com/BurntSushi/xgbutil"
5 7 "github.com/BurntSushi/xgbutil/ewmh"
6 8 "github.com/BurntSushi/xgbutil/xevent"
@@ -92,7 +94,7 @@ func (wm *state) headsLoad() {
92 94 // Make the first one active and the first N workspaces visible,
93 95 // where N is the number of heads
94 96 if firstTime {
95   - wm.workspaces[0].active = true
  97 + wm.workspaces[0].activeSet(true)
96 98 for i := 0; i < len(heads); i++ {
97 99 wm.workspaces[i].headSet(i)
98 100 }
@@ -104,7 +106,7 @@ func (wm *state) headsLoad() {
104 106 wrk.hide()
105 107 wrk.headSet(-1)
106 108 if wrk.active {
107   - wrk.active = false
  109 + wrk.activeSet(false)
108 110 activeHidden = true
109 111 }
110 112 }
@@ -135,7 +137,7 @@ func (wm *state) headsLoad() {
135 137 if activeHidden {
136 138 for _, wrk := range wm.workspaces {
137 139 if wrk.visible() {
138   - wrk.active = true
  140 + wrk.activeSet(true)
139 141 break
140 142 }
141 143 }
@@ -193,7 +195,7 @@ func (wm *state) fillWorkspaces(heads xinerama.Heads) {
193 195 "think you're configuration is correct.")
194 196
195 197 for i := len(wm.workspaces); i < len(heads); i++ {
196   - wm.workspaces = append(wm.workspaces, newWorkspace(i))
  198 + wm.workspaceAdd(i, fmt.Sprintf("Default workspace %d", i+1))
197 199 }
198 200 }
199 201
13 state_workspace.go
@@ -4,6 +4,7 @@ import (
4 4 "fmt"
5 5 "strings"
6 6
  7 + "github.com/BurntSushi/xgbutil/ewmh"
7 8 "github.com/BurntSushi/xgbutil/xrect"
8 9
9 10 "github.com/BurntSushi/wingo/logger"
@@ -105,14 +106,21 @@ func (wrkNew *workspace) activate(fallback bool, greedy bool) {
105 106 wrkNew.show()
106 107 }
107 108
108   - wrkActive.active = false
109   - wrkNew.active = true
  109 + wrkActive.activeSet(false)
  110 + wrkNew.activeSet(true)
110 111
111 112 if fallback {
112 113 WM.fallback()
113 114 }
114 115 }
115 116
  117 +func (wrk *workspace) activeSet(active bool) {
  118 + wrk.active = active
  119 + if active {
  120 + ewmh.CurrentDesktopSet(X, wrk.id)
  121 + }
  122 +}
  123 +
116 124 func (wrk *workspace) add(c *client) {
117 125 // Don't forget to add transients if this isn't the client's first workspace
118 126 if c.workspace != nil {
@@ -199,6 +207,7 @@ func (wrk *workspace) visible() bool {
199 207 func (wrk *workspace) nameSet(name string) {
200 208 wrk.name = name
201 209 wrk.promptUpdateName()
  210 + WM.ewmhUpdateDesktopNames()
202 211 }
203 212
204 213 func (wrk *workspace) headGeom() xrect.Rect {
4 xephyr-wingo
@@ -6,7 +6,7 @@
6 6 # cd $PWD
7 7
8 8 if [ "$1" != "--no-compile" ]; then
9   - go build -o zzz
  9 + go build
10 10 if [ ! $? = 0 ]; then
11 11 exit
12 12 fi
@@ -23,7 +23,7 @@ xemu=$!
23 23 sleep 0.5
24 24 export DISPLAY=:10
25 25
26   -DISPLAY=:10 ./zzz &
  26 +DISPLAY=:10 ./wingo &
27 27 # DISPLAY=:10 wingo &
28 28 # DISPLAY=:10 openbox &
29 29 # go run $PWD/wingo.go &

0 comments on commit 85d9565

Please sign in to comment.
Something went wrong with that request. Please try again.