fix(webview): keep touchpad gesture types out of ports
- commit
- bd52731840e29a1058da1f21c3db5907848a832c
- author
- brice · · 2026-06-18 11:29 UTC
- parent
- e5d6019
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
9 files · +81 -71
A internal/application/dto/touchpad_navigation.go +33 -0
| @@ -0,0 +1,33 @@ | |||
| 1 | + | package dto | |
| 2 | + | ||
| 3 | + | // TouchpadNavigationAction indicates the direction of a touchpad navigation gesture. | |
| 4 | + | type TouchpadNavigationAction int | |
| 5 | + | ||
| 6 | + | const ( | |
| 7 | + | // TouchpadNavigationBack indicates a backward navigation gesture. | |
| 8 | + | TouchpadNavigationBack TouchpadNavigationAction = iota | |
| 9 | + | // TouchpadNavigationForward indicates a forward navigation gesture. | |
| 10 | + | TouchpadNavigationForward | |
| 11 | + | ) | |
| 12 | + | ||
| 13 | + | // String returns a human-readable representation of the navigation action. | |
| 14 | + | func (a TouchpadNavigationAction) String() string { | |
| 15 | + | switch a { | |
| 16 | + | case TouchpadNavigationBack: | |
| 17 | + | return "back" | |
| 18 | + | case TouchpadNavigationForward: | |
| 19 | + | return "forward" | |
| 20 | + | default: | |
| 21 | + | return "unknown" | |
| 22 | + | } | |
| 23 | + | } | |
| 24 | + | ||
| 25 | + | // TouchpadNavigationGesture describes visual progress for a deliberate | |
| 26 | + | // two-finger history navigation gesture. | |
| 27 | + | type TouchpadNavigationGesture struct { | |
| 28 | + | Action TouchpadNavigationAction | |
| 29 | + | // Progress is normalized gesture progress from 0.0 to 1.0. | |
| 30 | + | Progress float64 | |
| 31 | + | ThresholdReached bool | |
| 32 | + | Active bool | |
| 33 | + | } | |
| @@ -0,0 +1,33 @@ | |||||
| 1 | + | package dto | |||
| 2 | + | ||||
| 3 | + | // TouchpadNavigationAction indicates the direction of a touchpad navigation gesture. | |||
| 4 | + | type TouchpadNavigationAction int | |||
| 5 | + | ||||
| 6 | + | const ( | |||
| 7 | + | // TouchpadNavigationBack indicates a backward navigation gesture. | |||
| 8 | + | TouchpadNavigationBack TouchpadNavigationAction = iota | |||
| 9 | + | // TouchpadNavigationForward indicates a forward navigation gesture. | |||
| 10 | + | TouchpadNavigationForward | |||
| 11 | + | ) | |||
| 12 | + | ||||
| 13 | + | // String returns a human-readable representation of the navigation action. | |||
| 14 | + | func (a TouchpadNavigationAction) String() string { | |||
| 15 | + | switch a { | |||
| 16 | + | case TouchpadNavigationBack: | |||
| 17 | + | return "back" | |||
| 18 | + | case TouchpadNavigationForward: | |||
| 19 | + | return "forward" | |||
| 20 | + | default: | |||
| 21 | + | return "unknown" | |||
| 22 | + | } | |||
| 23 | + | } | |||
| 24 | + | ||||
| 25 | + | // TouchpadNavigationGesture describes visual progress for a deliberate | |||
| 26 | + | // two-finger history navigation gesture. | |||
| 27 | + | type TouchpadNavigationGesture struct { | |||
| 28 | + | Action TouchpadNavigationAction | |||
| 29 | + | // Progress is normalized gesture progress from 0.0 to 1.0. | |||
| 30 | + | Progress float64 | |||
| 31 | + | ThresholdReached bool | |||
| 32 | + | Active bool | |||
| 33 | + | } | |||
M internal/application/port/webview.go +1 -33
| @@ -87,38 +87,6 @@ type Texture interface { | |||
| 87 | 87 | GoPointer() uintptr | |
| 88 | 88 | } | |
| 89 | 89 | ||
| 90 | - | // TouchpadNavigationAction indicates the direction of a touchpad navigation gesture. | |
| 91 | - | type TouchpadNavigationAction int | |
| 92 | - | ||
| 93 | - | const ( | |
| 94 | - | // TouchpadNavigationBack indicates a backward navigation gesture. | |
| 95 | - | TouchpadNavigationBack TouchpadNavigationAction = iota | |
| 96 | - | // TouchpadNavigationForward indicates a forward navigation gesture. | |
| 97 | - | TouchpadNavigationForward | |
| 98 | - | ) | |
| 99 | - | ||
| 100 | - | // String returns a human-readable representation of the navigation action. | |
| 101 | - | func (a TouchpadNavigationAction) String() string { | |
| 102 | - | switch a { | |
| 103 | - | case TouchpadNavigationBack: | |
| 104 | - | return "back" | |
| 105 | - | case TouchpadNavigationForward: | |
| 106 | - | return "forward" | |
| 107 | - | default: | |
| 108 | - | return "unknown" | |
| 109 | - | } | |
| 110 | - | } | |
| 111 | - | ||
| 112 | - | // TouchpadNavigationGesture describes visual progress for a deliberate | |
| 113 | - | // two-finger history navigation gesture. | |
| 114 | - | type TouchpadNavigationGesture struct { | |
| 115 | - | Action TouchpadNavigationAction | |
| 116 | - | // Progress is normalized gesture progress from 0.0 to 1.0. | |
| 117 | - | Progress float64 | |
| 118 | - | ThresholdReached bool | |
| 119 | - | Active bool | |
| 120 | - | } | |
| 121 | - | ||
| 122 | 90 | // WebViewCallbacks defines callback handlers for WebView events. | |
| 123 | 91 | // Implementations should invoke these on the main thread/goroutine. | |
| 124 | 92 | type WebViewCallbacks struct { | |
| @@ -171,7 +139,7 @@ type WebViewCallbacks struct { | |||
| 171 | 139 | OnAudioStateChanged func(playing bool) | |
| 172 | 140 | // OnTouchpadNavigationGesture is called while a two-finger touchpad history | |
| 173 | 141 | // navigation gesture is progressing or finishing. | |
| 174 | - | OnTouchpadNavigationGesture func(gesture TouchpadNavigationGesture) | |
| 142 | + | OnTouchpadNavigationGesture func(gesture dto.TouchpadNavigationGesture) | |
| 175 | 143 | } | |
| 176 | 144 | ||
| 177 | 145 | // FindOptions configures search behavior. | |
| @@ -87,38 +87,6 @@ type Texture interface { | |||||
| 87 | GoPointer() uintptr | 87 | GoPointer() uintptr | ||
| 88 | } | 88 | } | ||
| 89 | 89 | ||||
| 90 | - | // TouchpadNavigationAction indicates the direction of a touchpad navigation gesture. | |||
| 91 | - | type TouchpadNavigationAction int | |||
| 92 | - | ||||
| 93 | - | const ( | |||
| 94 | - | // TouchpadNavigationBack indicates a backward navigation gesture. | |||
| 95 | - | TouchpadNavigationBack TouchpadNavigationAction = iota | |||
| 96 | - | // TouchpadNavigationForward indicates a forward navigation gesture. | |||
| 97 | - | TouchpadNavigationForward | |||
| 98 | - | ) | |||
| 99 | - | ||||
| 100 | - | // String returns a human-readable representation of the navigation action. | |||
| 101 | - | func (a TouchpadNavigationAction) String() string { | |||
| 102 | - | switch a { | |||
| 103 | - | case TouchpadNavigationBack: | |||
| 104 | - | return "back" | |||
| 105 | - | case TouchpadNavigationForward: | |||
| 106 | - | return "forward" | |||
| 107 | - | default: | |||
| 108 | - | return "unknown" | |||
| 109 | - | } | |||
| 110 | - | } | |||
| 111 | - | ||||
| 112 | - | // TouchpadNavigationGesture describes visual progress for a deliberate | |||
| 113 | - | // two-finger history navigation gesture. | |||
| 114 | - | type TouchpadNavigationGesture struct { | |||
| 115 | - | Action TouchpadNavigationAction | |||
| 116 | - | // Progress is normalized gesture progress from 0.0 to 1.0. | |||
| 117 | - | Progress float64 | |||
| 118 | - | ThresholdReached bool | |||
| 119 | - | Active bool | |||
| 120 | - | } | |||
| 121 | - | ||||
| 122 | // WebViewCallbacks defines callback handlers for WebView events. | 90 | // WebViewCallbacks defines callback handlers for WebView events. | ||
| 123 | // Implementations should invoke these on the main thread/goroutine. | 91 | // Implementations should invoke these on the main thread/goroutine. | ||
| 124 | type WebViewCallbacks struct { | 92 | type WebViewCallbacks struct { | ||
| @@ -171,7 +139,7 @@ type WebViewCallbacks struct { | |||||
| 171 | OnAudioStateChanged func(playing bool) | 139 | OnAudioStateChanged func(playing bool) | ||
| 172 | // OnTouchpadNavigationGesture is called while a two-finger touchpad history | 140 | // OnTouchpadNavigationGesture is called while a two-finger touchpad history | ||
| 173 | // navigation gesture is progressing or finishing. | 141 | // navigation gesture is progressing or finishing. | ||
| 174 | - | OnTouchpadNavigationGesture func(gesture TouchpadNavigationGesture) | 142 | + | OnTouchpadNavigationGesture func(gesture dto.TouchpadNavigationGesture) |
| 175 | } | 143 | } | ||
| 176 | 144 | ||||
| 177 | // FindOptions configures search behavior. | 145 | // FindOptions configures search behavior. | ||
M internal/infrastructure/cef/touchpad_navigation.go +18 -18
| @@ -3,7 +3,7 @@ package cef | |||
| 3 | 3 | import ( | |
| 4 | 4 | "math" | |
| 5 | 5 | ||
| 6 | - | "github.com/bnema/dumber/internal/application/port" | |
| 6 | + | "github.com/bnema/dumber/internal/application/dto" | |
| 7 | 7 | cef2gtk "github.com/bnema/purego-cef2gtk" | |
| 8 | 8 | "github.com/bnema/puregotk/v4/gdk" | |
| 9 | 9 | ) | |
| @@ -25,7 +25,7 @@ type touchpadNavigationRecognizer struct { | |||
| 25 | 25 | thresholdReached bool | |
| 26 | 26 | verticalCanceled bool | |
| 27 | 27 | indicatorShown bool | |
| 28 | - | lastIndicatorAction port.TouchpadNavigationAction | |
| 28 | + | lastIndicatorAction dto.TouchpadNavigationAction | |
| 29 | 29 | } | |
| 30 | 30 | ||
| 31 | 31 | type touchpadNavigationInput struct { | |
| @@ -38,7 +38,7 @@ type touchpadNavigationInput struct { | |||
| 38 | 38 | ||
| 39 | 39 | type touchpadNavigationResult struct { | |
| 40 | 40 | HasIndicator bool | |
| 41 | - | Indicator port.TouchpadNavigationGesture | |
| 41 | + | Indicator dto.TouchpadNavigationGesture | |
| 42 | 42 | HasAction bool | |
| 43 | 43 | Action cef2gtk.NavigationSwipeAction | |
| 44 | 44 | } | |
| @@ -103,7 +103,7 @@ func (r *touchpadNavigationRecognizer) handleUpdate(input touchpadNavigationInpu | |||
| 103 | 103 | r.lastIndicatorAction = action | |
| 104 | 104 | return touchpadNavigationResult{ | |
| 105 | 105 | HasIndicator: true, | |
| 106 | - | Indicator: port.TouchpadNavigationGesture{ | |
| 106 | + | Indicator: dto.TouchpadNavigationGesture{ | |
| 107 | 107 | Action: action, | |
| 108 | 108 | Progress: progress, | |
| 109 | 109 | ThresholdReached: r.thresholdReached, | |
| @@ -138,7 +138,7 @@ func (r *touchpadNavigationRecognizer) finishIndicator(input touchpadNavigationI | |||
| 138 | 138 | threshold := normalizedTouchpadNavigationMinDelta(input.Config.TouchpadNavigationMinDelta) | |
| 139 | 139 | return touchpadNavigationResult{ | |
| 140 | 140 | HasIndicator: true, | |
| 141 | - | Indicator: port.TouchpadNavigationGesture{ | |
| 141 | + | Indicator: dto.TouchpadNavigationGesture{ | |
| 142 | 142 | Action: action, | |
| 143 | 143 | Progress: clampFloat(math.Abs(r.cumulativeDX)/threshold, 0, 1), | |
| 144 | 144 | ThresholdReached: triggered, | |
| @@ -147,12 +147,12 @@ func (r *touchpadNavigationRecognizer) finishIndicator(input touchpadNavigationI | |||
| 147 | 147 | } | |
| 148 | 148 | } | |
| 149 | 149 | ||
| 150 | - | func (r *touchpadNavigationRecognizer) indicatorAction(input touchpadNavigationInput) (port.TouchpadNavigationAction, bool) { | |
| 150 | + | func (r *touchpadNavigationRecognizer) indicatorAction(input touchpadNavigationInput) (dto.TouchpadNavigationAction, bool) { | |
| 151 | 151 | return r.resolvedDirection(input) | |
| 152 | 152 | } | |
| 153 | 153 | ||
| 154 | 154 | func (r *touchpadNavigationRecognizer) cancelAsTooVertical() touchpadNavigationResult { | |
| 155 | - | var action port.TouchpadNavigationAction | |
| 155 | + | var action dto.TouchpadNavigationAction | |
| 156 | 156 | hasAction := r.indicatorShown | |
| 157 | 157 | if hasAction { | |
| 158 | 158 | action = r.lastIndicatorAction | |
| @@ -164,7 +164,7 @@ func (r *touchpadNavigationRecognizer) cancelAsTooVertical() touchpadNavigationR | |||
| 164 | 164 | } | |
| 165 | 165 | return touchpadNavigationResult{ | |
| 166 | 166 | HasIndicator: true, | |
| 167 | - | Indicator: port.TouchpadNavigationGesture{ | |
| 167 | + | Indicator: dto.TouchpadNavigationGesture{ | |
| 168 | 168 | Action: action, | |
| 169 | 169 | Active: false, | |
| 170 | 170 | }, | |
| @@ -176,20 +176,20 @@ func (r *touchpadNavigationRecognizer) navigationAction(input touchpadNavigation | |||
| 176 | 176 | if !ok { | |
| 177 | 177 | return cef2gtk.NavigationSwipeBack, false | |
| 178 | 178 | } | |
| 179 | - | if action == port.TouchpadNavigationForward { | |
| 179 | + | if action == dto.TouchpadNavigationForward { | |
| 180 | 180 | return cef2gtk.NavigationSwipeForward, true | |
| 181 | 181 | } | |
| 182 | 182 | return cef2gtk.NavigationSwipeBack, true | |
| 183 | 183 | } | |
| 184 | 184 | ||
| 185 | - | func (r *touchpadNavigationRecognizer) resolvedDirection(input touchpadNavigationInput) (port.TouchpadNavigationAction, bool) { | |
| 186 | - | if r.cumulativeDX > 0 && input.CanGoBack && r.startedAtNavigationEdge(port.TouchpadNavigationBack) { | |
| 187 | - | return port.TouchpadNavigationBack, true | |
| 185 | + | func (r *touchpadNavigationRecognizer) resolvedDirection(input touchpadNavigationInput) (dto.TouchpadNavigationAction, bool) { | |
| 186 | + | if r.cumulativeDX > 0 && input.CanGoBack && r.startedAtNavigationEdge(dto.TouchpadNavigationBack) { | |
| 187 | + | return dto.TouchpadNavigationBack, true | |
| 188 | 188 | } | |
| 189 | - | if r.cumulativeDX < 0 && input.CanGoForward && r.startedAtNavigationEdge(port.TouchpadNavigationForward) { | |
| 190 | - | return port.TouchpadNavigationForward, true | |
| 189 | + | if r.cumulativeDX < 0 && input.CanGoForward && r.startedAtNavigationEdge(dto.TouchpadNavigationForward) { | |
| 190 | + | return dto.TouchpadNavigationForward, true | |
| 191 | 191 | } | |
| 192 | - | return port.TouchpadNavigationBack, false | |
| 192 | + | return dto.TouchpadNavigationBack, false | |
| 193 | 193 | } | |
| 194 | 194 | ||
| 195 | 195 | func (r *touchpadNavigationRecognizer) setGestureStart(input touchpadNavigationInput) { | |
| @@ -198,12 +198,12 @@ func (r *touchpadNavigationRecognizer) setGestureStart(input touchpadNavigationI | |||
| 198 | 198 | r.hasGestureStart = true | |
| 199 | 199 | } | |
| 200 | 200 | ||
| 201 | - | func (r *touchpadNavigationRecognizer) startedAtNavigationEdge(action port.TouchpadNavigationAction) bool { | |
| 201 | + | func (r *touchpadNavigationRecognizer) startedAtNavigationEdge(action dto.TouchpadNavigationAction) bool { | |
| 202 | 202 | if r.gestureViewWidth <= 0 { | |
| 203 | 203 | return false | |
| 204 | 204 | } | |
| 205 | 205 | edgeDistance := math.Min(r.gestureViewWidth*touchpadNavigationEdgeFraction, touchpadNavigationMaxEdgeDistance) | |
| 206 | - | if action == port.TouchpadNavigationForward { | |
| 206 | + | if action == dto.TouchpadNavigationForward { | |
| 207 | 207 | return r.gestureStartX >= r.gestureViewWidth-edgeDistance | |
| 208 | 208 | } | |
| 209 | 209 | return r.gestureStartX <= edgeDistance | |
| @@ -223,7 +223,7 @@ func (r *touchpadNavigationRecognizer) reset() { | |||
| 223 | 223 | r.thresholdReached = false | |
| 224 | 224 | r.verticalCanceled = false | |
| 225 | 225 | r.indicatorShown = false | |
| 226 | - | r.lastIndicatorAction = port.TouchpadNavigationBack | |
| 226 | + | r.lastIndicatorAction = dto.TouchpadNavigationBack | |
| 227 | 227 | } | |
| 228 | 228 | ||
| 229 | 229 | func isTouchpadNavigationPreciseEvent(event cef2gtk.ScrollEvent) bool { | |
| @@ -3,7 +3,7 @@ package cef | |||||
| 3 | import ( | 3 | import ( | ||
| 4 | "math" | 4 | "math" | ||
| 5 | 5 | ||||
| 6 | - | "github.com/bnema/dumber/internal/application/port" | 6 | + | "github.com/bnema/dumber/internal/application/dto" |
| 7 | cef2gtk "github.com/bnema/purego-cef2gtk" | 7 | cef2gtk "github.com/bnema/purego-cef2gtk" | ||
| 8 | "github.com/bnema/puregotk/v4/gdk" | 8 | "github.com/bnema/puregotk/v4/gdk" | ||
| 9 | ) | 9 | ) | ||
| @@ -25,7 +25,7 @@ type touchpadNavigationRecognizer struct { | |||||
| 25 | thresholdReached bool | 25 | thresholdReached bool | ||
| 26 | verticalCanceled bool | 26 | verticalCanceled bool | ||
| 27 | indicatorShown bool | 27 | indicatorShown bool | ||
| 28 | - | lastIndicatorAction port.TouchpadNavigationAction | 28 | + | lastIndicatorAction dto.TouchpadNavigationAction |
| 29 | } | 29 | } | ||
| 30 | 30 | ||||
| 31 | type touchpadNavigationInput struct { | 31 | type touchpadNavigationInput struct { | ||
| @@ -38,7 +38,7 @@ type touchpadNavigationInput struct { | |||||
| 38 | 38 | ||||
| 39 | type touchpadNavigationResult struct { | 39 | type touchpadNavigationResult struct { | ||
| 40 | HasIndicator bool | 40 | HasIndicator bool | ||
| 41 | - | Indicator port.TouchpadNavigationGesture | 41 | + | Indicator dto.TouchpadNavigationGesture |
| 42 | HasAction bool | 42 | HasAction bool | ||
| 43 | Action cef2gtk.NavigationSwipeAction | 43 | Action cef2gtk.NavigationSwipeAction | ||
| 44 | } | 44 | } | ||
| @@ -103,7 +103,7 @@ func (r *touchpadNavigationRecognizer) handleUpdate(input touchpadNavigationInpu | |||||
| 103 | r.lastIndicatorAction = action | 103 | r.lastIndicatorAction = action | ||
| 104 | return touchpadNavigationResult{ | 104 | return touchpadNavigationResult{ | ||
| 105 | HasIndicator: true, | 105 | HasIndicator: true, | ||
| 106 | - | Indicator: port.TouchpadNavigationGesture{ | 106 | + | Indicator: dto.TouchpadNavigationGesture{ |
| 107 | Action: action, | 107 | Action: action, | ||
| 108 | Progress: progress, | 108 | Progress: progress, | ||
| 109 | ThresholdReached: r.thresholdReached, | 109 | ThresholdReached: r.thresholdReached, | ||
| @@ -138,7 +138,7 @@ func (r *touchpadNavigationRecognizer) finishIndicator(input touchpadNavigationI | |||||
| 138 | threshold := normalizedTouchpadNavigationMinDelta(input.Config.TouchpadNavigationMinDelta) | 138 | threshold := normalizedTouchpadNavigationMinDelta(input.Config.TouchpadNavigationMinDelta) | ||
| 139 | return touchpadNavigationResult{ | 139 | return touchpadNavigationResult{ | ||
| 140 | HasIndicator: true, | 140 | HasIndicator: true, | ||
| 141 | - | Indicator: port.TouchpadNavigationGesture{ | 141 | + | Indicator: dto.TouchpadNavigationGesture{ |
| 142 | Action: action, | 142 | Action: action, | ||
| 143 | Progress: clampFloat(math.Abs(r.cumulativeDX)/threshold, 0, 1), | 143 | Progress: clampFloat(math.Abs(r.cumulativeDX)/threshold, 0, 1), | ||
| 144 | ThresholdReached: triggered, | 144 | ThresholdReached: triggered, | ||
| @@ -147,12 +147,12 @@ func (r *touchpadNavigationRecognizer) finishIndicator(input touchpadNavigationI | |||||
| 147 | } | 147 | } | ||
| 148 | } | 148 | } | ||
| 149 | 149 | ||||
| 150 | - | func (r *touchpadNavigationRecognizer) indicatorAction(input touchpadNavigationInput) (port.TouchpadNavigationAction, bool) { | 150 | + | func (r *touchpadNavigationRecognizer) indicatorAction(input touchpadNavigationInput) (dto.TouchpadNavigationAction, bool) { |
| 151 | return r.resolvedDirection(input) | 151 | return r.resolvedDirection(input) | ||
| 152 | } | 152 | } | ||
| 153 | 153 | ||||
| 154 | func (r *touchpadNavigationRecognizer) cancelAsTooVertical() touchpadNavigationResult { | 154 | func (r *touchpadNavigationRecognizer) cancelAsTooVertical() touchpadNavigationResult { | ||
| 155 | - | var action port.TouchpadNavigationAction | 155 | + | var action dto.TouchpadNavigationAction |
| 156 | hasAction := r.indicatorShown | 156 | hasAction := r.indicatorShown | ||
| 157 | if hasAction { | 157 | if hasAction { | ||
| 158 | action = r.lastIndicatorAction | 158 | action = r.lastIndicatorAction | ||
| @@ -164,7 +164,7 @@ func (r *touchpadNavigationRecognizer) cancelAsTooVertical() touchpadNavigationR | |||||
| 164 | } | 164 | } | ||
| 165 | return touchpadNavigationResult{ | 165 | return touchpadNavigationResult{ | ||
| 166 | HasIndicator: true, | 166 | HasIndicator: true, | ||
| 167 | - | Indicator: port.TouchpadNavigationGesture{ | 167 | + | Indicator: dto.TouchpadNavigationGesture{ |
| 168 | Action: action, | 168 | Action: action, | ||
| 169 | Active: false, | 169 | Active: false, | ||
| 170 | }, | 170 | }, | ||
| @@ -176,20 +176,20 @@ func (r *touchpadNavigationRecognizer) navigationAction(input touchpadNavigation | |||||
| 176 | if !ok { | 176 | if !ok { | ||
| 177 | return cef2gtk.NavigationSwipeBack, false | 177 | return cef2gtk.NavigationSwipeBack, false | ||
| 178 | } | 178 | } | ||
| 179 | - | if action == port.TouchpadNavigationForward { | 179 | + | if action == dto.TouchpadNavigationForward { |
| 180 | return cef2gtk.NavigationSwipeForward, true | 180 | return cef2gtk.NavigationSwipeForward, true | ||
| 181 | } | 181 | } | ||
| 182 | return cef2gtk.NavigationSwipeBack, true | 182 | return cef2gtk.NavigationSwipeBack, true | ||
| 183 | } | 183 | } | ||
| 184 | 184 | ||||
| 185 | - | func (r *touchpadNavigationRecognizer) resolvedDirection(input touchpadNavigationInput) (port.TouchpadNavigationAction, bool) { | 185 | + | func (r *touchpadNavigationRecognizer) resolvedDirection(input touchpadNavigationInput) (dto.TouchpadNavigationAction, bool) { |
| 186 | - | if r.cumulativeDX > 0 && input.CanGoBack && r.startedAtNavigationEdge(port.TouchpadNavigationBack) { | 186 | + | if r.cumulativeDX > 0 && input.CanGoBack && r.startedAtNavigationEdge(dto.TouchpadNavigationBack) { |
| 187 | - | return port.TouchpadNavigationBack, true | 187 | + | return dto.TouchpadNavigationBack, true |
| 188 | } | 188 | } | ||
| 189 | - | if r.cumulativeDX < 0 && input.CanGoForward && r.startedAtNavigationEdge(port.TouchpadNavigationForward) { | 189 | + | if r.cumulativeDX < 0 && input.CanGoForward && r.startedAtNavigationEdge(dto.TouchpadNavigationForward) { |
| 190 | - | return port.TouchpadNavigationForward, true | 190 | + | return dto.TouchpadNavigationForward, true |
| 191 | } | 191 | } | ||
| 192 | - | return port.TouchpadNavigationBack, false | 192 | + | return dto.TouchpadNavigationBack, false |
| 193 | } | 193 | } | ||
| 194 | 194 | ||||
| 195 | func (r *touchpadNavigationRecognizer) setGestureStart(input touchpadNavigationInput) { | 195 | func (r *touchpadNavigationRecognizer) setGestureStart(input touchpadNavigationInput) { | ||
| @@ -198,12 +198,12 @@ func (r *touchpadNavigationRecognizer) setGestureStart(input touchpadNavigationI | |||||
| 198 | r.hasGestureStart = true | 198 | r.hasGestureStart = true | ||
| 199 | } | 199 | } | ||
| 200 | 200 | ||||
| 201 | - | func (r *touchpadNavigationRecognizer) startedAtNavigationEdge(action port.TouchpadNavigationAction) bool { | 201 | + | func (r *touchpadNavigationRecognizer) startedAtNavigationEdge(action dto.TouchpadNavigationAction) bool { |
| 202 | if r.gestureViewWidth <= 0 { | 202 | if r.gestureViewWidth <= 0 { | ||
| 203 | return false | 203 | return false | ||
| 204 | } | 204 | } | ||
| 205 | edgeDistance := math.Min(r.gestureViewWidth*touchpadNavigationEdgeFraction, touchpadNavigationMaxEdgeDistance) | 205 | edgeDistance := math.Min(r.gestureViewWidth*touchpadNavigationEdgeFraction, touchpadNavigationMaxEdgeDistance) | ||
| 206 | - | if action == port.TouchpadNavigationForward { | 206 | + | if action == dto.TouchpadNavigationForward { |
| 207 | return r.gestureStartX >= r.gestureViewWidth-edgeDistance | 207 | return r.gestureStartX >= r.gestureViewWidth-edgeDistance | ||
| 208 | } | 208 | } | ||
| 209 | return r.gestureStartX <= edgeDistance | 209 | return r.gestureStartX <= edgeDistance | ||
| @@ -223,7 +223,7 @@ func (r *touchpadNavigationRecognizer) reset() { | |||||
| 223 | r.thresholdReached = false | 223 | r.thresholdReached = false | ||
| 224 | r.verticalCanceled = false | 224 | r.verticalCanceled = false | ||
| 225 | r.indicatorShown = false | 225 | r.indicatorShown = false | ||
| 226 | - | r.lastIndicatorAction = port.TouchpadNavigationBack | 226 | + | r.lastIndicatorAction = dto.TouchpadNavigationBack |
| 227 | } | 227 | } | ||
| 228 | 228 | ||||
| 229 | func isTouchpadNavigationPreciseEvent(event cef2gtk.ScrollEvent) bool { | 229 | func isTouchpadNavigationPreciseEvent(event cef2gtk.ScrollEvent) bool { | ||
M internal/infrastructure/cef/touchpad_navigation_test.go +5 -5
| @@ -3,7 +3,7 @@ package cef | |||
| 3 | 3 | import ( | |
| 4 | 4 | "testing" | |
| 5 | 5 | ||
| 6 | - | "github.com/bnema/dumber/internal/application/port" | |
| 6 | + | "github.com/bnema/dumber/internal/application/dto" | |
| 7 | 7 | cef2gtk "github.com/bnema/purego-cef2gtk" | |
| 8 | 8 | "github.com/bnema/puregotk/v4/gdk" | |
| 9 | 9 | "github.com/stretchr/testify/require" | |
| @@ -43,7 +43,7 @@ func TestTouchpadNavigationRecognizer_ReportsProgressAndNavigatesOnReleaseAfterT | |||
| 43 | 43 | CanGoForward: true, | |
| 44 | 44 | }) | |
| 45 | 45 | require.True(t, progress.HasIndicator) | |
| 46 | - | require.Equal(t, port.TouchpadNavigationBack, progress.Indicator.Action) | |
| 46 | + | require.Equal(t, dto.TouchpadNavigationBack, progress.Indicator.Action) | |
| 47 | 47 | require.True(t, progress.Indicator.Active) | |
| 48 | 48 | require.InDelta(t, 0.6, progress.Indicator.Progress, 0.001) | |
| 49 | 49 | require.False(t, progress.Indicator.ThresholdReached) | |
| @@ -56,7 +56,7 @@ func TestTouchpadNavigationRecognizer_ReportsProgressAndNavigatesOnReleaseAfterT | |||
| 56 | 56 | CanGoForward: true, | |
| 57 | 57 | }) | |
| 58 | 58 | require.True(t, armed.HasIndicator) | |
| 59 | - | require.Equal(t, port.TouchpadNavigationBack, armed.Indicator.Action) | |
| 59 | + | require.Equal(t, dto.TouchpadNavigationBack, armed.Indicator.Action) | |
| 60 | 60 | require.True(t, armed.Indicator.Active) | |
| 61 | 61 | require.InDelta(t, 1.0, armed.Indicator.Progress, 0.001) | |
| 62 | 62 | require.True(t, armed.Indicator.ThresholdReached) | |
| @@ -99,7 +99,7 @@ func TestTouchpadNavigationRecognizer_ReportsForwardProgressAndNavigatesOnReleas | |||
| 99 | 99 | CanGoForward: true, | |
| 100 | 100 | }) | |
| 101 | 101 | require.True(t, armed.HasIndicator) | |
| 102 | - | require.Equal(t, port.TouchpadNavigationForward, armed.Indicator.Action) | |
| 102 | + | require.Equal(t, dto.TouchpadNavigationForward, armed.Indicator.Action) | |
| 103 | 103 | require.True(t, armed.Indicator.Active) | |
| 104 | 104 | require.InDelta(t, 1.0, armed.Indicator.Progress, 0.001) | |
| 105 | 105 | require.True(t, armed.Indicator.ThresholdReached) | |
| @@ -466,7 +466,7 @@ func TestTouchpadNavigationRecognizer_ResetsBetweenConsecutiveGestures(t *testin | |||
| 466 | 466 | CanGoForward: true, | |
| 467 | 467 | }) | |
| 468 | 468 | require.True(t, secondUpdate.HasIndicator) | |
| 469 | - | require.Equal(t, port.TouchpadNavigationForward, secondUpdate.Indicator.Action) | |
| 469 | + | require.Equal(t, dto.TouchpadNavigationForward, secondUpdate.Indicator.Action) | |
| 470 | 470 | secondEnd := recognizer.Handle(touchpadNavigationInput{ | |
| 471 | 471 | Event: touchpadNavigationScrollEventAt(cef2gtk.ScrollPhaseEnd, 976, 0, 0), | |
| 472 | 472 | Config: cfg, | |
| @@ -3,7 +3,7 @@ package cef | |||||
| 3 | import ( | 3 | import ( | ||
| 4 | "testing" | 4 | "testing" | ||
| 5 | 5 | ||||
| 6 | - | "github.com/bnema/dumber/internal/application/port" | 6 | + | "github.com/bnema/dumber/internal/application/dto" |
| 7 | cef2gtk "github.com/bnema/purego-cef2gtk" | 7 | cef2gtk "github.com/bnema/purego-cef2gtk" | ||
| 8 | "github.com/bnema/puregotk/v4/gdk" | 8 | "github.com/bnema/puregotk/v4/gdk" | ||
| 9 | "github.com/stretchr/testify/require" | 9 | "github.com/stretchr/testify/require" | ||
| @@ -43,7 +43,7 @@ func TestTouchpadNavigationRecognizer_ReportsProgressAndNavigatesOnReleaseAfterT | |||||
| 43 | CanGoForward: true, | 43 | CanGoForward: true, | ||
| 44 | }) | 44 | }) | ||
| 45 | require.True(t, progress.HasIndicator) | 45 | require.True(t, progress.HasIndicator) | ||
| 46 | - | require.Equal(t, port.TouchpadNavigationBack, progress.Indicator.Action) | 46 | + | require.Equal(t, dto.TouchpadNavigationBack, progress.Indicator.Action) |
| 47 | require.True(t, progress.Indicator.Active) | 47 | require.True(t, progress.Indicator.Active) | ||
| 48 | require.InDelta(t, 0.6, progress.Indicator.Progress, 0.001) | 48 | require.InDelta(t, 0.6, progress.Indicator.Progress, 0.001) | ||
| 49 | require.False(t, progress.Indicator.ThresholdReached) | 49 | require.False(t, progress.Indicator.ThresholdReached) | ||
| @@ -56,7 +56,7 @@ func TestTouchpadNavigationRecognizer_ReportsProgressAndNavigatesOnReleaseAfterT | |||||
| 56 | CanGoForward: true, | 56 | CanGoForward: true, | ||
| 57 | }) | 57 | }) | ||
| 58 | require.True(t, armed.HasIndicator) | 58 | require.True(t, armed.HasIndicator) | ||
| 59 | - | require.Equal(t, port.TouchpadNavigationBack, armed.Indicator.Action) | 59 | + | require.Equal(t, dto.TouchpadNavigationBack, armed.Indicator.Action) |
| 60 | require.True(t, armed.Indicator.Active) | 60 | require.True(t, armed.Indicator.Active) | ||
| 61 | require.InDelta(t, 1.0, armed.Indicator.Progress, 0.001) | 61 | require.InDelta(t, 1.0, armed.Indicator.Progress, 0.001) | ||
| 62 | require.True(t, armed.Indicator.ThresholdReached) | 62 | require.True(t, armed.Indicator.ThresholdReached) | ||
| @@ -99,7 +99,7 @@ func TestTouchpadNavigationRecognizer_ReportsForwardProgressAndNavigatesOnReleas | |||||
| 99 | CanGoForward: true, | 99 | CanGoForward: true, | ||
| 100 | }) | 100 | }) | ||
| 101 | require.True(t, armed.HasIndicator) | 101 | require.True(t, armed.HasIndicator) | ||
| 102 | - | require.Equal(t, port.TouchpadNavigationForward, armed.Indicator.Action) | 102 | + | require.Equal(t, dto.TouchpadNavigationForward, armed.Indicator.Action) |
| 103 | require.True(t, armed.Indicator.Active) | 103 | require.True(t, armed.Indicator.Active) | ||
| 104 | require.InDelta(t, 1.0, armed.Indicator.Progress, 0.001) | 104 | require.InDelta(t, 1.0, armed.Indicator.Progress, 0.001) | ||
| 105 | require.True(t, armed.Indicator.ThresholdReached) | 105 | require.True(t, armed.Indicator.ThresholdReached) | ||
| @@ -466,7 +466,7 @@ func TestTouchpadNavigationRecognizer_ResetsBetweenConsecutiveGestures(t *testin | |||||
| 466 | CanGoForward: true, | 466 | CanGoForward: true, | ||
| 467 | }) | 467 | }) | ||
| 468 | require.True(t, secondUpdate.HasIndicator) | 468 | require.True(t, secondUpdate.HasIndicator) | ||
| 469 | - | require.Equal(t, port.TouchpadNavigationForward, secondUpdate.Indicator.Action) | 469 | + | require.Equal(t, dto.TouchpadNavigationForward, secondUpdate.Indicator.Action) |
| 470 | secondEnd := recognizer.Handle(touchpadNavigationInput{ | 470 | secondEnd := recognizer.Handle(touchpadNavigationInput{ | ||
| 471 | Event: touchpadNavigationScrollEventAt(cef2gtk.ScrollPhaseEnd, 976, 0, 0), | 471 | Event: touchpadNavigationScrollEventAt(cef2gtk.ScrollPhaseEnd, 976, 0, 0), | ||
| 472 | Config: cfg, | 472 | Config: cfg, | ||
M internal/infrastructure/cef/webview.go +9 -3
| @@ -1508,16 +1508,22 @@ func (wv *WebView) handleTouchpadNavigationScroll(event cef2gtk.ScrollEvent) { | |||
| 1508 | 1508 | if wv == nil || wv.destroyed.Load() { | |
| 1509 | 1509 | return | |
| 1510 | 1510 | } | |
| 1511 | + | wv.mu.Lock() | |
| 1512 | + | if wv.destroyed.Load() { | |
| 1513 | + | wv.mu.Unlock() | |
| 1514 | + | return | |
| 1515 | + | } | |
| 1511 | 1516 | if wv.touchpadNavigation == nil { | |
| 1512 | 1517 | wv.touchpadNavigation = newTouchpadNavigationRecognizer() | |
| 1513 | 1518 | } | |
| 1514 | 1519 | result := wv.touchpadNavigation.Handle(touchpadNavigationInput{ | |
| 1515 | 1520 | Event: event, | |
| 1516 | 1521 | Config: wv.inputConfig, | |
| 1517 | - | CanGoBack: wv.CanGoBack(), | |
| 1518 | - | CanGoForward: wv.CanGoForward(), | |
| 1522 | + | CanGoBack: wv.canGoBack, | |
| 1523 | + | CanGoForward: wv.canGoFwd, | |
| 1519 | 1524 | ViewWidth: wv.touchpadNavigationViewWidth(), | |
| 1520 | 1525 | }) | |
| 1526 | + | wv.mu.Unlock() | |
| 1521 | 1527 | if result.HasIndicator { | |
| 1522 | 1528 | wv.emitTouchpadNavigationGesture(result.Indicator) | |
| 1523 | 1529 | } | |
| @@ -1536,7 +1542,7 @@ func (wv *WebView) touchpadNavigationViewWidth() float64 { | |||
| 1536 | 1542 | return float64(wv.nativeWidget.GetWidth()) | |
| 1537 | 1543 | } | |
| 1538 | 1544 | ||
| 1539 | - | func (wv *WebView) emitTouchpadNavigationGesture(gesture port.TouchpadNavigationGesture) { | |
| 1545 | + | func (wv *WebView) emitTouchpadNavigationGesture(gesture dto.TouchpadNavigationGesture) { | |
| 1540 | 1546 | if wv == nil { | |
| 1541 | 1547 | return | |
| 1542 | 1548 | } | |
| @@ -1508,16 +1508,22 @@ func (wv *WebView) handleTouchpadNavigationScroll(event cef2gtk.ScrollEvent) { | |||||
| 1508 | if wv == nil || wv.destroyed.Load() { | 1508 | if wv == nil || wv.destroyed.Load() { | ||
| 1509 | return | 1509 | return | ||
| 1510 | } | 1510 | } | ||
| 1511 | + | wv.mu.Lock() | |||
| 1512 | + | if wv.destroyed.Load() { | |||
| 1513 | + | wv.mu.Unlock() | |||
| 1514 | + | return | |||
| 1515 | + | } | |||
| 1511 | if wv.touchpadNavigation == nil { | 1516 | if wv.touchpadNavigation == nil { | ||
| 1512 | wv.touchpadNavigation = newTouchpadNavigationRecognizer() | 1517 | wv.touchpadNavigation = newTouchpadNavigationRecognizer() | ||
| 1513 | } | 1518 | } | ||
| 1514 | result := wv.touchpadNavigation.Handle(touchpadNavigationInput{ | 1519 | result := wv.touchpadNavigation.Handle(touchpadNavigationInput{ | ||
| 1515 | Event: event, | 1520 | Event: event, | ||
| 1516 | Config: wv.inputConfig, | 1521 | Config: wv.inputConfig, | ||
| 1517 | - | CanGoBack: wv.CanGoBack(), | 1522 | + | CanGoBack: wv.canGoBack, |
| 1518 | - | CanGoForward: wv.CanGoForward(), | 1523 | + | CanGoForward: wv.canGoFwd, |
| 1519 | ViewWidth: wv.touchpadNavigationViewWidth(), | 1524 | ViewWidth: wv.touchpadNavigationViewWidth(), | ||
| 1520 | }) | 1525 | }) | ||
| 1526 | + | wv.mu.Unlock() | |||
| 1521 | if result.HasIndicator { | 1527 | if result.HasIndicator { | ||
| 1522 | wv.emitTouchpadNavigationGesture(result.Indicator) | 1528 | wv.emitTouchpadNavigationGesture(result.Indicator) | ||
| 1523 | } | 1529 | } | ||
| @@ -1536,7 +1542,7 @@ func (wv *WebView) touchpadNavigationViewWidth() float64 { | |||||
| 1536 | return float64(wv.nativeWidget.GetWidth()) | 1542 | return float64(wv.nativeWidget.GetWidth()) | ||
| 1537 | } | 1543 | } | ||
| 1538 | 1544 | ||||
| 1539 | - | func (wv *WebView) emitTouchpadNavigationGesture(gesture port.TouchpadNavigationGesture) { | 1545 | + | func (wv *WebView) emitTouchpadNavigationGesture(gesture dto.TouchpadNavigationGesture) { |
| 1540 | if wv == nil { | 1546 | if wv == nil { | ||
| 1541 | return | 1547 | return | ||
| 1542 | } | 1548 | } | ||
M internal/ui/app.go +3 -2
| @@ -13,6 +13,7 @@ import ( | |||
| 13 | 13 | "time" | |
| 14 | 14 | "unsafe" | |
| 15 | 15 | ||
| 16 | + | "github.com/bnema/dumber/internal/application/dto" | |
| 16 | 17 | "github.com/bnema/dumber/internal/application/port" | |
| 17 | 18 | "github.com/bnema/dumber/internal/application/usecase" | |
| 18 | 19 | "github.com/bnema/dumber/internal/domain/entity" | |
| @@ -593,7 +594,7 @@ func (a *App) browserWindowForAnyPane(paneID entity.PaneID) *browserWindow { | |||
| 593 | 594 | return nil | |
| 594 | 595 | } | |
| 595 | 596 | ||
| 596 | - | func (a *App) handleTouchpadNavigationGesture(paneID entity.PaneID, gesture port.TouchpadNavigationGesture) { | |
| 597 | + | func (a *App) handleTouchpadNavigationGesture(paneID entity.PaneID, gesture dto.TouchpadNavigationGesture) { | |
| 597 | 598 | if a == nil { | |
| 598 | 599 | return | |
| 599 | 600 | } | |
| @@ -3194,7 +3195,7 @@ func (a *App) initContentCoordinator( | |||
| 3194 | 3195 | a.contentCoord.SetOnLaunchExternalURL(a.deps.LaunchExternalURL) | |
| 3195 | 3196 | } | |
| 3196 | 3197 | ||
| 3197 | - | a.contentCoord.SetOnTouchpadNavigationGesture(func(paneID entity.PaneID, gesture port.TouchpadNavigationGesture) { | |
| 3198 | + | a.contentCoord.SetOnTouchpadNavigationGesture(func(paneID entity.PaneID, gesture dto.TouchpadNavigationGesture) { | |
| 3198 | 3199 | a.handleTouchpadNavigationGesture(paneID, gesture) | |
| 3199 | 3200 | }) | |
| 3200 | 3201 | ||
| @@ -13,6 +13,7 @@ import ( | |||||
| 13 | "time" | 13 | "time" | ||
| 14 | "unsafe" | 14 | "unsafe" | ||
| 15 | 15 | ||||
| 16 | + | "github.com/bnema/dumber/internal/application/dto" | |||
| 16 | "github.com/bnema/dumber/internal/application/port" | 17 | "github.com/bnema/dumber/internal/application/port" | ||
| 17 | "github.com/bnema/dumber/internal/application/usecase" | 18 | "github.com/bnema/dumber/internal/application/usecase" | ||
| 18 | "github.com/bnema/dumber/internal/domain/entity" | 19 | "github.com/bnema/dumber/internal/domain/entity" | ||
| @@ -593,7 +594,7 @@ func (a *App) browserWindowForAnyPane(paneID entity.PaneID) *browserWindow { | |||||
| 593 | return nil | 594 | return nil | ||
| 594 | } | 595 | } | ||
| 595 | 596 | ||||
| 596 | - | func (a *App) handleTouchpadNavigationGesture(paneID entity.PaneID, gesture port.TouchpadNavigationGesture) { | 597 | + | func (a *App) handleTouchpadNavigationGesture(paneID entity.PaneID, gesture dto.TouchpadNavigationGesture) { |
| 597 | if a == nil { | 598 | if a == nil { | ||
| 598 | return | 599 | return | ||
| 599 | } | 600 | } | ||
| @@ -3194,7 +3195,7 @@ func (a *App) initContentCoordinator( | |||||
| 3194 | a.contentCoord.SetOnLaunchExternalURL(a.deps.LaunchExternalURL) | 3195 | a.contentCoord.SetOnLaunchExternalURL(a.deps.LaunchExternalURL) | ||
| 3195 | } | 3196 | } | ||
| 3196 | 3197 | ||||
| 3197 | - | a.contentCoord.SetOnTouchpadNavigationGesture(func(paneID entity.PaneID, gesture port.TouchpadNavigationGesture) { | 3198 | + | a.contentCoord.SetOnTouchpadNavigationGesture(func(paneID entity.PaneID, gesture dto.TouchpadNavigationGesture) { |
| 3198 | a.handleTouchpadNavigationGesture(paneID, gesture) | 3199 | a.handleTouchpadNavigationGesture(paneID, gesture) | ||
| 3199 | }) | 3200 | }) | ||
| 3200 | 3201 | ||||
M internal/ui/component/touchpad_navigation_indicator.go +7 -7
| @@ -1,7 +1,7 @@ | |||
| 1 | 1 | package component | |
| 2 | 2 | ||
| 3 | 3 | import ( | |
| 4 | - | "github.com/bnema/dumber/internal/application/port" | |
| 4 | + | "github.com/bnema/dumber/internal/application/dto" | |
| 5 | 5 | "github.com/bnema/puregotk/v4/glib" | |
| 6 | 6 | "github.com/bnema/puregotk/v4/gtk" | |
| 7 | 7 | ) | |
| @@ -114,7 +114,7 @@ func (i *TouchpadNavigationIndicator) Widget() *gtk.Widget { | |||
| 114 | 114 | return &i.container.Widget | |
| 115 | 115 | } | |
| 116 | 116 | ||
| 117 | - | func (i *TouchpadNavigationIndicator) ShowGesture(gesture port.TouchpadNavigationGesture) { | |
| 117 | + | func (i *TouchpadNavigationIndicator) ShowGesture(gesture dto.TouchpadNavigationGesture) { | |
| 118 | 118 | if i == nil || i.container == nil || i.icon == nil || i.label == nil || i.bar == nil { | |
| 119 | 119 | return | |
| 120 | 120 | } | |
| @@ -123,7 +123,7 @@ func (i *TouchpadNavigationIndicator) ShowGesture(gesture port.TouchpadNavigatio | |||
| 123 | 123 | i.container.RemoveCssClass("hiding") | |
| 124 | 124 | i.container.RemoveCssClass("back") | |
| 125 | 125 | i.container.RemoveCssClass("forward") | |
| 126 | - | if gesture.Action == port.TouchpadNavigationForward { | |
| 126 | + | if gesture.Action == dto.TouchpadNavigationForward { | |
| 127 | 127 | i.container.AddCssClass("forward") | |
| 128 | 128 | i.container.SetHalign(gtk.AlignEndValue) | |
| 129 | 129 | i.bar.SetInverted(true) | |
| @@ -206,16 +206,16 @@ func (i *TouchpadNavigationIndicator) cancelHideTimer() { | |||
| 206 | 206 | } | |
| 207 | 207 | } | |
| 208 | 208 | ||
| 209 | - | func touchpadNavigationIndicatorIcon(gesture port.TouchpadNavigationGesture) string { | |
| 210 | - | if gesture.Action == port.TouchpadNavigationForward { | |
| 209 | + | func touchpadNavigationIndicatorIcon(gesture dto.TouchpadNavigationGesture) string { | |
| 210 | + | if gesture.Action == dto.TouchpadNavigationForward { | |
| 211 | 211 | return "→" | |
| 212 | 212 | } | |
| 213 | 213 | return "←" | |
| 214 | 214 | } | |
| 215 | 215 | ||
| 216 | - | func touchpadNavigationIndicatorLabel(gesture port.TouchpadNavigationGesture) string { | |
| 216 | + | func touchpadNavigationIndicatorLabel(gesture dto.TouchpadNavigationGesture) string { | |
| 217 | 217 | suffix := "Back" | |
| 218 | - | if gesture.Action == port.TouchpadNavigationForward { | |
| 218 | + | if gesture.Action == dto.TouchpadNavigationForward { | |
| 219 | 219 | suffix = "Forward" | |
| 220 | 220 | } | |
| 221 | 221 | if gesture.ThresholdReached { | |
| @@ -1,7 +1,7 @@ | |||||
| 1 | package component | 1 | package component | ||
| 2 | 2 | ||||
| 3 | import ( | 3 | import ( | ||
| 4 | - | "github.com/bnema/dumber/internal/application/port" | 4 | + | "github.com/bnema/dumber/internal/application/dto" |
| 5 | "github.com/bnema/puregotk/v4/glib" | 5 | "github.com/bnema/puregotk/v4/glib" | ||
| 6 | "github.com/bnema/puregotk/v4/gtk" | 6 | "github.com/bnema/puregotk/v4/gtk" | ||
| 7 | ) | 7 | ) | ||
| @@ -114,7 +114,7 @@ func (i *TouchpadNavigationIndicator) Widget() *gtk.Widget { | |||||
| 114 | return &i.container.Widget | 114 | return &i.container.Widget | ||
| 115 | } | 115 | } | ||
| 116 | 116 | ||||
| 117 | - | func (i *TouchpadNavigationIndicator) ShowGesture(gesture port.TouchpadNavigationGesture) { | 117 | + | func (i *TouchpadNavigationIndicator) ShowGesture(gesture dto.TouchpadNavigationGesture) { |
| 118 | if i == nil || i.container == nil || i.icon == nil || i.label == nil || i.bar == nil { | 118 | if i == nil || i.container == nil || i.icon == nil || i.label == nil || i.bar == nil { | ||
| 119 | return | 119 | return | ||
| 120 | } | 120 | } | ||
| @@ -123,7 +123,7 @@ func (i *TouchpadNavigationIndicator) ShowGesture(gesture port.TouchpadNavigatio | |||||
| 123 | i.container.RemoveCssClass("hiding") | 123 | i.container.RemoveCssClass("hiding") | ||
| 124 | i.container.RemoveCssClass("back") | 124 | i.container.RemoveCssClass("back") | ||
| 125 | i.container.RemoveCssClass("forward") | 125 | i.container.RemoveCssClass("forward") | ||
| 126 | - | if gesture.Action == port.TouchpadNavigationForward { | 126 | + | if gesture.Action == dto.TouchpadNavigationForward { |
| 127 | i.container.AddCssClass("forward") | 127 | i.container.AddCssClass("forward") | ||
| 128 | i.container.SetHalign(gtk.AlignEndValue) | 128 | i.container.SetHalign(gtk.AlignEndValue) | ||
| 129 | i.bar.SetInverted(true) | 129 | i.bar.SetInverted(true) | ||
| @@ -206,16 +206,16 @@ func (i *TouchpadNavigationIndicator) cancelHideTimer() { | |||||
| 206 | } | 206 | } | ||
| 207 | } | 207 | } | ||
| 208 | 208 | ||||
| 209 | - | func touchpadNavigationIndicatorIcon(gesture port.TouchpadNavigationGesture) string { | 209 | + | func touchpadNavigationIndicatorIcon(gesture dto.TouchpadNavigationGesture) string { |
| 210 | - | if gesture.Action == port.TouchpadNavigationForward { | 210 | + | if gesture.Action == dto.TouchpadNavigationForward { |
| 211 | return "→" | 211 | return "→" | ||
| 212 | } | 212 | } | ||
| 213 | return "←" | 213 | return "←" | ||
| 214 | } | 214 | } | ||
| 215 | 215 | ||||
| 216 | - | func touchpadNavigationIndicatorLabel(gesture port.TouchpadNavigationGesture) string { | 216 | + | func touchpadNavigationIndicatorLabel(gesture dto.TouchpadNavigationGesture) string { |
| 217 | suffix := "Back" | 217 | suffix := "Back" | ||
| 218 | - | if gesture.Action == port.TouchpadNavigationForward { | 218 | + | if gesture.Action == dto.TouchpadNavigationForward { |
| 219 | suffix = "Forward" | 219 | suffix = "Forward" | ||
| 220 | } | 220 | } | ||
| 221 | if gesture.ThresholdReached { | 221 | if gesture.ThresholdReached { | ||
M internal/ui/coordinator/content/callbacks.go +2 -1
| @@ -5,6 +5,7 @@ import ( | |||
| 5 | 5 | "net/url" | |
| 6 | 6 | "strings" | |
| 7 | 7 | ||
| 8 | + | "github.com/bnema/dumber/internal/application/dto" | |
| 8 | 9 | "github.com/bnema/dumber/internal/application/port" | |
| 9 | 10 | "github.com/bnema/dumber/internal/application/usecase" | |
| 10 | 11 | "github.com/bnema/dumber/internal/domain/entity" | |
| @@ -87,7 +88,7 @@ func (c *Coordinator) setupWebViewCallbacks(ctx context.Context, paneID entity.P | |||
| 87 | 88 | OnLinkHover: func(uri string) { | |
| 88 | 89 | c.onLinkHover(paneID, uri) | |
| 89 | 90 | }, | |
| 90 | - | OnTouchpadNavigationGesture: func(gesture port.TouchpadNavigationGesture) { | |
| 91 | + | OnTouchpadNavigationGesture: func(gesture dto.TouchpadNavigationGesture) { | |
| 91 | 92 | if c.onTouchpadNavigationGesture != nil { | |
| 92 | 93 | c.onTouchpadNavigationGesture(paneID, gesture) | |
| 93 | 94 | } | |
| @@ -5,6 +5,7 @@ import ( | |||||
| 5 | "net/url" | 5 | "net/url" | ||
| 6 | "strings" | 6 | "strings" | ||
| 7 | 7 | ||||
| 8 | + | "github.com/bnema/dumber/internal/application/dto" | |||
| 8 | "github.com/bnema/dumber/internal/application/port" | 9 | "github.com/bnema/dumber/internal/application/port" | ||
| 9 | "github.com/bnema/dumber/internal/application/usecase" | 10 | "github.com/bnema/dumber/internal/application/usecase" | ||
| 10 | "github.com/bnema/dumber/internal/domain/entity" | 11 | "github.com/bnema/dumber/internal/domain/entity" | ||
| @@ -87,7 +88,7 @@ func (c *Coordinator) setupWebViewCallbacks(ctx context.Context, paneID entity.P | |||||
| 87 | OnLinkHover: func(uri string) { | 88 | OnLinkHover: func(uri string) { | ||
| 88 | c.onLinkHover(paneID, uri) | 89 | c.onLinkHover(paneID, uri) | ||
| 89 | }, | 90 | }, | ||
| 90 | - | OnTouchpadNavigationGesture: func(gesture port.TouchpadNavigationGesture) { | 91 | + | OnTouchpadNavigationGesture: func(gesture dto.TouchpadNavigationGesture) { |
| 91 | if c.onTouchpadNavigationGesture != nil { | 92 | if c.onTouchpadNavigationGesture != nil { | ||
| 92 | c.onTouchpadNavigationGesture(paneID, gesture) | 93 | c.onTouchpadNavigationGesture(paneID, gesture) | ||
| 93 | } | 94 | } | ||
M internal/ui/coordinator/content/coordinator.go +3 -2
| @@ -4,6 +4,7 @@ import ( | |||
| 4 | 4 | "context" | |
| 5 | 5 | "sync" | |
| 6 | 6 | ||
| 7 | + | "github.com/bnema/dumber/internal/application/dto" | |
| 7 | 8 | "github.com/bnema/dumber/internal/application/port" | |
| 8 | 9 | "github.com/bnema/dumber/internal/application/usecase" | |
| 9 | 10 | "github.com/bnema/dumber/internal/domain/entity" | |
| @@ -65,7 +66,7 @@ type Coordinator struct { | |||
| 65 | 66 | onActiveNavigationCommitted func(paneID entity.PaneID, uri string) | |
| 66 | 67 | ||
| 67 | 68 | // Callback when a CEF touchpad history navigation gesture progresses. | |
| 68 | - | onTouchpadNavigationGesture func(paneID entity.PaneID, gesture port.TouchpadNavigationGesture) | |
| 69 | + | onTouchpadNavigationGesture func(paneID entity.PaneID, gesture dto.TouchpadNavigationGesture) | |
| 69 | 70 | ||
| 70 | 71 | // Callback when the WebView becomes visible (first real commit) | |
| 71 | 72 | onWebViewShown func(paneID entity.PaneID) | |
| @@ -197,7 +198,7 @@ func (c *Coordinator) SetOnPaneURIUpdated(fn func(paneID entity.PaneID, url stri | |||
| 197 | 198 | ||
| 198 | 199 | // SetOnTouchpadNavigationGesture sets the callback for CEF two-finger history | |
| 199 | 200 | // navigation gesture progress. | |
| 200 | - | func (c *Coordinator) SetOnTouchpadNavigationGesture(fn func(paneID entity.PaneID, gesture port.TouchpadNavigationGesture)) { | |
| 201 | + | func (c *Coordinator) SetOnTouchpadNavigationGesture(fn func(paneID entity.PaneID, gesture dto.TouchpadNavigationGesture)) { | |
| 201 | 202 | c.onTouchpadNavigationGesture = fn | |
| 202 | 203 | } | |
| 203 | 204 | ||
| @@ -4,6 +4,7 @@ import ( | |||||
| 4 | "context" | 4 | "context" | ||
| 5 | "sync" | 5 | "sync" | ||
| 6 | 6 | ||||
| 7 | + | "github.com/bnema/dumber/internal/application/dto" | |||
| 7 | "github.com/bnema/dumber/internal/application/port" | 8 | "github.com/bnema/dumber/internal/application/port" | ||
| 8 | "github.com/bnema/dumber/internal/application/usecase" | 9 | "github.com/bnema/dumber/internal/application/usecase" | ||
| 9 | "github.com/bnema/dumber/internal/domain/entity" | 10 | "github.com/bnema/dumber/internal/domain/entity" | ||
| @@ -65,7 +66,7 @@ type Coordinator struct { | |||||
| 65 | onActiveNavigationCommitted func(paneID entity.PaneID, uri string) | 66 | onActiveNavigationCommitted func(paneID entity.PaneID, uri string) | ||
| 66 | 67 | ||||
| 67 | // Callback when a CEF touchpad history navigation gesture progresses. | 68 | // Callback when a CEF touchpad history navigation gesture progresses. | ||
| 68 | - | onTouchpadNavigationGesture func(paneID entity.PaneID, gesture port.TouchpadNavigationGesture) | 69 | + | onTouchpadNavigationGesture func(paneID entity.PaneID, gesture dto.TouchpadNavigationGesture) |
| 69 | 70 | ||||
| 70 | // Callback when the WebView becomes visible (first real commit) | 71 | // Callback when the WebView becomes visible (first real commit) | ||
| 71 | onWebViewShown func(paneID entity.PaneID) | 72 | onWebViewShown func(paneID entity.PaneID) | ||
| @@ -197,7 +198,7 @@ func (c *Coordinator) SetOnPaneURIUpdated(fn func(paneID entity.PaneID, url stri | |||||
| 197 | 198 | ||||
| 198 | // SetOnTouchpadNavigationGesture sets the callback for CEF two-finger history | 199 | // SetOnTouchpadNavigationGesture sets the callback for CEF two-finger history | ||
| 199 | // navigation gesture progress. | 200 | // navigation gesture progress. | ||
| 200 | - | func (c *Coordinator) SetOnTouchpadNavigationGesture(fn func(paneID entity.PaneID, gesture port.TouchpadNavigationGesture)) { | 201 | + | func (c *Coordinator) SetOnTouchpadNavigationGesture(fn func(paneID entity.PaneID, gesture dto.TouchpadNavigationGesture)) { |
| 201 | c.onTouchpadNavigationGesture = fn | 202 | c.onTouchpadNavigationGesture = fn | ||
| 202 | } | 203 | } | ||
| 203 | 204 | ||||