mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-07 22:55:40 +12:00
Qt: Fix Wayland support
Qt will only create a Wayland surface when show() is called on the main window and on the ScreenWidget. Thus, call the function before creating the GL context. Doesn't cause regressions on XWayland, untested in other platforms. Fixes #586
This commit is contained in:
parent
3eb89847ad
commit
5f48028284
3 changed files with 4 additions and 3 deletions
src/panda_qt
|
@ -7,6 +7,5 @@ int main(int argc, char *argv[]) {
|
|||
QApplication app(argc, argv);
|
||||
MainWindow window(&app);
|
||||
|
||||
window.show();
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ 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);
|
||||
|
@ -699,4 +700,4 @@ void MainWindow::setupControllerSensors(SDL_GameController* controller) {
|
|||
if (haveAccelerometer) {
|
||||
SDL_GameControllerSetSensorEnabled(controller, SDL_SENSOR_ACCEL, SDL_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue