Skip to content

Commit 410aa0e

Browse files
committed
Fix touch coordinate misalignment on RPi 7 inch screen
The video widget was using setFullScreen which maintained aspect ratio despite IgnoreAspectRatio being set. This caused the AA video window to only occupy 75% of the physical screen width while touch coordinates were scaled to the full screen dimensions. Solution: Explicitly set video widget geometry to match the physical screen dimensions using QScreen geometry instead of relying on setFullScreen. This ensures the video output fills the entire screen and touch coordinates map correctly to the displayed content. Impact: Touch input now correctly maps to displayed AA buttons and controls. Video fills entire 800x480 RPi 7 inch screen. Eliminates the 25% horizontal offset in touch coordinates.
1 parent bf7f010 commit 410aa0e

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

src/autoapp/Projection/QtVideoOutput.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
*/
1818

1919
#include <QApplication>
20+
#include <QGuiApplication>
21+
#include <QScreen>
2022
#include <mutex>
2123
#include <f1x/openauto/autoapp/Projection/QtVideoOutput.hpp>
2224
#include <f1x/openauto/Common/Log.hpp>
@@ -103,11 +105,25 @@ void QtVideoOutput::onStartPlayback()
103105
videoWidget_->setAttribute(Qt::WA_OpaquePaintEvent, true);
104106
videoWidget_->setAttribute(Qt::WA_NoSystemBackground, true);
105107
videoWidget_->setAspectRatioMode(Qt::IgnoreAspectRatio);
106-
videoWidget_->setFocus();
107108
videoWidget_->setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
109+
110+
// Get the physical screen geometry and set widget to exactly match it
111+
QScreen *screen = QGuiApplication::primaryScreen();
112+
if (screen != nullptr) {
113+
QRect screenGeometry = screen->geometry();
114+
videoWidget_->setGeometry(screenGeometry);
115+
OPENAUTO_LOG(info) << "[QtVideoOutput] Set video widget geometry to: "
116+
<< screenGeometry.width() << "x" << screenGeometry.height()
117+
<< " at (" << screenGeometry.x() << "," << screenGeometry.y() << ")";
118+
} else {
119+
// Fallback to fullscreen if screen detection fails
120+
videoWidget_->setFullScreen(true);
121+
OPENAUTO_LOG(warning) << "[QtVideoOutput] Could not detect screen, using setFullScreen()";
122+
}
123+
108124
videoWidget_->raise();
109-
videoWidget_->setFullScreen(true);
110125
videoWidget_->show();
126+
videoWidget_->setFocus();
111127
videoWidget_->activateWindow();
112128

113129
// Connect state change signals to track when player is ready

0 commit comments

Comments
 (0)