Skip to content

Commit 21e02f5

Browse files
Drakiruszephylac
authored andcommitted
fixes Hover and some coding style
1 parent 1cebfed commit 21e02f5

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ It's also possible to [manually install](https://github.com/go-flutter-desktop/g
4949
- <kbd>Right</kbd> <kbd>ctrl-Right</kbd> <kbd>ctrl-shift-Right</kbd>
5050
- <kbd>Backspace</kbd> <kbd>ctrl-Backspace</kbd> <kbd>Delete</kbd>
5151
- Mouse-over/hovering
52+
- Mouse-buttons
5253
- RawKeyboard events (through `RawKeyEventDataLinux` regardless of the platform)
5354

5455
Are you missing a feature? [Open an issue!](https://github.com/go-flutter-desktop/go-flutter/issues/new)

embedder/embedder.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,14 @@ const (
143143
PointerPhaseHover PointerPhase = C.kHover
144144
)
145145

146-
// PointerPhase corresponds to the C.enum describing phase of the mouse pointer.
146+
// PointerButtonMouse corresponds to the C.enum describing the mouse buttons.
147147
type PointerButtonMouse int64
148148

149149
// Values representing the mouse buttons.
150150
const (
151151
PointerButtonMousePrimary PointerButtonMouse = C.kFlutterPointerButtonMousePrimary
152152
PointerButtonMouseSecondary PointerButtonMouse = C.kFlutterPointerButtonMouseSecondary
153153
PointerButtonMouseMiddle PointerButtonMouse = C.kFlutterPointerButtonMouseMiddle
154-
PointerButtonMouseBack PointerButtonMouse = C.kFlutterPointerButtonMouseBack
155-
PointerButtonMouseForward PointerButtonMouse = C.kFlutterPointerButtonMouseForward
156154
)
157155

158156
// PointerSignalKind corresponds to the C.enum describing signal kind of the mouse pointer.

glfw.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,28 +117,29 @@ func (m *windowManager) glfwCursorPosCallback(window *glfw.Window, x, y float64)
117117
func (m *windowManager) handleButtonPhase(window *glfw.Window, action glfw.Action, buttons embedder.PointerButtonMouse) {
118118
if action == glfw.Press {
119119
m.pointerButton |= buttons
120-
// If only one button is pressed then each bits of buttons will be equals to m.pointerButton
121-
// 2019-06-18, FlutterPointerPhase with mouse
122-
// Refer to (https://github.com/flutter/engine/blob/master/shell/platform/embedder/embedder.h#L280-L314)
120+
// If only one button is pressed then each bits of buttons will be equals
121+
// to m.pointerButton.
123122
if m.pointerButton == buttons {
124123
m.sendPointerEventButton(window, embedder.PointerPhaseDown)
125124
} else {
125+
// if any other buttons are already pressed when a new button is pressed,
126+
// the engine is expecting a Move phase instead of a Down phase.
126127
m.sendPointerEventButton(window, embedder.PointerPhaseMove)
127128
}
128129
m.pointerPhase = embedder.PointerPhaseMove
129130
}
130131

131132
if action == glfw.Release {
132133
m.pointerButton ^= buttons
133-
// If all button are released then m.pointerButton will be equals to 0
134-
// 2019-06-18, FlutterPointerPhase with mouse
135-
// Refer to (https://github.com/flutter/engine/blob/master/shell/platform/embedder/embedder.h#L280-L314)
134+
// If all button are released then m.pointerButton is cleared
136135
if m.pointerButton == 0 {
137136
m.sendPointerEventButton(window, embedder.PointerPhaseUp)
137+
m.pointerPhase = embedder.PointerPhaseHover
138138
} else {
139+
// if any other buttons are still pressed when one button is released
140+
// the engine is expecting a Move phase instead of a Up phase.
139141
m.sendPointerEventButton(window, embedder.PointerPhaseMove)
140142
}
141-
m.pointerPhase = embedder.PointerPhaseHover
142143
}
143144
}
144145

0 commit comments

Comments
 (0)