Skip to content

Commit

Permalink
Don't hook QImage constructor outside of xochitl
Browse files Browse the repository at this point in the history
This would replace the FB of apps using QT twice, causing artefacts on
the display.
Also adds regression integration tests.

Closes #44
  • Loading branch information
timower committed May 25, 2024
1 parent f2e8823 commit fd1e6bd
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 11 deletions.
4 changes: 2 additions & 2 deletions libs/rm2fb/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
#include <cstring>
#include <unistd.h>

namespace {

bool inXochitl = false;

namespace {

const unistdpp::Result<ControlSocket>&
getControlSocket() {
static auto socket = []() -> unistdpp::Result<ControlSocket> {
Expand Down
8 changes: 6 additions & 2 deletions libs/rm2fb/ImageHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#include <dlfcn.h>
#include <iostream>

// TODO: clean
extern bool inXochitl;

extern "C" {

void
Expand All @@ -15,8 +18,9 @@ _ZN6QImageC1EiiNS_6FormatE(void* that, int x, int y, int f) {
void*, uint8_t*, int32_t, int32_t, int32_t, int, void (*)(void*), void*))
dlsym(RTLD_NEXT, "_ZN6QImageC1EPhiiiNS_6FormatEPFvPvES2_");

if (const auto& fb = SharedFB::getInstance();
x == fb_width && y == fb_height && first_alloc && fb.has_value()) {
if (const auto& fb = SharedFB::getInstance(); inXochitl && x == fb_width &&
y == fb_height && first_alloc &&
fb.has_value()) {
std::cerr << "REPLACING THE IMAGE with shared memory\n";
first_alloc = false;

Expand Down
2 changes: 2 additions & 0 deletions libs/rm2fb/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

using namespace unistdpp;

bool inXochitl = true;

namespace {
constexpr auto tcp_port = 8888;

Expand Down
3 changes: 3 additions & 0 deletions test/integration/assets/calculator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions test/integration/assets/calculator_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions test/integration/assets/startup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 25 additions & 5 deletions test/integration/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ tap_at() {
"$TEST_BINARY" 127.0.0.1 8888 touch "$1" "$2"
}

press_power() {
"$TEST_BINARY" 127.0.0.1 8888 power
}

image=$(docker run --name rm-docker --rm -d -p 2222:22 -p 8888:8888 "$DOCKER_IMAGE")
trap cleanup EXIT

Expand All @@ -61,7 +65,7 @@ scp -P 2222 "$IPKS_PATH"/*.ipk root@localhost:
do_ssh systemctl restart systemd-timesyncd
do_ssh opkg update

do_ssh opkg install ./*.ipk || true # TODO: xochitl doesn't configure for 3.5+
do_ssh opkg install ./*.ipk calculator || true # TODO: xochitl doesn't configure for 3.5+

# Start rocket, which should trigger the rm2fb socket and start the service.
do_ssh systemctl start rocket
Expand All @@ -71,25 +75,41 @@ sleep 2
check_screenshot "startup.png"

# tilem
tap_at 538 1050
tap_at 666 1050
sleep 2
check_screenshot "tilem.png"
tap_at 840 962
sleep 2
check_screenshot "startup.png"

# Yaft
tap_at 860 1042
tap_at 986 1042
sleep 3
check_screenshot "yaft.png"
tap_at 76 1832
sleep 1
tap_at 324, 1704
tap_at 324 1704
sleep 2
check_screenshot "startup.png"

# Calculator
tap_at 484 1054
sleep 3
check_screenshot "calculator.png"
tap_at 826 1440
sleep 1
check_screenshot "calculator_3.png"

press_power
sleep 1
tap_at 702 718 # Stop sleeping
sleep 1
tap_at 824 1124 # Kill calculator
sleep 1
check_screenshot "startup.png"

# Xochitl
tap_at 710 1086
tap_at 832 1086
sleep 60

check_screenshot \
Expand Down

0 comments on commit fd1e6bd

Please sign in to comment.