Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions images/chromium-headful/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=$CACHEIDPREFIX-ap
x11-apps \
# xprop, used to detect when the window manager has taken the display
x11-utils \
# no panel: a tint2 started inside a session declares a strut that can
# reserve part of the work area, leaving a maximized window short of the
# display with the root background showing beside it
# not started by the image: kept for workloads that start a tint2 panel
# through the process API
tint2 \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: keep a note so the dependency is visible next time someone audits this list.

Suggested change
tint2 \
# not started by the image: kept for workloads that start a tint2 panel
# through the process API
tint2 \

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied.

wget \
xdg-utils \
libvulkan1 \
Expand Down
7 changes: 7 additions & 0 deletions images/chromium-headful/openbox/rc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
<animateIconify>no</animateIconify>
</theme>

<!-- A docked app such as a tint2 panel with panel_dock = 1 must not reserve
part of the work area: the strut leaves a maximized browser short of
the display with the root background showing beside it. -->
<dock>
<noStrut>yes</noStrut>
</dock>

<!-- This file replaces the distro rc.xml, so keep the input bindings needed
for focus, titlebar movement, resizing, and popup close actions here. -->
<mouse>
Expand Down
96 changes: 96 additions & 0 deletions server/e2e/e2e_tint2_dock_strut_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package e2e

import (
"context"
"fmt"
"os/exec"
"strconv"
"strings"
"testing"
"time"

instanceoapi "github.com/kernel/kernel-images/server/lib/oapi"
"github.com/samber/lo"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

const dockedTint2Config = `panel_dock = 1
panel_position = bottom center horizontal
panel_size = 100% 30
`

// getNetWorkarea reads the first desktop's _NET_WORKAREA as x, y, width, height.
func getNetWorkarea(ctx context.Context, c *TestContainer) ([4]int, error) {
var area [4]int
out, err := execCombinedOutput(ctx, c, "bash", []string{"-c", "DISPLAY=:1 xprop -root _NET_WORKAREA"})
if err != nil {
return area, fmt.Errorf("xprop exec: %w (out=%q)", err, out)
}
_, values, ok := strings.Cut(out, "=")
if !ok {
return area, fmt.Errorf("unexpected xprop output %q", out)
}
fields := strings.Split(values, ",")
if len(fields) < 4 {
return area, fmt.Errorf("unexpected _NET_WORKAREA %q", out)
}
for i := range area {
if area[i], err = strconv.Atoi(strings.TrimSpace(fields[i])); err != nil {
return area, fmt.Errorf("parse _NET_WORKAREA %q: %w", out, err)
}
}
return area, nil
}

// TestHeadfulDockedTint2KeepsFullWorkarea starts a docked tint2 panel through
// the process API and checks that it does not reserve any of the work area, so
// a maximized browser still covers the whole display.
func TestHeadfulDockedTint2KeepsFullWorkarea(t *testing.T) {
if _, err := exec.LookPath("docker"); err != nil {
t.Skipf("docker not available: %v", err)
}

ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
defer cancel()

c := NewTestContainer(t, headfulImage)
require.NoError(t, c.Start(ctx, ContainerConfig{Env: map[string]string{
"CHROMIUM_FLAGS": "--user-data-dir=/home/kernel/user-data --disable-dev-shm-usage --disable-gpu --start-maximized --remote-allow-origins=*",
}}), "failed to start container")
defer c.Stop(ctx)
require.NoError(t, c.WaitReady(ctx), "api not ready")
require.NoError(t, c.WaitDevTools(ctx), "devtools not ready")

waitForWindowState(t, ctx, c, "maximized", "baseline")
rootW, rootH, err := getXRootResolution(ctx, c)
require.NoError(t, err, "x root resolution")

client, err := c.APIClient()
require.NoError(t, err)
out, err := execCombinedOutput(ctx, c, "bash", []string{"-c", "cat > /tmp/tint2rc <<'EOF'\n" + dockedTint2Config + "EOF"})
require.NoError(t, err, "write tint2rc: %s", out)
spawn, err := client.ProcessSpawnWithResponse(ctx, instanceoapi.ProcessSpawnRequest{
Command: "tint2",
Args: lo.ToPtr([]string{"-c", "/tmp/tint2rc"}),
Env: lo.ToPtr(map[string]string{"DISPLAY": ":1"}),
})
require.NoError(t, err, "spawn tint2")
require.NotNil(t, spawn.JSON200, "spawn tint2: %s", spawn.Body)
defer client.ProcessKillWithResponse(context.Background(), spawn.JSON200.ProcessId.String(), instanceoapi.ProcessKillRequest{Signal: "KILL"})

require.Eventually(t, func() bool {
out, err := execCombinedOutput(ctx, c, "bash", []string{"-c", "DISPLAY=:1 xwininfo -root -tree"})
return err == nil && strings.Contains(out, "tint2")
}, 20*time.Second, 250*time.Millisecond, "tint2 panel never mapped")
// Give openbox time to dock the panel and publish any strut it causes.
time.Sleep(2 * time.Second)

area, err := getNetWorkarea(ctx, c)
require.NoError(t, err, "read _NET_WORKAREA")
assert.Equal(t, [4]int{0, 0, rootW, rootH}, area, "docked tint2 reserved part of the work area")

win := waitForWindowState(t, ctx, c, "maximized", "with tint2")
assert.Equal(t, rootW, win.Width, "maximized window is narrower than the display")
assert.Equal(t, rootH, win.Height, "maximized window is shorter than the display")
}
Loading