feat/xdg-foreign fdbb95e

workspace_clip_test.go RawHistoryFolder

1package vulkan
2
3import (
4	"image"
5	"image/color"
6	"testing"
7
8	"github.com/bnema/neferwl/internal/ports"
9)
10
11func TestWorkspaceClipWindowsPopupsAndLayers(t *testing.T) {
12	r, err := New(64, 48)
13	if err != nil {
14		t.Skipf("Vulkan unavailable: %v", err)
15	}
16	defer r.Close()
17	red := color.RGBA{255, 0, 0, 255}
18	green := color.RGBA{0, 255, 0, 255}
19	contents := map[ports.WindowID]ports.SurfaceContent{1: solidContent(t, 64, 48, red), 2: solidContent(t, 8, 8, green)}
20	clip := ports.Rect{X: 16, Y: 12, W: 32, H: 24}
21	scene := ports.Scene{Seq: 1, OutputWidth: 64, OutputHeight: 48, Background: "#000000", WorkspaceClip: clip,
22		Windows: []ports.SceneWindow{{ID: 1, Rect: ports.Rect{W: 64, H: 48}}},
23		Layers:  []ports.SceneLayer{{ID: 2, Rect: ports.Rect{W: 8, H: 8}, Layer: ports.LayerTop}},
24	}
25	if err := render(r, scene, contents); err != nil {
26		t.Fatal(err)
27	}
28	pixels := readPixels(t, r)
29	for point, want := range map[image.Point]color.RGBA{{0, 0}: green, {10, 10}: {0, 0, 0, 255}, {16, 12}: red, {47, 35}: red, {48, 36}: {0, 0, 0, 255}} {
30		if got := pixels.RGBAAt(point.X, point.Y); got != want {
31			t.Errorf("pixel %v=%v, want %v", point, got, want)
32		}
33	}
34	// Content-only damage at the same scene sequence must remain clipped.
35	changed := contents[1]
36	changed.Seq++
37	changed.DamageHistory = []ports.SeqDamage{{Seq: changed.Seq, Full: true}}
38	if _, err := changed.SHM.File.WriteAt([]byte{255, 255, 255, 255}, 0); err != nil {
39		t.Fatal(err)
40	}
41	contents[1] = changed
42	if err := render(r, scene, contents); err != nil {
43		t.Fatal(err)
44	}
45	if got := readPixels(t, r).RGBAAt(10, 10); got != (color.RGBA{0, 0, 0, 255}) {
46		t.Fatalf("damage escaped clip: %v", got)
47	}
48	// A popup from a workspace surface is clipped too; input popups over
49	// layers retain output-wide bounds.
50	scene.Seq++
51	scene.Windows = []ports.SceneWindow{{ID: 1, Rect: ports.Rect{W: 64, H: 48}, Popup: true}}
52	if err := render(r, scene, contents); err != nil {
53		t.Fatal(err)
54	}
55	if got := readPixels(t, r).RGBAAt(10, 10); got != (color.RGBA{0, 0, 0, 255}) {
56		t.Fatalf("popup escaped clip: %v", got)
57	}
58	// Popups above layers belong to output-wide controls, not the workspace.
59	scene.Seq++
60	scene.Windows[0].OverLayers = true
61	if err := render(r, scene, contents); err != nil {
62		t.Fatal(err)
63	}
64	if got := readPixels(t, r).RGBAAt(10, 10); got != red {
65		t.Fatalf("output-wide popup clipped: %v", got)
66	}
67	scene.Windows[0].OverLayers = false
68	// Switching back to inherited geometry repaints the margins.
69	scene.Seq++
70	scene.WorkspaceClip = ports.Rect{}
71	if err := render(r, scene, contents); err != nil {
72		t.Fatal(err)
73	}
74	if got := readPixels(t, r).RGBAAt(10, 10); got != red {
75		t.Fatalf("stale clip after inheritance: %v", got)
76	}
77}

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