Skip to content
Open
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
22 changes: 12 additions & 10 deletions src/output/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1675,6 +1675,7 @@ namespace umbriel {
wlr_box outputArea{};
wlr_output_effective_resolution(m_output, &outputArea.width, &outputArea.height);
if (outputArea.width <= 0 || outputArea.height <= 0) {
m_arrangedUsableArea = {};
return;
}

Expand Down Expand Up @@ -1744,21 +1745,22 @@ namespace umbriel {
m_server->scheduleIpcLayersEvent();
m_server->scheduleIpcOutputsEvent();
const wlr_box layoutUsableArea = this->usableArea();
// Arrangement runs on every layer commit; only a changed result is worth a line.
const wlr_box& logged = m_loggedUsableArea;
if (layoutUsableArea.x != logged.x
|| layoutUsableArea.y != logged.y
|| layoutUsableArea.width != logged.width
|| layoutUsableArea.height != logged.height) {
m_loggedUsableArea = layoutUsableArea;
// Arrangement runs on every layer commit. Only a changed usable area re-lays out the workspace: that arrange is
// unanimated, so running it for a layer that reserves nothing (an OSD) would land an in-flight scroll at once.
const wlr_box& arranged = m_arrangedUsableArea;
if (layoutUsableArea.x != arranged.x
|| layoutUsableArea.y != arranged.y
|| layoutUsableArea.width != arranged.width
|| layoutUsableArea.height != arranged.height) {
m_arrangedUsableArea = layoutUsableArea;
markDirty(Dirty::QuitConfirm);
kLog.debug(
"{} usable={}x{}+{}+{}", m_output->name, layoutUsableArea.width, layoutUsableArea.height, layoutUsableArea.x,
layoutUsableArea.y
);
}
if (m_workspaceGroup != nullptr && m_workspaceGroup->active() != nullptr) {
m_workspaceGroup->active()->markArrange(false);
if (m_workspaceGroup != nullptr && m_workspaceGroup->active() != nullptr) {
m_workspaceGroup->active()->markArrange(false);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/output/output.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ namespace umbriel {
wlr_scene_optimized_blur* m_optimizedBlur = nullptr;
std::unique_ptr<WorkspaceGroup> m_workspaceGroup;
wlr_box m_localUsableArea{};
wlr_box m_loggedUsableArea{};
wlr_box m_arrangedUsableArea{};
int m_arrangedLayoutX = 0;
int m_arrangedLayoutY = 0;

Expand Down
75 changes: 75 additions & 0 deletions tests/harness/checks/animation/layer_commit_keeps_scroll.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/env bash
# A layer surface that maps without changing the usable area, such as an OSD shown as focus moves, must not re-arrange
# the workspace: that arrange is unanimated and, landing before the focus scroll is flushed, would carry the strip to its
# target in one frame.
set -euo pipefail
source "$UMBRIEL_HARNESS_LIB"

readonly SHOT="$UMBRIEL_RUNTIME_DIR/layer-commit-keeps-scroll.png"
readonly LAYER_LOG="$UMBRIEL_RUNTIME_DIR/layer.log"
readonly GREEN='g > 0.8 && r < 0.2 && b < 0.2'

# A slow refresh keeps the focus request and the layer's first commit inside one frame.
printf '\n[layout.scrolling]\ndefault_extent_fraction = 0.5\n\n[colors]\nbackdrop = "#000000FF"\n\n[output.HEADLESS-1]\nmode = "1280x720@10"\n' >> "$UMBRIEL_CONFIG"
"$UMBRIEL" msg config-reload > /dev/null
"$UMBRIEL" settle
"$UMBRIEL" clock-freeze

spawn_client() {
FILL_COLOR=$2 RESIZE_FILL_COLOR=$2 "$UMBRIEL_UNMAP_CLIENT" "$1" 400 300 > "$UMBRIEL_RUNTIME_DIR/$1.log" 2>&1 &
}

wait_for_windows() {
for _ in $(seq 60); do
[[ $("$UMBRIEL" windows --json | jq 'length') -eq $1 ]] && return 0
sleep 0.25
done
echo "timed out waiting for $1 windows, saw $("$UMBRIEL" windows --json | jq 'length')"
return 1
}

finish() {
"$UMBRIEL" clock-advance 10000
"$UMBRIEL" settle
}

green_box() {
grim "$SHOT"
"$UMBRIEL_PIXEL_PROBE" "$SHOT" bbox "$GREEN"
}

spawn_client scroll-blue 0xFF0000FF
wait_for_windows 1
spawn_client scroll-magenta 0xFFFF00FF
wait_for_windows 2
spawn_client scroll-green 0xFF00FF00
wait_for_windows 3
"$UMBRIEL" msg window-focus-left > /dev/null
"$UMBRIEL" msg window-focus-left > /dev/null
finish
start=$(green_box)

mkfifo "$UMBRIEL_RUNTIME_DIR/layer.fifo"
"$UMBRIEL_LAYER_CLIENT" HEADLESS-1 0 overlay-layer commit-on-stdin < "$UMBRIEL_RUNTIME_DIR/layer.fifo" \
> "$LAYER_LOG" 2>&1 &
exec {layer_fd}> "$UMBRIEL_RUNTIME_DIR/layer.fifo"
await_lines "$LAYER_LOG" waiting 1

# The OSD maps right after the focus request, before the scroll it starts is flushed.
"$UMBRIEL" msg window-focus-right > /dev/null
"$UMBRIEL" msg window-focus-right > /dev/null
printf '\n' >&"$layer_fd"
await_lines "$LAYER_LOG" ready 1
"$UMBRIEL" clock-advance 40
midway=$(green_box)
finish
landed=$(green_box)

if [[ $start == "$landed" ]]; then
echo "focusing the green column did not scroll the strip: green stayed at $landed"
exit 1
fi
if [[ $midway == "$landed" ]]; then
echo "mapping a layer surface landed the focus scroll at once: green was at $landed 40 ms in (started at $start)"
exit 1
fi
13 changes: 12 additions & 1 deletion tests/harness/clients/layer_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// LAYER_CONTROL enables stdin commands: frames LABEL COUNT, color LABEL AARRGGBB, child-color LABEL AARRGGBB,
// child-move LABEL X Y, and margins LABEL TOP RIGHT BOTTOM LEFT. Each prints done after its frame callbacks arrive.
// popup-resize LABEL WIDTH HEIGHT overlaps two reposition requests and waits for its own token before redrawing.
// `commit-on-stdin` prints waiting and holds the initial commit until a line arrives on stdin, so a check can map the
// surface right after another request, as a shell OSD does.

#include <wayland-client.h>

Expand Down Expand Up @@ -594,7 +596,7 @@ int main(int argc, char** argv) {
if (argc < 3) {
std::println(
"usage: layer-client <output> <exclusive-height-or-zero-background> [bottom-layer|overlay-layer] "
"[log-configures] "
"[log-configures] [commit-on-stdin] "
"[keyboard=none|on-demand|exclusive] [release-on-escape] [popup-on-click|popup-on-release] "
"[popup-color=<ARGB>]"
);
Expand All @@ -611,6 +613,7 @@ int main(int argc, char** argv) {
// A 200x200 bottom-layer square in the top-left corner, which the overview mirrors into every workspace preview.
bool bottom = false;
bool overlay = false;
bool commitOnStdin = false;
for (int index = 3; index < argc; ++index) {
const std::string option = argv[index];
if (option == "bottom-layer") {
Expand All @@ -625,6 +628,8 @@ int main(int argc, char** argv) {
state.keyboardInteractivity = ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE;
} else if (option == "release-on-escape") {
state.releaseOnEscape = true;
} else if (option == "commit-on-stdin") {
commitOnStdin = true;
} else if (option == "log-configures") {
state.logConfigures = true;
} else if (option == "popup-on-click") {
Expand Down Expand Up @@ -722,6 +727,12 @@ int main(int argc, char** argv) {
}
}
zwlr_layer_surface_v1_set_anchor(state.layerSurface, anchors);
if (commitOnStdin) {
std::println("waiting");
char byte = 0;
while (read(STDIN_FILENO, &byte, 1) == 1 && byte != '\n') {
}
}
wl_surface_commit(state.surface);

const bool control = std::getenv("LAYER_CONTROL") != nullptr;
Expand Down
Loading