From a62dff42361fd0d57798d7413129fe04cf1bb7cc Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Thu, 25 Jul 2024 13:01:24 -0400 Subject: [PATCH] Update code for x backend --- x/backend.go | 18 +++++++-------- x/selection.go | 26 ---------------------- x/window.go | 59 +++++++++++++++++++++++++++++--------------------- 3 files changed, 43 insertions(+), 60 deletions(-) delete mode 100644 x/selection.go diff --git a/x/backend.go b/x/backend.go index 8ce1e25..9057e21 100644 --- a/x/backend.go +++ b/x/backend.go @@ -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 () { diff --git a/x/selection.go b/x/selection.go deleted file mode 100644 index ddd9199..0000000 --- a/x/selection.go +++ /dev/null @@ -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 -} diff --git a/x/window.go b/x/window.go index e3a5569..8ae9693 100644 --- a/x/window.go +++ b/x/window.go @@ -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) {