Merge current main into PR #1067

This commit is contained in:
Kurt Himebauch committed 2026-10-22 12:13:50 -04:00
commit 96a8501343
11 files changed
+406 -151

No files matched your search

+16 -34
View File
@@ -1,58 +1,40 @@
name: Human authorship
name: Build validation
on:
pull_request_target:
branches: [main]
types: [opened, synchronize, reopened, edited, ready_for_review]
push:
branches: [main]
workflow_run:
workflows: [Build APK]
types: [completed]
workflow_dispatch:
inputs:
pr_number:
description: Pull request to validate; empty for main
required: false
permissions:
contents: read
actions: read
pull-requests: read
statuses: write
jobs:
authorship:
name: Validate human authorship
validate:
name: Build APK
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}
ref: ${{ github.workflow_sha }}
fetch-depth: 0
persist-credentials: false
- name: Check the proposed or merged history
id: validate
- name: Validate source and APK compilation
env:
GH_TOKEN: ${{ github.token }}
EVENT_NAME: ${{ github.event_name }}
PR_NUMBER: ${{ github.event.pull_request.number }}
BEFORE: ${{ github.event.before }}
AFTER: ${{ github.sha }}
PR_HEAD: ${{ github.event.pull_request.head.sha }}
run: |
set -euo pipefail
if [ "$EVENT_NAME" = pull_request_target ]; then
gh auth setup-git
git fetch --no-tags origin "refs/pull/$PR_NUMBER/head"
test "$(git rev-parse FETCH_HEAD)" = "$PR_HEAD"
base=$(git merge-base HEAD FETCH_HEAD)
python3 tools/release/check_authorship.py "$base..FETCH_HEAD" --event "$GITHUB_EVENT_PATH"
elif [ "$EVENT_NAME" = push ] && [ "$BEFORE" != 0000000000000000000000000000000000000000 ]; then
python3 tools/release/check_authorship.py "$BEFORE..$AFTER"
else
python3 tools/release/check_authorship.py HEAD
fi
- name: Publish the required result on the actual proposed commit
if: always()
env:
GH_TOKEN: ${{ github.token }}
TARGET_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
RESULT: ${{ steps.validate.outcome == 'success' && 'success' || 'failure' }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
gh api --method POST "repos/$GITHUB_REPOSITORY/statuses/$TARGET_SHA" \
-f context='Human authorship' -f state="$RESULT" -f target_url="$RUN_URL" \
-f description='Bot authors and bot co-author trailers are forbidden'
gh auth setup-git
python3 tools/release/validate_apk.py
+1 -1
View File
@@ -87,7 +87,7 @@ jobs:
build:
needs: xbox
name: Build APK
name: Compile and test APK
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }}
runs-on: ubuntu-24.04
timeout-minutes: 45
+33 -1
View File
@@ -2650,6 +2650,38 @@ __attribute__((visibility("hidden"))) static int triton_get_feature(DeckHidraw &
static constexpr uint32_t TRITON_HWID = 72;
static constexpr uint32_t TRITON_FW_TIMESTAMP = 0x6AC686B3;
// Steam compares the controller's firmware with TRITON_FW_TS in its bundled hardwareupdater.cfg (and blocks
// with a required update below MUST_UPDATE_TRITON_FW_TS), so the emulated pad reports at least the build
// Steam ships.
static uint32_t triton_fw_timestamp() {
static const uint32_t timestamp = [] {
std::vector<std::string> roots;
char exe[PATH_MAX];
ssize_t n = readlink("/proc/self/exe", exe, sizeof(exe) - 1);
if (n > 0) {
std::string path(exe, static_cast<size_t>(n));
size_t bin = path.rfind('/');
size_t root = bin == std::string::npos || bin == 0 ? std::string::npos : path.rfind('/', bin - 1);
if (bin != std::string::npos && bin > 0) roots.push_back(path.substr(0, bin));
if (root != std::string::npos) roots.push_back(path.substr(0, root));
}
if (const char *home = getenv("HOME")) roots.push_back(std::string(home) + "/.local/share/Steam");
uint32_t newest = TRITON_FW_TIMESTAMP;
for (const std::string &root : roots) {
std::ifstream cfg(root + "/bin/hardwareupdater/hardwareupdater.cfg");
std::string line;
while (std::getline(cfg, line)) {
if (line.rfind("TRITON_FW_TS:", 0) != 0) continue;
uint32_t shipped = static_cast<uint32_t>(strtoul(line.c_str() + 13, nullptr, 16));
if (shipped > newest) newest = shipped;
}
}
if (newest != TRITON_FW_TIMESTAMP) Logger::log("triton: reporting firmware %08x, the build Steam ships\n", newest);
return newest;
}();
return timestamp;
}
__attribute__((visibility("hidden"))) static int triton_pad_feature(DeckHidraw &triton, uint8_t *buf, size_t size, bool set) {
if (!buf || size < 2) {
errno = EINVAL;
@@ -2670,7 +2702,7 @@ __attribute__((visibility("hidden"))) static int triton_pad_feature(DeckHidraw &
switch (triton.pending_feature) {
case DECK_GET_ATTRIBUTES_VALUES: {
static const uint8_t kIds[] = {0x01, 0x02, 0x04, 0x09, 0x0a, 0x0b};
const uint32_t values[] = {static_cast<uint32_t>(TRITON_WIRED_PRODUCT), 0, TRITON_FW_TIMESTAMP, TRITON_HWID, 0, 4000};
const uint32_t values[] = {static_cast<uint32_t>(TRITON_WIRED_PRODUCT), 0, triton_fw_timestamp(), TRITON_HWID, 0, 4000};
reply[2] = sizeof(kIds) * 5;
for (size_t i = 0; i < sizeof(kIds); i++) {
reply[3 + i * 5] = kIds[i];
+6 -4
View File
@@ -22,9 +22,11 @@ through `kwin_wayland_wrapper`. KWin composites in software (QPainter) - the Adr
DRM device - so games and emulators from the menu go through `droiddeck-gpu`, and Steam goes back
to the app as a Steam session.
`build-kwin.sh` builds KWin 6.7.5's Wayland executable and library on a native ARM64 runner, using a disposable
Arch Linux ARM chroot with every build package signature-checked. The KDE source tarball is pinned
by SHA-256 (the same digest in Arch's KWin PKGBUILD); `patches/0001-respect-nested-desktop-scale.patch`
`kwin.env` pins the KWin version shared by the build and packaging jobs. `build-kwin.sh` builds that version's
Wayland executable and library on a native ARM64 runner, using a disposable
Arch Linux ARM chroot with every build package signature-checked. It matches the current KWin package
in Arch Linux ARM even when that repository trails KDE's latest release. The source tarball is pinned
by SHA-256 from KDE's official source inventory; `patches/0001-respect-nested-desktop-scale.patch`
lets Display Settings control the inner desktop scale independently of the outer window size.
It keeps layer sizes, pointer/touch coordinates and the cursor in the same physical pixels.
The behavior is enabled only with `DROIDDECK_NESTED_SCALE`, which the desktop script supplies.
@@ -32,7 +34,7 @@ The behavior is enabled only with `DROIDDECK_NESTED_SCALE`, which the desktop sc
The desktop workflow replaces the same-version `kwin_wayland` executable and `libkwin.so`; the rest
comes from the signature-checked Arch packages. `desktop-kde.kwin.txt` records the source, patch,
executable, library and build package hashes. Corresponding source is
https://download.kde.org/stable/plasma/6.7.5/kwin-6.7.5.tar.xz plus the patch in this repository.
https://download.kde.org/stable/plasma/6.8.0/kwin-6.8.0.tar.xz plus the patch in this repository.
The inventories use `.gzip` rather than `.gz`: Android's asset packer expands `.gz` and strips
its suffix. The shared local/CI runtime payload check verifies the exact APK names and bytes.
+8 -3
View File
@@ -3,8 +3,9 @@ set -euo pipefail
out=$(realpath -m "${1:?out dir}")
here=$(cd "$(dirname "$0")" && pwd)
[ "$(uname -m)" = aarch64 ] || { echo 'KWin needs a native aarch64 runner' >&2; exit 1; }
version=6.7.5
source_sha=6baa910b732d93c48c90f9c1cc685cc93d0b8de0cdf138c24192c045bc3a48e2
source "$here/kwin.env"
version=$DESKTOP_KWIN_VERSION
source_sha=4bfaf31e29a8f9fdf231dc3bbb9b09b0ce07cae9fee7a01cfc86425ece796258
mirror=https://fl.us.mirror.archlinuxarm.org/aarch64
builder=68B3537F39A313B3E574D06777193F152BDBE6A6
work=$(mktemp -d)
@@ -18,7 +19,11 @@ for repo in core extra alarm; do
done
touch "$work/runtime.txt"
python3 "$here/closure.py" "$work/db" "$work/runtime.txt" "$here/kwin-build-seeds.txt" > "$work/packages.txt"
grep -Eq '^extra/kwin-6\.7\.5-[0-9]+-aarch64\.pkg\.tar\.' "$work/packages.txt"
kwin_package=$(awk '$1 ~ /^extra\/kwin-.*-aarch64\.pkg\.tar\./ {print $1}' "$work/packages.txt")
case $kwin_package in
"extra/kwin-$version"-[0-9]*-aarch64.pkg.tar.*) ;;
*) echo "KWin package $kwin_package does not match source KWin $version" >&2; exit 1 ;;
esac
export work mirror builder here
download() {
local entry=$1 sum=$2 file=${1#*/}
+7 -1
View File
@@ -2,6 +2,7 @@
set -euo pipefail
out=${1:?out dir}
here=$(cd "$(dirname "$0")" && pwd)
source "$here/kwin.env"
mirror=${ALARM_MIRROR:-https://fl.us.mirror.archlinuxarm.org/aarch64}
case $mirror in https://*) ;; *) echo "ALARM_MIRROR must be https" >&2; exit 1 ;; esac
builder=68B3537F39A313B3E574D06777193F152BDBE6A6
@@ -36,8 +37,13 @@ done < "$work/pkglist.txt"
cp -a "$here/overlay/." "$work/root/"
if [ -n "${KDE_KWIN_OVERRIDE:-}" ]; then
kwin_package=$(awk '$1 ~ /^extra\/kwin-.*-aarch64\.pkg\.tar\./ {print $1}' "$work/pkglist.txt")
case $kwin_package in
"extra/kwin-$DESKTOP_KWIN_VERSION"-[0-9]*-aarch64.pkg.tar.*) ;;
*) echo "KWin package $kwin_package does not match the built KWin $DESKTOP_KWIN_VERSION" >&2; exit 1 ;;
esac
install -m 755 "$KDE_KWIN_OVERRIDE/kwin_wayland" "$work/root/usr/bin/kwin_wayland"
install -m 755 "$KDE_KWIN_OVERRIDE/libkwin.so.6.7.5" "$work/root/usr/lib/libkwin.so.6.7.5"
install -m 755 "$KDE_KWIN_OVERRIDE/libkwin.so.$DESKTOP_KWIN_VERSION" "$work/root/usr/lib/libkwin.so.$DESKTOP_KWIN_VERSION"
fi
if [ -d "$work/root/usr/share/locale" ]; then
+1
View File
@@ -0,0 +1 @@
DESKTOP_KWIN_VERSION=6.8.0
@@ -8,8 +8,8 @@ Third-party files in DroidDeck's KDE desktop package (tools/desktop-kde/overlay)
- steam.svg: Papirus icon theme (https://github.com/PapirusDevelopmentTeam/papirus-icon-theme),
GPL-3.0.
- kwin_wayland: KWin 6.7.5, GPL-2.0-or-later. Built with DroidDeck's nested desktop scale patch.
Corresponding source: https://download.kde.org/stable/plasma/6.7.5/kwin-6.7.5.tar.xz and
- kwin_wayland: KWin 6.8.0, GPL-2.0-or-later. Built with DroidDeck's nested desktop scale patch.
Corresponding source: https://download.kde.org/stable/plasma/6.8.0/kwin-6.8.0.tar.xz and
https://github.com/Droid-Deck/DroidDeck/tree/fix/kde-desktop-followups/tools/desktop-kde/patches
(the source and patch hashes are recorded in desktop-kde.kwin.txt beside the package).
@@ -1,78 +1,27 @@
--- a/src/backends/wayland/wayland_output.cpp
+++ b/src/backends/wayland/wayland_output.cpp
@@ -294,6 +294,11 @@
}
}
+qreal WaylandOutput::presentationScale() const
+{
+ return qEnvironmentVariableIsSet("DROIDDECK_NESTED_SCALE") ? m_pendingScale : scale();
+}
+
bool WaylandOutput::present(const QList<OutputLayer *> &layersToUpdate, const std::shared_ptr<OutputFrame> &frame)
{
auto cursorLayers = layersToUpdate | std::views::filter([](OutputLayer *layer) {
@@ -312,7 +317,7 @@
m_surface->attachBuffer(buffer);
m_mapped = true;
}
- m_viewport->setDestination(QSize(std::round(modeSize().width() / scale()), std::round(modeSize().height() / scale())));
+ m_viewport->setDestination(QSize(std::round(modeSize().width() / presentationScale()), std::round(modeSize().height() / presentationScale())));
m_surface->setScale(1);
// commit the subsurfaces before the main surface
for (OutputLayer *layer : layersToUpdate) {
@@ -375,9 +380,11 @@
next.enabled = props->enabled.value_or(m_state.enabled);
next.transform = props->transform.value_or(m_state.transform);
next.position = props->pos.value_or(m_state.position);
- // intentionally ignored, as it would get overwritten
- // with the fractional scale protocol anyways
- // next.scale = props->scale.value_or(m_state.scale);
+
+ if (qEnvironmentVariableIsSet("DROIDDECK_NESTED_SCALE")) {
+ next.scale = props->scale.value_or(m_state.scale);
+ next.scaleSetting = props->scaleSetting.value_or(m_state.scaleSetting);
+ }
next.desiredMode = props->desiredMode.value_or(m_state.desiredMode);
next.uuid = props->uuid.value_or(m_state.uuid);
next.replicationSource = props->replicationSource.value_or(m_state.replicationSource);
@@ -466,7 +473,9 @@
State next = m_state;
next.modes = {mode};
next.currentMode = mode;
- next.scale = m_pendingScale;
+ if (!qEnvironmentVariableIsSet("DROIDDECK_NESTED_SCALE")) {
+ next.scale = m_pendingScale;
+ }
setState(next);
Q_EMIT m_backend->outputsQueried();
--- a/src/backends/wayland/wayland_output.h
+++ b/src/backends/wayland/wayland_output.h
@@ -93,6 +93,8 @@
void init(const QSize &pixelSize, qreal scale, bool fullscreen);
+
+ qreal presentationScale() const;
bool isReady() const;
KWayland::Client::Surface *surface() const;
WaylandCursor *cursor() const;
diff --git a/src/backends/wayland/wayland_backend.cpp b/src/backends/wayland/wayland_backend.cpp
index f43f03d..211ef09 100644
--- a/src/backends/wayland/wayland_backend.cpp
+++ b/src/backends/wayland/wayland_backend.cpp
@@ -107,8 +107,9 @@
@@ -106,16 +106,8 @@ WaylandInputDevice::WaylandInputDevice(KWayland::Client::Pointer *pointer, Wayla
WaylandOutput *output = m_seat->backend()->findOutput(m_pointer->enteredSurface());
Q_ASSERT(output);
const auto subsurface = m_seat->backend()->findSubSurface(m_pointer->enteredSurface());
- const QPointF absolutePos = output->position() + relativeToSurface
- + (subsurface ? subsurface->position() : QPoint());
+ const QPointF absolutePos = output->position()
+ + (relativeToSurface + (subsurface ? subsurface->position() : QPoint()))
+ * output->presentationScale() / output->scale();
- // A position in the host window is in the coordinates the panel is driven in, while
- // the compositor works in the picture as the user sees it. On a rotated display those
- // are not the same, so the position has to be turned back.
- const QPointF inPanel = relativeToSurface + (subsurface ? subsurface->position() : QPoint());
- // Exactly the size the surface is given in WaylandOutput::present(), rounding and all -
- // turning a position needs the bounds it was expressed in, and being off by the
- // rounding here shifts the pointer by a little more the further it travels.
- const QSizeF panelSize = QSize(std::round(output->modeSize().width() / output->scale()),
- std::round(output->modeSize().height() / output->scale()));
- const QPointF absolutePos = output->position() + output->transform().inverted().map(inPanel, panelSize);
+ const QPointF hostPosition = relativeToSurface + (subsurface ? subsurface->position() : QPoint());
+ const QPointF absolutePos = output->mapToOutput(hostPosition);
Q_EMIT pointerMotionAbsolute(absolutePos, std::chrono::milliseconds(time), this);
});
connect(pointer, &Pointer::buttonStateChanged, this, [this](quint32 serial, quint32 time, quint32 button, Pointer::ButtonState nativeState) {
@@ -182,7 +183,11 @@
@@ -189,7 +181,11 @@ WaylandInputDevice::WaylandInputDevice(KWayland::Client::RelativePointer *relati
, m_relativePointer(relativePointer)
{
connect(relativePointer, &RelativePointer::relativeMotion, this, [this](const QSizeF &delta, const QSizeF &deltaNonAccelerated, quint64 timestamp) {
@@ -84,16 +33,17 @@
+ Q_EMIT pointerMotion(sizeToPoint(delta) * factor, sizeToPoint(deltaNonAccelerated) * factor, std::chrono::microseconds(timestamp), this);
});
}
@@ -199,13 +204,19 @@
@@ -206,13 +202,21 @@ WaylandInputDevice::WaylandInputDevice(KWayland::Client::Touch *touch, WaylandSe
connect(touch, &Touch::sequenceStarted, this, [this](TouchPoint *tp) {
auto o = m_seat->backend()->findOutput(tp->surface());
Q_ASSERT(o);
- const QPointF position = o->position() + tp->position();
+ const auto subsurface = m_seat->backend()->findSubSurface(tp->surface());
+ const QPointF position = o->position()
+ + (tp->position() + (subsurface ? subsurface->position() : QPoint()))
+ * o->presentationScale() / o->scale();
+ const QPointF hostPosition = tp->position() + (subsurface ? subsurface->position() : QPoint());
+ const QPointF position = qEnvironmentVariableIsSet("DROIDDECK_NESTED_SCALE")
+ ? o->mapToOutput(hostPosition)
+ : o->position() + tp->position();
Q_EMIT touchDown(tp->id(), position, std::chrono::milliseconds(tp->time()), this);
});
connect(touch, &Touch::pointAdded, this, [this](TouchPoint *tp) {
@@ -101,27 +51,46 @@
Q_ASSERT(o);
- const QPointF position = o->position() + tp->position();
+ const auto subsurface = m_seat->backend()->findSubSurface(tp->surface());
+ const QPointF position = o->position()
+ + (tp->position() + (subsurface ? subsurface->position() : QPoint()))
+ * o->presentationScale() / o->scale();
+ const QPointF hostPosition = tp->position() + (subsurface ? subsurface->position() : QPoint());
+ const QPointF position = qEnvironmentVariableIsSet("DROIDDECK_NESTED_SCALE")
+ ? o->mapToOutput(hostPosition)
+ : o->position() + tp->position();
Q_EMIT touchDown(tp->id(), position, std::chrono::milliseconds(tp->time()), this);
});
connect(touch, &Touch::pointRemoved, this, [this](TouchPoint *tp) {
@@ -214,7 +225,10 @@
@@ -221,7 +225,11 @@ WaylandInputDevice::WaylandInputDevice(KWayland::Client::Touch *touch, WaylandSe
connect(touch, &Touch::pointMoved, this, [this](TouchPoint *tp) {
auto o = m_seat->backend()->findOutput(tp->surface());
Q_ASSERT(o);
- const QPointF position = o->position() + tp->position();
+ const auto subsurface = m_seat->backend()->findSubSurface(tp->surface());
+ const QPointF position = o->position()
+ + (tp->position() + (subsurface ? subsurface->position() : QPoint()))
+ * o->presentationScale() / o->scale();
+ const QPointF hostPosition = tp->position() + (subsurface ? subsurface->position() : QPoint());
+ const QPointF position = qEnvironmentVariableIsSet("DROIDDECK_NESTED_SCALE")
+ ? o->mapToOutput(hostPosition)
+ : o->position() + tp->position();
Q_EMIT touchMotion(tp->id(), position, std::chrono::milliseconds(tp->time()), this);
});
}
diff --git a/src/backends/wayland/wayland_egl_backend.cpp b/src/backends/wayland/wayland_egl_backend.cpp
index 0c03222..c587db5 100644
--- a/src/backends/wayland/wayland_egl_backend.cpp
+++ b/src/backends/wayland/wayland_egl_backend.cpp
@@ -232,7 +232,9 @@ bool WaylandEglCursorLayer::endFrame(const Region &renderedDeviceRegion, const R
wl_buffer *buffer = m_backend->backend()->importBuffer(m_buffer->buffer());
Q_ASSERT(buffer);
- static_cast<WaylandOutput *>(m_output.get())->cursor()->update(buffer, m_buffer->buffer()->size() / m_output->scale(), (hotspot() / m_output->scale()).toPoint());
+ auto output = static_cast<WaylandOutput *>(m_output.get());
+ output->cursor()->update(buffer, m_buffer->buffer()->size() / output->presentationScale(),
+ (hotspot() / output->presentationScale()).toPoint());
EGLNativeFence releaseFence{m_backend->eglDisplayObject()};
m_swapchain->release(m_buffer, releaseFence.takeFileDescriptor());
diff --git a/src/backends/wayland/wayland_layer.cpp b/src/backends/wayland/wayland_layer.cpp
index 311be7f..f91a3fb 100644
--- a/src/backends/wayland/wayland_layer.cpp
+++ b/src/backends/wayland/wayland_layer.cpp
@@ -95,7 +95,7 @@
@@ -95,7 +95,7 @@ void WaylandLayer::commit(PresentationMode presentationMode)
// this is a bit annoying, we need a new Wayland protocol
// to do this properly with fractional scaling. Until we
// have that, it may cause blurriness in some cases!
@@ -130,29 +99,74 @@
if (m_viewport) {
m_viewport->setSource(sourceRect());
m_viewport->setDestination(logicalTarget.size());
--- a/src/backends/wayland/wayland_qpainter_backend.cpp
+++ b/src/backends/wayland/wayland_qpainter_backend.cpp
@@ -124,7 +124,9 @@
wl_buffer *buffer = static_cast<WaylandOutput *>(m_output.get())->backend()->importBuffer(m_back->buffer());
Q_ASSERT(buffer);
- static_cast<WaylandOutput *>(m_output.get())->cursor()->update(buffer, m_back->buffer()->size() / m_output->scale(), hotspot().toPoint());
+ auto output = static_cast<WaylandOutput *>(m_output.get());
+ output->cursor()->update(buffer, m_back->buffer()->size() / output->presentationScale(),
+ (hotspot() * output->scale() / output->presentationScale()).toPoint());
m_swapchain->release(m_back);
return true;
diff --git a/src/backends/wayland/wayland_output.cpp b/src/backends/wayland/wayland_output.cpp
index 1543058..a22d974 100644
--- a/src/backends/wayland/wayland_output.cpp
+++ b/src/backends/wayland/wayland_output.cpp
@@ -314,7 +314,7 @@ std::expected<void, OutputError> WaylandOutput::present(const QList<OutputLayer
m_surface->attachBuffer(buffer);
m_mapped = true;
}
- const Rect rect(QPoint(), QSize(std::round(modeSize().width() / scale()), std::round(modeSize().height() / scale())));
+ const Rect rect(QPoint(), QSize(std::round(modeSize().width() / presentationScale()), std::round(modeSize().height() / presentationScale())));
m_xdgShellSurface->setWindowGeometry(rect);
m_viewport->setDestination(rect.size());
m_surface->setScale(1);
@@ -379,9 +379,10 @@ void WaylandOutput::applyChanges(const OutputConfiguration &config)
next.enabled = props->enabled.value_or(m_state.enabled);
next.transform = props->transform.value_or(m_state.transform);
next.position = props->pos.value_or(m_state.position);
- // intentionally ignored, as it would get overwritten
- // with the fractional scale protocol anyways
- // next.scale = props->scale.value_or(m_state.scale);
+ if (qEnvironmentVariableIsSet("DROIDDECK_NESTED_SCALE")) {
+ next.scale = props->scale.value_or(m_state.scale);
+ next.scaleSetting = props->scaleSetting.value_or(m_state.scaleSetting);
+ }
next.desiredMode = props->desiredMode.value_or(m_state.desiredMode);
next.uuid = props->uuid.value_or(m_state.uuid);
next.replicationSource = props->replicationSource.value_or(m_state.replicationSource);
@@ -397,6 +398,19 @@ void WaylandOutput::applyChanges(const OutputConfiguration &config)
setState(next);
}
--- a/src/backends/wayland/wayland_egl_backend.cpp
+++ b/src/backends/wayland/wayland_egl_backend.cpp
@@ -202,7 +202,9 @@
wl_buffer *buffer = m_backend->backend()->importBuffer(m_buffer->buffer());
Q_ASSERT(buffer);
- static_cast<WaylandOutput *>(m_output.get())->cursor()->update(buffer, m_buffer->buffer()->size() / m_output->scale(), (hotspot() / m_output->scale()).toPoint());
+ auto output = static_cast<WaylandOutput *>(m_output.get());
+ output->cursor()->update(buffer, m_buffer->buffer()->size() / output->presentationScale(),
+ (hotspot() / output->presentationScale()).toPoint());
EGLNativeFence releaseFence{m_backend->eglDisplayObject()};
m_swapchain->release(m_buffer, releaseFence.takeFileDescriptor());
+qreal WaylandOutput::presentationScale() const
+{
+ return qEnvironmentVariableIsSet("DROIDDECK_NESTED_SCALE") ? m_pendingScale : scale();
+}
+
+QPointF WaylandOutput::mapToOutput(const QPointF &hostPosition) const
+{
+ const QPointF inPanel = hostPosition * presentationScale() / scale();
+ const QSizeF panelSize = QSize(std::round(modeSize().width() / scale()),
+ std::round(modeSize().height() / scale()));
+ return position() + transform().inverted().map(inPanel, panelSize);
+}
+
bool WaylandOutput::isReady() const
{
return m_ready;
@@ -472,7 +486,9 @@ void WaylandOutput::applyConfigure(const QSize &size, quint32 serial)
State next = m_state;
next.modes = {mode};
next.currentMode = mode;
- next.scale = m_pendingScale;
+ if (!qEnvironmentVariableIsSet("DROIDDECK_NESTED_SCALE")) {
+ next.scale = m_pendingScale;
+ }
setState(next);
Q_EMIT m_backend->outputsQueried();
diff --git a/src/backends/wayland/wayland_output.h b/src/backends/wayland/wayland_output.h
index dab061b..c019577 100644
--- a/src/backends/wayland/wayland_output.h
+++ b/src/backends/wayland/wayland_output.h
@@ -92,6 +92,8 @@ public:
void init(const QSize &pixelSize, qreal scale, bool fullscreen);
+ qreal presentationScale() const;
+ QPointF mapToOutput(const QPointF &hostPosition) const;
bool isReady() const;
KWayland::Client::Surface *surface() const;
WaylandCursor *cursor() const;
+106
View File
@@ -0,0 +1,106 @@
#!/usr/bin/env python3
"""Publish the APK result only after trusted source and metadata validation."""
import json
import os
import subprocess
from urllib.parse import urlencode
from check_authorship import check_revision, event_violations
def api(path, *args):
return json.loads(subprocess.check_output(["gh", "api", path, *args], text=True))
def compilation_state(run, jobs):
for job in jobs:
if job["name"] in ("Compile and test APK", "Build APK"):
if job["status"] != "completed":
return "pending"
return "success" if job["conclusion"] == "success" else "failure"
return "failure" if run["status"] == "completed" else "pending"
def fetch_source(ref, sha):
subprocess.run(["git", "fetch", "--no-tags", "origin", ref], check=True)
fetched = subprocess.check_output(["git", "rev-parse", "FETCH_HEAD"], text=True).strip()
if fetched != sha:
raise RuntimeError("Pull request changed while validating")
def documentation_only(sha):
base = subprocess.check_output(["git", "merge-base", "origin/main", sha], text=True).strip()
paths = subprocess.check_output(["git", "diff", "--no-renames", "--name-only", "-z", base, sha]).split(b"\0")
return all(path.endswith(b".md") or path in (b"LICENSE", b".gitignore") for path in paths if path)
def main():
with open(os.environ["GITHUB_EVENT_PATH"], encoding="utf-8") as source:
event = json.load(source)
repo = os.environ["GITHUB_REPOSITORY"]
event_name = os.environ["GITHUB_EVENT_NAME"]
pr_number = event.get("number") if event_name == "pull_request_target" else None
if event_name == "workflow_dispatch":
pr_number = int(event.get("inputs", {}).get("pr_number") or 0)
run = event.get("workflow_run", {})
expected = event.get("pull_request", {}).get("head", {}).get("sha")
if event_name == "workflow_run":
expected = run["head_sha"]
if run["event"] == "pull_request":
prs = api(f"repos/{repo}/commits/{expected}/pulls")
pr_number = next((pr["number"] for pr in prs
if pr["state"] == "open" and pr["head"]["sha"] == expected), None)
if pr_number is None:
print("Ignoring a superseded or closed pull request build")
return
elif run["head_branch"] != event["repository"]["default_branch"]:
return
if pr_number:
pr = api(f"repos/{repo}/pulls/{pr_number}")
sha = pr["head"]["sha"]
if pr["state"] != "open" or (expected and sha != expected):
print("Ignoring a superseded or closed pull request event")
return
ref = f"refs/pull/{pr_number}/head"
source_event = "pull_request"
else:
pr = None
sha = expected or event.get("after") or os.environ["GITHUB_SHA"]
ref = sha
source_event = "push"
state = "failure"
description = "APK source validation failed"
target = f"https://github.com/{repo}/actions/runs/{os.environ['GITHUB_RUN_ID']}"
try:
fetch_source(ref, sha)
commits, errors = check_revision(sha)
if pr:
errors.extend(event_violations({"pull_request": pr}))
if errors:
raise RuntimeError("\n".join(errors))
print(f"Source and metadata validated for {len(commits)} commits")
if pr and documentation_only(sha):
state = "success"
description = "Source validated; no APK source changes"
return
query = urlencode({"head_sha": sha, "event": source_event, "per_page": 20})
runs = api(f"repos/{repo}/actions/workflows/build.yml/runs?{query}")["workflow_runs"]
runs = [item for item in runs if item["head_sha"] == sha]
if runs:
latest = max(runs, key=lambda item: item["id"])
jobs = api(f"repos/{repo}/actions/runs/{latest['id']}/jobs?per_page=100")["jobs"]
state = compilation_state(latest, jobs)
target = latest["html_url"]
else:
state = "pending"
description = {"pending": "Source validated; awaiting APK compilation",
"success": "Source validation and APK compilation passed",
"failure": "APK compilation failed"}[state]
finally:
api(f"repos/{repo}/statuses/{sha}", "--method", "POST",
"-f", "context=Build APK", "-f", f"state={state}",
"-f", f"description={description}", "-f", f"target_url={target}")
if __name__ == "__main__":
main()
+107
View File
@@ -0,0 +1,107 @@
import contextlib
import json
import os
from pathlib import Path
import subprocess
import sys
import tempfile
import unittest
from unittest.mock import patch
RELEASE = Path(__file__).resolve().parents[1] / "release"
sys.path.insert(0, str(RELEASE))
import validate_apk
class ValidateApkTest(unittest.TestCase):
def setUp(self):
self.temp = tempfile.TemporaryDirectory()
self.addCleanup(self.temp.cleanup)
self.root = Path(self.temp.name)
subprocess.run(["git", "init", "-q", self.root], check=True)
self.git("config", "user.name", "Human Developer")
self.git("config", "user.email", "human@example.org")
self.git("commit", "--allow-empty", "-qm", "Baseline")
self.git("update-ref", "refs/remotes/origin/main", "HEAD")
self.statuses = []
def git(self, *args):
return subprocess.check_output(["git", "-C", self.root, *args], text=True).strip()
def validate(self, message="Source change", body="", result="success", stale=False, completed=False, filename="source.kt"):
(self.root / filename).write_text(message)
self.git("add", filename)
self.git("commit", "--allow-empty", "-qm", message)
sha = self.git("rev-parse", "HEAD")
pr = {"number": 1, "state": "open", "head": {"sha": sha}, "user": {"login": "human", "type": "User"},
"title": "Source change", "body": body}
event = {"number": 1, "pull_request": {"head": {"sha": "stale" if stale else sha}}}
if completed:
event = {"workflow_run": {"event": "pull_request", "head_sha": "stale" if stale else sha}}
path = self.root / "event.json"
path.write_text(json.dumps(event))
def api(path, *args):
if "/statuses/" in path:
self.statuses.append(dict(value.split("=", 1) for value in args if "=" in value))
return {}
if path.endswith("/pulls/1"):
return pr
if "/commits/" in path and path.endswith("/pulls"):
return [pr]
if "workflows/build.yml/runs?" in path:
return {"workflow_runs": [{"id": 7, "head_sha": sha, "status": "completed", "html_url": "https://example.org/build"}]}
if path.endswith("/jobs?per_page=100"):
return {"jobs": [{"name": "Compile and test APK", "status": "in_progress" if result == "pending" else "completed", "conclusion": result}]}
raise AssertionError(path)
env = {"GITHUB_EVENT_PATH": str(path), "GITHUB_REPOSITORY": "owner/repo",
"GITHUB_EVENT_NAME": "workflow_run" if completed else "pull_request_target", "GITHUB_RUN_ID": "8"}
with contextlib.chdir(self.root), patch.dict(os.environ, env), patch.object(validate_apk, "api", side_effect=api), patch.object(validate_apk, "fetch_source"):
validate_apk.main()
def test_success_requires_compilation_and_clean_authorship(self):
self.validate()
self.assertEqual(self.statuses[-1]["state"], "success")
def test_successful_build_cannot_hide_bot_commit(self):
with self.assertRaises(RuntimeError):
self.validate(message="Change\n\nCo-authored-by: OpenAI Codex <codex@openai.com>")
self.assertEqual(self.statuses[-1]["state"], "failure")
def test_successful_build_cannot_hide_squash_metadata(self):
with self.assertRaises(RuntimeError):
self.validate(body="Co-authored-by: Claude <claude@example.org>")
self.assertEqual(self.statuses[-1]["state"], "failure")
def test_pending_or_failed_compilation_never_passes(self):
for result in ("pending", "failure"):
self.validate(result=result)
self.assertEqual(self.statuses[-1]["state"], result)
def test_superseded_event_cannot_replace_current_status(self):
self.validate(stale=True)
self.assertEqual(self.statuses, [])
def test_completed_build_revalidates_current_squash_metadata(self):
with self.assertRaises(RuntimeError):
self.validate(body="Co-authored-by: Claude <claude@example.org>", completed=True)
self.assertEqual(self.statuses[-1]["state"], "failure")
def test_superseded_build_cannot_replace_current_status(self):
self.validate(stale=True, completed=True)
self.assertEqual(self.statuses, [])
def test_documentation_passes_without_waiting_for_a_skipped_build(self):
self.validate(filename="README.md", result="pending")
self.assertEqual(self.statuses[-1]["state"], "success")
def test_renaming_code_to_documentation_still_requires_compilation(self):
(self.root / "source.kt").write_text("source")
self.git("add", "source.kt")
self.git("commit", "-qm", "Add source")
self.git("update-ref", "refs/remotes/origin/main", "HEAD")
self.git("mv", "source.kt", "README.md")
self.git("commit", "-qm", "Rename source")
with contextlib.chdir(self.root):
self.assertFalse(validate_apk.documentation_only(self.git("rev-parse", "HEAD")))