Update code for x backend
This commit is contained in:
parent
196afbc2f3
commit
20d9154b1d
18
x/backend.go
18
x/backend.go
@ -102,20 +102,20 @@ func (this *Backend) NewBox () tomo.Box {
|
|||||||
return this.system.NewBox()
|
return this.system.NewBox()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Backend) NewCanvasBox () tomo.CanvasBox {
|
func (this *Backend) NewTextBox () tomo.TextBox {
|
||||||
return this.system.NewCanvasBox()
|
return this.system.NewTextBox()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Backend) NewContainerBox () tomo.ContainerBox {
|
func (this *Backend) NewCanvasBox () tomo.CanvasBox {
|
||||||
return this.system.NewContainerBox()
|
return this.system.NewCanvasBox()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Backend) NewSurfaceBox () (tomo.SurfaceBox, error) {
|
func (this *Backend) NewSurfaceBox () (tomo.SurfaceBox, error) {
|
||||||
return this.system.NewSurfaceBox()
|
return this.system.NewSurfaceBox()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Backend) NewTextBox () tomo.TextBox {
|
func (this *Backend) NewContainerBox () tomo.ContainerBox {
|
||||||
return this.system.NewTextBox()
|
return this.system.NewContainerBox()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Backend) NewTexture (source image.Image) canvas.TextureCloser {
|
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)
|
return xcanvas.NewCanvas(this.x, bounds)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Backend) SetStyle (style tomo.Style) {
|
func (this *Backend) SetStyle (style *tomo.Style) {
|
||||||
this.system.SetStyle(style)
|
this.system.SetStyle(style)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Backend) SetIcons (icons tomo.Icons) {
|
func (this *Backend) SetIconSet (icons tomo.IconSet) {
|
||||||
this.system.SetIcons(icons)
|
this.system.SetIconSet(icons)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Backend) assert () {
|
func (this *Backend) assert () {
|
||||||
|
@ -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
|
|
||||||
}
|
|
59
x/window.go
59
x/window.go
@ -4,6 +4,7 @@ import "image"
|
|||||||
|
|
||||||
import "git.tebibyte.media/tomo/tomo"
|
import "git.tebibyte.media/tomo/tomo"
|
||||||
import "git.tebibyte.media/tomo/tomo/data"
|
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/event"
|
||||||
import "git.tebibyte.media/tomo/tomo/canvas"
|
import "git.tebibyte.media/tomo/tomo/canvas"
|
||||||
import "git.tebibyte.media/tomo/backend/x/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)
|
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 { }
|
wmIcons := []ewmh.WmIcon { }
|
||||||
|
|
||||||
for _, icon := range sizes {
|
for _, icon := range textures {
|
||||||
icon, ok := icon.(*xcanvas.Texture)
|
icon := xcanvas.AssertTexture(icon)
|
||||||
if !ok { continue }
|
|
||||||
|
|
||||||
bounds := icon.Bounds()
|
bounds := icon.Bounds()
|
||||||
width := bounds.Dx()
|
width := bounds.Dx()
|
||||||
@ -232,6 +238,26 @@ func (this *window) SetBounds (bounds image.Rectangle) {
|
|||||||
bounds.Min.Y + bounds.Dy())
|
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) {
|
func (this *window) NewMenu (bounds image.Rectangle) (tomo.Window, error) {
|
||||||
menu, err := this.backend.newWindow (
|
menu, err := this.backend.newWindow (
|
||||||
bounds.Add(this.metrics.bounds.Min), true)
|
bounds.Add(this.metrics.bounds.Min), true)
|
||||||
@ -262,29 +288,12 @@ func (this *window) NewModal (bounds image.Rectangle) (tomo.Window, error) {
|
|||||||
return modal, err
|
return modal, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *window) NewChild (bounds image.Rectangle) (tomo.Window, error) {
|
func (this *window) Modifiers () input.Modifiers {
|
||||||
leader := this.leader
|
return this.hierarchy.Modifiers()
|
||||||
|
|
||||||
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) Widget () (tomo.Window, error) {
|
func (this *window) MousePosition () image.Point {
|
||||||
// TODO
|
return this.hierarchy.MousePosition()
|
||||||
return nil, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *window) Copy (data.Data) {
|
func (this *window) Copy (data.Data) {
|
||||||
|
Loading…
Reference in New Issue
Block a user