Terrible discovery (panels don't work properly)
This commit is contained in:
parent
bdc1109bcf
commit
3aa8495873
@ -227,15 +227,33 @@ func (window *window) NewModal (width, height int) (elements.Window, error) {
|
|||||||
|
|
||||||
func (window mainWindow) NewPanel (width, height int) (elements.Window, error) {
|
func (window mainWindow) NewPanel (width, height int) (elements.Window, error) {
|
||||||
panel, err := window.backend.newWindow(width, height)
|
panel, err := window.backend.newWindow(width, height)
|
||||||
hints, _ := icccm.WmHintsGet(window.backend.connection, panel.xWindow.Id)
|
if err != nil { return nil, err }
|
||||||
hints.WindowGroup = window.xWindow.Id
|
panel.setClientLeader(window.window)
|
||||||
icccm.WmHintsSet (
|
panel.setType("UTILITY")
|
||||||
window.backend.connection,
|
|
||||||
panel.xWindow.Id,
|
|
||||||
hints)
|
|
||||||
return panel, err
|
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 () {
|
func (window *window) Show () {
|
||||||
if window.child == nil {
|
if window.child == nil {
|
||||||
window.xCanvas.For (func (x, y int) xgraphics.BGRA {
|
window.xCanvas.For (func (x, y int) xgraphics.BGRA {
|
||||||
|
40
examples/panels/main.go
Normal file
40
examples/panels/main.go
Normal 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()
|
||||||
|
}
|
7
tomo.go
7
tomo.go
@ -40,10 +40,9 @@ func Do (callback func ()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWindow creates a new window using the current backend, and returns it as a
|
// 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
|
// MainWindow. If the window could not be created, an error is returned
|
||||||
// why. If this function is called without a running backend, an error is
|
// explaining why.
|
||||||
// returned as well.
|
func NewWindow (width, height int) (window elements.MainWindow, err error) {
|
||||||
func NewWindow (width, height int) (window elements.Window, err error) {
|
|
||||||
assertBackend()
|
assertBackend()
|
||||||
return backend.NewWindow(width, height)
|
return backend.NewWindow(width, height)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user