Terrible discovery (panels don't work properly)

This commit is contained in:
Sasha Koshka 2023-03-24 17:38:21 -04:00
parent bdc1109bcf
commit 3aa8495873
3 changed files with 67 additions and 10 deletions

View File

@ -227,15 +227,33 @@ func (window *window) NewModal (width, height int) (elements.Window, error) {
func (window mainWindow) NewPanel (width, height int) (elements.Window, error) {
panel, err := window.backend.newWindow(width, height)
hints, _ := icccm.WmHintsGet(window.backend.connection, panel.xWindow.Id)
hints.WindowGroup = window.xWindow.Id
icccm.WmHintsSet (
window.backend.connection,
panel.xWindow.Id,
hints)
if err != nil { return nil, err }
panel.setClientLeader(window.window)
panel.setType("UTILITY")
return panel, err
}
func (window *window) setType (ty string) error {
return ewmh.WmWindowTypeSet (
window.backend.connection,
window.xWindow.Id,
[]string { "_NET_WM_WINDOW_TYPE_" + ty })
}
func (window *window) setClientLeader (leader *window) error {
// FIXME: doe not fucking work
hints, _ := icccm.WmHintsGet(window.backend.connection, window.xWindow.Id)
if hints == nil {
hints = &icccm.Hints { }
}
hints.Flags |= icccm.HintWindowGroup
hints.WindowGroup = leader.xWindow.Id
return icccm.WmHintsSet (
window.backend.connection,
window.xWindow.Id,
hints)
}
func (window *window) Show () {
if window.child == nil {
window.xCanvas.For (func (x, y int) xgraphics.BGRA {

40
examples/panels/main.go Normal file
View File

@ -0,0 +1,40 @@
package main
import "fmt"
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/elements"
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
func main () {
tomo.Run(run)
}
func run () {
window, _ := tomo.NewWindow(2, 2)
window.SetTitle("Main")
container := containers.NewContainer(basicLayouts.Vertical { true, true })
container.Adopt(basicElements.NewLabel("Main window", false), true)
window.Adopt(container)
window.OnClose(tomo.Stop)
window.Show()
createPanel(window, 0)
// createPanel(window, 1)
// createPanel(window, 2)
// createPanel(window, 3)
}
func createPanel (parent elements.MainWindow, id int) {
window, _ := parent.NewPanel(2, 2)
title := fmt.Sprint("Panel #", id)
window.SetTitle(title)
container := containers.NewContainer(basicLayouts.Vertical { true, true })
container.Adopt(basicElements.NewLabel(title, false), true)
window.Adopt(container)
window.Show()
}

View File

@ -40,10 +40,9 @@ func Do (callback func ()) {
}
// NewWindow creates a new window using the current backend, and returns it as a
// Window. If the window could not be created, an error is returned explaining
// why. If this function is called without a running backend, an error is
// returned as well.
func NewWindow (width, height int) (window elements.Window, err error) {
// MainWindow. If the window could not be created, an error is returned
// explaining why.
func NewWindow (width, height int) (window elements.MainWindow, err error) {
assertBackend()
return backend.NewWindow(width, height)
}