Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qt: Fix Wayland support #699

Merged
merged 2 commits into from
Dec 28, 2024
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
1 change: 0 additions & 1 deletion src/panda_qt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ int main(int argc, char *argv[]) {
QApplication app(argc, argv);
MainWindow window(&app);

window.show();
return app.exec();
}
5 changes: 2 additions & 3 deletions src/panda_qt/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ MainWindow::MainWindow(QApplication* app, QWidget* parent) : QMainWindow(parent)
// Enable drop events for loading ROMs
setAcceptDrops(true);
resize(800, 240 * 4);
show();

// We pass a callback to the screen widget that will be triggered every time we resize the screen
screen = new ScreenWidget([this](u32 width, u32 height) { handleScreenResize(width, height); }, this);
setCentralWidget(screen);

screen->show();
appRunning = true;

// Set our menu bar up
menuBar = new QMenuBar(nullptr);

Expand Down Expand Up @@ -699,4 +698,4 @@ void MainWindow::setupControllerSensors(SDL_GameController* controller) {
if (haveAccelerometer) {
SDL_GameControllerSetSensorEnabled(controller, SDL_SENSOR_ACCEL, SDL_TRUE);
}
}
}
3 changes: 2 additions & 1 deletion src/panda_qt/screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ ScreenWidget::ScreenWidget(ResizeCallback resizeCallback, QWidget* parent) : QWi
setAttribute(Qt::WA_KeyCompression, false);
setFocusPolicy(Qt::StrongFocus);
setMouseTracking(true);
show();

if (!createGLContext()) {
Helpers::panic("Failed to create GL context for display");
Expand Down Expand Up @@ -84,7 +85,7 @@ bool ScreenWidget::createGLContext() {
}

qreal ScreenWidget::devicePixelRatioFromScreen() const {
const QScreen* screenForRatio = window()->windowHandle()->screen();
const QScreen* screenForRatio = windowHandle()->screen();
if (!screenForRatio) {
screenForRatio = QGuiApplication::primaryScreen();
}
Expand Down
Loading