void MainWindow::showEvent(QShowEvent *) { // some window managers get pissed (xfwm4 breaks, metacity complains) if fixed window size is set too early. if (!fullscreen_) doSetWindowSize(winSize_); w_->showEvent(this); }
void MainWindow::doShowFullScreen() { const int screen = QApplication::desktop()->screenNumber(this); w_->setFullMode(true); doSetWindowSize(QSize(-1, -1)); // If the window is outside the screen it will be moved to the primary screen by Qt. { const QRect &rect = QApplication::desktop()->screenGeometry(screen); QPoint p(pos()); if (p.x() > rect.right()) p.setX(rect.right()); else if (p.x() < rect.left()) p.setX(rect.left()); if (p.y() > rect.bottom()) p.setY(rect.bottom()); else if (p.y() < rect.top()) p.setY(rect.top()); if (p != pos()) move(p); } showFullScreen(); correctFullScreenGeometry(); #ifdef Q_WS_MAC // work around annoying random non-updating OpenGL on Mac OS X after full screen. centralWidget()->hide(); centralWidget()->show(); #endif w_->parentExclusiveEvent(hasFocus()); }
void doSetWindowFullscreen(bool fullscreen) { Window::Ptr window = getCurrentWindow(); if (window) { bool isAlreadyFullscreen = windowNonFullscreenBounds.find(window) != windowNonFullscreenBounds.end(); if (fullscreen && !isAlreadyFullscreen) { windowNonFullscreenBounds.insert(std::make_pair(window, Rectangle(window->getPosition(), window->getSize()))); glutFullScreen(); } else if (!fullscreen && isAlreadyFullscreen) { const Rectangle& bounds = windowNonFullscreenBounds.find(window)->second; doSetWindowSize(bounds.size); doSetWindowPosition(bounds.upperLeftCorner); windowNonFullscreenBounds.erase(window); } } }
void MainWindow::toggleFullScreen() { if (fullscreen_) { fullscreen_ = false; w_->parentExclusiveEvent(false); w_->setFullMode(false); showNormal(); if (isVisible()) doSetWindowSize(winSize_); activateWindow(); } else { fullscreen_ = true; if (isVisible()) doShowFullScreen(); } }
void MainWindow::setWindowSize(const QSize &sz) { winSize_ = sz; if (!fullscreen_ && isVisible()) doSetWindowSize(sz); }