Skip to content

Commit

Permalink
Merge pull request #699 from DaniElectra/wayland
Browse files Browse the repository at this point in the history
Qt: Fix Wayland support
  • Loading branch information
wheremyfoodat authored Dec 28, 2024
2 parents 3eb8984 + 8604a98 commit 4ea15c9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
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

0 comments on commit 4ea15c9

Please sign in to comment.