diff --git a/backends/x/event.go b/backends/x/event.go index d4e7017..189237c 100644 --- a/backends/x/event.go +++ b/backends/x/event.go @@ -272,10 +272,7 @@ func (window *Window) compressMotionNotify ( typedEvent, ok := untypedEvent.Event.(xproto.MotionNotifyEvent) if !ok { continue } - if firstEvent.Event == typedEvent.Event && - typedEvent.Detail >= 4 && - typedEvent.Detail <= 7 { - + if firstEvent.Event == typedEvent.Event { lastEvent = typedEvent defer func (index int) { xevent.DequeueAt(window.backend.connection, index) diff --git a/elements/basic/scrollcontainer.go b/elements/basic/scrollcontainer.go index a5a372a..747b81b 100644 --- a/elements/basic/scrollcontainer.go +++ b/elements/basic/scrollcontainer.go @@ -20,7 +20,7 @@ type ScrollContainer struct { exists bool enabled bool dragging bool - dragOffset image.Point + dragOffset int gutter image.Rectangle bar image.Rectangle } @@ -29,7 +29,7 @@ type ScrollContainer struct { exists bool enabled bool dragging bool - dragOffset image.Point + dragOffset int gutter image.Rectangle bar image.Rectangle } @@ -111,12 +111,16 @@ func (element *ScrollContainer) HandleKeyUp (key tomo.Key, modifiers tomo.Modifi func (element *ScrollContainer) HandleMouseDown (x, y int, button tomo.Button) { point := image.Pt(x, y) - if point.In(element.horizontal.gutter) { + if point.In(element.horizontal.bar) { element.horizontal.dragging = true + element.horizontal.dragOffset = + point.Sub(element.horizontal.bar.Min).X element.dragHorizontalBar(point) - } else if point.In(element.vertical.gutter) { + } else if point.In(element.vertical.bar) { element.vertical.dragging = true + element.vertical.dragOffset = + point.Sub(element.vertical.bar.Min).Y element.dragVerticalBar(point) } else if child, ok := element.child.(tomo.MouseTarget); ok { @@ -353,8 +357,7 @@ func (element *ScrollContainer) dragHorizontalBar (mousePosition image.Point) { scrollX := float64(element.child.ScrollContentBounds().Dx()) / float64(element.horizontal.gutter.Dx()) * - float64 ( - mousePosition.X - element.horizontal.bar.Dx() / 2) + float64(mousePosition.X - element.horizontal.dragOffset) scrollY := element.child.ScrollViewportBounds().Min.Y element.child.ScrollTo(image.Pt(int(scrollX), scrollY)) } @@ -363,8 +366,7 @@ func (element *ScrollContainer) dragVerticalBar (mousePosition image.Point) { scrollY := float64(element.child.ScrollContentBounds().Dy()) / float64(element.vertical.gutter.Dy()) * - float64 ( - mousePosition.Y - element.vertical.bar.Dy() / 2) + float64(mousePosition.Y - element.vertical.dragOffset) scrollX := element.child.ScrollViewportBounds().Min.X element.child.ScrollTo(image.Pt(scrollX, int(scrollY))) }