Unify window and mainWindow

This commit is contained in:
Sasha Koshka 2024-06-07 01:07:28 -04:00
parent adf0ef3a89
commit 6eff6887e7

View File

@ -18,7 +18,6 @@ import "github.com/jezek/xgbutil/keybind"
import "github.com/jezek/xgbutil/mousebind"
import "github.com/jezek/xgbutil/xgraphics"
type mainWindow struct { *window }
type window struct {
backend *Backend
hierarchy *system.Hierarchy
@ -28,6 +27,7 @@ type window struct {
title string
leader *window
modalParent *window
hasModal bool
shy bool
@ -63,28 +63,24 @@ func (this *windowLink) NotifyMinimumSizeChange () {
func (this *Backend) NewWindow (
bounds image.Rectangle,
) (
output tomo.MainWindow,
output tomo.Window,
err error,
) {
this.assert()
window, err := this.newWindow(bounds, false)
output = mainWindow { window: window }
return output, err
return this.newWindow(bounds, false)
}
func (this *Backend) NewPlainWindow (
bounds image.Rectangle,
) (
output tomo.MainWindow,
output tomo.Window,
err error,
) {
this.assert()
window, err := this.newWindow(bounds, false)
window.setType("dock")
output = mainWindow { window: window }
return output, err
return window, err
}
func (this *Backend) newWindow (
@ -100,6 +96,7 @@ func (this *Backend) newWindow (
window := &window { backend: this }
link := &windowLink { window: window }
window.hierarchy = this.system.NewHierarchy(link)
window.leader = window
window.xWindow, err = xwindow.Generate(this.x)
if err != nil { return }
@ -247,18 +244,23 @@ func (this *window) NewModal (bounds image.Rectangle) (tomo.Window, error) {
return modal, err
}
func (this mainWindow) NewChild (bounds image.Rectangle) (tomo.Window, error) {
func (this *window) NewChild (bounds image.Rectangle) (tomo.Window, error) {
leader := this.leader
child, err := this.backend.newWindow (
bounds.Add(this.metrics.bounds.Min), false)
child.leader = leader
if err != nil { return nil, err }
child.setClientLeader(this.window)
this.setClientLeader(this.window)
child.setClientLeader(leader)
leader.setClientLeader(leader)
icccm.WmTransientForSet (
this.backend.x,
this.xWindow.Id,
this.xWindow.Id)
this.setType("UTILITY")
// this.inheritProperties(this.window)
child.xWindow.Id,
leader.xWindow.Id)
child.setType("UTILITY")
// child.inheritProperties(leader.window)
return this, err
}