detached 00a0a44

refactor(core): reuse contains for border hit zones

commit
00a0a44da34e46b9a9fa695e01cab7fdeb1f1578
author
brice · · 2026-10-21 05:46 UTC
committer
brice · · 2026-10-21 07:11 UTC
parent
d029245
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
1 file · +4 -8
M internal/core/border.go +4 -8
@@ -18,10 +18,6 @@ type border struct {
1818 // The effective minimum also includes 5% of the lane and four border widths.
1919 const borderMinWidth = 48
2020
21-func borderContains(r Rect, x, y int) bool {
22- return x >= r.X && x < r.X+r.W && y >= r.Y && y < r.Y+r.H
23-}
24-
2521 func borderZone(a, b, pad int) (int, int) {
2622 mid := (a + b) / 2
2723 lo, hi := min(a, mid-pad), max(b, mid+pad)
@@ -29,13 +25,13 @@ func borderZone(a, b, pad int) (int, int) {
2925 }
3026
3127 func (w *Workspace) borderAt(x, y, pad int) (border, bool) {
32- if w.fullscreen != 0 || !borderContains(w.Usable, x, y) {
28+ if w.fullscreen != 0 || !contains(w.Usable, x, y) {
3329 return border{}, false
3430 }
3531 // Overview and preview are Monitor presentation, not Workspace state. Their
3632 // caller must not ask for workspace borders while presenting those scenes.
3733 for _, p := range w.Layout() {
38- if p.Floating && !p.Hidden && !p.Below && borderContains(p.Rect, x, y) {
34+ if p.Floating && !p.Hidden && !p.Below && contains(p.Rect, x, y) {
3935 return border{}, false
4036 }
4137 }
@@ -52,7 +48,7 @@ func (w *Workspace) borderAt(x, y, pad int) (border, bool) {
5248 for j := 0; j+1 < len(rows); j++ {
5349 lo, size := borderZone(rows[j].Y+rows[j].H, rows[j+1].Y, pad)
5450 b := border{kind: borderRow, col: i, row: j, rect: Rect{X: r.X, Y: lo, W: r.W, H: size}}
55- if borderContains(b.rect, x, y) {
51+ if contains(b.rect, x, y) {
5652 return b, true
5753 }
5854 }
@@ -66,7 +62,7 @@ func (w *Workspace) borderAt(x, y, pad int) (border, bool) {
6662 top, bottom := max(r.Y, next.Y), min(r.Y+r.H, next.Y+next.H)
6763 lo, size := borderZone(r.X+r.W, next.X, pad)
6864 b := border{kind: borderColumn, col: i, rect: Rect{X: lo, Y: top, W: size, H: max(bottom-top, 0)}}
69- if borderContains(b.rect, x, y) {
65+ if contains(b.rect, x, y) {
7066 return b, true
7167 }
7268 }
@@ -18,10 +18,6 @@ type border struct {
18 // The effective minimum also includes 5% of the lane and four border widths.18 // The effective minimum also includes 5% of the lane and four border widths.
19 const borderMinWidth = 4819 const borderMinWidth = 48
20 20
21-func borderContains(r Rect, x, y int) bool {
22- return x >= r.X && x < r.X+r.W && y >= r.Y && y < r.Y+r.H
23-}
24-
25 func borderZone(a, b, pad int) (int, int) {21 func borderZone(a, b, pad int) (int, int) {
26 mid := (a + b) / 222 mid := (a + b) / 2
27 lo, hi := min(a, mid-pad), max(b, mid+pad)23 lo, hi := min(a, mid-pad), max(b, mid+pad)
@@ -29,13 +25,13 @@ func borderZone(a, b, pad int) (int, int) {
29 }25 }
30 26
31 func (w *Workspace) borderAt(x, y, pad int) (border, bool) {27 func (w *Workspace) borderAt(x, y, pad int) (border, bool) {
32- if w.fullscreen != 0 || !borderContains(w.Usable, x, y) {28+ if w.fullscreen != 0 || !contains(w.Usable, x, y) {
33 return border{}, false29 return border{}, false
34 }30 }
35 // Overview and preview are Monitor presentation, not Workspace state. Their31 // Overview and preview are Monitor presentation, not Workspace state. Their
36 // caller must not ask for workspace borders while presenting those scenes.32 // caller must not ask for workspace borders while presenting those scenes.
37 for _, p := range w.Layout() {33 for _, p := range w.Layout() {
38- if p.Floating && !p.Hidden && !p.Below && borderContains(p.Rect, x, y) {34+ if p.Floating && !p.Hidden && !p.Below && contains(p.Rect, x, y) {
39 return border{}, false35 return border{}, false
40 }36 }
41 }37 }
@@ -52,7 +48,7 @@ func (w *Workspace) borderAt(x, y, pad int) (border, bool) {
52 for j := 0; j+1 < len(rows); j++ {48 for j := 0; j+1 < len(rows); j++ {
53 lo, size := borderZone(rows[j].Y+rows[j].H, rows[j+1].Y, pad)49 lo, size := borderZone(rows[j].Y+rows[j].H, rows[j+1].Y, pad)
54 b := border{kind: borderRow, col: i, row: j, rect: Rect{X: r.X, Y: lo, W: r.W, H: size}}50 b := border{kind: borderRow, col: i, row: j, rect: Rect{X: r.X, Y: lo, W: r.W, H: size}}
55- if borderContains(b.rect, x, y) {51+ if contains(b.rect, x, y) {
56 return b, true52 return b, true
57 }53 }
58 }54 }
@@ -66,7 +62,7 @@ func (w *Workspace) borderAt(x, y, pad int) (border, bool) {
66 top, bottom := max(r.Y, next.Y), min(r.Y+r.H, next.Y+next.H)62 top, bottom := max(r.Y, next.Y), min(r.Y+r.H, next.Y+next.H)
67 lo, size := borderZone(r.X+r.W, next.X, pad)63 lo, size := borderZone(r.X+r.W, next.X, pad)
68 b := border{kind: borderColumn, col: i, rect: Rect{X: lo, Y: top, W: size, H: max(bottom-top, 0)}}64 b := border{kind: borderColumn, col: i, rect: Rect{X: lo, Y: top, W: size, H: max(bottom-top, 0)}}
69- if borderContains(b.rect, x, y) {65+ if contains(b.rect, x, y) {
70 return b, true66 return b, true
71 }67 }
72 }68 }

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 23

Tags 10

↑↓ moveenter openesc close