mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 14:18:24 +02:00
Attempting to fix offscreen UI event handling
This commit is contained in:
parent
ce9a6298f0
commit
7edf138843
8 changed files with 75 additions and 22 deletions
|
@ -4919,3 +4919,43 @@ mat4 Application::getHMDSensorPose() const {
|
||||||
}
|
}
|
||||||
return mat4();
|
return mat4();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QRect savedGeometry;
|
||||||
|
static QScreen* originalScreen = nullptr;
|
||||||
|
|
||||||
|
void Application::setFullscreen(const QScreen* target) {
|
||||||
|
// Work around Qt bug that prevents floating menus being shown when in fullscreen mode.
|
||||||
|
// https://bugreports.qt.io/browse/QTBUG-41883
|
||||||
|
// Known issue: Top-level menu items don't highlight when cursor hovers. This is probably a side-effect of the work-around.
|
||||||
|
// TODO: Remove this work-around once the bug has been fixed and restore the following lines.
|
||||||
|
//_window->setWindowState(fullscreen ? (_window->windowState() | Qt::WindowFullScreen) :
|
||||||
|
// (_window->windowState() & ~Qt::WindowFullScreen));
|
||||||
|
if (!_window->isFullScreen()) {
|
||||||
|
savedGeometry = _window->geometry();
|
||||||
|
originalScreen = _window->windowHandle()->screen();
|
||||||
|
qDebug() << savedGeometry;
|
||||||
|
}
|
||||||
|
_window->hide();
|
||||||
|
_window->setGeometry(target->availableGeometry());
|
||||||
|
// _window->windowHandle()->setScreen((QScreen*)target);
|
||||||
|
_window->showFullScreen();
|
||||||
|
if (!_aboutToQuit) {
|
||||||
|
_window->show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Application::unsetFullscreen() {
|
||||||
|
_window->hide();
|
||||||
|
// _window->windowHandle()->setScreen(originalScreen);
|
||||||
|
// _window->setGeometry(savedGeometry);
|
||||||
|
_window->setWindowState(_window->windowState() & ~Qt::WindowFullScreen);
|
||||||
|
_window->show();
|
||||||
|
|
||||||
|
QTimer* geometryTimer = new QTimer();
|
||||||
|
// FIXME do better and moving from screen to screen on unset of fullscreen
|
||||||
|
geometryTimer->singleShot(2000, [=]{
|
||||||
|
qDebug() << savedGeometry;
|
||||||
|
_window->setGeometry(savedGeometry);
|
||||||
|
geometryTimer->deleteLater();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -287,6 +287,8 @@ public:
|
||||||
virtual bool isOptionChecked(const QString& name);
|
virtual bool isOptionChecked(const QString& name);
|
||||||
virtual void setIsOptionChecked(const QString& path, bool checked);
|
virtual void setIsOptionChecked(const QString& path, bool checked);
|
||||||
virtual GlWindow* getVisibleWindow();
|
virtual GlWindow* getVisibleWindow();
|
||||||
|
virtual void setFullscreen(const QScreen* target) override;
|
||||||
|
virtual void unsetFullscreen() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DisplayPlugin * getActiveDisplayPlugin();
|
DisplayPlugin * getActiveDisplayPlugin();
|
||||||
|
|
|
@ -53,8 +53,11 @@ const DisplayPluginList& getDisplayPlugins() {
|
||||||
|
|
||||||
DisplayPlugin* PLUGIN_POOL[] = {
|
DisplayPlugin* PLUGIN_POOL[] = {
|
||||||
new Basic2DWindowOpenGLDisplayPlugin(),
|
new Basic2DWindowOpenGLDisplayPlugin(),
|
||||||
|
#ifdef DEBUG
|
||||||
new NullDisplayPlugin(),
|
new NullDisplayPlugin(),
|
||||||
new SideBySideStereoDisplayPlugin(),
|
#endif
|
||||||
|
// FIXME fix stereo display plugins
|
||||||
|
// new SideBySideStereoDisplayPlugin(),
|
||||||
// new InterleavedStereoDisplayPlugin(),
|
// new InterleavedStereoDisplayPlugin(),
|
||||||
#if (OVR_MAJOR_VERSION == 5)
|
#if (OVR_MAJOR_VERSION == 5)
|
||||||
new Oculus_0_5_DisplayPlugin(),
|
new Oculus_0_5_DisplayPlugin(),
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
//
|
//
|
||||||
// Created by Bradley Austin Davis on 2015/05/29
|
// Created by Bradley Austin Davis on 2015/05/29
|
||||||
// Copyright 2015 High Fidelity, Inc.
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
@ -8,7 +9,6 @@
|
||||||
#include "MainWindowOpenGLDisplayPlugin.h"
|
#include "MainWindowOpenGLDisplayPlugin.h"
|
||||||
|
|
||||||
#include <QOpenGLContext>
|
#include <QOpenGLContext>
|
||||||
#include <QWidget>
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
|
||||||
#include <GlWindow.h>
|
#include <GlWindow.h>
|
||||||
|
|
|
@ -9,8 +9,6 @@
|
||||||
|
|
||||||
#include "WindowOpenGLDisplayPlugin.h"
|
#include "WindowOpenGLDisplayPlugin.h"
|
||||||
|
|
||||||
class QGLWidget;
|
|
||||||
|
|
||||||
class MainWindowOpenGLDisplayPlugin : public WindowOpenGLDisplayPlugin {
|
class MainWindowOpenGLDisplayPlugin : public WindowOpenGLDisplayPlugin {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -18,6 +18,9 @@
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QResizeEvent>
|
#include <QResizeEvent>
|
||||||
#include <QOpenGLContext>
|
#include <QOpenGLContext>
|
||||||
|
#include <QGuiApplication>
|
||||||
|
#include <QScreen>
|
||||||
|
|
||||||
|
|
||||||
#include <OVR_CAPI_GL.h>
|
#include <OVR_CAPI_GL.h>
|
||||||
|
|
||||||
|
@ -58,21 +61,24 @@ void Oculus_0_5_DisplayPlugin::activate(PluginContainer * container) {
|
||||||
}
|
}
|
||||||
|
|
||||||
OculusBaseDisplayPlugin::activate(container);
|
OculusBaseDisplayPlugin::activate(container);
|
||||||
|
QScreen* target{nullptr};
|
||||||
|
QPoint targetPosition{ _hmd->WindowsPos.x, _hmd->WindowsPos.y };
|
||||||
|
foreach(auto screen, qApp->screens()) {
|
||||||
|
QRect screenPosition = screen->geometry();
|
||||||
|
QPoint position = screenPosition.topLeft();
|
||||||
|
if (position == targetPosition) {
|
||||||
|
target = screen;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (target) {
|
||||||
|
container->setFullscreen(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
_window->installEventFilter(this);
|
||||||
_window->makeCurrent();
|
_window->makeCurrent();
|
||||||
_hmdWindow = new GlWindow(QOpenGLContext::currentContext());
|
|
||||||
|
|
||||||
QSurfaceFormat format;
|
|
||||||
initSurfaceFormat(format);
|
|
||||||
_hmdWindow->setFlags(Qt::FramelessWindowHint);
|
|
||||||
_hmdWindow->setFormat(format);
|
|
||||||
_hmdWindow->create();
|
|
||||||
_hmdWindow->setGeometry(_hmd->WindowsPos.x, _hmd->WindowsPos.y, _hmd->Resolution.w, _hmd->Resolution.h);
|
|
||||||
//_hmdWindow->setGeometry(0, -1080, _hmd->Resolution.w, _hmd->Resolution.h);
|
|
||||||
_hmdWindow->show();
|
|
||||||
_hmdWindow->installEventFilter(this);
|
|
||||||
bool makeCurrentResult = _hmdWindow->makeCurrent();
|
|
||||||
qDebug() << makeCurrentResult;
|
|
||||||
ovrGLConfig config; memset(&config, 0, sizeof(ovrRenderAPIConfig));
|
ovrGLConfig config; memset(&config, 0, sizeof(ovrRenderAPIConfig));
|
||||||
auto& header = config.Config.Header;
|
auto& header = config.Config.Header;
|
||||||
header.API = ovrRenderAPI_OpenGL;
|
header.API = ovrRenderAPI_OpenGL;
|
||||||
|
@ -100,11 +106,12 @@ void Oculus_0_5_DisplayPlugin::activate(PluginContainer * container) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Oculus_0_5_DisplayPlugin::deactivate(PluginContainer* container) {
|
void Oculus_0_5_DisplayPlugin::deactivate(PluginContainer* container) {
|
||||||
_hmdWindow->deleteLater();
|
_window->removeEventFilter(this);
|
||||||
_hmdWindow = nullptr;
|
|
||||||
|
|
||||||
OculusBaseDisplayPlugin::deactivate(container);
|
OculusBaseDisplayPlugin::deactivate(container);
|
||||||
|
|
||||||
|
container->unsetFullscreen();
|
||||||
|
|
||||||
ovrHmd_Destroy(_hmd);
|
ovrHmd_Destroy(_hmd);
|
||||||
_hmd = nullptr;
|
_hmd = nullptr;
|
||||||
ovr_Shutdown();
|
ovr_Shutdown();
|
||||||
|
@ -116,7 +123,7 @@ void Oculus_0_5_DisplayPlugin::preRender() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Oculus_0_5_DisplayPlugin::preDisplay() {
|
void Oculus_0_5_DisplayPlugin::preDisplay() {
|
||||||
_hmdWindow->makeCurrent();
|
_window->makeCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Oculus_0_5_DisplayPlugin::display(GLuint finalTexture, const glm::uvec2& sceneSize) {
|
void Oculus_0_5_DisplayPlugin::display(GLuint finalTexture, const glm::uvec2& sceneSize) {
|
||||||
|
@ -151,7 +158,8 @@ bool Oculus_0_5_DisplayPlugin::eventFilter(QObject* receiver, QEvent* event) {
|
||||||
// at 60 Hz. This would introduce judder. Perhaps we can push mirroring to a separate
|
// at 60 Hz. This would introduce judder. Perhaps we can push mirroring to a separate
|
||||||
// thread
|
// thread
|
||||||
void Oculus_0_5_DisplayPlugin::finishFrame() {
|
void Oculus_0_5_DisplayPlugin::finishFrame() {
|
||||||
_hmdWindow->doneCurrent();
|
_window->doneCurrent();
|
||||||
|
// _hmdWindow->doneCurrent();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -41,7 +41,6 @@ protected:
|
||||||
private:
|
private:
|
||||||
ovrTexture _eyeTextures[2];
|
ovrTexture _eyeTextures[2];
|
||||||
static const QString NAME;
|
static const QString NAME;
|
||||||
GlWindow* _hmdWindow;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
class GlWindow;
|
class GlWindow;
|
||||||
|
class QScreen;
|
||||||
|
|
||||||
class PluginContainer {
|
class PluginContainer {
|
||||||
public:
|
public:
|
||||||
|
@ -14,4 +15,6 @@ public:
|
||||||
virtual bool isOptionChecked(const QString& name) = 0;
|
virtual bool isOptionChecked(const QString& name) = 0;
|
||||||
virtual void setIsOptionChecked(const QString& path, bool checked) = 0;
|
virtual void setIsOptionChecked(const QString& path, bool checked) = 0;
|
||||||
virtual GlWindow* getVisibleWindow() = 0;
|
virtual GlWindow* getVisibleWindow() = 0;
|
||||||
|
virtual void setFullscreen(const QScreen* targetScreen) = 0;
|
||||||
|
virtual void unsetFullscreen() = 0;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue