feat: split kiosk into fallback canvas and OSD overlay layers (#8)
Build Ground Station / build (push) Successful in 37s
Build Ground Station / build (push) Successful in 37s
Drive two independent visual layers per display target from one shared video presence signal: the fullscreen fallback/menu canvas below video and a transparent, input-transparent OSD overlay above video, reserved as the future flight OSD rendering surface. WFB and video decode stay out of the UI process; pilot video keeps rendering priority.
This commit was merged in pull request #12.
This commit is contained in:
@@ -5,18 +5,25 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/BurntSushi/xgb/shape"
|
||||
"github.com/BurntSushi/xgb/xproto"
|
||||
)
|
||||
|
||||
func TestX11FullscreenArgsKeepCanvasBelowVideo(t *testing.T) {
|
||||
args := x11FullscreenArgs(0x1a2b)
|
||||
|
||||
joined := strings.Join(args, " ")
|
||||
if !strings.Contains(joined, "add,fullscreen,below") {
|
||||
t.Fatalf("args %v must request fullscreen with below stacking", args)
|
||||
func TestX11FullscreenArgsOrderByRole(t *testing.T) {
|
||||
below := strings.Join(x11FullscreenArgs(0x1a2b, RoleBelow), " ")
|
||||
if !strings.Contains(below, "add,fullscreen,below") {
|
||||
t.Fatalf("args %q must request fullscreen with below stacking", below)
|
||||
}
|
||||
if !strings.Contains(joined, "0x00001a2b") {
|
||||
t.Fatalf("args %v must reference the kiosk window id", args)
|
||||
if !strings.Contains(below, "0x00001a2b") {
|
||||
t.Fatalf("args %q must reference the kiosk window id", below)
|
||||
}
|
||||
|
||||
above := strings.Join(x11FullscreenArgs(0x1a2b, RoleAbove), " ")
|
||||
if strings.Contains(above, "below") {
|
||||
t.Fatalf("args %q must never stack the OSD overlay below video", above)
|
||||
}
|
||||
if !strings.Contains(above, "add,fullscreen,above") {
|
||||
t.Fatalf("args %q must request fullscreen with above stacking", above)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +43,7 @@ func TestX11OpenerAppliesFullscreenArgsThroughHook(t *testing.T) {
|
||||
return errors.New("wmctrl missing")
|
||||
}}
|
||||
|
||||
if err := opener.applyFullscreen(x11FullscreenArgs(0x42)); err == nil {
|
||||
if err := opener.applyFullscreen(x11FullscreenArgs(0x42, RoleBelow)); err == nil {
|
||||
t.Fatal("hook error must propagate for logging")
|
||||
}
|
||||
if len(got) != 1 || !strings.Contains(strings.Join(got[0], " "), "add,fullscreen,below") {
|
||||
@@ -189,3 +196,104 @@ func TestX11FontPatternRequestsUnicodeFixedFont(t *testing.T) {
|
||||
t.Fatalf("font pattern %q must select a Unicode encoding for the exact fallback text", iso10646FontPattern)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLayerMarkerIdentifiesOwnLayerWindows(t *testing.T) {
|
||||
if layerMarkerValue(RoleBelow) == layerMarkerValue(RoleAbove) {
|
||||
t.Fatal("roles must carry distinct marker payloads")
|
||||
}
|
||||
for _, role := range []LayerRole{RoleBelow, RoleAbove} {
|
||||
if !markerIsGroundstation(layerMarkerValue(role)) {
|
||||
t.Fatalf("marker %q must identify our own window", layerMarkerValue(role))
|
||||
}
|
||||
}
|
||||
for _, foreign := range []string{"", "video", "desktop", "groundstation-fake"} {
|
||||
if markerIsGroundstation(foreign) {
|
||||
t.Fatalf("foreign marker payload %q must not identify our windows", foreign)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarkerWalkBoundsStayBoundedAndCoverFrameDepth(t *testing.T) {
|
||||
depth, nodes := markerWalkBounds()
|
||||
if depth <= 0 || nodes <= 0 {
|
||||
t.Fatalf("marker walk bounds depth=%d nodes=%d must be positive", depth, nodes)
|
||||
}
|
||||
if nodes < depth {
|
||||
t.Fatalf("node budget %d must cover at least a depth-%d ancestor chain", nodes, depth)
|
||||
}
|
||||
// A reparenting window manager puts each of our two layer windows inside
|
||||
// its own frame, so the walk must reach our window below one frame.
|
||||
if depth < 2 {
|
||||
t.Fatalf("marker walk depth %d must cover our window below a window-manager frame", depth)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEWMHWindowTypeAnnouncesOverlayRoleOnly(t *testing.T) {
|
||||
if name := ewmhWindowTypeName(RoleAbove); !strings.Contains(name, "DOCK") {
|
||||
t.Fatalf("OSD overlay window type %q must be the always-above helper role", name)
|
||||
}
|
||||
if name := ewmhWindowTypeName(RoleBelow); name != "" {
|
||||
t.Fatalf("fallback canvas must keep announcing no window type, got %q", name)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPresentedVideoDecisionExcludesOwnLayersAndHelpers(t *testing.T) {
|
||||
video := windowFacts{inputOutput: true, viewable: true}
|
||||
if !isPresentedVideoWindow(video) {
|
||||
t.Fatal("a presented output window must count as video")
|
||||
}
|
||||
for name, facts := range map[string]windowFacts{
|
||||
"input-only": {viewable: true},
|
||||
"override-redirect": {inputOutput: true, viewable: true, overrideRedirect: true},
|
||||
"unmapped": {inputOutput: true},
|
||||
"auxiliary": {inputOutput: true, viewable: true, auxiliary: true},
|
||||
"groundstation-canvas": {inputOutput: true, viewable: true, groundstation: true},
|
||||
"groundstation-osd": {inputOutput: true, viewable: true, groundstation: true},
|
||||
} {
|
||||
if isPresentedVideoWindow(facts) {
|
||||
t.Fatalf("%s window must never count as video", name)
|
||||
}
|
||||
}
|
||||
// Window-manager frames around our layer windows carry no marker of
|
||||
// their own; groundstationLayerWindow finds the marker below the frame,
|
||||
// so framed Ground Station layers land in these same excluded facts.
|
||||
}
|
||||
|
||||
func TestStackOrderByRoleKeepsLayersOnTheirSideOfVideo(t *testing.T) {
|
||||
if mode := stackModeForVideoAppear(RoleBelow); mode != xproto.StackModeBelow {
|
||||
t.Fatalf("canvas must park below appearing video, got %v", mode)
|
||||
}
|
||||
if mode := stackModeForVideoAppear(RoleAbove); mode != xproto.StackModeAbove {
|
||||
t.Fatalf("OSD overlay must rise above appearing video, got %v", mode)
|
||||
}
|
||||
if !raisesOnVideoEnd(RoleBelow) {
|
||||
t.Fatal("canvas must raise itself when video ends so the fallback returns")
|
||||
}
|
||||
if raisesOnVideoEnd(RoleAbove) {
|
||||
t.Fatal("OSD overlay is already above video and must not restack on video end")
|
||||
}
|
||||
}
|
||||
|
||||
func TestOSDEventMaskNeverSelectsDeviceInput(t *testing.T) {
|
||||
if osdEventMask&deviceInputEventMask != 0 {
|
||||
t.Fatalf("OSD event mask must not select pointer or key input: %b", osdEventMask)
|
||||
}
|
||||
if osdEventMask&xproto.EventMaskExposure == 0 {
|
||||
t.Fatal("OSD event mask must still select exposure for redraws")
|
||||
}
|
||||
}
|
||||
|
||||
func TestTransparentShapesEmptyInputAndOutput(t *testing.T) {
|
||||
var input, output bool
|
||||
for _, kind := range transparentShapeKinds() {
|
||||
switch kind {
|
||||
case shape.SkInput:
|
||||
input = true
|
||||
case shape.SkBounding:
|
||||
output = true
|
||||
}
|
||||
}
|
||||
if !input || !output {
|
||||
t.Fatalf("shape kinds %v must empty both the input and the bounding region", transparentShapeKinds())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user