History

Working on fullscreen targeting

Brad Davis committed 11 years ago

Commit 2bb7a201 parent de446fe2 files · +13 −28Browse files

Showing the changes to interface/src/Application.cpp (1 of 2 files). Show all

Unified · Split

interface/src/Application.cpp+12−28
@@ -4917,42 +4917,26 @@ mat4 Application::getHMDSensorPose() const { · 4916 unmodified lines
4917 return mat4();4917 return mat4();
4918}4918}
4919 4919
4920static QRect savedGeometry;
4921static QScreen* originalScreen = nullptr;
4922
4923void Application::setFullscreen(const QScreen* target) {4920void Application::setFullscreen(const QScreen* target) {
4924 // Work around Qt bug that prevents floating menus being shown when in fullscreen mode.
4925 // https://bugreports.qt.io/browse/QTBUG-41883
4926 // Known issue: Top-level menu items don't highlight when cursor hovers. This is probably a side-effect of the work-around.
4927 // TODO: Remove this work-around once the bug has been fixed and restore the following lines.
4928 //_window->setWindowState(fullscreen ? (_window->windowState() | Qt::WindowFullScreen) :
4929 // (_window->windowState() & ~Qt::WindowFullScreen));
4930 if (!_window->isFullScreen()) {4921 if (!_window->isFullScreen()) {
4931 savedGeometry = _window->geometry();4922 _savedGeometry = _window->geometry();
4932 originalScreen = _window->windowHandle()->screen();
4933 qDebug() << savedGeometry;
4934 }4923 }
4935 _window->hide();4924#ifdef Q_OS_MAC
4936 _window->setGeometry(target->availableGeometry());4925 _window->setGeometry(target->availableGeometry());
4937// _window->windowHandle()->setScreen((QScreen*)target);4926#endif
4927 _window->windowHandle()->setScreen((QScreen*)target);
4938 _window->showFullScreen();4928 _window->showFullScreen();
4939 if (!_aboutToQuit) {
4940 _window->show();
4941 }
4942}4929}
4943 4930
4944void Application::unsetFullscreen() {4931void Application::unsetFullscreen() {
4945 _window->hide();4932 _window->showNormal();
4946// _window->windowHandle()->setScreen(originalScreen);4933#ifdef Q_OS_MAC
4947// _window->setGeometry(savedGeometry);4934 QTimer* timer = new QTimer();
4948 _window->setWindowState(_window->windowState() & ~Qt::WindowFullScreen);4935 timer->singleShot(1000, [=] {
4949 _window->show();
4950
4951 QTimer* geometryTimer = new QTimer();
4952 // FIXME do better and moving from screen to screen on unset of fullscreen
4953 geometryTimer->singleShot(2000, [=]{
4954 qDebug() << savedGeometry;
4955 _window->setGeometry(savedGeometry);4936 _window->setGeometry(savedGeometry);
4956 geometryTimer->deleteLater();4937 timer->deleteLater();
4957 });4938 });
4939#else
4940 _window->setGeometry(_savedGeometry);
4941#endif
4958}4942}