mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 19:22:57 +02:00
Merge pull request #15301 from SaracenOne/disable_away_on_focus_loss_push_2
case 22190: Disable triggering away state when interface focus lost
This commit is contained in:
commit
32d3014d0d
6 changed files with 53 additions and 2 deletions
|
@ -985,6 +985,7 @@ const bool DEFAULT_PREFER_STYLUS_OVER_LASER = false;
|
||||||
const bool DEFAULT_PREFER_AVATAR_FINGER_OVER_STYLUS = false;
|
const bool DEFAULT_PREFER_AVATAR_FINGER_OVER_STYLUS = false;
|
||||||
const QString DEFAULT_CURSOR_NAME = "DEFAULT";
|
const QString DEFAULT_CURSOR_NAME = "DEFAULT";
|
||||||
const bool DEFAULT_MINI_TABLET_ENABLED = true;
|
const bool DEFAULT_MINI_TABLET_ENABLED = true;
|
||||||
|
const bool DEFAULT_AWAY_STATE_WHEN_FOCUS_LOST_IN_VR_ENABLED = true;
|
||||||
|
|
||||||
QSharedPointer<OffscreenUi> getOffscreenUI() {
|
QSharedPointer<OffscreenUi> getOffscreenUI() {
|
||||||
#if !defined(DISABLE_QML)
|
#if !defined(DISABLE_QML)
|
||||||
|
@ -1015,6 +1016,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
_preferStylusOverLaserSetting("preferStylusOverLaser", DEFAULT_PREFER_STYLUS_OVER_LASER),
|
_preferStylusOverLaserSetting("preferStylusOverLaser", DEFAULT_PREFER_STYLUS_OVER_LASER),
|
||||||
_preferAvatarFingerOverStylusSetting("preferAvatarFingerOverStylus", DEFAULT_PREFER_AVATAR_FINGER_OVER_STYLUS),
|
_preferAvatarFingerOverStylusSetting("preferAvatarFingerOverStylus", DEFAULT_PREFER_AVATAR_FINGER_OVER_STYLUS),
|
||||||
_constrainToolbarPosition("toolbar/constrainToolbarToCenterX", true),
|
_constrainToolbarPosition("toolbar/constrainToolbarToCenterX", true),
|
||||||
|
_awayStateWhenFocusLostInVREnabled("awayStateWhenFocusLostInVREnabled", DEFAULT_AWAY_STATE_WHEN_FOCUS_LOST_IN_VR_ENABLED),
|
||||||
_preferredCursor("preferredCursor", DEFAULT_CURSOR_NAME),
|
_preferredCursor("preferredCursor", DEFAULT_CURSOR_NAME),
|
||||||
_miniTabletEnabledSetting("miniTabletEnabled", DEFAULT_MINI_TABLET_ENABLED),
|
_miniTabletEnabledSetting("miniTabletEnabled", DEFAULT_MINI_TABLET_ENABLED),
|
||||||
_scaleMirror(1.0f),
|
_scaleMirror(1.0f),
|
||||||
|
@ -3642,6 +3644,11 @@ void Application::setSettingConstrainToolbarPosition(bool setting) {
|
||||||
getOffscreenUI()->setConstrainToolbarToCenterX(setting);
|
getOffscreenUI()->setConstrainToolbarToCenterX(setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::setAwayStateWhenFocusLostInVREnabled(bool enabled) {
|
||||||
|
_awayStateWhenFocusLostInVREnabled.set(enabled);
|
||||||
|
emit awayStateWhenFocusLostInVRChanged(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
void Application::setMiniTabletEnabled(bool enabled) {
|
void Application::setMiniTabletEnabled(bool enabled) {
|
||||||
_miniTabletEnabledSetting.set(enabled);
|
_miniTabletEnabledSetting.set(enabled);
|
||||||
emit miniTabletEnabledChanged(enabled);
|
emit miniTabletEnabledChanged(enabled);
|
||||||
|
|
|
@ -241,6 +241,9 @@ public:
|
||||||
float getSettingConstrainToolbarPosition() { return _constrainToolbarPosition.get(); }
|
float getSettingConstrainToolbarPosition() { return _constrainToolbarPosition.get(); }
|
||||||
void setSettingConstrainToolbarPosition(bool setting);
|
void setSettingConstrainToolbarPosition(bool setting);
|
||||||
|
|
||||||
|
float getAwayStateWhenFocusLostInVREnabled() { return _awayStateWhenFocusLostInVREnabled.get(); }
|
||||||
|
void setAwayStateWhenFocusLostInVREnabled(bool setting);
|
||||||
|
|
||||||
Q_INVOKABLE void setMinimumGPUTextureMemStabilityCount(int stabilityCount) { _minimumGPUTextureMemSizeStabilityCount = stabilityCount; }
|
Q_INVOKABLE void setMinimumGPUTextureMemStabilityCount(int stabilityCount) { _minimumGPUTextureMemSizeStabilityCount = stabilityCount; }
|
||||||
|
|
||||||
NodeToOctreeSceneStats* getOcteeSceneStats() { return &_octreeServerSceneStats; }
|
NodeToOctreeSceneStats* getOcteeSceneStats() { return &_octreeServerSceneStats; }
|
||||||
|
@ -371,6 +374,7 @@ signals:
|
||||||
void loginDialogFocusDisabled();
|
void loginDialogFocusDisabled();
|
||||||
|
|
||||||
void miniTabletEnabledChanged(bool enabled);
|
void miniTabletEnabledChanged(bool enabled);
|
||||||
|
void awayStateWhenFocusLostInVRChanged(bool enabled);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
QVector<EntityItemID> pasteEntities(float x, float y, float z);
|
QVector<EntityItemID> pasteEntities(float x, float y, float z);
|
||||||
|
@ -673,6 +677,7 @@ private:
|
||||||
Setting::Handle<bool> _preferStylusOverLaserSetting;
|
Setting::Handle<bool> _preferStylusOverLaserSetting;
|
||||||
Setting::Handle<bool> _preferAvatarFingerOverStylusSetting;
|
Setting::Handle<bool> _preferAvatarFingerOverStylusSetting;
|
||||||
Setting::Handle<bool> _constrainToolbarPosition;
|
Setting::Handle<bool> _constrainToolbarPosition;
|
||||||
|
Setting::Handle<bool> _awayStateWhenFocusLostInVREnabled;
|
||||||
Setting::Handle<QString> _preferredCursor;
|
Setting::Handle<QString> _preferredCursor;
|
||||||
Setting::Handle<bool> _miniTabletEnabledSetting;
|
Setting::Handle<bool> _miniTabletEnabledSetting;
|
||||||
Setting::Handle<bool> _keepLogWindowOnTop { "keepLogWindowOnTop", false };
|
Setting::Handle<bool> _keepLogWindowOnTop { "keepLogWindowOnTop", false };
|
||||||
|
|
|
@ -30,6 +30,9 @@ HMDScriptingInterface::HMDScriptingInterface() {
|
||||||
connect(qApp, &Application::miniTabletEnabledChanged, [this](bool enabled) {
|
connect(qApp, &Application::miniTabletEnabledChanged, [this](bool enabled) {
|
||||||
emit miniTabletEnabledChanged(enabled);
|
emit miniTabletEnabledChanged(enabled);
|
||||||
});
|
});
|
||||||
|
connect(qApp, &Application::awayStateWhenFocusLostInVRChanged, [this](bool enabled) {
|
||||||
|
emit awayStateWhenFocusLostInVRChanged(enabled);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 HMDScriptingInterface::calculateRayUICollisionPoint(const glm::vec3& position, const glm::vec3& direction) const {
|
glm::vec3 HMDScriptingInterface::calculateRayUICollisionPoint(const glm::vec3& position, const glm::vec3& direction) const {
|
||||||
|
@ -137,6 +140,14 @@ bool HMDScriptingInterface::getMiniTabletEnabled() {
|
||||||
return qApp->getMiniTabletEnabled();
|
return qApp->getMiniTabletEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HMDScriptingInterface::setAwayStateWhenFocusLostInVREnabled(bool enabled) {
|
||||||
|
qApp->setAwayStateWhenFocusLostInVREnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HMDScriptingInterface::getAwayStateWhenFocusLostInVREnabled() {
|
||||||
|
return qApp->getAwayStateWhenFocusLostInVREnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QScriptValue HMDScriptingInterface::getHUDLookAtPosition2D(QScriptContext* context, QScriptEngine* engine) {
|
QScriptValue HMDScriptingInterface::getHUDLookAtPosition2D(QScriptContext* context, QScriptEngine* engine) {
|
||||||
glm::vec3 hudIntersection;
|
glm::vec3 hudIntersection;
|
||||||
|
|
|
@ -375,6 +375,14 @@ signals:
|
||||||
*/
|
*/
|
||||||
bool miniTabletEnabledChanged(bool enabled);
|
bool miniTabletEnabledChanged(bool enabled);
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Triggered when the altering the mode for going into an away state when the interface focus is lost in VR.
|
||||||
|
* @function HMD.awayStateWhenFocusLostInVRChanged
|
||||||
|
* @param {boolean} enabled - <code>true</code> if the setting to go into an away state in VR when the interface focus is lost is enabled, otherwise <code>false</code>.
|
||||||
|
* @returns {Signal}
|
||||||
|
*/
|
||||||
|
bool awayStateWhenFocusLostInVRChanged(bool enabled);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HMDScriptingInterface();
|
HMDScriptingInterface();
|
||||||
|
|
||||||
|
@ -423,6 +431,9 @@ public:
|
||||||
void setMiniTabletEnabled(bool enabled);
|
void setMiniTabletEnabled(bool enabled);
|
||||||
bool getMiniTabletEnabled();
|
bool getMiniTabletEnabled();
|
||||||
|
|
||||||
|
void setAwayStateWhenFocusLostInVREnabled(bool enabled);
|
||||||
|
bool getAwayStateWhenFocusLostInVREnabled();
|
||||||
|
|
||||||
QVariant getPlayAreaRect();
|
QVariant getPlayAreaRect();
|
||||||
QVector<glm::vec3> getSensorPositions();
|
QVector<glm::vec3> getSensorPositions();
|
||||||
|
|
||||||
|
|
|
@ -112,6 +112,12 @@ void setupPreferences() {
|
||||||
preferences->addPreference(new CheckPreference(UI_CATEGORY, "Constrain Toolbar Position to Horizontal Center", getter, setter));
|
preferences->addPreference(new CheckPreference(UI_CATEGORY, "Constrain Toolbar Position to Horizontal Center", getter, setter));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto getter = []()->bool { return qApp->getAwayStateWhenFocusLostInVREnabled(); };
|
||||||
|
auto setter = [](bool value) { qApp->setAwayStateWhenFocusLostInVREnabled(value); };
|
||||||
|
preferences->addPreference(new CheckPreference(UI_CATEGORY, "Go into away state when interface window loses focus in VR", getter, setter));
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
auto getter = []()->float { return qApp->getDesktopTabletScale(); };
|
auto getter = []()->float { return qApp->getDesktopTabletScale(); };
|
||||||
auto setter = [](float value) { qApp->setDesktopTabletScale(value); };
|
auto setter = [](float value) { qApp->setDesktopTabletScale(value); };
|
||||||
|
|
|
@ -67,6 +67,8 @@ var avatarPosition = MyAvatar.position;
|
||||||
var wasHmdMounted = HMD.mounted;
|
var wasHmdMounted = HMD.mounted;
|
||||||
var previousBubbleState = Users.getIgnoreRadiusEnabled();
|
var previousBubbleState = Users.getIgnoreRadiusEnabled();
|
||||||
|
|
||||||
|
var enterAwayStateWhenFocusLostInVR = HMD.enterAwayStateWhenFocusLostInVR;
|
||||||
|
|
||||||
// some intervals we may create/delete
|
// some intervals we may create/delete
|
||||||
var avatarMovedInterval;
|
var avatarMovedInterval;
|
||||||
|
|
||||||
|
@ -283,8 +285,10 @@ function maybeGoAway() {
|
||||||
if (Reticle.mouseCaptured !== wasMouseCaptured) {
|
if (Reticle.mouseCaptured !== wasMouseCaptured) {
|
||||||
wasMouseCaptured = !wasMouseCaptured;
|
wasMouseCaptured = !wasMouseCaptured;
|
||||||
if (!wasMouseCaptured) {
|
if (!wasMouseCaptured) {
|
||||||
goAway();
|
if (enterAwayStateWhenFocusLostInVR) {
|
||||||
return;
|
goAway();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,9 +361,14 @@ eventMapping.from(Controller.Standard.Back).peek().to(goActive);
|
||||||
eventMapping.from(Controller.Standard.Start).peek().to(goActive);
|
eventMapping.from(Controller.Standard.Start).peek().to(goActive);
|
||||||
Controller.enableMapping(eventMappingName);
|
Controller.enableMapping(eventMappingName);
|
||||||
|
|
||||||
|
function awayStateWhenFocusLostInVRChanged(enabled) {
|
||||||
|
enterAwayStateWhenFocusLostInVR = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
Script.scriptEnding.connect(function () {
|
Script.scriptEnding.connect(function () {
|
||||||
Script.clearInterval(maybeIntervalTimer);
|
Script.clearInterval(maybeIntervalTimer);
|
||||||
goActive();
|
goActive();
|
||||||
|
HMD.awayStateWhenFocusLostInVRChanged.disconnect(awayStateWhenFocusLostInVRChanged);
|
||||||
Controller.disableMapping(eventMappingName);
|
Controller.disableMapping(eventMappingName);
|
||||||
Controller.mousePressEvent.disconnect(goActive);
|
Controller.mousePressEvent.disconnect(goActive);
|
||||||
Controller.keyPressEvent.disconnect(maybeGoActive);
|
Controller.keyPressEvent.disconnect(maybeGoActive);
|
||||||
|
@ -367,6 +376,8 @@ Script.scriptEnding.connect(function () {
|
||||||
Messages.unsubscribe(CHANNEL_AWAY_ENABLE);
|
Messages.unsubscribe(CHANNEL_AWAY_ENABLE);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
HMD.awayStateWhenFocusLostInVRChanged.connect(awayStateWhenFocusLostInVRChanged);
|
||||||
|
|
||||||
if (HMD.active && !HMD.mounted) {
|
if (HMD.active && !HMD.mounted) {
|
||||||
print("Starting script, while HMD is active and not mounted...");
|
print("Starting script, while HMD is active and not mounted...");
|
||||||
goAway(true);
|
goAway(true);
|
||||||
|
|
Loading…
Reference in a new issue