refactor(browser): fix focus_state_machine widget method calls
- Fixed 3 widget method call errors in focus_state_machine.go - Replaced leaf.container.Allocation() with webkit.WidgetGetAllocation() - Replaced viewWidget.GrabFocus() with webkit.WidgetGrabFocus() - Replaced widget.AddController() with webkit.WidgetAddController() - WidgetGrabFocus already existed in widgets.go, removed duplicate All widget operations now use webkit helper functions consistently.
- commit
- 7f3cf6d381e5a016359a72ecd2d21a27411cf8d0
- author
- bamen · · 2025-10-08 16:20 UTC
- committer
- bamen · · 2025-10-08 20:14 UTC
- parent
- 70d31c4
- signature
- unsigned
1 file · +4 -7
M internal/app/browser/focus_state_machine.go +4 -7
| @@ -561,13 +561,10 @@ func (fsm *FocusStateMachine) findTopLeftPane(leaves []*paneNode) *paneNode { | |||
| 561 | 561 | continue | |
| 562 | 562 | } | |
| 563 | 563 | ||
| 564 | - | bounds := leaf.container.Allocation() | |
| 565 | - | if bounds == nil { | |
| 566 | - | continue | |
| 567 | - | } | |
| 564 | + | x, y, _, _ := webkit.WidgetGetAllocation(leaf.container) | |
| 568 | 565 | ||
| 569 | 566 | // Score based on distance from top-left corner (0,0) | |
| 570 | - | score := float64(bounds.X()) + float64(bounds.Y()) | |
| 567 | + | score := float64(x) + float64(y) | |
| 571 | 568 | if score < bestScore { | |
| 572 | 569 | bestScore = score | |
| 573 | 570 | bestPane = leaf | |
| @@ -630,7 +627,7 @@ func (fsm *FocusStateMachine) applyGTKFocus(node *paneNode) error { | |||
| 630 | 627 | return fmt.Errorf("webview has no valid widget") | |
| 631 | 628 | } | |
| 632 | 629 | ||
| 633 | - | viewWidget.GrabFocus() | |
| 630 | + | webkit.WidgetGrabFocus(viewWidget) | |
| 634 | 631 | return nil | |
| 635 | 632 | } | |
| 636 | 633 | ||
| @@ -939,7 +936,7 @@ func (fsm *FocusStateMachine) attachGTKController(node *paneNode) { | |||
| 939 | 936 | }) | |
| 940 | 937 | ||
| 941 | 938 | // Add controller to widget | |
| 942 | - | widget.AddController(controller) | |
| 939 | + | webkit.WidgetAddController(widget, controller) | |
| 943 | 940 | ||
| 944 | 941 | // Store controller pointer as token for later removal | |
| 945 | 942 | node.focusControllerToken = uintptr(controller.Native()) | |
| @@ -561,13 +561,10 @@ func (fsm *FocusStateMachine) findTopLeftPane(leaves []*paneNode) *paneNode { | |||||
| 561 | continue | 561 | continue | ||
| 562 | } | 562 | } | ||
| 563 | 563 | ||||
| 564 | - | bounds := leaf.container.Allocation() | 564 | + | x, y, _, _ := webkit.WidgetGetAllocation(leaf.container) |
| 565 | - | if bounds == nil { | |||
| 566 | - | continue | |||
| 567 | - | } | |||
| 568 | 565 | ||||
| 569 | // Score based on distance from top-left corner (0,0) | 566 | // Score based on distance from top-left corner (0,0) | ||
| 570 | - | score := float64(bounds.X()) + float64(bounds.Y()) | 567 | + | score := float64(x) + float64(y) |
| 571 | if score < bestScore { | 568 | if score < bestScore { | ||
| 572 | bestScore = score | 569 | bestScore = score | ||
| 573 | bestPane = leaf | 570 | bestPane = leaf | ||
| @@ -630,7 +627,7 @@ func (fsm *FocusStateMachine) applyGTKFocus(node *paneNode) error { | |||||
| 630 | return fmt.Errorf("webview has no valid widget") | 627 | return fmt.Errorf("webview has no valid widget") | ||
| 631 | } | 628 | } | ||
| 632 | 629 | ||||
| 633 | - | viewWidget.GrabFocus() | 630 | + | webkit.WidgetGrabFocus(viewWidget) |
| 634 | return nil | 631 | return nil | ||
| 635 | } | 632 | } | ||
| 636 | 633 | ||||
| @@ -939,7 +936,7 @@ func (fsm *FocusStateMachine) attachGTKController(node *paneNode) { | |||||
| 939 | }) | 936 | }) | ||
| 940 | 937 | ||||
| 941 | // Add controller to widget | 938 | // Add controller to widget | ||
| 942 | - | widget.AddController(controller) | 939 | + | webkit.WidgetAddController(widget, controller) |
| 943 | 940 | ||||
| 944 | // Store controller pointer as token for later removal | 941 | // Store controller pointer as token for later removal | ||
| 945 | node.focusControllerToken = uintptr(controller.Native()) | 942 | node.focusControllerToken = uintptr(controller.Native()) | ||