diff --git a/app/os_x11.go b/app/os_x11.go index e5a8ed12..53d0540e 100644 --- a/app/os_x11.go +++ b/app/os_x11.go @@ -598,6 +598,7 @@ func (h *x11EventHandler) handleEvents() bool { case C.Button3: btn = pointer.ButtonSecondary case C.Button4: + btn = pointer.ButtonQuaternary ev.Kind = pointer.Scroll // scroll up or left (if shift is pressed). if ev.Modifiers == key.ModShift { @@ -606,6 +607,7 @@ func (h *x11EventHandler) handleEvents() bool { ev.Scroll.Y = -scrollScale } case C.Button5: + btn = pointer.ButtonQuinary // scroll down or right (if shift is pressed). ev.Kind = pointer.Scroll if ev.Modifiers == key.ModShift { @@ -614,17 +616,24 @@ func (h *x11EventHandler) handleEvents() bool { ev.Scroll.Y = +scrollScale } case 6: + btn = pointer.ButtonSenary // http://xahlee.info/linux/linux_x11_mouse_button_number.html // scroll left. ev.Kind = pointer.Scroll ev.Scroll.X = -scrollScale * 2 case 7: + btn = pointer.ButtonSeptenary // scroll right ev.Kind = pointer.Scroll ev.Scroll.X = +scrollScale * 2 + case 8: + btn = pointer.ButtonOctonary + case 9: + btn = pointer.ButtonNonary default: continue } + // Update button state for all button events (including scroll events) switch _type { case C.ButtonPress: w.pointerBtns |= btn diff --git a/examples/inputlog/main.go b/examples/inputlog/main.go index b8657b06..b683ae74 100644 --- a/examples/inputlog/main.go +++ b/examples/inputlog/main.go @@ -15,7 +15,6 @@ import ( "github.com/mleku/fromage/op" "github.com/mleku/fromage/op/clip" "github.com/mleku/fromage/op/paint" - "github.com/mleku/fromage/unit" "github.com/mleku/fromage/widget/material" ) @@ -78,13 +77,7 @@ func (h *InputHandler) Layout(gtx layout.Context, th *material.Theme) { return layout.Dimensions{Size: gtx.Constraints.Max} }) - // Add some text at the top - label := layout.Rigid(func(gtx layout.Context) layout.Dimensions { - return material.Label(th, unit.Sp(16), - "Input Logger - Move mouse and press keys to see events logged").Layout(gtx) - }) - - flex.Layout(gtx, label, box) + flex.Layout(gtx, box) // Handle events after layout h.handleEvents(gtx) diff --git a/io/pointer/pointer.go b/io/pointer/pointer.go index 99a5896b..ad5e8d99 100644 --- a/io/pointer/pointer.go +++ b/io/pointer/pointer.go @@ -92,7 +92,7 @@ type Priority uint8 type Source uint8 // Buttons is a set of mouse buttons -type Buttons uint8 +type Buttons uint16 // Cursor denotes a pre-defined cursor shape. Its Add method adds an // operation that sets the cursor shape for the current clip area. @@ -225,6 +225,14 @@ const ( // ButtonQuinary is the fifth button, usually used for browser // navigation (forward) ButtonQuinary + // ButtonSenary is the sixth button, usually used for scroll left + ButtonSenary + // ButtonSeptenary is the seventh button, usually used for scroll right + ButtonSeptenary + // ButtonOctonary is the eighth button, usually browser back navigation + ButtonOctonary + // ButtonNonary is the ninth button, usually browser forward navigation + ButtonNonary ) func (s ScrollRange) Union(s2 ScrollRange) ScrollRange { @@ -338,6 +346,18 @@ func (b Buttons) String() string { if b.Contain(ButtonQuinary) { strs = append(strs, "ButtonQuinary") } + if b.Contain(ButtonSenary) { + strs = append(strs, "ButtonSenary") + } + if b.Contain(ButtonSeptenary) { + strs = append(strs, "ButtonSeptenary") + } + if b.Contain(ButtonOctonary) { + strs = append(strs, "ButtonOctonary") + } + if b.Contain(ButtonNonary) { + strs = append(strs, "ButtonNonary") + } return strings.Join(strs, "|") }