refactor(browser): fix workspace_navigation widget method calls
- Fixed 5 widget method call errors in workspace_navigation.go - Replaced container.AddController() with webkit.WidgetAddController() - Replaced all container.Allocation() calls with webkit.WidgetGetAllocation() - Allocation() returned *gdk.Rectangle, now using (x, y, width, height) tuple All geometric calculations for focus navigation now use webkit helpers.
- commit
- 2b5245e53c1d7fce46b0d4fac7afe9ad1b6fed53
- author
- bamen · · 2025-10-08 18:01 UTC
- committer
- bamen · · 2025-10-08 16:23 UTC
- parent
- 7f3cf6d
- signature
- unsigned
1 file · +13 -27
M internal/app/browser/workspace_navigation.go +13 -27
| @@ -107,7 +107,7 @@ func (wm *WorkspaceManager) ensureHover(node *paneNode) { | |||
| 107 | 107 | wm.SetActivePane(node, SourceMouse) | |
| 108 | 108 | }) | |
| 109 | 109 | ||
| 110 | - | node.container.AddController(controller) | |
| 110 | + | webkit.WidgetAddController(node.container, controller) | |
| 111 | 111 | // Store controller pointer as token for later removal | |
| 112 | 112 | node.hoverToken = uintptr(controller.Native()) | |
| 113 | 113 | if node.hoverToken == 0 { | |
| @@ -252,14 +252,9 @@ func (wm *WorkspaceManager) focusAdjacent(direction string) bool { | |||
| 252 | 252 | return true | |
| 253 | 253 | } | |
| 254 | 254 | ||
| 255 | - | currentBounds := currentFocused.container.Allocation() | |
| 256 | - | if currentBounds == nil { | |
| 257 | - | log.Printf("[workspace] unable to compute bounds for active pane") | |
| 258 | - | return false | |
| 259 | - | } | |
| 260 | - | ||
| 261 | - | cx := float64(currentBounds.X()) + float64(currentBounds.Width())/2.0 | |
| 262 | - | cy := float64(currentBounds.Y()) + float64(currentBounds.Height())/2.0 | |
| 255 | + | curX, curY, curWidth, curHeight := webkit.WidgetGetAllocation(currentFocused.container) | |
| 256 | + | cx := float64(curX) + float64(curWidth)/2.0 | |
| 257 | + | cy := float64(curY) + float64(curHeight)/2.0 | |
| 263 | 258 | ||
| 264 | 259 | leaves := wm.collectLeaves() | |
| 265 | 260 | bestScore := math.MaxFloat64 | |
| @@ -271,12 +266,9 @@ func (wm *WorkspaceManager) focusAdjacent(direction string) bool { | |||
| 271 | 266 | continue | |
| 272 | 267 | } | |
| 273 | 268 | ||
| 274 | - | bounds := candidate.container.Allocation() | |
| 275 | - | if bounds == nil { | |
| 276 | - | continue | |
| 277 | - | } | |
| 278 | - | tx := float64(bounds.X()) + float64(bounds.Width())/2.0 | |
| 279 | - | ty := float64(bounds.Y()) + float64(bounds.Height())/2.0 | |
| 269 | + | x, y, width, height := webkit.WidgetGetAllocation(candidate.container) | |
| 270 | + | tx := float64(x) + float64(width)/2.0 | |
| 271 | + | ty := float64(y) + float64(height)/2.0 | |
| 280 | 272 | ||
| 281 | 273 | dx := tx - cx | |
| 282 | 274 | dy := ty - cy | |
| @@ -332,12 +324,9 @@ func (wm *WorkspaceManager) structuralNeighbor(node *paneNode, direction string) | |||
| 332 | 324 | return nil | |
| 333 | 325 | } | |
| 334 | 326 | ||
| 335 | - | refBounds := node.container.Allocation() | |
| 336 | - | if refBounds == nil { | |
| 337 | - | return nil | |
| 338 | - | } | |
| 339 | - | cx := float64(refBounds.X()) + float64(refBounds.Width())/2.0 | |
| 340 | - | cy := float64(refBounds.Y()) + float64(refBounds.Height())/2.0 | |
| 327 | + | refX, refY, refWidth, refHeight := webkit.WidgetGetAllocation(node.container) | |
| 328 | + | cx := float64(refX) + float64(refWidth)/2.0 | |
| 329 | + | cy := float64(refY) + float64(refHeight)/2.0 | |
| 341 | 330 | axisVertical := direction == "up" || direction == "down" | |
| 342 | 331 | ||
| 343 | 332 | for parent := node.parent; parent != nil; parent = parent.parent { | |
| @@ -382,12 +371,9 @@ func (wm *WorkspaceManager) closestLeafFromSubtree(node *paneNode, cx, cy float6 | |||
| 382 | 371 | continue | |
| 383 | 372 | } | |
| 384 | 373 | ||
| 385 | - | bounds := leaf.container.Allocation() | |
| 386 | - | if bounds == nil { | |
| 387 | - | continue | |
| 388 | - | } | |
| 389 | - | tx := float64(bounds.X()) + float64(bounds.Width())/2.0 | |
| 390 | - | ty := float64(bounds.Y()) + float64(bounds.Height())/2.0 | |
| 374 | + | x, y, width, height := webkit.WidgetGetAllocation(leaf.container) | |
| 375 | + | tx := float64(x) + float64(width)/2.0 | |
| 376 | + | ty := float64(y) + float64(height)/2.0 | |
| 391 | 377 | dx := tx - cx | |
| 392 | 378 | dy := ty - cy | |
| 393 | 379 | var score float64 | |
| @@ -107,7 +107,7 @@ func (wm *WorkspaceManager) ensureHover(node *paneNode) { | |||||
| 107 | wm.SetActivePane(node, SourceMouse) | 107 | wm.SetActivePane(node, SourceMouse) | ||
| 108 | }) | 108 | }) | ||
| 109 | 109 | ||||
| 110 | - | node.container.AddController(controller) | 110 | + | webkit.WidgetAddController(node.container, controller) |
| 111 | // Store controller pointer as token for later removal | 111 | // Store controller pointer as token for later removal | ||
| 112 | node.hoverToken = uintptr(controller.Native()) | 112 | node.hoverToken = uintptr(controller.Native()) | ||
| 113 | if node.hoverToken == 0 { | 113 | if node.hoverToken == 0 { | ||
| @@ -252,14 +252,9 @@ func (wm *WorkspaceManager) focusAdjacent(direction string) bool { | |||||
| 252 | return true | 252 | return true | ||
| 253 | } | 253 | } | ||
| 254 | 254 | ||||
| 255 | - | currentBounds := currentFocused.container.Allocation() | 255 | + | curX, curY, curWidth, curHeight := webkit.WidgetGetAllocation(currentFocused.container) |
| 256 | - | if currentBounds == nil { | 256 | + | cx := float64(curX) + float64(curWidth)/2.0 |
| 257 | - | log.Printf("[workspace] unable to compute bounds for active pane") | 257 | + | cy := float64(curY) + float64(curHeight)/2.0 |
| 258 | - | return false | |||
| 259 | - | } | |||
| 260 | - | ||||
| 261 | - | cx := float64(currentBounds.X()) + float64(currentBounds.Width())/2.0 | |||
| 262 | - | cy := float64(currentBounds.Y()) + float64(currentBounds.Height())/2.0 | |||
| 263 | 258 | ||||
| 264 | leaves := wm.collectLeaves() | 259 | leaves := wm.collectLeaves() | ||
| 265 | bestScore := math.MaxFloat64 | 260 | bestScore := math.MaxFloat64 | ||
| @@ -271,12 +266,9 @@ func (wm *WorkspaceManager) focusAdjacent(direction string) bool { | |||||
| 271 | continue | 266 | continue | ||
| 272 | } | 267 | } | ||
| 273 | 268 | ||||
| 274 | - | bounds := candidate.container.Allocation() | 269 | + | x, y, width, height := webkit.WidgetGetAllocation(candidate.container) |
| 275 | - | if bounds == nil { | 270 | + | tx := float64(x) + float64(width)/2.0 |
| 276 | - | continue | 271 | + | ty := float64(y) + float64(height)/2.0 |
| 277 | - | } | |||
| 278 | - | tx := float64(bounds.X()) + float64(bounds.Width())/2.0 | |||
| 279 | - | ty := float64(bounds.Y()) + float64(bounds.Height())/2.0 | |||
| 280 | 272 | ||||
| 281 | dx := tx - cx | 273 | dx := tx - cx | ||
| 282 | dy := ty - cy | 274 | dy := ty - cy | ||
| @@ -332,12 +324,9 @@ func (wm *WorkspaceManager) structuralNeighbor(node *paneNode, direction string) | |||||
| 332 | return nil | 324 | return nil | ||
| 333 | } | 325 | } | ||
| 334 | 326 | ||||
| 335 | - | refBounds := node.container.Allocation() | 327 | + | refX, refY, refWidth, refHeight := webkit.WidgetGetAllocation(node.container) |
| 336 | - | if refBounds == nil { | 328 | + | cx := float64(refX) + float64(refWidth)/2.0 |
| 337 | - | return nil | 329 | + | cy := float64(refY) + float64(refHeight)/2.0 |
| 338 | - | } | |||
| 339 | - | cx := float64(refBounds.X()) + float64(refBounds.Width())/2.0 | |||
| 340 | - | cy := float64(refBounds.Y()) + float64(refBounds.Height())/2.0 | |||
| 341 | axisVertical := direction == "up" || direction == "down" | 330 | axisVertical := direction == "up" || direction == "down" | ||
| 342 | 331 | ||||
| 343 | for parent := node.parent; parent != nil; parent = parent.parent { | 332 | for parent := node.parent; parent != nil; parent = parent.parent { | ||
| @@ -382,12 +371,9 @@ func (wm *WorkspaceManager) closestLeafFromSubtree(node *paneNode, cx, cy float6 | |||||
| 382 | continue | 371 | continue | ||
| 383 | } | 372 | } | ||
| 384 | 373 | ||||
| 385 | - | bounds := leaf.container.Allocation() | 374 | + | x, y, width, height := webkit.WidgetGetAllocation(leaf.container) |
| 386 | - | if bounds == nil { | 375 | + | tx := float64(x) + float64(width)/2.0 |
| 387 | - | continue | 376 | + | ty := float64(y) + float64(height)/2.0 |
| 388 | - | } | |||
| 389 | - | tx := float64(bounds.X()) + float64(bounds.Width())/2.0 | |||
| 390 | - | ty := float64(bounds.Y()) + float64(bounds.Height())/2.0 | |||
| 391 | dx := tx - cx | 377 | dx := tx - cx | ||
| 392 | dy := ty - cy | 378 | dy := ty - cy | ||
| 393 | var score float64 | 379 | var score float64 | ||