all: remove unused fields, functions and add missing error handling

Credit to staticcheck.io.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-02-27 22:26:54 +01:00
parent 4b7387369b
commit bfb50cef5d
10 changed files with 19 additions and 53 deletions
+5 -6
View File
@@ -36,12 +36,11 @@ type eglContext struct {
} }
var ( var (
nilEGLDisplay _EGLDisplay nilEGLDisplay _EGLDisplay
nilEGLSurface _EGLSurface nilEGLSurface _EGLSurface
nilEGLContext _EGLContext nilEGLContext _EGLContext
nilEGLConfig _EGLConfig nilEGLConfig _EGLConfig
nilEGLNativeWindowType NativeWindowType EGL_DEFAULT_DISPLAY NativeDisplayType
EGL_DEFAULT_DISPLAY NativeDisplayType
) )
const ( const (
-7
View File
@@ -1001,13 +1001,6 @@ func (w *window) isAnimating() bool {
return w.animating || w.fling.anim.Active() return w.animating || w.fling.anim.Active()
} }
func (w *window) kill(err error) {
if w.pendingErr == nil {
w.pendingErr = err
}
w.dead = true
}
func (w *window) draw(sync bool) { func (w *window) draw(sync bool) {
w.flushScroll() w.flushScroll()
w.mu.Lock() w.mu.Lock()
+3 -5
View File
@@ -203,11 +203,9 @@ func (w *x11Window) atom(name string, onlyIfExists bool) C.Atom {
// in x11window.loop. // in x11window.loop.
// //
type x11EventHandler struct { type x11EventHandler struct {
w *x11Window w *x11Window
text []byte text []byte
xev *C.XEvent xev *C.XEvent
status C.Status
keysym C.KeySym
} }
// handleEvents returns true if the window needs to be redrawn. // handleEvents returns true if the window needs to be redrawn.
-5
View File
@@ -272,11 +272,6 @@ const (
materialTexture materialTexture
) )
const (
attribPos = 0
attribUV = 1
)
func New(ctx backend.Device) (*GPU, error) { func New(ctx backend.Device) (*GPU, error) {
defFBO := ctx.CurrentFramebuffer() defFBO := ctx.CurrentFramebuffer()
g := &GPU{ g := &GPU{
+3 -8
View File
@@ -107,14 +107,6 @@ const (
pathBatchSize = 10000 pathBatchSize = 10000
) )
const (
attribPathCorner = 0
attribPathMaxY = 1
attribPathFrom = 2
attribPathCtrl = 3
attribPathTo = 4
)
func newPather(ctx backend.Device) *pather { func newPather(ctx backend.Device) *pather {
return &pather{ return &pather{
ctx: ctx, ctx: ctx,
@@ -217,6 +209,9 @@ func (s *fboSet) resize(ctx backend.Device, sizes []image.Point) {
} }
tex, err := ctx.NewTexture(backend.TextureFormatFloat, sz.X, sz.Y, backend.FilterNearest, backend.FilterNearest, tex, err := ctx.NewTexture(backend.TextureFormatFloat, sz.X, sz.Y, backend.FilterNearest, backend.FilterNearest,
backend.BufferBindingTexture|backend.BufferBindingFramebuffer) backend.BufferBindingTexture|backend.BufferBindingFramebuffer)
if err != nil {
panic(err)
}
fbo, err := ctx.NewFramebuffer(tex, 0) fbo, err := ctx.NewFramebuffer(tex, 0)
if err != nil { if err != nil {
panic(err) panic(err)
+4 -7
View File
@@ -23,9 +23,6 @@ type FrameEvent struct {
// Frame replaces the window's frame with the new // Frame replaces the window's frame with the new
// frame. // frame.
Frame func(frame *op.Ops) Frame func(frame *op.Ops)
// Whether this draw is system generated and needs a complete
// frame before proceeding.
sync bool
} }
// Config defines the essential properties of // Config defines the essential properties of
@@ -96,7 +93,7 @@ func (l Stage) String() string {
} }
} }
func (_ FrameEvent) ImplementsEvent() {} func (FrameEvent) ImplementsEvent() {}
func (_ StageEvent) ImplementsEvent() {} func (StageEvent) ImplementsEvent() {}
func (_ *CommandEvent) ImplementsEvent() {} func (*CommandEvent) ImplementsEvent() {}
func (_ DestroyEvent) ImplementsEvent() {} func (DestroyEvent) ImplementsEvent() {}
-2
View File
@@ -36,8 +36,6 @@ type FlexChild struct {
// Spacing determine the spacing mode for a Flex. // Spacing determine the spacing mode for a Flex.
type Spacing uint8 type Spacing uint8
type flexMode uint8
const ( const (
// SpaceEnd leaves space at the end. // SpaceEnd leaves space at the end.
SpaceEnd Spacing = iota SpaceEnd Spacing = iota
+4 -5
View File
@@ -95,11 +95,10 @@ type Ops struct {
// StackOp saves and restores the operation state // StackOp saves and restores the operation state
// in a stack-like manner. // in a stack-like manner.
type StackOp struct { type StackOp struct {
stackDepth int id stackID
id stackID macroID int
macroID int active bool
active bool ops *Ops
ops *Ops
} }
// MacroOp records a list of operations for later use. // MacroOp records a list of operations for later use.
-7
View File
@@ -132,13 +132,6 @@ func toPointF(p image.Point) f32.Point {
return f32.Point{X: float32(p.X), Y: float32(p.Y)} return f32.Point{X: float32(p.X), Y: float32(p.Y)}
} }
func toRectF(r image.Rectangle) f32.Rectangle {
return f32.Rectangle{
Min: toPointF(r.Min),
Max: toPointF(r.Max),
}
}
func drawInk(gtx *layout.Context, c widget.Click) { func drawInk(gtx *layout.Context, c widget.Click) {
d := gtx.Now().Sub(c.Time) d := gtx.Now().Sub(c.Time)
t := float32(d.Seconds()) t := float32(d.Seconds())
-1
View File
@@ -17,7 +17,6 @@ import (
type Icon struct { type Icon struct {
Color color.RGBA Color color.RGBA
src []byte src []byte
size unit.Value
// Cached values. // Cached values.
op paint.ImageOp op paint.ImageOp
imgSize int imgSize int