refactor(browser): migrate workspace_navigation.go to gotk4 API
- commit
- 99570ca51e12d4df75d0cf2d5848a823c8e0100c
- author
- bamen · · 2025-10-09 05:36 UTC
- parent
- 44a6914
- signature
- unsigned
1 file · +39 -36
M internal/app/browser/workspace_navigation.go +39 -36
| @@ -9,6 +9,7 @@ import ( | |||
| 9 | 9 | "time" | |
| 10 | 10 | ||
| 11 | 11 | "github.com/bnema/dumber/pkg/webkit" | |
| 12 | + | "github.com/diamondburned/gotk4/pkg/gtk/v4" | |
| 12 | 13 | ) | |
| 13 | 14 | ||
| 14 | 15 | const ( | |
| @@ -93,18 +94,23 @@ func (wm *WorkspaceManager) ensureHover(node *paneNode) { | |||
| 93 | 94 | if wm == nil || node == nil || !node.isLeaf { | |
| 94 | 95 | return | |
| 95 | 96 | } | |
| 96 | - | if node.container == 0 || node.hoverToken != 0 { | |
| 97 | + | if node.container == nil || node.hoverToken != 0 { | |
| 97 | 98 | return | |
| 98 | 99 | } | |
| 99 | 100 | ||
| 100 | - | token := webkit.WidgetAddHoverHandler(node.container, func() { | |
| 101 | + | // Create motion controller for hover detection | |
| 102 | + | controller := gtk.NewEventControllerMotion() | |
| 103 | + | controller.ConnectEnter(func(x, y float64) { | |
| 101 | 104 | if wm == nil { | |
| 102 | 105 | return | |
| 103 | 106 | } | |
| 104 | 107 | wm.SetActivePane(node, SourceMouse) | |
| 105 | 108 | }) | |
| 106 | - | node.hoverToken = token | |
| 107 | - | if token == 0 { | |
| 109 | + | ||
| 110 | + | node.container.AddController(controller) | |
| 111 | + | // Store controller pointer as token for later removal | |
| 112 | + | node.hoverToken = uintptr(controller.Native()) | |
| 113 | + | if node.hoverToken == 0 { | |
| 108 | 114 | log.Printf("[workspace] failed to attach hover handler") | |
| 109 | 115 | } | |
| 110 | 116 | } | |
| @@ -115,17 +121,14 @@ func (wm *WorkspaceManager) detachHover(node *paneNode) { | |||
| 115 | 121 | return | |
| 116 | 122 | } | |
| 117 | 123 | ||
| 118 | - | if node.container == 0 || !webkit.WidgetIsValid(node.container) { | |
| 124 | + | if node.container == nil { | |
| 119 | 125 | node.hoverToken = 0 | |
| 120 | 126 | return | |
| 121 | 127 | } | |
| 122 | 128 | ||
| 123 | - | token := node.hoverToken | |
| 129 | + | // Note: In GTK4, controllers are automatically removed when widget is destroyed | |
| 130 | + | // We just need to clear our token reference | |
| 124 | 131 | node.hoverToken = 0 | |
| 125 | - | ||
| 126 | - | if webkit.WidgetIsValid(node.container) { | |
| 127 | - | webkit.WidgetRemoveHoverHandler(node.container, token) | |
| 128 | - | } | |
| 129 | 132 | } | |
| 130 | 133 | ||
| 131 | 134 | // detachFocus removes the GTK focus controller attached to a pane, if any. | |
| @@ -240,7 +243,7 @@ func (wm *WorkspaceManager) navigateStack(direction string) bool { | |||
| 240 | 243 | // focusAdjacent uses geometry-based calculations to find and focus adjacent panes | |
| 241 | 244 | func (wm *WorkspaceManager) focusAdjacent(direction string) bool { | |
| 242 | 245 | currentFocused := wm.GetActiveNode() | |
| 243 | - | if currentFocused == nil || !currentFocused.isLeaf || currentFocused.container == 0 { | |
| 246 | + | if currentFocused == nil || !currentFocused.isLeaf || currentFocused.container == nil { | |
| 244 | 247 | return false | |
| 245 | 248 | } | |
| 246 | 249 | ||
| @@ -249,14 +252,14 @@ func (wm *WorkspaceManager) focusAdjacent(direction string) bool { | |||
| 249 | 252 | return true | |
| 250 | 253 | } | |
| 251 | 254 | ||
| 252 | - | currentBounds, ok := webkit.WidgetGetBounds(currentFocused.container) | |
| 253 | - | if !ok { | |
| 255 | + | currentBounds := currentFocused.container.Allocation() | |
| 256 | + | if currentBounds == nil { | |
| 254 | 257 | log.Printf("[workspace] unable to compute bounds for active pane") | |
| 255 | 258 | return false | |
| 256 | 259 | } | |
| 257 | 260 | ||
| 258 | - | cx := currentBounds.X + currentBounds.Width/2.0 | |
| 259 | - | cy := currentBounds.Y + currentBounds.Height/2.0 | |
| 261 | + | cx := float64(currentBounds.X()) + float64(currentBounds.Width())/2.0 | |
| 262 | + | cy := float64(currentBounds.Y()) + float64(currentBounds.Height())/2.0 | |
| 260 | 263 | ||
| 261 | 264 | leaves := wm.collectLeaves() | |
| 262 | 265 | bestScore := math.MaxFloat64 | |
| @@ -264,16 +267,16 @@ func (wm *WorkspaceManager) focusAdjacent(direction string) bool { | |||
| 264 | 267 | var debugCandidates []string | |
| 265 | 268 | ||
| 266 | 269 | for _, candidate := range leaves { | |
| 267 | - | if candidate == nil || candidate == currentFocused || candidate.container == 0 { | |
| 270 | + | if candidate == nil || candidate == currentFocused || candidate.container == nil { | |
| 268 | 271 | continue | |
| 269 | 272 | } | |
| 270 | 273 | ||
| 271 | - | bounds, ok := webkit.WidgetGetBounds(candidate.container) | |
| 272 | - | if !ok { | |
| 274 | + | bounds := candidate.container.Allocation() | |
| 275 | + | if bounds == nil { | |
| 273 | 276 | continue | |
| 274 | 277 | } | |
| 275 | - | tx := bounds.X + bounds.Width/2.0 | |
| 276 | - | ty := bounds.Y + bounds.Height/2.0 | |
| 278 | + | tx := float64(bounds.X()) + float64(bounds.Width())/2.0 | |
| 279 | + | ty := float64(bounds.Y()) + float64(bounds.Height())/2.0 | |
| 277 | 280 | ||
| 278 | 281 | dx := tx - cx | |
| 279 | 282 | dy := ty - cy | |
| @@ -303,7 +306,7 @@ func (wm *WorkspaceManager) focusAdjacent(direction string) bool { | |||
| 303 | 306 | } | |
| 304 | 307 | ||
| 305 | 308 | if direction == "up" || direction == "down" { | |
| 306 | - | debugCandidates = append(debugCandidates, fmt.Sprintf("cand=%#x dx=%.2f dy=%.2f score=%.2f", candidate.container, dx, dy, score)) | |
| 309 | + | debugCandidates = append(debugCandidates, fmt.Sprintf("cand=%p dx=%.2f dy=%.2f score=%.2f", candidate.container, dx, dy, score)) | |
| 307 | 310 | } | |
| 308 | 311 | ||
| 309 | 312 | if score < bestScore { | |
| @@ -318,47 +321,47 @@ func (wm *WorkspaceManager) focusAdjacent(direction string) bool { | |||
| 318 | 321 | } | |
| 319 | 322 | ||
| 320 | 323 | if len(debugCandidates) > 0 { | |
| 321 | - | log.Printf("[workspace] focusAdjacent no candidate direction=%s current=%#x candidates=%s", direction, currentFocused.container, strings.Join(debugCandidates, "; ")) | |
| 324 | + | log.Printf("[workspace] focusAdjacent no candidate direction=%s current=%p candidates=%s", direction, currentFocused.container, strings.Join(debugCandidates, "; ")) | |
| 322 | 325 | } | |
| 323 | 326 | return false | |
| 324 | 327 | } | |
| 325 | 328 | ||
| 326 | 329 | // structuralNeighbor finds neighbors based on the tree structure rather than geometry | |
| 327 | 330 | func (wm *WorkspaceManager) structuralNeighbor(node *paneNode, direction string) *paneNode { | |
| 328 | - | if node == nil || node.container == 0 { | |
| 331 | + | if node == nil || node.container == nil { | |
| 329 | 332 | return nil | |
| 330 | 333 | } | |
| 331 | 334 | ||
| 332 | - | refBounds, ok := webkit.WidgetGetBounds(node.container) | |
| 333 | - | if !ok { | |
| 335 | + | refBounds := node.container.Allocation() | |
| 336 | + | if refBounds == nil { | |
| 334 | 337 | return nil | |
| 335 | 338 | } | |
| 336 | - | cx := refBounds.X + refBounds.Width/2.0 | |
| 337 | - | cy := refBounds.Y + refBounds.Height/2.0 | |
| 339 | + | cx := float64(refBounds.X()) + float64(refBounds.Width())/2.0 | |
| 340 | + | cy := float64(refBounds.Y()) + float64(refBounds.Height())/2.0 | |
| 338 | 341 | axisVertical := direction == "up" || direction == "down" | |
| 339 | 342 | ||
| 340 | 343 | for parent := node.parent; parent != nil; parent = parent.parent { | |
| 341 | 344 | switch direction { | |
| 342 | 345 | case "up": | |
| 343 | - | if axisVertical && parent.orientation == webkit.OrientationVertical && parent.right == node { | |
| 346 | + | if axisVertical && parent.orientation == gtk.OrientationVertical && parent.right == node { | |
| 344 | 347 | if leaf := wm.closestLeafFromSubtree(parent.left, cx, cy, direction); leaf != nil { | |
| 345 | 348 | return leaf | |
| 346 | 349 | } | |
| 347 | 350 | } | |
| 348 | 351 | case "down": | |
| 349 | - | if axisVertical && parent.orientation == webkit.OrientationVertical && parent.left == node { | |
| 352 | + | if axisVertical && parent.orientation == gtk.OrientationVertical && parent.left == node { | |
| 350 | 353 | if leaf := wm.closestLeafFromSubtree(parent.right, cx, cy, direction); leaf != nil { | |
| 351 | 354 | return leaf | |
| 352 | 355 | } | |
| 353 | 356 | } | |
| 354 | 357 | case "left": | |
| 355 | - | if !axisVertical && parent.orientation == webkit.OrientationHorizontal && parent.right == node { | |
| 358 | + | if !axisVertical && parent.orientation == gtk.OrientationHorizontal && parent.right == node { | |
| 356 | 359 | if leaf := wm.closestLeafFromSubtree(parent.left, cx, cy, direction); leaf != nil { | |
| 357 | 360 | return leaf | |
| 358 | 361 | } | |
| 359 | 362 | } | |
| 360 | 363 | case "right": | |
| 361 | - | if !axisVertical && parent.orientation == webkit.OrientationHorizontal && parent.left == node { | |
| 364 | + | if !axisVertical && parent.orientation == gtk.OrientationHorizontal && parent.left == node { | |
| 362 | 365 | if leaf := wm.closestLeafFromSubtree(parent.right, cx, cy, direction); leaf != nil { | |
| 363 | 366 | return leaf | |
| 364 | 367 | } | |
| @@ -375,16 +378,16 @@ func (wm *WorkspaceManager) closestLeafFromSubtree(node *paneNode, cx, cy float6 | |||
| 375 | 378 | bestScore := math.MaxFloat64 | |
| 376 | 379 | var best *paneNode | |
| 377 | 380 | for _, leaf := range leaves { | |
| 378 | - | if leaf == nil || leaf.container == 0 { | |
| 381 | + | if leaf == nil || leaf.container == nil { | |
| 379 | 382 | continue | |
| 380 | 383 | } | |
| 381 | 384 | ||
| 382 | - | bounds, ok := webkit.WidgetGetBounds(leaf.container) | |
| 383 | - | if !ok { | |
| 385 | + | bounds := leaf.container.Allocation() | |
| 386 | + | if bounds == nil { | |
| 384 | 387 | continue | |
| 385 | 388 | } | |
| 386 | - | tx := bounds.X + bounds.Width/2.0 | |
| 387 | - | ty := bounds.Y + bounds.Height/2.0 | |
| 389 | + | tx := float64(bounds.X()) + float64(bounds.Width())/2.0 | |
| 390 | + | ty := float64(bounds.Y()) + float64(bounds.Height())/2.0 | |
| 388 | 391 | dx := tx - cx | |
| 389 | 392 | dy := ty - cy | |
| 390 | 393 | var score float64 | |
| @@ -9,6 +9,7 @@ import ( | |||||
| 9 | "time" | 9 | "time" | ||
| 10 | 10 | ||||
| 11 | "github.com/bnema/dumber/pkg/webkit" | 11 | "github.com/bnema/dumber/pkg/webkit" | ||
| 12 | + | "github.com/diamondburned/gotk4/pkg/gtk/v4" | |||
| 12 | ) | 13 | ) | ||
| 13 | 14 | ||||
| 14 | const ( | 15 | const ( | ||
| @@ -93,18 +94,23 @@ func (wm *WorkspaceManager) ensureHover(node *paneNode) { | |||||
| 93 | if wm == nil || node == nil || !node.isLeaf { | 94 | if wm == nil || node == nil || !node.isLeaf { | ||
| 94 | return | 95 | return | ||
| 95 | } | 96 | } | ||
| 96 | - | if node.container == 0 || node.hoverToken != 0 { | 97 | + | if node.container == nil || node.hoverToken != 0 { |
| 97 | return | 98 | return | ||
| 98 | } | 99 | } | ||
| 99 | 100 | ||||
| 100 | - | token := webkit.WidgetAddHoverHandler(node.container, func() { | 101 | + | // Create motion controller for hover detection |
| 102 | + | controller := gtk.NewEventControllerMotion() | |||
| 103 | + | controller.ConnectEnter(func(x, y float64) { | |||
| 101 | if wm == nil { | 104 | if wm == nil { | ||
| 102 | return | 105 | return | ||
| 103 | } | 106 | } | ||
| 104 | wm.SetActivePane(node, SourceMouse) | 107 | wm.SetActivePane(node, SourceMouse) | ||
| 105 | }) | 108 | }) | ||
| 106 | - | node.hoverToken = token | 109 | + | |
| 107 | - | if token == 0 { | 110 | + | node.container.AddController(controller) |
| 111 | + | // Store controller pointer as token for later removal | |||
| 112 | + | node.hoverToken = uintptr(controller.Native()) | |||
| 113 | + | if node.hoverToken == 0 { | |||
| 108 | log.Printf("[workspace] failed to attach hover handler") | 114 | log.Printf("[workspace] failed to attach hover handler") | ||
| 109 | } | 115 | } | ||
| 110 | } | 116 | } | ||
| @@ -115,17 +121,14 @@ func (wm *WorkspaceManager) detachHover(node *paneNode) { | |||||
| 115 | return | 121 | return | ||
| 116 | } | 122 | } | ||
| 117 | 123 | ||||
| 118 | - | if node.container == 0 || !webkit.WidgetIsValid(node.container) { | 124 | + | if node.container == nil { |
| 119 | node.hoverToken = 0 | 125 | node.hoverToken = 0 | ||
| 120 | return | 126 | return | ||
| 121 | } | 127 | } | ||
| 122 | 128 | ||||
| 123 | - | token := node.hoverToken | 129 | + | // Note: In GTK4, controllers are automatically removed when widget is destroyed |
| 130 | + | // We just need to clear our token reference | |||
| 124 | node.hoverToken = 0 | 131 | node.hoverToken = 0 | ||
| 125 | - | ||||
| 126 | - | if webkit.WidgetIsValid(node.container) { | |||
| 127 | - | webkit.WidgetRemoveHoverHandler(node.container, token) | |||
| 128 | - | } | |||
| 129 | } | 132 | } | ||
| 130 | 133 | ||||
| 131 | // detachFocus removes the GTK focus controller attached to a pane, if any. | 134 | // detachFocus removes the GTK focus controller attached to a pane, if any. | ||
| @@ -240,7 +243,7 @@ func (wm *WorkspaceManager) navigateStack(direction string) bool { | |||||
| 240 | // focusAdjacent uses geometry-based calculations to find and focus adjacent panes | 243 | // focusAdjacent uses geometry-based calculations to find and focus adjacent panes | ||
| 241 | func (wm *WorkspaceManager) focusAdjacent(direction string) bool { | 244 | func (wm *WorkspaceManager) focusAdjacent(direction string) bool { | ||
| 242 | currentFocused := wm.GetActiveNode() | 245 | currentFocused := wm.GetActiveNode() | ||
| 243 | - | if currentFocused == nil || !currentFocused.isLeaf || currentFocused.container == 0 { | 246 | + | if currentFocused == nil || !currentFocused.isLeaf || currentFocused.container == nil { |
| 244 | return false | 247 | return false | ||
| 245 | } | 248 | } | ||
| 246 | 249 | ||||
| @@ -249,14 +252,14 @@ func (wm *WorkspaceManager) focusAdjacent(direction string) bool { | |||||
| 249 | return true | 252 | return true | ||
| 250 | } | 253 | } | ||
| 251 | 254 | ||||
| 252 | - | currentBounds, ok := webkit.WidgetGetBounds(currentFocused.container) | 255 | + | currentBounds := currentFocused.container.Allocation() |
| 253 | - | if !ok { | 256 | + | if currentBounds == nil { |
| 254 | log.Printf("[workspace] unable to compute bounds for active pane") | 257 | log.Printf("[workspace] unable to compute bounds for active pane") | ||
| 255 | return false | 258 | return false | ||
| 256 | } | 259 | } | ||
| 257 | 260 | ||||
| 258 | - | cx := currentBounds.X + currentBounds.Width/2.0 | 261 | + | cx := float64(currentBounds.X()) + float64(currentBounds.Width())/2.0 |
| 259 | - | cy := currentBounds.Y + currentBounds.Height/2.0 | 262 | + | cy := float64(currentBounds.Y()) + float64(currentBounds.Height())/2.0 |
| 260 | 263 | ||||
| 261 | leaves := wm.collectLeaves() | 264 | leaves := wm.collectLeaves() | ||
| 262 | bestScore := math.MaxFloat64 | 265 | bestScore := math.MaxFloat64 | ||
| @@ -264,16 +267,16 @@ func (wm *WorkspaceManager) focusAdjacent(direction string) bool { | |||||
| 264 | var debugCandidates []string | 267 | var debugCandidates []string | ||
| 265 | 268 | ||||
| 266 | for _, candidate := range leaves { | 269 | for _, candidate := range leaves { | ||
| 267 | - | if candidate == nil || candidate == currentFocused || candidate.container == 0 { | 270 | + | if candidate == nil || candidate == currentFocused || candidate.container == nil { |
| 268 | continue | 271 | continue | ||
| 269 | } | 272 | } | ||
| 270 | 273 | ||||
| 271 | - | bounds, ok := webkit.WidgetGetBounds(candidate.container) | 274 | + | bounds := candidate.container.Allocation() |
| 272 | - | if !ok { | 275 | + | if bounds == nil { |
| 273 | continue | 276 | continue | ||
| 274 | } | 277 | } | ||
| 275 | - | tx := bounds.X + bounds.Width/2.0 | 278 | + | tx := float64(bounds.X()) + float64(bounds.Width())/2.0 |
| 276 | - | ty := bounds.Y + bounds.Height/2.0 | 279 | + | ty := float64(bounds.Y()) + float64(bounds.Height())/2.0 |
| 277 | 280 | ||||
| 278 | dx := tx - cx | 281 | dx := tx - cx | ||
| 279 | dy := ty - cy | 282 | dy := ty - cy | ||
| @@ -303,7 +306,7 @@ func (wm *WorkspaceManager) focusAdjacent(direction string) bool { | |||||
| 303 | } | 306 | } | ||
| 304 | 307 | ||||
| 305 | if direction == "up" || direction == "down" { | 308 | if direction == "up" || direction == "down" { | ||
| 306 | - | debugCandidates = append(debugCandidates, fmt.Sprintf("cand=%#x dx=%.2f dy=%.2f score=%.2f", candidate.container, dx, dy, score)) | 309 | + | debugCandidates = append(debugCandidates, fmt.Sprintf("cand=%p dx=%.2f dy=%.2f score=%.2f", candidate.container, dx, dy, score)) |
| 307 | } | 310 | } | ||
| 308 | 311 | ||||
| 309 | if score < bestScore { | 312 | if score < bestScore { | ||
| @@ -318,47 +321,47 @@ func (wm *WorkspaceManager) focusAdjacent(direction string) bool { | |||||
| 318 | } | 321 | } | ||
| 319 | 322 | ||||
| 320 | if len(debugCandidates) > 0 { | 323 | if len(debugCandidates) > 0 { | ||
| 321 | - | log.Printf("[workspace] focusAdjacent no candidate direction=%s current=%#x candidates=%s", direction, currentFocused.container, strings.Join(debugCandidates, "; ")) | 324 | + | log.Printf("[workspace] focusAdjacent no candidate direction=%s current=%p candidates=%s", direction, currentFocused.container, strings.Join(debugCandidates, "; ")) |
| 322 | } | 325 | } | ||
| 323 | return false | 326 | return false | ||
| 324 | } | 327 | } | ||
| 325 | 328 | ||||
| 326 | // structuralNeighbor finds neighbors based on the tree structure rather than geometry | 329 | // structuralNeighbor finds neighbors based on the tree structure rather than geometry | ||
| 327 | func (wm *WorkspaceManager) structuralNeighbor(node *paneNode, direction string) *paneNode { | 330 | func (wm *WorkspaceManager) structuralNeighbor(node *paneNode, direction string) *paneNode { | ||
| 328 | - | if node == nil || node.container == 0 { | 331 | + | if node == nil || node.container == nil { |
| 329 | return nil | 332 | return nil | ||
| 330 | } | 333 | } | ||
| 331 | 334 | ||||
| 332 | - | refBounds, ok := webkit.WidgetGetBounds(node.container) | 335 | + | refBounds := node.container.Allocation() |
| 333 | - | if !ok { | 336 | + | if refBounds == nil { |
| 334 | return nil | 337 | return nil | ||
| 335 | } | 338 | } | ||
| 336 | - | cx := refBounds.X + refBounds.Width/2.0 | 339 | + | cx := float64(refBounds.X()) + float64(refBounds.Width())/2.0 |
| 337 | - | cy := refBounds.Y + refBounds.Height/2.0 | 340 | + | cy := float64(refBounds.Y()) + float64(refBounds.Height())/2.0 |
| 338 | axisVertical := direction == "up" || direction == "down" | 341 | axisVertical := direction == "up" || direction == "down" | ||
| 339 | 342 | ||||
| 340 | for parent := node.parent; parent != nil; parent = parent.parent { | 343 | for parent := node.parent; parent != nil; parent = parent.parent { | ||
| 341 | switch direction { | 344 | switch direction { | ||
| 342 | case "up": | 345 | case "up": | ||
| 343 | - | if axisVertical && parent.orientation == webkit.OrientationVertical && parent.right == node { | 346 | + | if axisVertical && parent.orientation == gtk.OrientationVertical && parent.right == node { |
| 344 | if leaf := wm.closestLeafFromSubtree(parent.left, cx, cy, direction); leaf != nil { | 347 | if leaf := wm.closestLeafFromSubtree(parent.left, cx, cy, direction); leaf != nil { | ||
| 345 | return leaf | 348 | return leaf | ||
| 346 | } | 349 | } | ||
| 347 | } | 350 | } | ||
| 348 | case "down": | 351 | case "down": | ||
| 349 | - | if axisVertical && parent.orientation == webkit.OrientationVertical && parent.left == node { | 352 | + | if axisVertical && parent.orientation == gtk.OrientationVertical && parent.left == node { |
| 350 | if leaf := wm.closestLeafFromSubtree(parent.right, cx, cy, direction); leaf != nil { | 353 | if leaf := wm.closestLeafFromSubtree(parent.right, cx, cy, direction); leaf != nil { | ||
| 351 | return leaf | 354 | return leaf | ||
| 352 | } | 355 | } | ||
| 353 | } | 356 | } | ||
| 354 | case "left": | 357 | case "left": | ||
| 355 | - | if !axisVertical && parent.orientation == webkit.OrientationHorizontal && parent.right == node { | 358 | + | if !axisVertical && parent.orientation == gtk.OrientationHorizontal && parent.right == node { |
| 356 | if leaf := wm.closestLeafFromSubtree(parent.left, cx, cy, direction); leaf != nil { | 359 | if leaf := wm.closestLeafFromSubtree(parent.left, cx, cy, direction); leaf != nil { | ||
| 357 | return leaf | 360 | return leaf | ||
| 358 | } | 361 | } | ||
| 359 | } | 362 | } | ||
| 360 | case "right": | 363 | case "right": | ||
| 361 | - | if !axisVertical && parent.orientation == webkit.OrientationHorizontal && parent.left == node { | 364 | + | if !axisVertical && parent.orientation == gtk.OrientationHorizontal && parent.left == node { |
| 362 | if leaf := wm.closestLeafFromSubtree(parent.right, cx, cy, direction); leaf != nil { | 365 | if leaf := wm.closestLeafFromSubtree(parent.right, cx, cy, direction); leaf != nil { | ||
| 363 | return leaf | 366 | return leaf | ||
| 364 | } | 367 | } | ||
| @@ -375,16 +378,16 @@ func (wm *WorkspaceManager) closestLeafFromSubtree(node *paneNode, cx, cy float6 | |||||
| 375 | bestScore := math.MaxFloat64 | 378 | bestScore := math.MaxFloat64 | ||
| 376 | var best *paneNode | 379 | var best *paneNode | ||
| 377 | for _, leaf := range leaves { | 380 | for _, leaf := range leaves { | ||
| 378 | - | if leaf == nil || leaf.container == 0 { | 381 | + | if leaf == nil || leaf.container == nil { |
| 379 | continue | 382 | continue | ||
| 380 | } | 383 | } | ||
| 381 | 384 | ||||
| 382 | - | bounds, ok := webkit.WidgetGetBounds(leaf.container) | 385 | + | bounds := leaf.container.Allocation() |
| 383 | - | if !ok { | 386 | + | if bounds == nil { |
| 384 | continue | 387 | continue | ||
| 385 | } | 388 | } | ||
| 386 | - | tx := bounds.X + bounds.Width/2.0 | 389 | + | tx := float64(bounds.X()) + float64(bounds.Width())/2.0 |
| 387 | - | ty := bounds.Y + bounds.Height/2.0 | 390 | + | ty := float64(bounds.Y()) + float64(bounds.Height())/2.0 |
| 388 | dx := tx - cx | 391 | dx := tx - cx | ||
| 389 | dy := ty - cy | 392 | dy := ty - cy | ||
| 390 | var score float64 | 393 | var score float64 | ||