Repository: FreeCAD/FreeCAD
File: src/Gui/MainWindow.cpp (C++)

Code before:
    int x, y, w, h;
    if (iss >> x >> y >> w >> h) {
        pos = QPoint(x, y);
        size = QSize(w, h);
    }

    max = d->hGrp->GetBool("Maximized", max);
    showStatusBar = d->hGrp->GetBool("StatusBar", showStatusBar);
    std::string wstate = d->hGrp->GetASCII("MainWindowState");
    if (!wstate.empty()) {
        windowState = QByteArray::fromBase64(wstate.c_str());
    }

    resize(size);
    // TODO: Hotfix to be removed as soon as possible after 1.1.0 Release
#ifdef FC_OS_WIN64
    if (checkFirstRun()) {
        int topLeftXY = 10;
        this->move(topLeftXY, topLeftXY);
    }
    else {
        moveToDefaultPosition(rect, pos);
    }
#else
    // TODO: Hotfix to be removed as soon as possible after 1.1.0 Release
    if (getenv("WAYLAND_DISPLAY") && checkFirstRun()) {
        int topLeftXY = 10;
        this->move(topLeftXY, topLeftXY);
    }
    else {  // all Linux x11 and Mac
        moveToDefaultPosition(rect, pos);
    }
#endif

    Base::StateLocker guard(d->_restoring);

    d->restoreWindowState(windowState);
    std::clog << "Main window restored" << std::endl;

    max ? showMaximized() : show();

    // make menus and tooltips usable in fullscreen under Windows, see issue #7563
#if defined(Q_OS_WIN)
# if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
    if (QWindow* win = this->windowHandle()) {
        QWindowsWindowFunctions::setHasBorderInFullScreen(win, true);
    }
# else
    using namespace QNativeInterface::Private;
    if (auto* windowsWindow = dynamic_cast<QWindowsWindow*>(this->windowHandle())) {
        windowsWindow->setHasBorderInFullScreen(true);

Review comment (suggestion):
FreeCAD is already using `QGuiApplication::platformName() == QString::fromStdString("wayland")` for such a test.

Code after:
    std::string geometry = d->hGrp->GetASCII("Geometry");
    std::istringstream iss(geometry);
    int x, y, w, h;
    if (iss >> x >> y >> w >> h) {
        pos = QPoint(x, y);
        size = QSize(w, h);
    }

    max = d->hGrp->GetBool("Maximized", max);
    showStatusBar = d->hGrp->GetBool("StatusBar", showStatusBar);
    std::string wstate = d->hGrp->GetASCII("MainWindowState");
    if (!wstate.empty()) {
        windowState = QByteArray::fromBase64(wstate.c_str());
    }

    resize(size);
    // TODO: Hotfix to be removed as soon as possible after 1.1.0 Release
#ifdef FC_OS_WIN64
    if (checkFirstRun()) {
        const int topLeftXY = 10;
        this->move(topLeftXY, topLeftXY);
    }
    else {
        moveToDefaultPosition(rect, pos);
    }
#else
    // TODO: Hotfix to be removed as soon as possible after 1.1.0 Release
    if (QGuiApplication::platformName() == QString::fromStdString("wayland") && checkFirstRun()) {
        const int topLeftXY = 10;
        this->move(topLeftXY, topLeftXY);
    }
    else {  // all Linux x11 and Mac
        moveToDefaultPosition(rect, pos);
    }
#endif

    Base::StateLocker guard(d->_restoring);

    d->restoreWindowState(windowState);
    std::clog << "Main window restored" << std::endl;

    max ? showMaximized() : show();

    // make menus and tooltips usable in fullscreen under Windows, see issue #7563
#if defined(Q_OS_WIN)
# if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
    if (QWindow* win = this->windowHandle()) {
        QWindowsWindowFunctions::setHasBorderInFullScreen(win, true);
    }
# else
    using namespace QNativeInterface::Private;