Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
View
@@ -81,9 +81,6 @@ func main() {
WM = newState()
WM.headsLoad()
- // Set supported atoms
- ewmh.SupportedSet(X, []string{"_NET_WM_ICON"})
-
// Attach all global key bindings
attachAllKeys()
@@ -123,3 +120,24 @@ func main() {
// pprof.WriteHeapProfile(f)
// f.Close()
}
+
+func set_supported() {
+ // Purposefully NOT supported
+ // _NET_DESKTOP_GEOMETRY, _NET_DESKTOP_VIEWPORT, _NET_VIRTUAL_ROOTS
+
+ // Some day...
+ // _NET_DESKTOP_LAYOUT, _NET_SHOWING_DESKTOP
+
+ // breadcrumb: _NET_ACTIVE_WINDOW, _NET_WORKAREA,
+ // _NET_SUPPORTING_WM_CHECK,
+
+ supported := []string{
+ "_NET_SUPPORTED", "_NET_CLIENT_LIST", "_NET_CLIENT_LIST_STACKING",
+ "_NET_NUMBER_OF_DESKTOPS", "_NET_CURRENT_DESKTOP",
+ "_NET_DESKTOP_NAMES",
+
+ "_NET_WM_ICON",
+ }
+ // Set supported atoms
+ ewmh.SupportedSet(X, supported)
+}
34 state.go
View
@@ -23,23 +23,33 @@ type state struct {
}
func newState() *state {
- stickyWrk := newWorkspace(-1)
- stickyWrk.nameSet("Sticky")
-
- wrks := make(workspaces, len(CONF.workspaces))
- for i, wrkName := range CONF.workspaces {
- wrks[i] = newWorkspace(i)
- wrks[i].nameSet(wrkName)
- }
-
- return &state{
+ wm := &state{
clients: make([]*client, 0),
stack: make([]*client, 0),
focus: make([]*client, 0),
heads: nil,
- workspaces: wrks,
- stickyWrk: stickyWrk,
+ workspaces: make(workspaces, 0, len(CONF.workspaces)),
+ stickyWrk: nil,
+ }
+
+ // Add the special workspace that holds windows that are always visible
+ wm.stickyWrk = newWorkspace(-1)
+ wm.stickyWrk.nameSet("Sticky")
+
+ for i, wrkName := range CONF.workspaces {
+ wm.workspaceAdd(i, wrkName)
}
+
+ return wm
+}
+
+func (wm *state) workspaceAdd(id int, name string) {
+ wrk := newWorkspace(id)
+ wrk.nameSet(name)
+ wm.workspaces = append(wm.workspaces, wrk)
+
+ ewmh.NumberOfDesktopsSet(X, len(wm.workspaces))
+ wm.ewmhUpdateDesktopNames()
}
func (wm *state) clientAdd(c *client) {
24 state_ewmh.go
View
@@ -0,0 +1,24 @@
+package main
+
+import (
+ "fmt"
+ "strings"
+
+ "github.com/BurntSushi/xgbutil/ewmh"
+)
+
+func (wm *state) ewmhUpdateDesktopNames() {
+ if wm == nil || wm.workspaces == nil {
+ return // still starting up
+ }
+
+ names := make([]string, len(wm.workspaces))
+ for i, wrk := range wm.workspaces {
+ if len(strings.TrimSpace(wrk.name)) == 0 {
+ names[i] = fmt.Sprintf("Default workspace %d", i)
+ } else {
+ names[i] = wrk.name
+ }
+ }
+ ewmh.DesktopNamesSet(X, names)
+}
10 state_head.go
View
@@ -1,6 +1,8 @@
package main
import (
+ "fmt"
+
"github.com/BurntSushi/xgbutil"
"github.com/BurntSushi/xgbutil/ewmh"
"github.com/BurntSushi/xgbutil/xevent"
@@ -92,7 +94,7 @@ func (wm *state) headsLoad() {
// Make the first one active and the first N workspaces visible,
// where N is the number of heads
if firstTime {
- wm.workspaces[0].active = true
+ wm.workspaces[0].activeSet(true)
for i := 0; i < len(heads); i++ {
wm.workspaces[i].headSet(i)
}
@@ -104,7 +106,7 @@ func (wm *state) headsLoad() {
wrk.hide()
wrk.headSet(-1)
if wrk.active {
- wrk.active = false
+ wrk.activeSet(false)
activeHidden = true
}
}
@@ -135,7 +137,7 @@ func (wm *state) headsLoad() {
if activeHidden {
for _, wrk := range wm.workspaces {
if wrk.visible() {
- wrk.active = true
+ wrk.activeSet(true)
break
}
}
@@ -193,7 +195,7 @@ func (wm *state) fillWorkspaces(heads xinerama.Heads) {
"think you're configuration is correct.")
for i := len(wm.workspaces); i < len(heads); i++ {
- wm.workspaces = append(wm.workspaces, newWorkspace(i))
+ wm.workspaceAdd(i, fmt.Sprintf("Default workspace %d", i+1))
}
}
13 state_workspace.go
View
@@ -4,6 +4,7 @@ import (
"fmt"
"strings"
+ "github.com/BurntSushi/xgbutil/ewmh"
"github.com/BurntSushi/xgbutil/xrect"
"github.com/BurntSushi/wingo/logger"
@@ -105,14 +106,21 @@ func (wrkNew *workspace) activate(fallback bool, greedy bool) {
wrkNew.show()
}
- wrkActive.active = false
- wrkNew.active = true
+ wrkActive.activeSet(false)
+ wrkNew.activeSet(true)
if fallback {
WM.fallback()
}
}
+func (wrk *workspace) activeSet(active bool) {
+ wrk.active = active
+ if active {
+ ewmh.CurrentDesktopSet(X, wrk.id)
+ }
+}
+
func (wrk *workspace) add(c *client) {
// Don't forget to add transients if this isn't the client's first workspace
if c.workspace != nil {
@@ -199,6 +207,7 @@ func (wrk *workspace) visible() bool {
func (wrk *workspace) nameSet(name string) {
wrk.name = name
wrk.promptUpdateName()
+ WM.ewmhUpdateDesktopNames()
}
func (wrk *workspace) headGeom() xrect.Rect {
4 xephyr-wingo
View
@@ -6,7 +6,7 @@
# cd $PWD
if [ "$1" != "--no-compile" ]; then
- go build -o zzz
+ go build
if [ ! $? = 0 ]; then
exit
fi
@@ -23,7 +23,7 @@ xemu=$!
sleep 0.5
export DISPLAY=:10
-DISPLAY=:10 ./zzz &
+DISPLAY=:10 ./wingo &
# DISPLAY=:10 wingo &
# DISPLAY=:10 openbox &
# go run $PWD/wingo.go &
Please sign in to comment.
Something went wrong with that request. Please try again.