feat/data-dnd e05cb15

windows.go RawHistoryFolder

1package core
2
3import (
4	"time"
5
6	"github.com/bnema/neferwl/internal/ports"
7)
8
9// windowRecord is what core knows about one client surface besides its
10// place in the layout. Fields fill in as wayland reports them, in any order.
11type windowRecord struct {
12	// client holds the app ID and PID of a mapped window, for State.
13	client   ports.WindowMapped
14	mappedAt time.Time
15	// region is the input region; nil accepts input everywhere.
16	region *ports.InputRegionChanged
17	// inhibitShortcuts asks to keep compositor binds while focused;
18	// idleInhibit keeps the session awake.
19	inhibitShortcuts bool
20	idleInhibit      bool
21}
22
23// windowRegistry owns the per-surface records. Dropping a surface removes
24// everything core keeps about it in one call.
25type windowRegistry struct {
26	records map[WindowID]*windowRecord
27}
28
29func newWindowRegistry() windowRegistry {
30	return windowRegistry{records: map[WindowID]*windowRecord{}}
31}
32
33// at returns the record of id, creating it.
34func (r *windowRegistry) at(id WindowID) *windowRecord {
35	rec := r.records[id]
36	if rec == nil {
37		rec = &windowRecord{}
38		r.records[id] = rec
39	}
40	return rec
41}
42
43// lookup returns the record of id, or the zero record when there is none.
44func (r *windowRegistry) lookup(id WindowID) windowRecord {
45	if rec := r.records[id]; rec != nil {
46		return *rec
47	}
48	return windowRecord{}
49}
50
51func (r *windowRegistry) mapped(v ports.WindowMapped, now time.Time) {
52	rec := r.at(v.ID)
53	rec.client, rec.mappedAt = v, now
54}
55
56// setAppID updates the app ID of a mapped window only.
57func (r *windowRegistry) setAppID(id WindowID, appID string) {
58	if rec := r.records[id]; rec != nil && rec.client.ID != 0 {
59		rec.client.AppID = appID
60	}
61}
62
63func (r *windowRegistry) setRegion(v ports.InputRegionChanged) { r.at(v.ID).region = &v }
64
65func (r *windowRegistry) setInhibitShortcuts(id WindowID, on bool) {
66	if on {
67		r.at(id).inhibitShortcuts = true
68	} else if rec := r.records[id]; rec != nil {
69		rec.inhibitShortcuts = false
70	}
71}
72
73func (r *windowRegistry) setIdleInhibit(id WindowID, on bool) {
74	if on {
75		r.at(id).idleInhibit = true
76	} else if rec := r.records[id]; rec != nil {
77		rec.idleInhibit = false
78	}
79}
80
81// drop forgets the surface.
82func (r *windowRegistry) drop(id WindowID) { delete(r.records, id) }
83
84// layerGone forgets the input region of a layer surface that is no longer
85// mapped; layers get no WindowUnmapped. The record goes once it is empty.
86func (r *windowRegistry) layerGone(id WindowID) {
87	rec := r.records[id]
88	if rec == nil {
89		return
90	}
91	rec.region = nil
92	if *rec == (windowRecord{}) {
93		delete(r.records, id)
94	}
95}
96
97// acceptsInput reports whether the surface-local point is in id's input
98// region.
99func (r *windowRegistry) acceptsInput(id WindowID, x, y float64) bool {
100	rec := r.records[id]
101	if rec == nil || rec.region == nil || rec.region.All {
102		return true
103	}
104	for _, box := range rec.region.Rects {
105		if x >= float64(box.X) && x < float64(box.X+box.W) && y >= float64(box.Y) && y < float64(box.Y+box.H) {
106			return true
107		}
108	}
109	return false
110}

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 25

Tags 10

↑↓ moveenter openesc close