Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 52a0136e60 | |||
| 5657f85c83 | |||
| a9ac9f6600 | |||
| 6eff6887e7 | |||
| adf0ef3a89 | |||
| 07bcd119d7 | |||
| c51ce65c88 | |||
| 0d93d73c32 | |||
| 006921d690 | |||
| f2bcc217a4 | |||
| a4e067cacb | |||
| 5a2b4cc2f5 | |||
| 250c3076fb |
5
go.mod
5
go.mod
@@ -3,11 +3,8 @@ module git.tebibyte.media/tomo/backend
|
|||||||
go 1.20
|
go 1.20
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.tebibyte.media/tomo/tomo v0.34.0
|
git.tebibyte.media/tomo/tomo v0.36.0
|
||||||
git.tebibyte.media/tomo/typeset v0.7.1
|
git.tebibyte.media/tomo/typeset v0.7.1
|
||||||
)
|
|
||||||
|
|
||||||
require (
|
|
||||||
git.tebibyte.media/tomo/xgbkb v1.0.1
|
git.tebibyte.media/tomo/xgbkb v1.0.1
|
||||||
github.com/jezek/xgb v1.1.1
|
github.com/jezek/xgb v1.1.1
|
||||||
github.com/jezek/xgbutil v0.0.0-20231116234834-47f30c120111
|
github.com/jezek/xgbutil v0.0.0-20231116234834-47f30c120111
|
||||||
|
|||||||
4
go.sum
4
go.sum
@@ -1,6 +1,6 @@
|
|||||||
git.tebibyte.media/sashakoshka/xgbkb v1.0.0/go.mod h1:pNcE6TRO93vHd6q42SdwLSTTj25L0Yzggz7yLe0JV6Q=
|
git.tebibyte.media/sashakoshka/xgbkb v1.0.0/go.mod h1:pNcE6TRO93vHd6q42SdwLSTTj25L0Yzggz7yLe0JV6Q=
|
||||||
git.tebibyte.media/tomo/tomo v0.34.0 h1:r5yJPks9rtzdDI2RyAUdqa1qb6BebG0QFe2cTmcFi+0=
|
git.tebibyte.media/tomo/tomo v0.36.0 h1:V9vyPYb4kpUceBhcDF/XyLDACzE5lY8kYEGHAkIsqs0=
|
||||||
git.tebibyte.media/tomo/tomo v0.34.0/go.mod h1:C9EzepS9wjkTJjnZaPBh22YvVPyA4hbBAJVU20Rdmps=
|
git.tebibyte.media/tomo/tomo v0.36.0/go.mod h1:C9EzepS9wjkTJjnZaPBh22YvVPyA4hbBAJVU20Rdmps=
|
||||||
git.tebibyte.media/tomo/typeset v0.7.1 h1:aZrsHwCG5ZB4f5CruRFsxLv5ezJUCFUFsQJJso2sXQ8=
|
git.tebibyte.media/tomo/typeset v0.7.1 h1:aZrsHwCG5ZB4f5CruRFsxLv5ezJUCFUFsQJJso2sXQ8=
|
||||||
git.tebibyte.media/tomo/typeset v0.7.1/go.mod h1:PwDpSdBF3l/EzoIsa2ME7QffVVajnTHZN6l3MHEGe1g=
|
git.tebibyte.media/tomo/typeset v0.7.1/go.mod h1:PwDpSdBF3l/EzoIsa2ME7QffVVajnTHZN6l3MHEGe1g=
|
||||||
git.tebibyte.media/tomo/xgbkb v1.0.1 h1:b3HDUopjdQp1MZrb5Vpil4bOtk3NnNXtfQW27Blw2kE=
|
git.tebibyte.media/tomo/xgbkb v1.0.1 h1:b3HDUopjdQp1MZrb5Vpil4bOtk3NnNXtfQW27Blw2kE=
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ type box struct {
|
|||||||
parent parent
|
parent parent
|
||||||
outer anyBox
|
outer anyBox
|
||||||
|
|
||||||
|
role tomo.Role
|
||||||
|
|
||||||
bounds image.Rectangle
|
bounds image.Rectangle
|
||||||
minSize image.Point
|
minSize image.Point
|
||||||
userMinSize image.Point
|
userMinSize image.Point
|
||||||
@@ -106,6 +108,10 @@ func (this *box) MinimumSize () image.Point {
|
|||||||
return this.minSize
|
return this.minSize
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *box) Role () tomo.Role {
|
||||||
|
return this.role
|
||||||
|
}
|
||||||
|
|
||||||
func (this *box) borderSum () tomo.Inset {
|
func (this *box) borderSum () tomo.Inset {
|
||||||
sum := tomo.Inset { }
|
sum := tomo.Inset { }
|
||||||
for _, border := range this.border {
|
for _, border := range this.border {
|
||||||
@@ -182,6 +188,10 @@ func (this *box) SetPadding (padding tomo.Inset) {
|
|||||||
this.invalidateMinimum()
|
this.invalidateMinimum()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *box) SetRole (role tomo.Role) {
|
||||||
|
this.role = role
|
||||||
|
}
|
||||||
|
|
||||||
func (this *box) SetDNDData (dat data.Data) {
|
func (this *box) SetDNDData (dat data.Data) {
|
||||||
this.dndData = dat
|
this.dndData = dat
|
||||||
}
|
}
|
||||||
@@ -191,7 +201,7 @@ func (this *box) SetDNDAccept (types ...data.Mime) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *box) SetFocused (focused bool) {
|
func (this *box) SetFocused (focused bool) {
|
||||||
hierarchy := this.parent.getHierarchy()
|
hierarchy := this.getHierarchy()
|
||||||
if hierarchy == nil {
|
if hierarchy == nil {
|
||||||
focusedCopy := focused
|
focusedCopy := focused
|
||||||
this.focusQueued = &focusedCopy
|
this.focusQueued = &focusedCopy
|
||||||
@@ -217,7 +227,7 @@ func (this *box) SetFocusable (focusable bool) {
|
|||||||
func (this *box) Focused () bool {
|
func (this *box) Focused () bool {
|
||||||
hierarchy := this.getHierarchy()
|
hierarchy := this.getHierarchy()
|
||||||
if hierarchy == nil { return false }
|
if hierarchy == nil { return false }
|
||||||
return hierarchy.isFocused(this)
|
return hierarchy.isFocused(this.outer)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *box) Modifiers () input.Modifiers {
|
func (this *box) Modifiers () input.Modifiers {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ func (this *Hierarchy) HandleKeyDown (key input.Key, numberPad bool) {
|
|||||||
// be called *before* HandleKeyUp.
|
// be called *before* HandleKeyUp.
|
||||||
func (this *Hierarchy) HandleKeyUp (key input.Key, numberPad bool) {
|
func (this *Hierarchy) HandleKeyUp (key input.Key, numberPad bool) {
|
||||||
if target := this.keyboardTarget(); target != nil {
|
if target := this.keyboardTarget(); target != nil {
|
||||||
target.handleKeyDown(key, numberPad)
|
target.handleKeyUp(key, numberPad)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,6 @@ type System struct {
|
|||||||
type BackendLink interface {
|
type BackendLink interface {
|
||||||
// NewTexture creates a new texture from an image.
|
// NewTexture creates a new texture from an image.
|
||||||
NewTexture (image.Image) canvas.TextureCloser
|
NewTexture (image.Image) canvas.TextureCloser
|
||||||
// NewCanvas creates a new blank canvas with the specified bounds.
|
|
||||||
NewCanvas (image.Rectangle) canvas.Canvas
|
|
||||||
// NewSurface creates a new surface with the specified bounds.
|
// NewSurface creates a new surface with the specified bounds.
|
||||||
NewSurface (image.Rectangle) (SurfaceLink, error)
|
NewSurface (image.Rectangle) (SurfaceLink, error)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,10 +31,6 @@ func (this *backendLink) NewTexture (source image.Image) canvas.TextureCloser {
|
|||||||
return this.backend.NewTexture(source)
|
return this.backend.NewTexture(source)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *backendLink) NewCanvas (bounds image.Rectangle) canvas.Canvas {
|
|
||||||
return this.backend.NewCanvas(bounds)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *backendLink) NewSurface (bounds image.Rectangle) (system.SurfaceLink, error) {
|
func (this *backendLink) NewSurface (bounds image.Rectangle) (system.SurfaceLink, error) {
|
||||||
// TODO
|
// TODO
|
||||||
return nil, errors.New("x: not implemented")
|
return nil, errors.New("x: not implemented")
|
||||||
@@ -126,7 +122,7 @@ func (this *Backend) NewTexture (source image.Image) canvas.TextureCloser {
|
|||||||
return xcanvas.NewTextureFrom(source)
|
return xcanvas.NewTextureFrom(source)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Backend) NewCanvas (bounds image.Rectangle) canvas.Canvas {
|
func (this *Backend) NewCanvas (bounds image.Rectangle) canvas.CanvasCloser {
|
||||||
return xcanvas.NewCanvas(this.x, bounds)
|
return xcanvas.NewCanvas(this.x, bounds)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,9 +49,10 @@ func (this *Canvas) Push (window xproto.Window) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Close frees this canvas from the X server.
|
// Close frees this canvas from the X server.
|
||||||
func (this *Canvas) Close () {
|
func (this *Canvas) Close () error {
|
||||||
this.assert()
|
this.assert()
|
||||||
this.Image.Destroy()
|
this.Image.Destroy()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Canvas) assert () {
|
func (this *Canvas) assert () {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ type scrollSum struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this needs to be configurable, we need a config api
|
// TODO: this needs to be configurable, we need a config api
|
||||||
const scrollDistance = 16
|
const scrollDistance = 32
|
||||||
|
|
||||||
func (sum *scrollSum) add (button xproto.Button, window *window, state uint16) {
|
func (sum *scrollSum) add (button xproto.Button, window *window, state uint16) {
|
||||||
if xgbkb.StateToModifiers(state).Shift {
|
if xgbkb.StateToModifiers(state).Shift {
|
||||||
|
|||||||
41
x/window.go
41
x/window.go
@@ -18,7 +18,6 @@ import "github.com/jezek/xgbutil/keybind"
|
|||||||
import "github.com/jezek/xgbutil/mousebind"
|
import "github.com/jezek/xgbutil/mousebind"
|
||||||
import "github.com/jezek/xgbutil/xgraphics"
|
import "github.com/jezek/xgbutil/xgraphics"
|
||||||
|
|
||||||
type mainWindow struct { *window }
|
|
||||||
type window struct {
|
type window struct {
|
||||||
backend *Backend
|
backend *Backend
|
||||||
hierarchy *system.Hierarchy
|
hierarchy *system.Hierarchy
|
||||||
@@ -28,6 +27,7 @@ type window struct {
|
|||||||
|
|
||||||
title string
|
title string
|
||||||
|
|
||||||
|
leader *window
|
||||||
modalParent *window
|
modalParent *window
|
||||||
hasModal bool
|
hasModal bool
|
||||||
shy bool
|
shy bool
|
||||||
@@ -63,28 +63,24 @@ func (this *windowLink) NotifyMinimumSizeChange () {
|
|||||||
func (this *Backend) NewWindow (
|
func (this *Backend) NewWindow (
|
||||||
bounds image.Rectangle,
|
bounds image.Rectangle,
|
||||||
) (
|
) (
|
||||||
output tomo.MainWindow,
|
output tomo.Window,
|
||||||
err error,
|
err error,
|
||||||
) {
|
) {
|
||||||
this.assert()
|
this.assert()
|
||||||
window, err := this.newWindow(bounds, false)
|
return this.newWindow(bounds, false)
|
||||||
|
|
||||||
output = mainWindow { window: window }
|
|
||||||
return output, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Backend) NewPlainWindow (
|
func (this *Backend) NewPlainWindow (
|
||||||
bounds image.Rectangle,
|
bounds image.Rectangle,
|
||||||
) (
|
) (
|
||||||
output tomo.MainWindow,
|
output tomo.Window,
|
||||||
err error,
|
err error,
|
||||||
) {
|
) {
|
||||||
this.assert()
|
this.assert()
|
||||||
window, err := this.newWindow(bounds, false)
|
window, err := this.newWindow(bounds, false)
|
||||||
window.setType("dock")
|
window.setType("dock")
|
||||||
|
|
||||||
output = mainWindow { window: window }
|
return window, err
|
||||||
return output, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Backend) newWindow (
|
func (this *Backend) newWindow (
|
||||||
@@ -100,6 +96,7 @@ func (this *Backend) newWindow (
|
|||||||
window := &window { backend: this }
|
window := &window { backend: this }
|
||||||
link := &windowLink { window: window }
|
link := &windowLink { window: window }
|
||||||
window.hierarchy = this.system.NewHierarchy(link)
|
window.hierarchy = this.system.NewHierarchy(link)
|
||||||
|
window.leader = window
|
||||||
|
|
||||||
window.xWindow, err = xwindow.Generate(this.x)
|
window.xWindow, err = xwindow.Generate(this.x)
|
||||||
if err != nil { return }
|
if err != nil { return }
|
||||||
@@ -178,10 +175,11 @@ 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 ...image.Image) {
|
func (this *window) SetIcon (sizes ...canvas.Texture) {
|
||||||
wmIcons := []ewmh.WmIcon { }
|
wmIcons := []ewmh.WmIcon { }
|
||||||
|
|
||||||
for _, icon := range sizes {
|
for _, icon := range sizes {
|
||||||
|
// TODO we use textures now. make this better
|
||||||
width := icon.Bounds().Max.X
|
width := icon.Bounds().Max.X
|
||||||
height := icon.Bounds().Max.Y
|
height := icon.Bounds().Max.Y
|
||||||
wmIcon := ewmh.WmIcon {
|
wmIcon := ewmh.WmIcon {
|
||||||
@@ -247,19 +245,24 @@ func (this *window) NewModal (bounds image.Rectangle) (tomo.Window, error) {
|
|||||||
return modal, err
|
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 (
|
child, err := this.backend.newWindow (
|
||||||
bounds.Add(this.metrics.bounds.Min), false)
|
bounds.Add(this.metrics.bounds.Min), false)
|
||||||
|
child.leader = leader
|
||||||
if err != nil { return nil, err }
|
if err != nil { return nil, err }
|
||||||
child.setClientLeader(this.window)
|
|
||||||
this.setClientLeader(this.window)
|
child.setClientLeader(leader)
|
||||||
|
leader.setClientLeader(leader)
|
||||||
|
|
||||||
icccm.WmTransientForSet (
|
icccm.WmTransientForSet (
|
||||||
this.backend.x,
|
this.backend.x,
|
||||||
this.xWindow.Id,
|
child.xWindow.Id,
|
||||||
this.xWindow.Id)
|
leader.xWindow.Id)
|
||||||
this.setType("UTILITY")
|
child.setType("UTILITY")
|
||||||
// this.inheritProperties(this.window)
|
// child.inheritProperties(leader.window)
|
||||||
return this, err
|
return child, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *window) Widget () (tomo.Window, error) {
|
func (this *window) Widget () (tomo.Window, error) {
|
||||||
@@ -361,7 +364,7 @@ func (this *window) reallocateCanvas () {
|
|||||||
|
|
||||||
if larger || smaller {
|
if larger || smaller {
|
||||||
if this.xCanvas != nil {
|
if this.xCanvas != nil {
|
||||||
this.xCanvas.Destroy()
|
this.xCanvas.Close()
|
||||||
}
|
}
|
||||||
this.xCanvas = xcanvas.NewCanvasFrom(xgraphics.New (
|
this.xCanvas = xcanvas.NewCanvasFrom(xgraphics.New (
|
||||||
this.backend.x,
|
this.backend.x,
|
||||||
|
|||||||
Reference in New Issue
Block a user