Update X backend
This commit is contained in:
parent
2af42a3568
commit
a60a729ad9
34
x/backend.go
34
x/backend.go
@ -4,7 +4,9 @@ import "image"
|
|||||||
import "errors"
|
import "errors"
|
||||||
import "git.tebibyte.media/tomo/tomo"
|
import "git.tebibyte.media/tomo/tomo"
|
||||||
import "git.tebibyte.media/tomo/xgbkb"
|
import "git.tebibyte.media/tomo/xgbkb"
|
||||||
|
import "git.tebibyte.media/tomo/tomo/data"
|
||||||
import "git.tebibyte.media/tomo/tomo/canvas"
|
import "git.tebibyte.media/tomo/tomo/canvas"
|
||||||
|
import "git.tebibyte.media/tomo/backend/style"
|
||||||
import "git.tebibyte.media/tomo/backend/x/canvas"
|
import "git.tebibyte.media/tomo/backend/x/canvas"
|
||||||
import "git.tebibyte.media/tomo/backend/internal/system"
|
import "git.tebibyte.media/tomo/backend/internal/system"
|
||||||
|
|
||||||
@ -17,6 +19,9 @@ import "github.com/jezek/xgbutil/mousebind"
|
|||||||
type Backend struct {
|
type Backend struct {
|
||||||
x *xgbutil.XUtil
|
x *xgbutil.XUtil
|
||||||
system *system.System
|
system *system.System
|
||||||
|
|
||||||
|
style *style.Style
|
||||||
|
iconSet style.IconSet
|
||||||
|
|
||||||
doChannel chan func()
|
doChannel chan func()
|
||||||
windows map[xproto.Window] *window
|
windows map[xproto.Window] *window
|
||||||
@ -126,19 +131,40 @@ 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) ColorRGBA (id tomo.Color) (r, g, b, a uint32) {
|
||||||
|
if col, ok := this.style.Colors[id]; ok {
|
||||||
|
return col.RGBA()
|
||||||
|
}
|
||||||
|
return 0xFFFF, 0, 0xFFFF, 0xFFFF // punish bad styles
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Backend) IconTexture (id tomo.Icon, size tomo.IconSize) canvas.Texture {
|
||||||
|
return this.iconSet.Icon(id, size)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Backend) MimeIconTexture (mime data.Mime, size tomo.IconSize) canvas.Texture {
|
||||||
|
return this.iconSet.MimeIcon(mime, size)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Backend) SetStyle (style *style.Style) {
|
||||||
|
this.style = style
|
||||||
this.system.SetStyle(style)
|
this.system.SetStyle(style)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Backend) SetIconSet (icons tomo.IconSet) {
|
func (this *Backend) SetIconSet (iconSet style.IconSet) {
|
||||||
this.system.SetIconSet(icons)
|
this.iconSet = iconSet
|
||||||
|
this.system.SetIconSet(iconSet)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Backend) SetFaceSet (faceSet style.FaceSet) {
|
||||||
|
this.system.SetFaceSet(faceSet)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Backend) assert () {
|
func (this *Backend) assert () {
|
||||||
if this == nil { panic("x: nil backend") }
|
if this == nil { panic("x: nil backend") }
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Backend) afterEvent () {
|
func (this *Backend) afterEvent () {
|
||||||
for _, window := range this.windows {
|
for _, window := range this.windows {
|
||||||
window.hierarchy.AfterEvent()
|
window.hierarchy.AfterEvent()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user