feat/hints a471fa4

client.go RawHistoryFolder

1package core
2
3import (
4	"context"
5
6	"github.com/bnema/neferwl/internal/ports"
7)
8
9// clientEvent applies one client event. publish asks for a new scene;
10// stop ends Run (a command could not be delivered).
11func (c *Core) clientEvent(ctx context.Context, ev ports.ClientEvent) (publish, stop bool) {
12	switch v := ev.(type) {
13	case ports.SessionLockChanged:
14		if !c.applyLockChanged(v) {
15			return false, false
16		}
17	case ports.CaptureSessionOpen:
18		c.captureOpen(v)
19	case ports.CaptureSessionClose:
20		c.captureClose(v.ID)
21	case ports.CaptureFrameTaken:
22		// Nothing new to show (the target flashes already): no scene.
23		if !c.captureFrame(v) {
24			return false, false
25		}
26	case ports.CaptureExclusionBegin:
27		c.captureExclusionBegin(v)
28	case ports.CaptureExclusionLayer:
29		c.captureExclusionLayer(v)
30	case ports.CaptureExclusionEnd:
31		c.captureExclusionEnd(v.Session)
32	case ports.LayerChanged:
33		c.layerChanged = true
34		c.setLayers(v.Layers)
35	case ports.InputRegionChanged:
36		c.windows.setRegion(v)
37	case ports.WindowMapped:
38		c.mapWindow(v)
39	case ports.WindowResized:
40		c.resizeFloating(v)
41	case ports.PopupRequest:
42		if err := c.placePopup(ctx, v); err != nil {
43			return false, true
44		}
45	case ports.PopupMapped:
46		if p := c.popups[v.ID]; p != nil {
47			p.mapped = true
48		}
49	case ports.ShortcutsInhibit:
50		c.windows.setInhibitShortcuts(v.Window, v.Active)
51		if err := c.updateInhibit(ctx); err != nil {
52			return false, true
53		}
54		return false, false
55	case ports.OutputPower:
56		if i := c.screenIndex(v.Output); i >= 0 && c.screens[i].off == v.On {
57			c.screens[i].off = !v.On
58		}
59	case ports.IdleInhibit:
60		c.windows.setIdleInhibit(v.Window, v.Active)
61		c.publishState()
62		return false, false
63	case ports.WindowAppID:
64		c.windows.setAppID(v.ID, v.AppID)
65	case ports.WindowParent:
66		if _, w := c.screenOf(v.ID); w != nil {
67			w.SetDialogParent(v.ID, v.Parent)
68		}
69	case ports.WindowModal:
70		if _, w := c.screenOf(v.ID); w != nil {
71			w.SetModal(v.ID, v.Modal)
72		}
73	case ports.WindowUnmapped:
74		if c.unmapClient(ctx, v) != nil {
75			return false, true
76		}
77	case ports.PointerConstrained:
78		c.constrained = v
79	case ports.PointerWarp:
80		if c.warpPointer(ctx, v) != nil {
81			return false, true
82		}
83	case ports.WindowMoveRequest:
84		if c.clientDrag(ctx, v) != nil {
85			return false, true
86		}
87	case ports.DataDragStarted:
88		if c.startDataDrag(ctx, v) != nil {
89			return false, true
90		}
91		return false, false
92	case ports.DataDragIcon:
93		if !c.setDataDragIcon(v) {
94			return false, false
95		}
96	case ports.DataDragEnded:
97		if c.dataDrag == nil {
98			return false, false
99		}
100		c.abortDataDrag()
101		if c.finishDataDrag(ctx) != nil {
102			return false, true
103		}
104		return false, false
105	case ports.WindowFullscreenRequest:
106		if c.fullscreenRequest(ctx, v) != nil {
107			return false, true
108		}
109	case ports.WorkspaceActivate:
110		if c.activateWorkspaces(ctx, v) != nil {
111			return false, true
112		}
113	case ports.WindowActivate:
114		if c.activate(ctx, v.ID) != nil {
115			return false, true
116		}
117	}
118	return true, false
119}
120
121// unmapClient drops a window or popup the client unmapped.
122func (c *Core) unmapClient(ctx context.Context, v ports.WindowUnmapped) error {
123	if c.popups[v.ID] != nil {
124		if err := c.dropPopup(ctx, v.ID); err != nil {
125			return err
126		}
127	}
128	if err := c.closePopupsOf(ctx, v.ID); err != nil {
129		return err
130	}
131	c.windows.drop(v.ID)
132	if c.drag != nil && c.drag.id == v.ID {
133		c.abortDrag()
134	}
135	if err := c.dataDragGone(ctx, v.ID); err != nil {
136		return err
137	}
138	c.unmapWindow(v)
139	c.releaseSlots()
140	if c.pointer == v.ID {
141		c.pointer = 0
142		if err := c.pointerFocus(ctx, ports.PointerFocus{}); err != nil {
143			return err
144		}
145	}
146	return nil
147}
148
149// fullscreenRequest answers xdg_toplevel set/unset_fullscreen, from the
150// window itself or a taskbar (External).
151func (c *Core) fullscreenRequest(ctx context.Context, v ports.WindowFullscreenRequest) error {
152	c.configures.answer[v.ID] = true
153	if v.Fullscreen && !v.External && c.now().Sub(c.windows.lookup(v.ID).mappedAt) < fullscreenGrace {
154		return nil
155	}
156	// A taskbar request is a user action on that window, as an
157	// activation: it comes on screen with the focus, leaving
158	// another window's fullscreen.
159	if v.External && v.Fullscreen {
160		if err := c.activate(ctx, v.ID); err != nil {
161			return err
162		}
163	}
164	if s, _ := c.screenOf(v.ID); s != nil {
165		s.mon.SetFullscreen(v.ID, v.Fullscreen)
166		if w := s.mon.Current(); v.Fullscreen && w.fullscreen == v.ID {
167			// A taskbar or late fullscreen request that took
168			// effect: the window does not fade in, it keeps the
169			// direct scanout path. One that was ignored (the
170			// grace after the map) leaves the entrance running.
171			delete(s.rects, v.ID)
172		}
173	}
174	return nil
175}
176
177// activateWorkspaces shows the workspaces of v by stable ID, in order.
178func (c *Core) activateWorkspaces(ctx context.Context, v ports.WorkspaceActivate) error {
179	before := c.cur().mon.Current()
180	for _, id := range v.IDs {
181		for i, sc := range c.screens {
182			if sc.name() == "" {
183				continue
184			}
185			for w := range sc.mon.all() {
186				if w.ID == id {
187					c.focusScreen = i
188					sc.mon.show(w)
189					break
190				}
191			}
192		}
193	}
194	return c.workspaceVisible(ctx, c.cur().mon.Current() != before)
195}

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