Update code for x backend

This commit is contained in:
Sasha Koshka 2024-07-25 13:01:24 -04:00
parent 196afbc2f3
commit a62dff4236
3 changed files with 43 additions and 60 deletions

View File

@ -102,20 +102,20 @@ func (this *Backend) NewBox () tomo.Box {
return this.system.NewBox()
}
func (this *Backend) NewCanvasBox () tomo.CanvasBox {
return this.system.NewCanvasBox()
func (this *Backend) NewTextBox () tomo.TextBox {
return this.system.NewTextBox()
}
func (this *Backend) NewContainerBox () tomo.ContainerBox {
return this.system.NewContainerBox()
func (this *Backend) NewCanvasBox () tomo.CanvasBox {
return this.system.NewCanvasBox()
}
func (this *Backend) NewSurfaceBox () (tomo.SurfaceBox, error) {
return this.system.NewSurfaceBox()
}
func (this *Backend) NewTextBox () tomo.TextBox {
return this.system.NewTextBox()
func (this *Backend) NewContainerBox () tomo.ContainerBox {
return this.system.NewContainerBox()
}
func (this *Backend) NewTexture (source image.Image) canvas.TextureCloser {
@ -126,12 +126,12 @@ func (this *Backend) NewCanvas (bounds image.Rectangle) canvas.CanvasCloser {
return xcanvas.NewCanvas(this.x, bounds)
}
func (this *Backend) SetStyle (style tomo.Style) {
func (this *Backend) SetStyle (style *tomo.Style) {
this.system.SetStyle(style)
}
func (this *Backend) SetIcons (icons tomo.Icons) {
this.system.SetIcons(icons)
func (this *Backend) SetIconSet (icons tomo.IconSet) {
this.system.SetIconSet(icons)
}
func (this *Backend) assert () {

View File

@ -1,26 +0,0 @@
package x
import "io"
import "strings"
import "git.tebibyte.media/tomo/xgbsel/v2"
import "git.tebibyte.media/tomo/tomo/data"
type selectionData struct {
data data.Data
}
func (this selectionData) Convert (target xgbsel.Target) (io.ReadSeekCloser, bool) {
mimeStr, _ := target.ToMime()
ty, subty, _ := strings.Cut(string(mimeStr), "/")
mime := data.M(ty, subty)
stream, ok := this.data[mime]
stream.Seek(0, io.SeekStart)
return stream, ok
}
func (this selectionData) Supported () (targets []xgbsel.Target) {
for mime := range this.data {
targets = append(targets, xgbsel.MimeToTargets(mime.String())...)
}
return targets
}

View File

@ -4,6 +4,7 @@ import "image"
import "git.tebibyte.media/tomo/tomo"
import "git.tebibyte.media/tomo/tomo/data"
import "git.tebibyte.media/tomo/tomo/input"
import "git.tebibyte.media/tomo/tomo/event"
import "git.tebibyte.media/tomo/tomo/canvas"
import "git.tebibyte.media/tomo/backend/x/canvas"
@ -179,12 +180,17 @@ func (this *window) SetTitle (title string) {
icccm.WmIconNameSet (this.backend.x, this.xWindow.Id, title)
}
func (this *window) SetIcon (sizes ...canvas.Texture) {
func (this *window) SetIcon (icon tomo.Icon) {
textures := []canvas.Texture {
icon.Texture(tomo.IconSizeSmall),
icon.Texture(tomo.IconSizeMedium),
icon.Texture(tomo.IconSizeLarge),
}
wmIcons := []ewmh.WmIcon { }
for _, icon := range sizes {
icon, ok := icon.(*xcanvas.Texture)
if !ok { continue }
for _, icon := range textures {
icon := xcanvas.AssertTexture(icon)
bounds := icon.Bounds()
width := bounds.Dx()
@ -232,6 +238,26 @@ func (this *window) SetBounds (bounds image.Rectangle) {
bounds.Min.Y + bounds.Dy())
}
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(leader)
leader.setClientLeader(leader)
icccm.WmTransientForSet (
this.backend.x,
child.xWindow.Id,
leader.xWindow.Id)
child.setType("UTILITY")
// child.inheritProperties(leader.window)
return child, err
}
func (this *window) NewMenu (bounds image.Rectangle) (tomo.Window, error) {
menu, err := this.backend.newWindow (
bounds.Add(this.metrics.bounds.Min), true)
@ -262,29 +288,12 @@ func (this *window) NewModal (bounds image.Rectangle) (tomo.Window, error) {
return modal, err
}
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(leader)
leader.setClientLeader(leader)
icccm.WmTransientForSet (
this.backend.x,
child.xWindow.Id,
leader.xWindow.Id)
child.setType("UTILITY")
// child.inheritProperties(leader.window)
return child, err
func (this *window) Modifiers () input.Modifiers {
return this.hierarchy.Modifiers()
}
func (this *window) Widget () (tomo.Window, error) {
// TODO
return nil, nil
func (this *window) MousePosition () image.Point {
return this.hierarchy.MousePosition()
}
func (this *window) Copy (data.Data) {